3 ms·
The difference here is that many people in the npm world are working on the web. Minimizing application size is of absolute importance on the web. If we copy
by maxthegeek1 11y ago
The difference here is that many people in the npm world are working on the web. Minimizing application size is of absolute importance on the web.
If we copy and past snippets of code between packages, we lose out on potential code de-duplication from dependency flattening.
If you're really worried about your dependencies disappearing/changing beneath you just check them into git.
- peterhadlaw 11y agoThis is a great comment, especially the advice to use git. Sometimes you may have dependencies, and that's okay. Keep track of them, see what changes in your own capacity. Also an added benefit is if the unicorn dependency distribution system goes bust, you still have local copies of everything.
- lewisl9029 11y agoI tried checking in all dependencies for one of my projects a while ago, and my git history quickly became ridiculously bloated as I added/upgraded/replaced more and more dependencies as time went on. For those who go this route, any advice on what you can do to keep your version control history from blowing up?
- wlesieutre 11y agoGit submodules maybe? https://git-scm.com/docs/git-submodule https://git-scm.com/docs/git-submodule
- lewisl9029 11y agoAhh... That must be what I was missing. So instead of checking in your dependencies into your app repo directly, you turn your dependencies folders into submodules to keep their histories separate from your app repo's history. Makes sense! I'll be sure to give that a try on my next project.
- wlesieutre 11y agoI've only made some small contributions to a project that used them and haven't set them up myself. But yeah, that's my understanding of it. There's a bit of extra overhead because you have to fetch them separately after cloning a repo, and updating them is separate from pulling origin/master. If you do one without the other you can probably get into unexpected version mismatches where your project doesn't play nicely with the dependencies.
- Macha 11y agoI guess I don't see what checking the dependencies into git gets you over just archiving your build artifacts instead, while the downsides are apparently visible (repository size/clutter increase, temptation for devs to modify code in your vendored dependencies etc.)
- maxthegeek1 11y agoThat's also a valid solution. Definitely better than copying and pasting code snippets as OP suggested.
- goldbrick 11y agoThis is absolutely true, which is what makes tree-shaking so exciting.