Make WordPress Core

Opened 6 months ago

Closed 6 months ago

Last modified 5 months ago

#61324 closed enhancement (fixed)

React: Upgrade to the new JSX transform

Reported by: youknowriad's profile youknowriad Owned by: ellatrix's profile ellatrix
Milestone: 6.6 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: gutenberg-merge has-patch
Focuses: javascript Cc:

Description

The next version of the WordPress packages is going to rely on the JSX transform after this Gutenberg PR https://github.com/WordPress/gutenberg/pull/61692

So this tickets tracks the backport of the webpack config change in that PR in order to be able to load the JSX runtime from the global variable.

Change History (9)

This ticket was mentioned in PR #6678 on WordPress/wordpress-develop by @youknowriad.


6 months ago
#1

  • Keywords has-patch added

Trac ticket: https://core.trac.wordpress.org/ticket/61324

Backports Gutenberg PR https://github.com/WordPress/gutenberg/pull/61692

This PR adds the necessary webpack config to build the React JSX Runtime script and adds the script to WordPress. Without this, the next package update on Core will be blocked as the new packages are going to be using the new JSX Runtime.

For the moment though, you can test that the PR adds the react-jsx-runtime script to wp-includes/js/dist/vendor/react-jsx-runtime.js
Also if you load manually the react-jsx-runtime in WordPress, you'll see the ReactJSXRuntime global available in the console.

#2 @ellatrix
6 months ago

  • Owner set to ellatrix
  • Resolution set to fixed
  • Status changed from new to closed

In 58271:

React: Upgrade to the new JSX transform.

See https://github.com/WordPress/gutenberg/pull/61692.
See https://github.com/WordPress/wordpress-develop/pull/6678.

Props youknowriad.

Fixes #61324.

#3 @ellatrix
6 months ago

In 58273:

Add missing vendors file after r58271.

See #61324.

#4 @desrosj
6 months ago

In 58408:

Coding Standards: Apply changes after running composer format.

This applies several formatting related changes made while running composer format.

Follow up to [55720], [58171], [58271], [58282], [58283], [58292], [58299], [58303], [58332].
See #51857, #60719, #60895, #61021, #61118, #61228, #61276, #61324.

This ticket was mentioned in PR #7021 on WordPress/wordpress-develop by @youknowriad.


5 months ago
#5

In 6.6 we tried moving away from the deprecated React UMD builds, the issue we faced is that there's a warning that is triggered on the console because we're not using a separate impact for createRoot. (SCRIPT_DEBUG true and npm run build)

Warning: You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".

This warning has been removed in React 19 though along with the removal of the UMD builds, so we should be able to revert this PR when we upgrade to React 19.

@Mamaduka commented on PR #7021:


5 months ago
#6

@youknowriad, can you share testing instructions for the core? From our Slack conversation, I remember that some changes were required for wp-env.

@youknowriad commented on PR #7021:


5 months ago
#7

Yes, so to reproduce the issue on core, you have to use the "build" folder in your environment so

  • in .env file, you can change the LOCAL_DIR to build instead of src
  • run npm run build
  • run npm run env:start to launch the environment

you should be able to see the issue in trunk but not in this PR.

#8 @youknowriad
5 months ago

In 58775:

Build Tools: Use umd builds provided by React instead of bundling our own builds.

We tried moving away from the deprecated React UMD builds previously,
the problem we faced is that there's a warning that is triggered on the console because we're not using a separate impact for createRoot.

This warning has been removed in React 19 along with the removal of the UMD builds, so we should be able to revert this commit when we upgrade to React 19 but for now, we need to restore the usage of the umd builds.

Props mamaduka.
See #61324.

Note: See TracTickets for help on using tickets.