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

NPM installs all files even with distribution build #15

Open
codejedi365 opened this issue May 22, 2021 · 1 comment · May be fixed by #16
Open

NPM installs all files even with distribution build #15

codejedi365 opened this issue May 22, 2021 · 1 comment · May be fixed by #16

Comments

@codejedi365
Copy link

codejedi365 commented May 22, 2021

Bug Report

Problem

When your package is installed by other users, your entire git package is installed with it and not just your distribution file. In node_modules, your package is installed like this by default:

Screen Shot 2021-05-22 at 11 28 17

Why?
I see that you are using a distribution build which is one step in the right direction to compatibility and good distribution practice. What you are missing is the minimalistic approach. When running npm publish, the npm pack command runs first. The pack command looks first for a files key entry in package.json, then a .npmignore, then defaults to .gitignore and uses this specification to determine which files to include before uploading to npmjs.com. Your package only requires 3 dependencies which will be installed automatically based on package.json and then of course your babel compiled dist file so that should be the only few that are installed (ignoring LICENSE or other npm publish specific files, see here). Your new installation will look like this:

Screen Shot 2021-05-22 at 11 26 35

node_modules may or may not exist depending on how npm runs installation and if there are other packages that use the same dependency (if so it will be hoisted).

You can review my repository if you would like to see an example. @codejedi365/gitlab-npm-audit-parser

Fix

  1. add a files array entry to package.json
  2. [Optional] add a .npmignore file (read this article first), only apply if it matters and step 1 is implemented.
  3. Republish a new update version to npm
  4. Tag/release new repository version to match publish.
@codejedi365 codejedi365 linked a pull request May 22, 2021 that will close this issue
@davorpa
Copy link

davorpa commented Sep 9, 2021

I agree, is how official remark plugins are done.

E.g.: lint-blockquote-indentation

https://github.com/remarkjs/remark-lint/blob/909d9cceea9007b8d4029c89c2209f428880914b/packages/remark-lint-blockquote-indentation/package.json#L30-L36

At least fill files property array in package.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants