Skip to content

Commit 8db1867

Browse files
General: VIPS library omit un-minimized and .map files.
Omit these files which offer little value since the VIPS library is primarily inlined WASM. Saves ~30MB total from the build output. Props swissspidy, westonruter, adamsilverstein, berislav.grgicak, knutsp. Fixes: #64734. git-svn-id: https://develop.svn.wordpress.org/trunk@61794 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 2fcf4f5 commit 8db1867

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

src/wp-includes/script-modules.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ function wp_default_script_modules() {
190190
wp_interactivity()->add_client_navigation_support_to_script_module( $script_module_id );
191191
}
192192

193+
// VIPS files are always minified — the non-minified versions are not
194+
// shipped because they are ~10MB of inlined WASM with no debugging value.
195+
if ( str_starts_with( $file_name, 'vips/' ) && ! str_contains( $file_name, '.min.' ) ) {
196+
$file_name = str_replace( '.js', '.min.js', $file_name );
197+
}
198+
193199
$path = includes_url( "js/dist/script-modules/{$file_name}" );
194200
$module_deps = $script_module_data['module_dependencies'] ?? array();
195201
wp_register_script_module( $script_module_id, $path, $module_deps, $script_module_data['version'], $args );

tests/phpunit/tests/script-modules/wpScriptModules.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,6 +1903,27 @@ public function test_dependent_of_default_script_modules() {
19031903
$this->assertEqualHTML( $expected, $actual );
19041904
}
19051905

1906+
/**
1907+
* Tests that VIPS script modules always use minified file paths.
1908+
*
1909+
* Non-minified VIPS files are not shipped because they are ~10MB of
1910+
* inlined WASM with no debugging value, so the registration should
1911+
* always point to the .min.js variants.
1912+
*
1913+
* @ticket 64734
1914+
*
1915+
* @covers ::wp_default_script_modules
1916+
*/
1917+
public function test_vips_script_modules_always_use_minified_paths() {
1918+
wp_default_script_modules();
1919+
wp_enqueue_script_module( '@wordpress/vips/loader' );
1920+
1921+
$actual = get_echo( array( wp_script_modules(), 'print_enqueued_script_modules' ) );
1922+
1923+
$this->assertStringContainsString( 'vips/loader.min.js', $actual );
1924+
$this->assertStringNotContainsString( 'vips/loader.js"', $actual );
1925+
}
1926+
19061927
/**
19071928
* Normalizes markup for snapshot.
19081929
*

tools/gutenberg/copy-gutenberg-build.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,21 @@ function copyDirectory( src, dest, transform = null, options = {} ) {
167167

168168
copyDirectory( srcPath, destPath, transform, options );
169169
} else {
170+
// Skip source map files (.map) — these are not useful in Core
171+
// and the sourceMappingURL references are already stripped from JS files.
172+
if ( /\.map$/.test( entry.name ) ) {
173+
continue;
174+
}
175+
176+
// Skip non-minified VIPS files — they are ~10MB of inlined WASM
177+
// with no debugging value over the minified versions.
178+
if (
179+
srcPath.includes( '/vips/' ) &&
180+
/(?<!\.min)\.js$/.test( entry.name )
181+
) {
182+
continue;
183+
}
184+
170185
// Skip PHP files if excludePHP is true
171186
if ( options.excludePHP && /\.php$/.test( entry.name ) ) {
172187
continue;

0 commit comments

Comments
 (0)