Skip to content
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

node_modules are added to npm release, adding 117MB #6

Closed
sschmidTU opened this issue Sep 15, 2020 · 2 comments
Closed

node_modules are added to npm release, adding 117MB #6

sschmidTU opened this issue Sep 15, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@sschmidTU
Copy link

sschmidTU commented Sep 15, 2020

🐞 Bug report

Description

the node_modules folder is unnecessarily added to the npm release of fse-cli, making up 117MB of the 118MB total package size. As a user of fse-cli, you certainly don't need eslint etc. packaged with this module.

🔬 Minimal Reproduction

run npm install fse-cli [--save-dev]
check size of node_modules/@atao60/fse-cli/node_modules

💻Your Environment

fse-cli Version:

0.0.29, also tested with 0.0.33

Comments

I'm not sure why this isn't ignored for the npm release, because you have node_modules/ added to your .gitignore, and according to this, npm releases should ignore all files in .gitignore (unless you have a .npmignore).
Maybe try changing node_modules/ to node_modules?
In our project we have node_modules/ and node_modules/* in the .gitignore.

Maybe you need to use a module system like webpack? There, you can definitely exclude the node_modules folder, and only package (and minify) the sources and builds necessary for running your module.

@sschmidTU sschmidTU added the bug Something isn't working label Sep 15, 2020
@atao60 atao60 added enhancement New feature or request and removed bug Something isn't working labels Sep 15, 2020
@atao60
Copy link
Owner

atao60 commented Sep 16, 2020

Thanks for trying @atao60/fse-cli.

Short story. Nothing to be done on @atao60/fse-cli side.

Long story short. Use npm ci in place of npm install.

Long story.

Neither .npmignore nor .gitignore are used by @atao60/fse-cli to "describe(..) the entries to be included when your package is installed as a dependency". But package.json#files is, cf. npm docs - npm-package.json- files, i.e. here:

  • the default ones: package.json, README.MD, CHANGELOG.md, USAGE, LICENCE (and ./dist/index.js but see below);
  • the explicit ones from "package.json#files": bin/, dist/, MANUAL.md, CONTRIBUTING.md, npm-shrinkwrap.json

So to be clear, node_modules is not embedded in the package.

But as stated by NPM docs - npm-install - Install a package, npm install in target project will install any entry in dependencies and devDependencies of @atao60/fse-cli. Recursively!

Then running pkgfiles with @atao60/fse-cli gives:

  • a Publishable Size of ~502 kB
  • a Size with Dependencies of ~144 MB

Now the strange thing. Running npm ll in the target project gives:

[...]
npm ERR! extraneous: @babel/cli@7.11.5 /mnt/data/workspaces/npm-public-packages/test-size-fse-cli/node_modules/@atao60/fse-cli/node_modules/@babel/cli
npm ERR! extraneous: @babel/core@7.11.5 /mnt/data/workspaces/npm-public-packages/test-size-fse-cli/node_modules/@atao60/fse-cli/node_modules/@babel/core
npm ERR! extraneous: @babel/plugin-proposal-decorators@7.10.5 /mnt/data/workspaces/npm-public-packages/test-size-fse-cli/node_modules/@atao60/fse-cli/node_modules/@babel/plugin-proposal-decorators
npm ERR! extraneous: @babel/preset-env@7.11.5 /mnt/data/workspaces/npm-public-packages/test-size-fse-cli/node_modules/@atao60/fse-cli/node_modules/@babel/preset-env
npm ERR! extraneous: @babel/preset-typescript@7.10.4 /mnt/data/workspaces/npm-public-packages/test-size-fse-cli/node_modules/@atao60/fse-cli/node_modules/@babel/preset-typescript
[...]

but npm purge doesn't remove those "extraneous" packages. It seems it works only for depth 0.

To avoid installing "extraneous" packages, you can use npm ci or npm ci --only=prod in place of npm install.

Or to remove them manually or with a dedicated script, in both cases based on the output of npm ll.

Then the size of node_modules/@atao60/fse-cli folder has shrunk to 40 Mo.

Any other idea will be welcome. So I'll keep this issue open for some time.

@atao60 atao60 added wontfix This will not be worked on and removed enhancement New feature or request labels Sep 16, 2020
@atao60 atao60 closed this as completed Sep 22, 2020
@atao60
Copy link
Owner

atao60 commented Jan 20, 2021

Reopening: will try with an embedded npm-shrinkwrap.json expunged from dev deps.

@atao60 atao60 reopened this Jan 20, 2021
@atao60 atao60 added enhancement New feature or request and removed wontfix This will not be worked on labels Jan 20, 2021
@atao60 atao60 closed this as completed in 3872fad Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants