Skip to content
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
merged 2 commits into from Dec 10, 2020

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Dec 10, 2020

Q                       A
Fixed Issues? Fixes #12478
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Please review with whitespaces diff off

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories area: react i: regression area: jsx labels Dec 10, 2020
@@ -0,0 +1 @@
const foo = /*#__PURE__*/undefined.jsx("p", {});
Copy link
Member Author

Choose a reason for hiding this comment

The 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.

@babel-bot
Copy link
Collaborator

babel-bot commented Dec 10, 2020

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/34726/

@nicolo-ribaudo
Copy link
Member Author

Btw, we have this test that ensures that even if we are always setting up the runtime, we don't inject it when it's not needed: https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-react-jsx/test/fixtures/nextAutoImport/no-jsx

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 10, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2cbe36d:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@@ -138,136 +138,134 @@ You can set \`throwIfNamespace: false\` to bypass this warning.`,

Program: {
enter(path, state) {
if (hasJSX(path)) {
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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)?

Copy link
Member Author

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.

@nicolo-ribaudo nicolo-ribaudo merged commit bf41718 into babel:main Dec 10, 2020
@nicolo-ribaudo nicolo-ribaudo deleted the regression-jsx-no-initially branch December 10, 2020 18:27
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Mar 12, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2021
weaverryan added a commit to weaverryan/webpack-encore that referenced this pull request Jul 6, 2022
weaverryan added a commit to weaverryan/webpack-encore that referenced this pull request Jul 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: jsx area: react i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pass.get(...) is not a function in @babel/plugin-transform-react-jsx
5 participants