swc
swc copied to clipboard
Add ".js" extensions on ESM import/export paths for ".jsx" files during transpilation
Describe the feature
When using the resolveFully: true flag regular .js file imports/exports get their file extensions added in the transpiled code and it would be cool if this could be extended to files imported with the .jsx file extension.
Current Behaviour
Using this command: swc ./src -d ./lib --strip-leading-paths
And these files: .swcrc
{
"module": {
"type": "es6",
"resolveFully": true
},
"jsc": {
"baseUrl": "."
"parser": {
"syntax": "ecmascript"
"jsx": true
}
}
}
src/button.jsx
export function Button(props) {
return <button {...props} />;
}
src/greet.js
export function greet() {
return "Hello";
}
src/index.js
export { greet } from "./greet";
export { Button } from "./button";
Outputs:
- lib/button.js
- lib/greet.js
- lib/index.js
Where index.js contains
export { greet } from "./greet.js";
export { Button } from "./button";
Desired Behaviour
Imports for files that were originally had a .jsx extension should resolve to full imports/exports with a .js extension.
export { greet } from "./greet.js";
export { Button } from "./button.js";
Related issues
- https://github.com/swc-project/swc/issues/8742
Babel plugin or link to the feature description
No response
Additional context
No response