vhf / remark-lint-alphabetize-lists

remark-lint-alphabetize-lists
7 stars 5 forks source link

NPM installs all files even with distribution build #15

Open codejedi365 opened 3 years ago

codejedi365 commented 3 years ago

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.
davorpa commented 3 years ago

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