jsreport / jsreport-core

The minimalist jsreport rendering core
GNU Lesser General Public License v3.0
86 stars 24 forks source link

Adding jsreport in dev-dependency while using jsreport -core in dependency #45

Closed gupta-nitish closed 4 years ago

gupta-nitish commented 5 years ago

Hi, We are using jsreport-core in our project and want to use jsreport package for development using jsreport studio. So we have added jsreport-core as a dependency and jsreport as a dev-dependency. While trying to start jsreport server with 'jsreport' package as a dev dependency, it keeps picking jsreport-core to start the server instead of the jsreport package and it also fails to use the extensions and the configuration provided in jsreport.config.json. Below are the logs for the above :

resolving jsreport location.. no entry point was found, creating a default instance using: require("jsreport-core")() starting jsreport.. jsreport successfully started

If we add jsreport as a normal dependency or remove jsreport-core from our dependencies, it works fine. How can we avoid this and use jsreport package to start the server instead?

Thanks in advance.

pofider commented 5 years ago

Why don't you want to use jsreport package also in the production? How do you start jsreport or jsreport core?

gupta-nitish commented 5 years ago

We are not using jsreport in production because we do not require all the extensions. To make it lightweight, we are using jsreport-core and are installing only the required extensions. For development, we are using jsreport-studio to design and test templates. That's why jsreport package is required as a dev dependency only.

To start jsreport, we run the following commands:-

>npm install jsreport-core --save
>npm install jsreport --save-dev
>jsreport init
>jsreport configure
>jsreport start
pofider commented 5 years ago

We are not using jsreport in production because we do not require all the extensions.

You can still disable extension you don't want to apply in production in config

{
   "extensions": {
     "studio": { "enabled": false },
     "express": { "enabled": false }
   }
}

or even white list extensions

{
  "extensionsList": [ "templates", "data", "chrome-pdf" ]
}

But anyway... In your mixed case with jsreport and jsreport-core, you would need to have different server.js and init code. Something like

if (development) {
 jsreport = require('jsreport-core')
} else {
 jsreport = require('jsreport')
}
pofider commented 4 years ago

To summary for this mixed case. Edit the server.js as mentioned.

if (development) {
 jsreport = require('jsreport-core')
} else {
 jsreport = require('jsreport')
}

and use node server.js instead of jsreport start Closing.