Skip to content

Build: Enable React Fast Refresh for block development#2519

Closed
gziolo wants to merge 5 commits into
WordPress:trunkfrom
gziolo:update/react-fast-refresh
Closed

Build: Enable React Fast Refresh for block development#2519
gziolo wants to merge 5 commits into
WordPress:trunkfrom
gziolo:update/react-fast-refresh

Conversation

@gziolo

@gziolo gziolo commented Apr 5, 2022

Copy link
Copy Markdown
Member

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.

@anton-vlasenko anton-vlasenko left a comment

Copy link
Copy Markdown

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.

Comment thread src/wp-includes/script-loader.php Outdated
Comment thread src/wp-includes/script-loader.php Outdated
Comment thread src/wp-includes/script-loader.php
Comment thread src/wp-includes/script-loader.php Outdated
@gziolo gziolo force-pushed the update/react-fast-refresh branch from 9cc28c4 to b1f7065 Compare April 11, 2022 13:39
@walbo

walbo commented Apr 11, 2022

Copy link
Copy Markdown
Member

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

@anton-vlasenko anton-vlasenko left a comment

Copy link
Copy Markdown

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

gziolo commented Apr 11, 2022

Copy link
Copy Markdown
Member Author

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