-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Feat react jsx #5131
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
Feat react jsx #5131
Conversation
Nx Cloud ReportCI ran the following commands for commit 4af43d8. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch Sent with 💌 from NxCloud. |
4fd91dc
to
1a501e0
Compare
28cc131
to
e0e42a0
Compare
b181dcf
to
b42061f
Compare
'react/jsx-uses-vars': 'warn', | ||
'react/no-danger-with-children': 'warn', | ||
'react/no-direct-mutation-state': 'warn', | ||
'react/no-is-mounted': 'warn', | ||
'react/no-typos': 'error', | ||
'react/react-in-jsx-scope': 'error', | ||
'react/jsx-uses-react': 'off', |
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.
Turned off since we no longer need these rules.
@@ -422,7 +422,6 @@ describe('lib', () => { | |||
outputPath: 'dist/libs/my-lib', | |||
project: 'libs/my-lib/package.json', | |||
tsConfig: 'libs/my-lib/tsconfig.lib.json', | |||
babelConfig: '@nrwl/react/plugins/bundle-babel', |
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.
This is deprecated and we should not generate new libraries with this option.
@@ -17,6 +18,13 @@ describe('react:storybook-configuration', () => { | |||
'@storybook/react': '^6.0.21', | |||
}, | |||
}); | |||
|
|||
jest.spyOn(logger, 'warn').mockImplementation(() => {}); |
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.
Turning off warn and debug so the test output is clean.
@@ -29,6 +29,13 @@ describe('migrate-defaults-5-to-6 schematic', () => { | |||
generateCypressSpecs: false, | |||
generateStories: false, | |||
}); | |||
|
|||
jest.spyOn(logger, 'warn').mockImplementation(() => {}); |
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.
Turning off warn and debug so the test output is clean.
e8e0f92
to
e20e9d5
Compare
59c69cb
to
74de523
Compare
988473a
to
2fdd287
Compare
packages/react/babel.ts
Outdated
|
||
// JSX spread is transformed into object spread in `@babel/plugin-transform-react-jsx` | ||
// `useBuiltIns` will be removed in Babel 8. | ||
if (presetOptions.runtime === 'automatic') { |
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.
since presetOptions.runtime
is nullable, but reactPresetOptions.runtime
is always set, should this be checking reactPresetOptions.runtime
instead?
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.
That's a good point, especially since we're not migrating their .babelrc
to set runtime
so we need to support it being undefined.
If I add a new library with |
hey @ptrhck . this was merged after 11.6.1 was released. I believe the intention for this change is to be released in version 12, coming soon |
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
This PR changes the default runtime to
automatic
so the new JSX transform is used.This change means users no longer need to
import React from 'react';
in their component files.Current Behavior
Uses "classic" runtime e.g.
React.createElement
Expected Behavior
Uses "automatic" runtime e.g.
_jsx(...)
from'react/jsx-runtime'
Related Issue(s)
Fixes #5090
Additional Information
jsx: 'react-jsx'
instead ofjsx: 'react'
(where applicable).@emotion/babel-plugin
instead of@emotion/babel-preset-css-prop
(where applicable)@nrwl/react:package
will warn user ifbabelConfig
is used -- it has been deprecated since Nx 10 -- we'll remove it in Nx 13.