• Ask a Question
  • Create a Poll
150
    Ask a Question
    Cancel
    150
    More answer You can create 5 answer(s).
      Ask a Poll
      Cancel

      What's a good way to include an npm module in git

      Kind of a noob question here…

      We’ve got a private npm module – a library – that needs to be included in other projects. So far, very simple.

      Currently, we’re simply "remembering" to manually do an npm run buld before pushing changes to our git repo, and then dependent projects when they do an npm run whatever, they’re setup to pull from our repo and use the latest version already "compiled" as a module.

      So, there are issues with this approach:

      1. It relies on humans being able to perfectly remember to do a build before pushing to origin. (inherently fragile).
      2. VSCode constantly shows me the build-artifacts as if they were source files. Git similarly shows merge conflicts relating to those files – which — really, aren’t source at all. They’re compilation artifacts, but I’m not sure I want to .gitignore them – because – well, the point of all of this is to create those artifacts for use in other projects… so they belong in the repo, just not as source files…

      So I’m not sure how to untangle this mess.

      I want:

      • A simple way to update the source that doesn’t cause git to become upset about merge conflicts for build artifacts, but only for actual source files
      • A simple way to ensure that the build artifacts are always updated upon push to origin (in fact, I’d prefer that it build & run our mocha tests and refuse to do a push if that fails)

      I’m only about 9mos into using git on github – so there’s a ton I don’t know…

      Ideas for better ways to manage this / automate this – are most welcome!

      The key to implementation is of course simplicity. If it’s easy to do, I’m sure I’ll do it, and can get others to do so. But if it’s a huge hurdle every time, well, we all know how well that goes over for other devs…

      0 Answers