-
-
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
Can't use ESM with jsc.paths
#7829
Comments
Hey @kdy1! Excited to see this marked as planned. Curious out of the suggestions above, what approach do you think the SWC project will take here? Or are you still unsure? |
I prefer following the direction of |
Haha sure thing – regardless, super happy this is getting looked at and let me know if I can help in any way :) |
I think {
"module": {
"type": "es6"
},
"jsc": {
"baseUrl": ".",
"target": "es2020",
"parser": {
"syntax": "typescript",
"decorators": true,
"importMeta": true
},
"paths": {
"@my/pkg": ["libs/pkg/src/index.js"],
}
}
} is a better API |
But maybe we need an option to fully qualify index.js even if we can remove it from the import. |
Filed #7861 |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Describe the bug
Hey folks,
I've come into a bit of a pickle. Node 19 drops support for
es-module-specifier-resolution
, which I have been using to support extension-less imports in my ESM codebase.I realized this makes it impossible for me to continue using
jsc.paths
in my TypeScript project, asts
files automatically have their extensions removed, yet if I usejs
as an extension, SWC can't find the path and doesn't transform the import.Example
results in:
and
results in:
Input code
Config
Playground link
No response
Expected behavior
I think that SWC should provide a similar mechanism to how TypeScript supports ESM, where TS files can be imported as JS (i.e.
jsc.paths
should find and transform the path appropriately).Better yet, now that you can import
ts
files in TS, what I really wish is that you could just always usets
extensions for everything and SWC would be smart enough to know to replace them withjs
in the transpiled code instead of just removing the extension.Actual behavior
Right now, SWC defaults to removing TS extensions unless you manually import TS files as JS (which luckily TS supports), however, this breaks down when using
jsc.paths
as described above. Starting in Node 19, this will result in un-runnable code without a custom loader.Version
1.3.77
Additional context
No response
The text was updated successfully, but these errors were encountered: