-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix: incorrect transform jsx-runtime
in development
#2741
Merged
kdy1
merged 46 commits into
swc-project:main
from
Shinyaigeek:fix/incorrect-import-jsx-development-runtime
Dec 10, 2021
Merged
Changes from 45 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
8444297
fix(es_transforms_react): fix import behavior in dev mode
Shinyaigeek b5e80d9
chore: add test for jsx-dev-runtime
Shinyaigeek 96087d1
Update: jsx_src not apply __source props in runtime automatic
Shinyaigeek 54e34c6
Update: jsx_self not apply __self into props with runtime: automatic
Shinyaigeek 77322cd
Update: chain source and self in jsxDev
Shinyaigeek 03469b0
Update: apply source and self and isStaticValidation with jsxDev
Shinyaigeek a8b4564
Chore: update test for jsx-dev-runtime
Shinyaigeek 7e0d292
Update: set __src and __self into props also in runtime: automatic
Shinyaigeek 512287d
Chore: remove unncecessary break line
Shinyaigeek 31c2085
Update: fix key handling
Shinyaigeek 59275d6
Update: get __source and __self from props and set it into jsxDEV in …
Shinyaigeek 798720c
Chore: add test for integration jsx, jsx_src, jsx_self
Shinyaigeek 1969dca
Chore: mv jsx-dev-transform test
Shinyaigeek 8f762f8
Refactor: replace String with str
Shinyaigeek a56ffa3
Refactor: avoied __ for __self and __source
Shinyaigeek 6b13073
Refactor: use undefined util module
Shinyaigeek 3526ff9
Refactor: replace Some -> once
Shinyaigeek 0e831ae
Chore: add some test for jsx transforms
Shinyaigeek d09b3a9
fix(es_transforms_react): fix import behavior in dev mode
Shinyaigeek c2b2e5e
chore: add test for jsx-dev-runtime
Shinyaigeek 4514808
Update: jsx_src not apply __source props in runtime automatic
Shinyaigeek 841e746
Update: jsx_self not apply __self into props with runtime: automatic
Shinyaigeek 04b436e
Update: chain source and self in jsxDev
Shinyaigeek faf413c
Update: apply source and self and isStaticValidation with jsxDev
Shinyaigeek 2971268
Chore: update test for jsx-dev-runtime
Shinyaigeek 0944196
Update: set __src and __self into props also in runtime: automatic
Shinyaigeek e5ebdd0
Chore: remove unncecessary break line
Shinyaigeek 93902b5
Update: fix key handling
Shinyaigeek ed291e2
Update: get __source and __self from props and set it into jsxDEV in …
Shinyaigeek 47a377d
Chore: add test for integration jsx, jsx_src, jsx_self
Shinyaigeek 211d214
Chore: mv jsx-dev-transform test
Shinyaigeek 3212e23
Refactor: replace String with str
Shinyaigeek cee7b47
Refactor: avoied __ for __self and __source
Shinyaigeek 6aa3885
Refactor: use undefined util module
Shinyaigeek 8829383
Refactor: replace Some -> once
Shinyaigeek e36fda1
Chore: add some test for jsx transforms
Shinyaigeek b1716df
Chore: add test case for Fragment jsxDev argument
Shinyaigeek 2454c08
Merge branch 'fix/incorrect-import-jsx-development-runtime' of https:…
Shinyaigeek 1004193
Chore: update other test case use Fragment with development mode
Shinyaigeek 5cd46d9
Update: atatch key and isStaticChild into Fragment with development mode
Shinyaigeek 5cae082
Chore: fmt
Shinyaigeek 79f6e2e
Chore: add test case for fragment
Shinyaigeek 8a8fc1e
Update: use undefined(DUMMY_SP) instread of Boxing
Shinyaigeek fdaaaa2
Chore: move jsxdev-args-with-gragment test from fixture into integration
Shinyaigeek 5be5cf0
Update: use chain instead of vec and into_iter
Shinyaigeek 5af8a79
Merge branch 'main' into fix/incorrect-import-jsx-development-runtime
kdy1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
8 changes: 8 additions & 0 deletions
8
crates/swc_ecma_transforms_react/tests/integration/fixture/jsx-dev-transform/input.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const App = ( | ||
<div> | ||
<div /> | ||
<> | ||
<div key={1}>hoge</div> | ||
</> | ||
</div> | ||
); |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_react/tests/integration/fixture/jsx-dev-transform/options.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "runtime": "automatic", "development": true } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this code will error if
/* @jsxRuntime automatic */
is used.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of this, the babel plugin detect attributes named
__source
and__self
and change those into arguments.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m sorry for that I did not know about jsx directives.
Is this the process below?
https://github.com/babel/babel/blob/main/packages/babel-plugin-transform-react-jsx/src/create-plugin.ts#L502
I am worried if my understanding is correct, but should I fix the code to set
__source
and__self
props as JSX attribute in development mode as usual?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for late response, I missed the email.
Yes.
I think so, as it's what babel does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your reply and help!
I fixed code like below
__source
and__self
to props withjsx_src
andjsx_self
(as usual)runtime: automatic
anddevelopment: true
configuration, swc extract__source
and__self
from JSX’s attributes and set it as_jsxDEV
’s arguments.it looks like there are not test settings to test
react
module(=jsx
withjsx_src
andjsx_self
) with a specific configuration, so I addedintegration
testing directory to testreact
module with a specific configuration.If there is yet something I missed, I will be happy if you pointed it out.