JamieMason / shrinkpack

Fast, resilient, reproducible builds with npm install.
https://www.npmjs.com/package/shrinkpack
MIT License
793 stars 38 forks source link

Use a local npm cache instead of copying? #55

Closed JamieMason closed 8 years ago

JamieMason commented 8 years ago

Currently shrinkpack

  1. Populates the cache located at npm config get cache.
  2. Copies the tarballs to ./node_shrinkwrap.
  3. Rewrites npm-shrinkwrap.json to point at eg file:node_shrinkwrap/lodash.isarray-3.0.4.tgz.

This issue proposes that instead shrinkpack;

  1. Set cache=node_shrinkwrap in .npmrc.
  2. Rewrites npm-shrinkwrap.json to point at eg file:node_shrinkwrap/lodash.isarray/3.0.4/package.tgz.
    Positives
  3. 👍 Should be much more efficient as the copying step is no longer needed.
  4. 👍 Should make the codebase simpler.
  5. 👍 Should address #31.
    Negatives/Considerations
  6. 👎 It will probably be a breaking change migrating from file:node_shrinkwrap/lodash.isarray-3.0.4.tgz to file:node_shrinkwrap/lodash.isarray/3.0.4/package.tgz.
  7. 👎 If committed, the package.json files in the npm cache will make commit diffs noisy (avoiding noisy diffs is one of the main benefits of shrinkpack) however;
    • 👍 They can be deleted (find node_cache -iname "*.json" -delete) and npm install works fine.
    • 👍 When deleting the package.json files, npm appears to restore them from the package.tgz without hitting the network.
    • 👍 You could ignore the .json files with .gitignore.
    • 👎 Struggling to find a pattern to ignore everything in node_cache except .tgz files.
JamieMason commented 8 years ago

Feedback welcome.

Not sure whether this is a good idea: on the face of it there are some good positives but, while avoiding some traps, it brings others of its own.

brutuscat commented 8 years ago

Well this looks like a show stopper... https://github.com/npm/npm/issues/7140

JamieMason commented 8 years ago

Thanks, yeah I think this overall is a bad idea.