fix(plugin-react): apply manual runtime interop#8546
Merged
patak-dev merged 3 commits intovitejs:mainfrom Jun 12, 2022
bluwy:fix-react-interop
Merged
fix(plugin-react): apply manual runtime interop#8546patak-dev merged 3 commits intovitejs:mainfrom bluwy:fix-react-interop
patak-dev merged 3 commits intovitejs:mainfrom
bluwy:fix-react-interop
Conversation
patak-dev
reviewed
Jun 11, 2022
Member
|
Looks good to me. We should check how it works when tge optimizer is disabled and commonjs is used. It should still work though, no? If not we could revert to the prev code in that case |
Member
Author
|
Looks like it does work with |
patak-dev
approved these changes
Jun 12, 2022
Member
patak-dev
left a comment
There was a problem hiding this comment.
Thanks for taking care of this @bluwy! Let's merge it and release a new plugin-react alpha so others can test.
I 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.
Sweet!
4 tasks
7 tasks
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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-runtimeandreact/jsx-dev-runtimeas I think that's a risky optimization.Additional context
The esbuild+rollup issue arise because the old interop code depends on
@rollup/plugin-commonjsto handle the CJS code. Without it, the interop failed, and without interop it caused #8468.Interop can't be applied with
importAnalysisBuildbecause the JSX code in question is innode_modules, andimportAnalysisBuilddon'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).