Lighter production dependencies #505
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Installing our JS SDK in an empty directory takes up to 84Mo of disk space,with more than 600 dependencies. Which is a lot.
The main culprits of all this weight are babel and webpack, which are necessary to build the browser version of the SDK. Those should be development dependencies, and not production ones.
This PR makes the following changes:
ora
module which is only used as a fancy progress bar displayed during build: since the build is now made only during development or before publishing the SDK, this is uselessinstall
directive in thescripts
section of the package.json file (this directive is used to build the SDK): it's redundant with the prepublish one (triggered before the package is published and after a rawnpm install
in dev-mode)files
section in thepackage.json
, listing the only files that should be pushed to NPM upon publication. The NPM package for this SDK will now only contain the following:index.js
,dist/
,src/
and the files that are always included in NPM packages (package*.json, LICENSE.md, README.md)What happens when the package is published?
Upon executing the
npm publish
command to publish the package on NPM, the following now happens:prepublish
script is triggered, (re)building the SDKfiles
section in package.json (including the newly builtdist/kuzzle.js
SDK for browsers)Impact for SDK developers
None.
How to test
npm pack
which will create a .tgz file simulating a NPM packagenpm install <path to the .tgz file>
Result: instead of a node_modules directory weighting 84Mo, the new one weights less than 650Ko, and it has now only 3 dependencies (kuzzle-sdk, min-req-promise, and ws).
Also,
npm pack
correctly shows that the SDK is built before being published, and the package correctly contains the updated browser version of the SDK (dist/kuzzle.js
)Other changes
audit
dependency. I have no clue about why it's listed as a dependency of this project