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
Setup JSX runtime even if the file doesn't contain JSX #12479
Merged
nicolo-ribaudo
merged 2 commits into
babel:main
from
nicolo-ribaudo:regression-jsx-no-initially
Dec 10, 2020
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
1 change: 1 addition & 0 deletions
1
.../babel-plugin-transform-react-jsx/test/fixtures/regression/issue-12478-automatic/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 @@ | ||
const foo = 2; |
6 changes: 6 additions & 0 deletions
6
...el-plugin-transform-react-jsx/test/fixtures/regression/issue-12478-automatic/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,6 @@ | ||
{ | ||
"plugins": [ | ||
["transform-react-jsx", { "runtime": "automatic" }], | ||
"./plugin.js" | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
...babel-plugin-transform-react-jsx/test/fixtures/regression/issue-12478-automatic/output.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 @@ | ||
const foo = /*#__PURE__*/undefined.jsx("p", {}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a different unrelated bug: #12467 I'm preparing another PR for it, but it's lower priority since it's not a regression. |
13 changes: 13 additions & 0 deletions
13
...babel-plugin-transform-react-jsx/test/fixtures/regression/issue-12478-automatic/plugin.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,13 @@ | ||
module.exports = ({ types: t }) => ({ | ||
visitor: { | ||
NumericLiteral(path) { | ||
path.replaceWith( | ||
t.jsxElement( | ||
t.jsxOpeningElement(t.jsxIdentifier("p"), []), | ||
t.jsxClosingElement(t.jsxIdentifier("p")), | ||
[] | ||
) | ||
); | ||
} | ||
} | ||
}); |
1 change: 1 addition & 0 deletions
1
...es/babel-plugin-transform-react-jsx/test/fixtures/regression/issue-12478-classic/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 @@ | ||
const foo = 2; |
6 changes: 6 additions & 0 deletions
6
...abel-plugin-transform-react-jsx/test/fixtures/regression/issue-12478-classic/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,6 @@ | ||
{ | ||
"plugins": [ | ||
["transform-react-jsx", { "runtime": "classic" }], | ||
"./plugin.js" | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
...s/babel-plugin-transform-react-jsx/test/fixtures/regression/issue-12478-classic/output.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 @@ | ||
const foo = /*#__PURE__*/React.createElement("p", null); |
13 changes: 13 additions & 0 deletions
13
...s/babel-plugin-transform-react-jsx/test/fixtures/regression/issue-12478-classic/plugin.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,13 @@ | ||
module.exports = ({ types: t }) => ({ | ||
visitor: { | ||
NumericLiteral(path) { | ||
path.replaceWith( | ||
t.jsxElement( | ||
t.jsxOpeningElement(t.jsxIdentifier("p"), []), | ||
t.jsxClosingElement(t.jsxIdentifier("p")), | ||
[] | ||
) | ||
); | ||
} | ||
} | ||
}); |
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'm assuming the reason why this was done originally was for performance? And that there aren't plugins that convert non-jsx stuff but that I guess isn't the case then
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.
Yeah probably for performance, but doing a deep traversal to check if there is JSX isn't going to be fast anyway.
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.
Makes me think this sort of thing shouldn't need to be set every file if it's the same for all of them (for the most part unless you use comments or overrides)?
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.
Yeah, usually you just set it once in the config file.