Re:Finally, a guide for Node.js and TypeScript and ESM that ...
by khalidx on Tuesday November 21, 2023 @07:50AM
(#38362964)
I generally agree with your statement, but have found ts-node incredibly valuable especially when developing servers or CLIs where I want to start/restart the process many times without a build step every time.
Re:Finally, a guide for Node.js and TypeScript and ESM that ...
by SahAssar on Tuesday November 21, 2023 @09:03AM
(#38363712)
Node has a built in watch mode and so does tsc. So if you start both you should get what you want.
Re:Finally, a guide for Node.js and TypeScript and ESM that ...
by azangru on Tuesday November 21, 2023 @07:49AM
(#38362958)
And for development?
Re:Finally, a guide for Node.js and TypeScript and ESM that ...
by demurgos on Tuesday November 21, 2023 @07:53AM
(#38363010)
With TS, I get type checking in the IDE; I don't need to rebuild every few seconds.
When I actually need to build and test, it's very fast (<2 seconds). I use Yarn workspaces/subprojects and TypeScript references with incremental builds so it's not really an issue.
Here is the `package.json` [0] for a serialization lib I did, you can check the `scripts` section: it's very minimal and I'm quite happy with it. I'm an old Gulp maintainer, so for a long time I had heavy Gulp config with a lot of processing. Over the years I could get rid of it. ESM was the last thing holding me back; and now I'm so happy that I can just use a few simple commands.
[0]: https://github.com/demurgos/kryo/blob/master/packages/kryo/p...
Re:Finally, a guide for Node.js and TypeScript and ESM that ...
by beepbooptheory on Tuesday November 21, 2023 @08:26AM
(#38363305)
or: `tsc --build --watch` and then just have another terminal to run.
Since TS 4.5 and their support for `.mts`, I finally settled on just chaining `tsc --build && node ./build/main.mjs`.