-
Notifications
You must be signed in to change notification settings - Fork 4.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
Add jsx-runtime
entry for the new automatic JSX transform
#34221
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
packages/element/jsx-runtime/package.json | ||
packages/element/jsx-dev-runtime/package.json |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,14 +30,12 @@ | |
"main": "index.js", | ||
"dependencies": { | ||
"@babel/core": "^7.13.10", | ||
"@babel/plugin-transform-react-jsx": "^7.12.7", | ||
"@babel/plugin-transform-runtime": "^7.13.10", | ||
"@babel/preset-env": "^7.13.10", | ||
"@babel/preset-react": "^7.10.1", | ||
"@babel/preset-typescript": "^7.13.0", | ||
"@babel/runtime": "^7.13.10", | ||
"@wordpress/babel-plugin-import-jsx-pragma": "file:../babel-plugin-import-jsx-pragma", | ||
"@wordpress/browserslist-config": "file:../browserslist-config", | ||
"@wordpress/element": "file:../element", | ||
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. I don't think we need this as a dependency. Peer dependency, probably, but not a dependency. 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. Right, I don't remember why we set them as dependencies. Maybe for developers' convenience because they would need to add |
||
"@wordpress/warning": "file:../warning", | ||
"browserslist": "^4.16.6", | ||
"core-js": "^3.12.1" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import 'react/jsx-dev-runtime'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
kevin940726 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"main": "../build/jsx-dev-runtime.js", | ||
"module": "../build-module/jsx-dev-runtime.js", | ||
"react-native": "../src/jsx-dev-runtime.js", | ||
"types": "./jsx-dev-runtime.d.ts", | ||
"sideEffects": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import 'react/jsx-runtime'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"main": "../build/jsx-runtime.js", | ||
"module": "../build-module/jsx-runtime.js", | ||
"react-native": "../src/jsx-runtime.js", | ||
"types": "./jsx-runtime.d.ts", | ||
"sideEffects": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from 'react/jsx-dev-runtime'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from 'react/jsx-runtime'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,21 +43,39 @@ const exportDefaultPackages = [ | |
module.exports = { | ||
...baseConfig, | ||
name: 'packages', | ||
entry: gutenbergPackages.reduce( ( memo, packageName ) => { | ||
return { | ||
...memo, | ||
[ packageName ]: { | ||
import: `./packages/${ packageName }`, | ||
entry: gutenbergPackages.reduce( | ||
( memo, packageName ) => { | ||
return { | ||
...memo, | ||
[ packageName ]: { | ||
import: `./packages/${ packageName }`, | ||
library: { | ||
name: [ 'wp', camelCaseDash( packageName ) ], | ||
type: 'window', | ||
export: exportDefaultPackages.includes( packageName ) | ||
? 'default' | ||
: undefined, | ||
}, | ||
}, | ||
}; | ||
}, | ||
{ | ||
'jsx-runtime': { | ||
import: './packages/element/jsx-runtime', | ||
library: { | ||
name: [ 'wp', 'jsxRuntime' ], | ||
type: 'window', | ||
}, | ||
}, | ||
'jsx-dev-runtime': { | ||
import: './packages/element/jsx-dev-runtime', | ||
library: { | ||
name: [ 'wp', camelCaseDash( packageName ) ], | ||
name: [ 'wp', 'jsxDevRuntime' ], | ||
type: 'window', | ||
export: exportDefaultPackages.includes( packageName ) | ||
? 'default' | ||
: undefined, | ||
}, | ||
}, | ||
}; | ||
}, {} ), | ||
} | ||
), | ||
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. Changes here need to be backported to Core's webpack config later as well. |
||
output: { | ||
devtoolNamespace: 'wp', | ||
filename: './build/[name]/index.min.js', | ||
|
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 not sure why we weren't doing this?
This let Babel knows that we're targeting production builds, and applies some prod-only enhancements. I guess it's because we didn't have any plugins that used this feature?
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 guess this was part of
npm run build:packages
internally no?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.
npm run build:packages
is also used bynpm run dev
, so I think no.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.
We use different environments in
npm run build:packages
:main
forbuild
foldersmodule
forbuild-module
foldersI guess the current flow doesn't care whether it's a production or development env. We leave that part to webpack to decide.
As far as I can tell, the Babel preset for WordPress has a special handling only for the
test
env.