-
Notifications
You must be signed in to change notification settings - Fork 46.3k
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
add jsx-runtime and jsx-dev-runtime modules #18299
Conversation
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 ded98d8:
|
Details of bundled changes.Comparing: 2666642...ded98d8 react
React: size: -3.5%, gzip: -2.6% Size changes (experimental) |
Details of bundled changes.Comparing: 2666642...ded98d8 react
Size changes (stable) |
@@ -34,6 +35,7 @@ describe('ReactElement.jsx', () => { | |||
ReactFeatureFlags.warnAboutSpreadingKeyToJSX = true; |
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.
If this test wasn't marked as "internal", it would fail on bundles as it should — because we haven't exposed these entry points on npm. To do that, check out how files in npm/
folders in different packages work. Also note (Oops, you have that part — but still need "files"
array in package.json
of each package.npm
entry points.)
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.
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.
Need to add npm entry points.
You'll also need to add them to |
Pls rebase :-) I think this should fail now. |
88ea8d9
to
9565d1b
Compare
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.
lg, pending CI, nits and a decision on UMD bundles.
Note that if we merge this now, the next release will go out with these entry points. Are we ready in terms of final naming, bundles, etc?
ef6fb14
to
a5aa16e
Compare
@@ -29,6 +30,7 @@ describe('ReactElement.jsx', () => { | |||
global.Symbol = undefined; | |||
|
|||
React = require('react'); | |||
jsxRuntime = require('react/jsx-runtime'); |
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.
Super nit: JSXRuntime in tests for capitalization consistency? I don't care tho
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.
Okay as we figured out, we still have an issue with duplication of bundle content.
What we need to do is to remove jsx from the React object completely, and to create separate entry points for both runtimes. Like src/jsx/JSXRuntime. There you can put the jsx() implementation with the minimal copy paste it needs (ReactElement) and an import of the current owner from React. Note you can’t just import it from parent folder. You need to get it from require(“react”) like all other packages do. Because otherwise we’ll get a copy of it in our bundle.
Then for FB bundle if we want to keep React.jsx working for a bit you could do this in the FB index file I think. Just re export from both React and Runtime.
packages/react/package.json
Outdated
@@ -29,6 +31,9 @@ | |||
"loose-envify": "^1.1.0", | |||
"object-assign": "^4.1.1" | |||
}, | |||
"peerDependencies": { |
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.
A package can't be its own peer. This isn't needed. If our scripts complain it's our scripts that should be fixed.
249203e
to
2b03ad8
Compare
This PR adds the
jsx-runtime
andjsx-dev-runtime
modules for the JSX Babel Plugin. WWW still relies onjsx/jsxs/jsxDEV
from the"react"
module, so once we refactor the code to point to the runtime modules we will removejsx/jsxs/jsxDEV
from the"react"
module.