Changeset 62072
- Timestamp:
- 03/20/2026 04:16:33 AM (8 days ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
src/wp-includes/script-loader.php (modified) (1 diff)
-
src/wp-includes/script-modules.php (modified) (2 diffs)
-
tools/gutenberg/copy.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/script-loader.php
r62060 r62072 282 282 * 'api-fetch.js' => array(... 283 283 */ 284 $assets_file = ABSPATH . WPINC . "/assets/script-loader-packages{$suffix}.php";284 $assets_file = ABSPATH . WPINC . '/assets/script-loader-packages.php'; 285 285 $assets = file_exists( $assets_file ) ? include $assets_file : array(); 286 286 287 287 foreach ( $assets as $file_name => $package_data ) { 288 $basename = str_replace( $suffix .'.js', '', basename( $file_name ) );288 $basename = str_replace( '.js', '', basename( $file_name ) ); 289 289 $handle = 'wp-' . $basename; 290 290 $path = "/wp-includes/js/dist/{$basename}{$suffix}.js"; -
trunk/src/wp-includes/script-modules.php
r61794 r62072 150 150 * Expects multidimensional array like: 151 151 * 152 * 'interactivity/index. min.js' => array('dependencies' => array(…), 'version' => '…'),153 * 'interactivity-router/index. min.js' => array('dependencies' => array(…), 'version' => '…'),154 * 'block-library/navigation/view. min.js' => …152 * 'interactivity/index.js' => array('dependencies' => array(…), 'version' => '…'), 153 * 'interactivity-router/index.js' => array('dependencies' => array(…), 'version' => '…'), 154 * 'block-library/navigation/view.js' => … 155 155 */ 156 $assets_file = ABSPATH . WPINC . "/assets/script-modules-packages{$suffix}.php";156 $assets_file = ABSPATH . WPINC . '/assets/script-modules-packages.php'; 157 157 $assets = file_exists( $assets_file ) ? include $assets_file : array(); 158 158 … … 193 193 // VIPS files are always minified — the non-minified versions are not 194 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.' )) {195 if ( str_starts_with( $file_name, 'vips/' ) ) { 196 196 $file_name = str_replace( '.js', '.min.js', $file_name ); 197 } elseif ( '' !== $suffix ) { 198 $file_name = str_replace( '.js', $suffix . '.js', $file_name ); 197 199 } 198 200 -
trunk/tools/gutenberg/copy.js
r62071 r62072 235 235 236 236 /** 237 * Generate script-modules-packages. min.php from individual asset files.238 * Re ads all view.min.asset.php files from modules/block-library and combines them239 * into a single PHP file.237 * Generate script-modules-packages.php from individual asset files. 238 * Recursively scans the Gutenberg modules/ directory for *.min.asset.php files 239 * and combines their contents into a single PHP file. 240 240 */ 241 241 function generateScriptModulesPackages() { 242 242 const modulesDir = path.join( gutenbergBuildDir, 'modules' ); 243 const assetsMin = {}; 244 const assetsRegular = {}; 243 const assets = {}; 245 244 246 245 /** … … 268 267 .split( path.sep ) 269 268 .join( '/' ); 270 const jsPathMin = normalizedPath.replace( 271 /\.asset\.php$/, 272 '.js' 273 ); 274 const jsPathRegular = jsPathMin.replace( /\.min\.js$/, '.js' ); 269 const jsPath = normalizedPath 270 .replace( /\.asset\.php$/, '.js' ) 271 .replace( /\.min\.js$/, '.js' ); 275 272 276 273 try { 277 274 const assetData = readReturnedValueFromPHPFile( fullPath ); 278 assetsMin[ jsPathMin ] = assetData; 279 assetsRegular[ jsPathRegular ] = assetData; 275 assets[ jsPath ] = assetData; 280 276 } catch ( error ) { 281 277 console.error( … … 290 286 processDirectory( modulesDir, modulesDir ); 291 287 292 // Generate both minified and non-minified PHP files using json2php. 293 const phpContentMin = 288 const phpContent = 294 289 '<?php return ' + 295 290 json2php.make( { 296 291 linebreak: '\n', 297 indent: ' ',292 indent: '\t', 298 293 shortArraySyntax: false, 299 } )( assets Min) +294 } )( assets ) + 300 295 ';'; 301 296 302 const phpContentRegular = 303 '<?php return ' + 304 json2php.make( { 305 linebreak: '\n', 306 indent: ' ', 307 shortArraySyntax: false, 308 } )( assetsRegular ) + 309 ';'; 310 311 const outputPathMin = path.join( 312 wpIncludesDir, 313 'assets/script-modules-packages.min.php' 314 ); 315 const outputPathRegular = path.join( 297 const outputPath = path.join( 316 298 wpIncludesDir, 317 299 'assets/script-modules-packages.php' 318 300 ); 319 301 320 fs.mkdirSync( path.dirname( outputPathMin ), { recursive: true } ); 321 fs.writeFileSync( outputPathMin, phpContentMin ); 322 fs.writeFileSync( outputPathRegular, phpContentRegular ); 302 fs.mkdirSync( path.dirname( outputPath ), { recursive: true } ); 303 fs.writeFileSync( outputPath, phpContent ); 323 304 324 305 console.log( 325 ` ✅ Generated with ${ Object.keys( assetsMin ).length } modules` 326 ); 327 } 328 329 /** 330 * Generate script-loader-packages.php and script-loader-packages.min.php from individual asset files. 331 * Reads all .min.asset.php files from scripts/ and combines them into PHP files for script registration. 332 * Generates both minified and non-minified versions. 306 ` ✅ Generated with ${ Object.keys( assets ).length } modules` 307 ); 308 } 309 310 /** 311 * Generate script-loader-packages.php from individual asset files. 312 * Reads all .min.asset.php files from scripts/ and combines them into a PHP file for script registration. 333 313 */ 334 314 function generateScriptLoaderPackages() { 335 315 const scriptsDir = path.join( gutenbergBuildDir, 'scripts' ); 336 const assetsMin = {}; 337 const assetsRegular = {}; 316 const assets = {}; 338 317 339 318 if ( ! fs.existsSync( scriptsDir ) ) { … … 366 345 } 367 346 368 // Create entries for both minified and non-minified versions. 369 const jsPathMin = `${ entry.name }.min.js`; 370 const jsPathRegular = `${ entry.name }.js`; 371 372 assetsMin[ jsPathMin ] = assetData; 373 assetsRegular[ jsPathRegular ] = assetData; 347 assets[ `${ entry.name }.js` ] = assetData; 374 348 } catch ( error ) { 375 349 console.error( … … 380 354 } 381 355 382 // Generate both minified and non-minified PHP files using json2php. 383 const phpContentMin = 356 const phpContent = 384 357 '<?php return ' + 385 358 json2php.make( { 386 359 linebreak: '\n', 387 indent: ' ',360 indent: '\t', 388 361 shortArraySyntax: false, 389 } )( assets Min) +362 } )( assets ) + 390 363 ';'; 391 364 392 const phpContentRegular = 393 '<?php return ' + 394 json2php.make( { 395 linebreak: '\n', 396 indent: ' ', 397 shortArraySyntax: false, 398 } )( assetsRegular ) + 399 ';'; 400 401 const outputPathMin = path.join( 402 wpIncludesDir, 403 'assets/script-loader-packages.min.php' 404 ); 405 const outputPathRegular = path.join( 365 const outputPath = path.join( 406 366 wpIncludesDir, 407 367 'assets/script-loader-packages.php' 408 368 ); 409 369 410 fs.mkdirSync( path.dirname( outputPathMin ), { recursive: true } ); 411 fs.writeFileSync( outputPathMin, phpContentMin ); 412 fs.writeFileSync( outputPathRegular, phpContentRegular ); 370 fs.mkdirSync( path.dirname( outputPath ), { recursive: true } ); 371 fs.writeFileSync( outputPath, phpContent ); 413 372 414 373 console.log( 415 ` ✅ Generated with ${ Object.keys( assets Min).length } packages`374 ` ✅ Generated with ${ Object.keys( assets ).length } packages` 416 375 ); 417 376 } … … 553 512 json2php.make( { 554 513 linebreak: '\n', 555 indent: ' ',514 indent: '\t', 556 515 shortArraySyntax: false, 557 516 } )( blocks ) +
Note: See TracChangeset
for help on using the changeset viewer.