News for hackers. Stuff that matters.
Re:NPMprune: Remove unnecessary files from node_modules to o... by creatonez on Wednesday November 29, 2023 @12:47PM (#38462547)
Just beware that some files may seem unnecessary but are expected from an idiomatic npm package. Three things that come to mind -- a markdown file named README.md, any generated typescript definitions, and typescript/babel sourcemaps. And something I've seen far too often: please don't give a minified, rolled up bundle as the only option, otherwise you are chucking your library's users back into the dark ages of Bower.js.
Re:NPMprune: Remove unnecessary files from node_modules to o... by josephg on Wednesday November 29, 2023 @03:02PM (#38464481)
Yep. And if you’re writing typescript, please include type definitions, source maps, type definition source maps and the original typescript source.

Having all of this stuff makes it possible to ctrl+click on functions in my libraries and read the corresponding source code. That’s a godsend during development - well worth a few extra kb of files in the npm module.

tsconfig.json:

    "declaration": true,
    "declarationMap": true,
    "sourceMap": true,
    ...
package.json (assuming typescript compiles src/ to dist/):

    "files": [
      "dist/*",
      "src/*"
    ],
Re:NPMprune: Remove unnecessary files from node_modules to o... by shepherdjerred on Wednesday November 29, 2023 @03:23PM (#38464752)
It makes me wonder why these are even configurable. These should all be emitted by default.
Re:NPMprune: Remove unnecessary files from node_modules to o... by nfriedly on Wednesday November 29, 2023 @01:25PM (#38463086)
The readme gets included automatically even if you don't specify it in the files field, ditto for the changelog license, and package.json.

Compare https://github.com/express-rate-limit/express-rate-limit/blo... to https://www.npmjs.com/package/express-rate-limit?activeTab=c...

Agree with you about the other points.

Re:NPMprune: Remove unnecessary files from node_modules to o... by rezonant on Wednesday November 29, 2023 @02:41PM (#38464216)
Strongly agree on minification. You should not minify or bundle anything in your NPM package. That decision should only be made by the top level project if it wishes.