Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native ESM support with ts-node on NodeJS with .mts files #221

Open
andriichern opened this issue Aug 31, 2022 · 5 comments
Open

Native ESM support with ts-node on NodeJS with .mts files #221

andriichern opened this issue Aug 31, 2022 · 5 comments

Comments

@andriichern
Copy link

Could not find any config that would be suitable for ts-node usage that supports esm modules.
Would appreciate any links on how to set up tsconfig-paths together with --loader ts-node/esm option.

If no do you plan to support new .mts and .cjs file extensions?

@andriichern andriichern changed the title Native ESM support with ts-node on NodeJS Native ESM support with ts-node on NodeJS with .mts/.cjs files Aug 31, 2022
@einSelbst
Copy link

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.

@andriichern
Copy link
Author

andriichern commented Sep 12, 2022

@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 andriichern changed the title Native ESM support with ts-node on NodeJS with .mts/.cjs files Native ESM support with ts-node on NodeJS with .mts files Sep 12, 2022
@einSelbst
Copy link

einSelbst commented Sep 15, 2022

@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.

@testgitdl
Copy link

We also need a solution for this. Any idea when it will be available? Thank you!

@slavafomin
Copy link

I'm writing an ESM migration guide and have stumbled upon this problem too. Has anybody found a solution for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants