Skip to content

Commit a6f272d

Browse files
ramonjdandrewserongadamsilverstein
committed
Build: Fix vips worker 404 when SCRIPT_DEBUG is true (#76657)
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
1 parent d587099 commit a6f272d

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

packages/wp-build/lib/build.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ async function bundlePackage( packageName, options = {} ) {
661661
id: scriptModuleId,
662662
path: `${ packageName }/${ fileName }`,
663663
asset: `${ packageName }/${ fileName }.min.asset.php`,
664+
min_only: isWasmWorker,
664665
} );
665666
}
666667
}
@@ -923,6 +924,7 @@ async function generateModuleRegistrationPhp( modules, replacements ) {
923924
`\t\t'id' => '${ module.id }',\n` +
924925
`\t\t'path' => '${ module.path }',\n` +
925926
`\t\t'asset' => '${ module.asset }',\n` +
927+
( module.min_only ? `\t\t'min_only' => true,\n` : '' ) +
926928
`\t),`
927929
)
928930
.join( '\n' );

packages/wp-build/templates/module-registration.php.template

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ function {{PREFIX}}_register_script_modules() {
3131

3232
$modules = require $modules_file;
3333
$base_url = $build_constants['build_url'] . 'modules/';
34-
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
3534

3635
foreach ( $modules as $module ) {
36+
// WASM-only modules (e.g., vips worker) only have .min.js; use it even when SCRIPT_DEBUG is `true`.
37+
$extension = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG && empty( $module['min_only'] ) )
38+
? '.js'
39+
: '.min.js';
40+
3741
$asset_path = $modules_dir . '/' . $module['asset'];
3842
$asset = file_exists( $asset_path ) ? require $asset_path : array();
3943

0 commit comments

Comments
 (0)