Closed Banou26 closed 4 years ago
Not entirely sure if this would work, but have you tried with a custom regex to replace the extension? Something like this I believe:
"(.+)\.ts$": "\\1.js"
https://github.com/tleunen/babel-plugin-module-resolver/blob/master/DOCS.md#regular-expressions
Doesn't seem to work, i tried yours, then changed it to
"(.+)\\.ts$": "\\1.js"
because vsc threw some
- Invalid escape character in string.
but still nothing.
Any other ideas ?
You're right, \\.
had to be used here.
If you have some time, you can try if it resolves to the right thing in this function. Especially line 80. https://github.com/tleunen/babel-plugin-module-resolver/blob/a65c39a7e495328a9d4d70e82b567122d729e6cb/src/resolvePath.js#L49-L90
ended up using https://github.com/karlprieb/babel-plugin-add-import-extension to replace .ts
import extension names by .js
Coming from https://github.com/babel/babel/issues/10951
So, the idea is just to transform file extensions from
.ts
to.js
because Babel actually transforms.ts
files to.js
but doesn't change the import paths.This is the only way i found to be able to use ESNext features with Typescript and top level await in node.
Don't really know how much work is needed for this. If you don't have the time, tell me and i'll try to do the PR myself.