Skip to content

JSX preserve mode: unused import of "react/jsx-runtime" #7433

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

Open
cknitt opened this issue May 6, 2025 · 6 comments
Open

JSX preserve mode: unused import of "react/jsx-runtime" #7433

cknitt opened this issue May 6, 2025 · 6 comments
Assignees
Milestone

Comments

@cknitt
Copy link
Member

cknitt commented May 6, 2025

When JSX preserve mode is active, the import statement

import * as JsxRuntime from "react/jsx-runtime";

is still emitted to the JS output, but is unused there.

@cknitt cknitt added this to the v12 milestone May 6, 2025
@nojaf
Copy link
Collaborator

nojaf commented May 8, 2025

@cristianoc do you have any ideas when the import * line is constructed?
In which phase would that happen? I think tackling it there might be the safer than avoid it in js_dump (since other code might need it).

@zth
Copy link
Collaborator

zth commented May 8, 2025

Do we really need to care about this for v12? Bundlers will just remove it because it's dead anyway.

@cristianoc
Copy link
Collaborator

@cristianoc do you have any ideas when the import * line is constructed? In which phase would that happen? I think tackling it there might be the safer than avoid it in js_dump (since other code might need it).

Looks like it's coming from a react external.
I guess the code is generated that makes use of jsx runtime, but later on dump is customised to emit preserve mode so it appears to be unused (but it was used, before dumping).

@nojaf
Copy link
Collaborator

nojaf commented May 8, 2025

Yes, I'm aware of that, it makes sense why it is there. I'm just wondering, where in the codebase it will organize the imports and how that part works?

@cristianoc
Copy link
Collaborator

Yes, I'm aware of that, it makes sense why it is there. I'm just wondering, where in the codebase it will organize the imports and how that part works?

I think it's in Lam_compile_main.compile, which does the last phase of compilation and determines dependencies.

@cknitt
Copy link
Member Author

cknitt commented May 8, 2025

Do we really need to care about this for v12? Bundlers will just remove it because it's dead anyway.

Certainly not a blocker, but still a bit weird to emit unused imports, we never did that before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants