Skip to content
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

Build: Enable React Fast Refresh for block development #2519

Closed
wants to merge 5 commits into from

Conversation

gziolo
Copy link
Member

@gziolo gziolo commented Apr 5, 2022

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

Depends on #2263.

Brings the same functionality introduced in the Gutenberg plugin with WordPress/gutenberg#28273. In effect, it brings React Fast Refresh support to WordPress core for block development with @wordpress/scripts.

The way I test it:

cd src/wp-content/plugins
npx @wordpress/create-block gutenpride -t @wordpress/create-block-tutorial-template
cd my-block
npm start -- --hot

Ensure your WordPress develop instance has SCRIPT_DEBUG set to true. It should be the default when using npm run env:start. You also need to activate the plugin with the Gurenpride block.

Screenshots

React.Refresh.Safari.mov
React.Refresh.Chrome.and.Safari.mov

This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copy link

@anton-vlasenko anton-vlasenko left a comment

Choose a reason for hiding this comment

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

@gziolo It would be nice to add a PHPUnit test for wp_register_development_scripts.
I'd be happy to assist with that.
Also, please see my notes below.
Thank you.

src/wp-includes/script-loader.php Outdated Show resolved Hide resolved
src/wp-includes/script-loader.php Outdated Show resolved Hide resolved
src/wp-includes/script-loader.php Show resolved Hide resolved
src/wp-includes/script-loader.php Outdated Show resolved Hide resolved
@walbo
Copy link
Member

walbo commented Apr 11, 2022

Tested and works as expected (tested in firefox and chrome with wp-scripts). 🎉

Copy link

@anton-vlasenko anton-vlasenko left a comment

Choose a reason for hiding this comment

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

I haven't reviewed JavaScript changes, but the PHP part of the PR looks good to me.

@gziolo
Copy link
Member Author

gziolo commented Apr 11, 2022

Committed with https://core.trac.wordpress.org/changeset/53140.

@gziolo gziolo closed this Apr 11, 2022
@gziolo gziolo deleted the update/react-fast-refresh branch April 11, 2022 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants