Skip to content

Lighter production dependencies #505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2020
Merged

Lighter production dependencies #505

merged 1 commit into from
Apr 15, 2020

Conversation

scottinet
Copy link
Contributor

@scottinet scottinet commented Apr 12, 2020

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:

  • move all development dependencies to devDependencies: babel, webpack, kuzdoc
  • remove the 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 useless
  • remove the install directive in the scripts 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 raw npm install in dev-mode)
  • add a files section in the package.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:

  • the prepublish script is triggered, (re)building the SDK
  • a .tgz file is created, containing only the NPM essential files, and the ones listed in the files section in package.json (including the newly built dist/kuzzle.js SDK for browsers)
  • the .tgz file is pushed to NPM

Impact for SDK developers

None.

How to test

  1. Pull this branch
  2. Start npm pack which will create a .tgz file simulating a NPM package
  3. Simulate an NPM install with the generated .tgz package in a local directory, using npm 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

  • remove the old, outdated and useless CHANGELOG.md file
  • update remaining dependencies
  • remove the audit dependency. I have no clue about why it's listed as a dependency of this project

@codecov
Copy link

codecov bot commented Apr 12, 2020

Codecov Report

Merging #505 into 7-dev will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##            7-dev     #505   +/-   ##
=======================================
  Coverage   95.79%   95.79%           
=======================================
  Files          32       32           
  Lines        1308     1308           
=======================================
  Hits         1253     1253           
  Misses         55       55           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 09191ca...883b8fd. Read the comment docs.

@rolljee rolljee merged commit 92c7356 into 7-dev Apr 15, 2020
@rolljee rolljee deleted the lighter-deps branch April 15, 2020 07:48
@scottinet scottinet mentioned this pull request Apr 15, 2020
scottinet added a commit that referenced this pull request Apr 16, 2020
# [7.1.4](https://github.com/kuzzleio/sdk-javascript/releases/tag/7.1.4) (2020-04-15)


#### Enhancements

- [ [#502](#502) ] Remove pagination from collection list   ([Aschen](https://github.com/Aschen))
- [ [#505](#505) ] Lighter production dependencies   ([scottinet](https://github.com/scottinet))
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants