0

While developing a TypeScript library that is being used as a dependency by other libraries or applications, what options do I have for propagating frequent changes in the library? Is there a way to achieve it without constantly incrementing the library version, publishing it to an NPM registry, and then updating the application that depends on it?

Coming from a server-side development background, I feel like I'm repeating these 3 steps way too often...

I would expect to be able to develop a library and use it immediately as a dependency in another project without being connected to a remote registry that requires an internet connection. It can easily be done in other languages like Java, Go, and Scala, not to mention others like PHP and Python.

The example I gave here with a single library is simplified of course. This issue quickly becomes a nightmare in the real world when you have a tree consisting of many dependencies.

vstrom coder
  • 297
  • 1
  • 8
  • Use semantic versioning? https://semver.org/ – dwjohnston Sep 08 '22 at 10:03
  • @dwjohnston, can you elaborate? How does it solve the problem? I still need to repeat the 3 steps mentioned for each minor change. – vstrom coder Sep 08 '22 at 10:10
  • Ah, sorry, I see the question is more about propagating the changes. In my experience, you have three options: 1. Do what you are are doing, and see the friction as a feature, not a bug (ie. making sure you are being deliberate about your changes). 2. Don't have multiple packages. Just build a monolith. 3. Use a monorepo. Be aware of all the pitfalls that can occur with hoisting in a monorepo. [eg see](https://stackoverflow.com/questions/62055604/is-there-a-way-to-tell-lerna-npm-to-really-look-in-my-own-node-modules-for-thos) – dwjohnston Sep 08 '22 at 10:26
  • #2 is not an option since I must have reusable packages that are used by other projects in the organization. As for #3, I don't see how it is related. As far as I know, it makes no difference whether the code is in multiple repositories or not. – vstrom coder Sep 08 '22 at 10:53
  • You can load the code dyamically from some other server, as Google Tag Manager does. But anyway, what's the issue you are dealing with? In the BE world you also need to update a library and push it to some registry like maven or nuget, isn't it? – Drag13 Sep 08 '22 at 13:50
  • I would expect to be able to either have a development configuration where a package can point to the source code of the dependent package or, have a non-final version number (i.e. like a SNAPSHOT version in Maven - https://maven.apache.org/guides/getting-started/index.html#What_is_a_SNAPSHOT_version) – vstrom coder Sep 08 '22 at 14:04

1 Answers1

2

You can use npm link to develop locally until you have a stable version. https://docs.npmjs.com/cli/v8/commands/npm-link

chuck
  • 36
  • 2