support `.js` extension for imports in `.ts` files
See original GitHub issueIt is supported in ts-node/esm and according to typescript that’s the recommended way to import https://twitter.com/orta/status/1444958295865937920
foo.ts
import bar from './bar.js' // bar.js does not exist on disk, it is the transpilation result of bar.ts
Right now this fails with ENOENT, here’s how it looks like in uvu’s typescript.module example when you use math.ts and utils.ts instead of .js
devDependencies:
+ loadr 0.1.1
+ tsm 2.0.0
+ uvu 0.5.1
dominikg@mb14:~/develop/uvu/examples/typescript.module$ pnpm test
> @ test /home/dominikg/develop/uvu/examples/typescript.module
> tsm node_modules/uvu/bin.js tests
(node:8503) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Error: ENOENT: no such file or directory, open '/home/dominikg/develop/uvu/examples/typescript.module/src/math.js'
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Appending .js extension on relative import statements during ...
The Typescript compiler allows import statement without an extension. It then goes on to add ".js" extension to the corresponding output ...
Read more >Provide a way to add the '.js' file extension to the end ... - GitHub
In order to use es6 modules in the browser, you need a .js file extension. However output doesn't add it. In ts: import...
Read more >autoimport in typescript when use ES Module doesn't add .js ...
1.Create a TypeScript project with "module": "ESNext" in tsconfig.json and "type": "module" in package.json · 2.create testexport.ts file export a value. export ...
Read more >Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >tsc-esm-fix - npm
Moreover, if understand TS/49271 correctly, nodenext + pkg.json type: module requires the .js extension in .d.ts files of external ESM ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Resolved 😃 Thanks for opening this up
Nice,
tsm@2.3.0
(PR #43) is working, thanks! 🙌