-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Aliases (Paths) Not Being Replaced #2523
Comments
amd is no work too |
es6 also doesn't work. This is mentioned in #702 (comment) |
swc_ecma_loader: - `TsConfigResolver`: Use `baseUrl` on exact match while resolving. (Closes #2126) swc_ecma_transforms_module: - Add `import_rewriter`. - `NodeImportResolver`: Don't strip extension if it's a directory. (Closes #2269) - `NodeImportResolver`: Don't strip extension if it's not `.ts`, `.js` nor `.tsx`. swc: - Use `import_rewriter`. (Closes #1943, Closes #2523) - Update test (Closes #2715)
Hey everybody, I saw a PR that was dealing with this was merged, so I went ahead and tried the latest Unfortunately, I have to report that, at least on my end, the paths are still not being transformed the way they should be. The steps I did were the following...
The import test from "~/utils";
test();
{
"jsc": {
"parser": {
"syntax": "typescript"
},
"target": "es2020",
"paths": {
"~/*": ["./src/*"]
},
"baseUrl": "."
}
}
Results? Well, ultimately, the results were the same as reported initially. 😔 The compiled code was: import test from "~/utils";
test();
//# sourceMappingURL=index.js.map So, "~" wasn't replaced. And, as stated above, once I switched to "module": {
"type": "commonjs"
} ... the path transformation was successful: "use strict";
var _utils = _interopRequireDefault(require("./utils"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
(0, _utils).default();
//# sourceMappingURL=index.js.map Hope I'm not missing something. If so, I'm sorry in advance for the trouble. 🙂 |
I think another issue is better. |
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
Just started playing with SWC and I I'd just like to say this is an amazing tool. Just amazed how it's fast and how much work has been put into it. 🙏🏻
So, in my code, I have
~/........
import statements, but, once the SWC has done its magic, these are replaced with correct paths - only when I set"type": "commonjs"
in my.swcrc
file. Otherwise, they just stay the same.Input code
So, this is the resulting code. As we can see, the import paths haven't changed (~ is still here).
But, if I were to use the commonjs module type, then I'd see the path built correctly:
Config
commonjs
works (paths are changed correctly):This one does not work:
Expected behavior
The paths to be correctly replaced.
Version
The version of @swc/core:
1.2.102
Additional context
Checked a couple of issues reported by other users (#2126, #2050), those didn't provide any clues unfortunately.
The text was updated successfully, but these errors were encountered: