node-prune

Dev tools

dependency pruning cli

SHOW HN2017

111points
61comments
#405of 2,242 in 2017
Top 19%of 2017 by points

How HN took it

MixedNo clear lean

6 positive, 14 neutral or asking, 2 mixed, 9 critical, out of 31 comments about the project. Thread score -0.13.

Idea: 1 for, 6 againstExecution: 0 for, 2 againstDesign: 2 for, 0 againstPerformance: 1 for, 0 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Useful for shrinking Lambda and Docker deployments

    From 3 comments
    • It's especially good for deployments to AWS Lambda.
      finstell on HN
    • Awesome idea. Especially if you’re packaging your projects via something like Docker this can shave hundreds of megabytes. (Even if you’re using the Docker layer cache, any…
      lxe on HN
    • Love it. Saved 600MB... and test cases still passed :) I ported it to bash really quick, as thats probably easier for people to drop into their dotfiles if they don't have a…
      gcommer on HN

Objections

  • Deleting files may break packages that need them at runtime

    From 3 comments
    • It looks like it removes the files necessary for "npm install" assuming that the module will do npm install immediately when you install it. This is not true for all cases…
      goldenkey on HN
    • Awesome idea. Especially if you’re packaging your projects via something like Docker this can shave hundreds of megabytes. (Even if you’re using the Docker layer cache, any…
      lxe on HN
    • No it should NOT be handled by npm. Imagine some npm project really needs those files. Like module that is rendering markdown files to html. If npm would be that "smart" to strip…
      finchisko on HN
  • Authors should fix packaging with .npmignore or files array instead

    From 3 comments
    • Shouldn't this be handled entirely by npm? If these files are unnecessary why do they get downloaded in the first place?
      sergiotapia on HN
    • Ideally people use the "files" array. It might be nice if someone writes a bot to go around and fix large packages by adding that.
      tjholowaychuk on HN
    • I guess there is the "files" and ".npmignore" which handle these, but they don't seem to be widely used in the community.
      hiphipjorge on HN
  • Removing .d.ts files breaks ts-node

    From 2 comments
    • https://github.com/tj/node-prune/blob/master/prune.go#L57 Doesn't this also result in .d.ts files being removed? These are type declaration files (Kinda like C's .h files) that…
      TheCoreh on HN
    • ts-node no longer works.
      latchkey on HN

Requests

  • Automate pull requests adding npmignore rules to large packages

    From 2 comments
    • Is this serious? I mean, kudos for helping push node module developers to make better use of `.npmignore` et al, but this project strikes me as overly snarky or even trolling...…
      namuol on HN
    • Even better: submit a PR auto fix these issues on the corresponding GitHub repo when pruning
      tomchentw on HN
  • Better documentation of what gets pruned and why

    From 2 comments
    • Rather than two giant 440px high images consisting of tiny text in the readme I'd quite love to read exactly what it does and why. Does it prune files in modules that are not…
      orf on HN
    • Maybe documentation should include uses cases? Newer users to npm + node might think this does something different. Just a suggestions.
      hiphipjorge on HN

Questions

  • Why write it in Go instead of shell or Node

    From 2 comments
    • No disrespect to TJ (he did many awesome projects I use almost daily), but wouldn't simple: 'find node_modules -not -regex ".*.[js,json]" -delete' do the same job? Why project in…
      finchisko on HN
    • Usually I don't care about what language an executable is written in. After all, as a user I'm just interested in whether it executes or not. But these small-software situations…
      andreineculau on HN
  • Should npm handle excluding unneeded files itself

    From 2 comments
    • Shouldn't this be handled entirely by npm? If these files are unnecessary why do they get downloaded in the first place?
      sergiotapia on HN
    • This is completely useless because npm still downloads those files and the hdd space is pretty negligeble. It should def go under the category of troll driven development. This…
      hiphipjorge on HN

Alternatives named

  • yarn autoclean

    From 2 comments
    • The Yarn autoclean command also does something like this: https://yarnpkg.com/lang/en/docs/cli/autoclean/
      mambodog on HN
    • you're looking for `yarn autoclean`. they have `.yarncleanrc` IIRC
      tuananh on HN
  • Shell find command to delete non-js files

    From 1 comment
    • No disrespect to TJ (he did many awesome projects I use almost daily), but wouldn't simple: 'find node_modules -not -regex ".*.[js,json]" -delete' do the same job? Why project in…
      finchisko on HN
  • npmignore whitelist or files array

    From 2 comments
    • Ideally people use the "files" array. It might be nice if someone writes a bot to go around and fix large packages by adding that.
      tjholowaychuk on HN
    • We've started publishing modules with a whitelist in the npmignore to help combat this. ``` * !dist/**/* ```
      vkjv on HN
  • Bundling with rollup or tree shaking

    From 2 comments
    • I've been thinking about this in a different way: what about bundling things with rollup.js? Then each package in require() would be just a package.json and an index.js. I think…
      franciscop on HN
    • Wouldnt it make more sense to bundle, minify and treeshake your package than to delete unused files in node_modules? Tree shaking will remove unsused code even from files you are…
      purrcat259 on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/15731936)