4 ms·
For people who are lazy, one of the easiest ways to get code reuse in Node, especially if writing a package in TS that needs to be compiled, is to push it to NP
by com2kid 4y ago
For people who are lazy, one of the easiest ways to get code reuse in Node, especially if writing a package in TS that needs to be compiled, is to push it to NPM and import it in another project.
Now days there are other, better, ways to do this, but for beginner and intermediate engineers, if you have some code in one Typescript repo, and you want to import/use it as a JS module in another repo, publishing to NPM is an obvious way to do this.
- Hackbraten 4y agoWhich better ways are you referring to?
- bdcravens 4y agoInstall from GitHub directly is probably the simplest.
- slaymaker1907 4y agoIt's really important for long term projects to keep access to all dependencies. Package lock files only guarantee that your inputs are still correct but they do not guarantee your inputs will still be around in 10 years.
- com2kid 4y agoFalls apart for typescript projects if js files aren't also committed and the package.json setup properly to export the JS code as a module. Installing from GH directly can also fall apart when fancy built scripts are in place that have to be ran to create actual useful code. :(
- squidsoup 4y agomonorepos/workspaces presumably
- com2kid 4y agonpm link can be used to work on dependencies locally. To install directly from GH, you can commit the compiled typescript into github, that will allow you to NPM install directly from GH.