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
6 changes: 6 additions & 0 deletions src/wp-includes/script-modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ function wp_default_script_modules() {
wp_interactivity()->add_client_navigation_support_to_script_module( $script_module_id );
}

// VIPS files are always minified — the non-minified versions are not
// shipped because they are ~10MB of inlined WASM with no debugging value.
if ( str_starts_with( $file_name, 'vips/' ) && ! str_contains( $file_name, '.min.' ) ) {
$file_name = str_replace( '.js', '.min.js', $file_name );
}

$path = includes_url( "js/dist/script-modules/{$file_name}" );
$module_deps = $script_module_data['module_dependencies'] ?? array();
wp_register_script_module( $script_module_id, $path, $module_deps, $script_module_data['version'], $args );
Expand Down
21 changes: 21 additions & 0 deletions tests/phpunit/tests/script-modules/wpScriptModules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1903,6 +1903,27 @@ public function test_dependent_of_default_script_modules() {
$this->assertEqualHTML( $expected, $actual );
}

/**
* Tests that VIPS script modules always use minified file paths.
*
* Non-minified VIPS files are not shipped because they are ~10MB of
* inlined WASM with no debugging value, so the registration should
* always point to the .min.js variants.
*
* @ticket 64734
*
* @covers ::wp_default_script_modules
*/
public function test_vips_script_modules_always_use_minified_paths() {
wp_default_script_modules();
wp_enqueue_script_module( '@wordpress/vips/loader' );

$actual = get_echo( array( wp_script_modules(), 'print_enqueued_script_modules' ) );

$this->assertStringContainsString( 'vips/loader.min.js', $actual );
$this->assertStringNotContainsString( 'vips/loader.js"', $actual );
}

/**
* Normalizes markup for snapshot.
*
Expand Down
15 changes: 15 additions & 0 deletions tools/gutenberg/copy-gutenberg-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@ function copyDirectory( src, dest, transform = null, options = {} ) {

copyDirectory( srcPath, destPath, transform, options );
} else {
// Skip source map files (.map) — these are not useful in Core
// and the sourceMappingURL references are already stripped from JS files.
if ( /\.map$/.test( entry.name ) ) {
continue;
}

// Skip non-minified VIPS files — they are ~10MB of inlined WASM
// with no debugging value over the minified versions.
if (
srcPath.includes( '/vips/' ) &&
/(?<!\.min)\.js$/.test( entry.name )
) {
continue;
}

// Skip PHP files if excludePHP is true
if ( options.excludePHP && /\.php$/.test( entry.name ) ) {
continue;
Expand Down
Loading