This draft PR is an attempt to ~finaly~ migrate from CJS to ESM.
Problem(s)
The most important problem is that ts-node (for dev) doesn't support tsconfig.paths aliases resolution in ESM. I've managed to quite fix that using a custom loader (./loader.js).
We also want to keep the commands and events HMR.
What I've done so far
Switch tsconfig.target and tsconfig.module to esnext
Complete the tsnode config block in the tsconfig json file
Change the case dep which was CJS-only with change-case.
Remove automatic DI in constructors in favor of a resolveDependencies
4.1 because of the error Cannot access X before initialization
but now i got a max memory call stack error...
Solutions
find a good loader file and make all of this work in ESM (currently being tested)
find a way to build ts -> js on watch and serve the dev process from the js files, while keeping the HMR and speed advantages
Notes
A lot of older attempts are stashed on @barthofu coder workspace.
@barthofu You could get rid of ts-node completely by using Bun. It is a drop-in replacement for Node.js, and it supports running TypeScript files directly.
This draft PR is an attempt to ~finaly~ migrate from CJS to ESM.
Problem(s)
The most important problem is that ts-node (for dev) doesn't support
tsconfig.paths
aliases resolution in ESM. I've managed to quite fix that using a custom loader (./loader.js
).We also want to keep the commands and events HMR.
What I've done so far
tsconfig.target
andtsconfig.module
toesnext
tsnode
config block in the tsconfig json filecase
dep which was CJS-only withchange-case
.resolveDependencies
4.1 because of the errorCannot access X before initialization
Solutions
Notes