From 15a2dee956c5ec3efe6bbf265e3192de548c75dd Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Wed, 25 Feb 2026 13:19:34 +0000 Subject: [PATCH] wp-build: Deregister script modules before re-registering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #75705 removed the `remove_action( 'wp_default_scripts', 'wp_default_script_modules' )` line to fix issues with third-party plugins using wp-build without Gutenberg activated. However, this caused a regression: since `wp_register_script_module()` does not override existing registrations, Gutenberg's bundled module versions are now silently ignored in favor of Core's versions. This is a problem for any module where Gutenberg's version differs from Core's (e.g., modules with additional bundled dependencies like the playlist view script module). Fix by calling `wp_deregister_script_module()` before registering each module. This is a more targeted approach than removing Core's entire registration action — it allows Core to register its modules normally while ensuring the plugin's versions take precedence. Co-Authored-By: Claude Opus 4.6 --- packages/wp-build/templates/module-registration.php.template | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/wp-build/templates/module-registration.php.template b/packages/wp-build/templates/module-registration.php.template index a531d8e2ca3bf5..c9cc9ac3bad559 100644 --- a/packages/wp-build/templates/module-registration.php.template +++ b/packages/wp-build/templates/module-registration.php.template @@ -28,6 +28,10 @@ if ( ! function_exists( '{{PREFIX}}_register_script_modules' ) ) { $asset_path = $modules_dir . '/' . $module['asset']; $asset = file_exists( $asset_path ) ? require $asset_path : array(); + // Deregister first to override any previously registered version + // (e.g., Core's default modules when running as a plugin). + wp_deregister_script_module( $module['id'] ); + wp_register_script_module( $module['id'], $base_url . $module['path'] . $extension,