Open andriichern opened 2 years ago
if you don't care about the paths in particular you could follow the setup in this (not mine) example repo https://github.com/felipeplets/esm-examples
Have a look at the linked stackoverflow answer too. See my (currently) open PR regarding the need for a specific flag for node-ts to work with relative imports too.
@einSelbst actually I tried to care about paths that were specified in paths
property of tsconfig
but now I can not. And this was the reason for this issue: run TS code with ts-node
& tsconfig-paths
(on VS Code also) that will then compiled to native esm
modules and run on Node, not in browser)))
And the problem is that currently tsconfig-paths
expects only .ts
files and fails with .mts
files (which are extensions for native Node .mjs
files)
@andriichern there is also https://www.npmjs.com/package/@swc-node/core which seems to support paths but I haven't used it myself. Don't know anything about VSCode support or handling of mts files tough.
We also need a solution for this. Any idea when it will be available? Thank you!
I'm writing an ESM migration guide and have stumbled upon this problem too. Has anybody found a solution for this?
Could not find any config that would be suitable for
ts-node
usage that supportsesm
modules. Would appreciate any links on how to set uptsconfig-paths
together with--loader ts-node/esm
option.If no do you plan to support new
.mts
and.cjs
file extensions?