wp_register_development_scripts()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
wp_register_development_scripts( WP_Scripts $scripts )
Описание
Эти скрипты включают горячую замену модулей (HMR) при разработке блоков с использованием wp-scripts start --hot.
См. также https://github.com/WordPress/gutenberg/tree/trunk/packages/scripts#start
Оригинал (английский)
These scripts enable hot module replacement (HMR) for block development when using wp-scripts start --hot.
Параметры
$scripts
WP_Scripts
обязательный
Исходный код
wp-includes/script-loader.php:180
function wp_register_development_scripts( $scripts ) {
if (
! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG
|| empty( $scripts->registered['react'] )
|| defined( 'WP_RUN_CORE_TESTS' )
) {
return;
}
// React Refresh runtime - exposes ReactRefreshRuntime global.
// No dependencies.
$scripts->add(
'wp-react-refresh-runtime',
'/wp-includes/js/dist/development/react-refresh-runtime.js',
array(),
'0.14.0'
);
// React Refresh entry - injects runtime into global hook.
// Must load before React to set up hooks.
$scripts->add(
'wp-react-refresh-entry',
'/wp-includes/js/dist/development/react-refresh-entry.js',
array( 'wp-react-refresh-runtime' ),
'0.14.0'
);
// Add entry as a dependency of React so it loads first.
// See https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/TROUBLESHOOTING.md#externalising-react.
$scripts->registered['react']->deps[] = 'wp-react-refresh-entry';
}
История изменений
| Версия | Описание |
|---|---|
| 6.0.0 | Introduced. |

