Skip to content
Closed
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
9 changes: 4 additions & 5 deletions bin/packages/build-vendors.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,15 @@ async function bundleReactJsxRuntime() {
async function bundleReactRefresh() {
console.log( '📦 Bundling React Refresh...' );

// Bundle react-refresh-entry
// Bundle react-refresh-entry using react-refresh
const entryDir = path.join( BUILD_DIR, 'react-refresh-entry' );
await mkdir( entryDir, { recursive: true } );

// The entry file uses ReactRefreshRuntime global, so no bundling needed
await esbuild.build( {
entryPoints: [
'@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js',
],
entryPoints: [ path.join( __dirname, 'react-refresh-entry.js' ) ],
outfile: path.join( entryDir, 'index.min.js' ),
bundle: true,
bundle: false,
format: 'iife',
target: 'es2015',
platform: 'browser',
Expand Down
16 changes: 16 additions & 0 deletions bin/packages/react-refresh-entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* React Refresh Entry
*
* Injects the React Refresh runtime into the global hook for hot module replacement.
* This file uses the ReactRefreshRuntime global provided by wp-react-refresh-runtime.
*/

/* global ReactRefreshRuntime */

if (
typeof ReactRefreshRuntime !== 'undefined' &&
! globalThis.__reactRefreshInjected
) {
ReactRefreshRuntime.injectIntoGlobalHook( globalThis );
globalThis.__reactRefreshInjected = true;
}
1 change: 1 addition & 0 deletions bin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"log-performance-results.js",
"packages/build-vendors.mjs",
"packages/build.mjs",
"packages/react-refresh-entry.js",
"packages/check-build-type-declaration-files.js",
"plugin/cli.js",
"plugin/commands/common.js",
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"@inquirer/prompts": "7.2.0",
"@octokit/rest": "16.26.0",
"@playwright/test": "1.57.0",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
"@storybook/addon-a11y": "10.1.11",
"@storybook/addon-docs": "10.1.11",
"@storybook/icons": "2.0.1",
Expand Down
Loading