npm linkfor TypeScript projects.
npm link is good, but TypeScript projects require a build step (transpilation from
*.js), otherwise your project will use stale
Running compile/watch in a separate terminal is an extra step, which may fail and again result in stale .js file being used. One terminal window with watcher needed for each linked project.
Sometimes you want to create a universal module, to be consumed by both Node and Browser.
You will have a hard choice to define a tsconfig compilation target.
For Node you want it high, e.g
es2018. You don't want to transpile down e.g
it creates weird stacktraces, compared to native stacktraces with
For Browser you want to be safe and transpile down to
es2015 or even
es5 (really?). This means,
e.g transpiling down
async/await and getting weird stacktraces in Node as a result.
Isn't it better if you can just publish source files (
*.ts in this case) and let the target
project decide how to transpile it?
You may have your dependencies in 2 modes:
- unlinked mode (default)
linked mode (similar to
Projects are installed under
In linked mode - symlink is created from the source dir of your project (e.g
In unlinked mode - files are copied from
yarn linked - enable linked mode
yarn unlinked - disable linked mode
yarn linked postinstall - needs to be called in your project's
postinstall AND after each
yarn upgrade of linked project.