-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Feature Request] Add extension to relative import id #1563
Comments
tsc doesn't append .mjs too. |
Yes, TypeScript works this way by design, and therefore esbuild's TypeScript support also works this way. If you would like for Microsoft to change how TypeScript works you should ask them, not me. I don't work at Microsoft and don't have any control over their roadmap. I believe microsoft/TypeScript#27957 is a relevant issue to follow. The workarounds for this situation are described here: #622 (comment). Either use |
TypeScript's upcoming version 4.5 now has a way to do this. If you have a TypeScript file that needs to import another TypeScript file that will have a Closing this issue since this is being addressed outside of esbuild by the TypeScript team, and is possible to implement within esbuild via a plugin without needing to modify esbuild itself. |
if someone is interrested in my solution: |
I think it's completely reasonable for a compiler to add a file extension as a transformation. Compilers make all kinds of adjustments for other nuanced mechanics of intent. At the very least, a plugin should solve this. And for what it's worth, the TS team has been repeatedly chided by the community for the decision. Their decision making isn't exactly pure. Edit: Boom. There's a plugin. https://github.com/favware/esbuild-plugin-file-path-extensions |
Feature Request
Add extension
.mjs
to relative import id,when specific
--out-extension:.js=.mjs
Repeoduce
Actual
$ node dist/index.mjs Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'path/to/dist/deps' imported from path/to/dist/index.mjs
Expected
$ node dist/index.mjs 42
The text was updated successfully, but these errors were encountered: