fix(plugin-react): apply manual runtime interop #8546
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fix #8468
Fix #5885
Supersedes #7246, though didn't implement deduping
react/jsx-runtime
andreact/jsx-dev-runtime
as I think that's a risky optimization.Additional context
The esbuild+rollup issue arise because the old interop code depends on
@rollup/plugin-commonjs
to handle the CJS code. Without it, the interop failed, and without interop it caused #8468.Interop can't be applied with
importAnalysisBuild
because the JSX code in question is innode_modules
, andimportAnalysisBuild
don't handle both JSX files (es-module-lexer) and those insidenode_modules
.This PR implements a virtual proxy file for the react runtime import that implements interop, working with esbuild.
(I have not tested without esbuild optimization in build)worksI think the issue at the start would've been better resolved with
optimizeDeps.extensions
. I'd love to start implementing it for plugin-vue and plugin-react, but there's one more piece I haven't implement in core.All-in-all, this PR helps prevent the regression at the meantime.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).