Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/babel-plugin-import-jsx-pragma/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ _Note:_ `@wordpress/babel-plugin-import-jsx-pragma` is included in `@wordpress/b

As the `@babel/plugin-transform-react-jsx` plugin offers options to customize the `pragma` to which the transform references, there are equivalent options to assign for customizing the imports generated.

For example, if you are using the `@wordpress/element` package, you may want to use the following configuration:
For example, if you are using the `react` package, you may want to use the following configuration:

```js
// .babelrc.js
Expand All @@ -49,7 +49,7 @@ module.exports = {
{
scopeVariable: 'createElement',
scopeVariableFrag: 'Fragment',
source: '@wordpress/element',
source: 'react',
isDefault: false,
},
],
Expand Down
4 changes: 4 additions & 0 deletions packages/babel-preset-default/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- The bundled `browserslist` dependency has been updated from requiring `^4.21.9` to requiring `^4.21.10` ([#54657](https://github.com/WordPress/gutenberg/pull/54657)).

## Enhancements

- Use `react` as the default scope variable for JSX pragma instead of `@wordpress/element`.

## 7.26.0 (2023-09-20)

## 7.25.0 (2023-08-31)
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset-default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module.exports = ( api ) => {
{
scopeVariable: 'createElement',
scopeVariableFrag: 'Fragment',
source: '@wordpress/element',
source: 'react',
isDefault: false,
},
],
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-preset-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"@babel/runtime": "^7.16.0",
"@wordpress/babel-plugin-import-jsx-pragma": "file:../babel-plugin-import-jsx-pragma",
"@wordpress/browserslist-config": "file:../browserslist-config",
"@wordpress/element": "file:../element",
"@wordpress/warning": "file:../warning",
"browserslist": "^4.21.10",
"core-js": "^3.31.0"
"core-js": "^3.31.0",
"react": "^18.2.0"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure that we need this dependency here but I just mirrored the previous @wordpress/element dependency.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency was added by @gziolo in #17027 and I don't understand the rationale very well. The preset doesn't use element or react. The problem was something like when a project (e.g., a block) depends on wp-scripts, it should install everything wp-scripts needs automatically, instead of the project's package.json having to specify additional dependencies explicitly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t remember the exact reasoning behind it. Maybe there is still value in keeping it but as a peer dependency since it’s React now. Although it doesn’t seem to be necessary anymore for plugins when using wp-scripts build because it converts imports to react or wp.element. It might be different with unit tests though.

},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native-editor/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ module.exports = function ( api ) {
/node_modules\/(react-native|@react-native-community|@react-navigation|react-native-reanimated)/,
},
{
// Auto-add `import { createElement } from '@wordpress/element';` when JSX is found.
// Auto-add `import { createElement } from 'react';` when JSX is found.
plugins: [
[
'@wordpress/babel-plugin-import-jsx-pragma',
{
scopeVariable: 'createElement',
scopeVariableFrag: 'Fragment',
source: '@wordpress/element',
source: 'react',
isDefault: false,
},
],
Expand Down