Skip to content
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

Add ".js" extensions on ESM import/export paths for ".jsx" files during transpilation #8935

Closed
mikefarquhar opened this issue May 8, 2024 · 1 comment · Fixed by #8936
Closed
Assignees
Milestone

Comments

@mikefarquhar
Copy link

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

Babel plugin or link to the feature description

No response

Additional context

No response

@kdy1 kdy1 added this to the Planned milestone May 8, 2024
@kdy1 kdy1 self-assigned this May 8, 2024
@kdy1 kdy1 closed this as completed in #8936 May 8, 2024
kdy1 added a commit that referenced this issue May 8, 2024
@kdy1 kdy1 modified the milestones: Planned, v1.5.5 May 8, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented Jun 7, 2024

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.

@swc-project swc-project locked as resolved and limited conversation to collaborators Jun 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

3 participants