@@ -234,14 +234,13 @@ function copyBlockAssets( config ) {
234234}
235235
236236/**
237- * Generate script-modules-packages.min. php from individual asset files.
238- * Reads all view .min.asset.php files from modules/block-library and combines them
239- * 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.
240240 */
241241function generateScriptModulesPackages ( ) {
242242 const modulesDir = path . join ( gutenbergBuildDir , 'modules' ) ;
243- const assetsMin = { } ;
244- const assetsRegular = { } ;
243+ const assets = { } ;
245244
246245 /**
247246 * Recursively process directory to find .asset.php files.
@@ -267,16 +266,13 @@ function generateScriptModulesPackages() {
267266 const normalizedPath = relativePath
268267 . split ( path . sep )
269268 . join ( '/' ) ;
270- const jsPathMin = normalizedPath . replace (
271- / \. a s s e t \. p h p $ / ,
272- '.js'
273- ) ;
274- const jsPathRegular = jsPathMin . replace ( / \. m i n \. j s $ / , '.js' ) ;
269+ const jsPath = normalizedPath
270+ . replace ( / \. a s s e t \. p h p $ / , '.js' )
271+ . replace ( / \. m i n \. j s $ / , '.js' ) ;
275272
276273 try {
277274 const assetData = readReturnedValueFromPHPFile ( fullPath ) ;
278- assetsMin [ jsPathMin ] = assetData ;
279- assetsRegular [ jsPathRegular ] = assetData ;
275+ assets [ jsPath ] = assetData ;
280276 } catch ( error ) {
281277 console . error (
282278 ` ⚠️ Error reading ${ relativePath } :` ,
@@ -289,52 +285,35 @@ function generateScriptModulesPackages() {
289285
290286 processDirectory ( modulesDir , modulesDir ) ;
291287
292- // Generate both minified and non-minified PHP files using json2php.
293- const phpContentMin =
294- '<?php return ' +
295- json2php . make ( {
296- linebreak : '\n' ,
297- indent : ' ' ,
298- shortArraySyntax : false ,
299- } ) ( assetsMin ) +
300- ';' ;
301-
302- const phpContentRegular =
288+ const phpContent =
303289 '<?php return ' +
304290 json2php . make ( {
305291 linebreak : '\n' ,
306- indent : ' ' ,
292+ indent : '\t ' ,
307293 shortArraySyntax : false ,
308- } ) ( assetsRegular ) +
294+ } ) ( assets ) +
309295 ';' ;
310296
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 (
316298 wpIncludesDir ,
317299 'assets/script-modules-packages.php'
318300 ) ;
319301
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 ) ;
323304
324305 console . log (
325- ` ✅ Generated with ${ Object . keys ( assetsMin ) . length } modules`
306+ ` ✅ Generated with ${ Object . keys ( assets ) . length } modules`
326307 ) ;
327308}
328309
329310/**
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.
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.
333313 */
334314function generateScriptLoaderPackages ( ) {
335315 const scriptsDir = path . join ( gutenbergBuildDir , 'scripts' ) ;
336- const assetsMin = { } ;
337- const assetsRegular = { } ;
316+ const assets = { } ;
338317
339318 if ( ! fs . existsSync ( scriptsDir ) ) {
340319 console . log ( ' ⚠️ Scripts directory not found' ) ;
@@ -365,12 +344,7 @@ function generateScriptLoaderPackages() {
365344 assetData . dependencies = [ ] ;
366345 }
367346
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 ;
374348 } catch ( error ) {
375349 console . error (
376350 ` ⚠️ Error reading ${ entry . name } /index.min.asset.php:` ,
@@ -379,40 +353,25 @@ function generateScriptLoaderPackages() {
379353 }
380354 }
381355
382- // Generate both minified and non-minified PHP files using json2php.
383- const phpContentMin =
384- '<?php return ' +
385- json2php . make ( {
386- linebreak : '\n' ,
387- indent : ' ' ,
388- shortArraySyntax : false ,
389- } ) ( assetsMin ) +
390- ';' ;
391-
392- const phpContentRegular =
356+ const phpContent =
393357 '<?php return ' +
394358 json2php . make ( {
395359 linebreak : '\n' ,
396- indent : ' ' ,
360+ indent : '\t ' ,
397361 shortArraySyntax : false ,
398- } ) ( assetsRegular ) +
362+ } ) ( assets ) +
399363 ';' ;
400364
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 (
406366 wpIncludesDir ,
407367 'assets/script-loader-packages.php'
408368 ) ;
409369
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 ) ;
413372
414373 console . log (
415- ` ✅ Generated with ${ Object . keys ( assetsMin ) . length } packages`
374+ ` ✅ Generated with ${ Object . keys ( assets ) . length } packages`
416375 ) ;
417376}
418377
@@ -552,7 +511,7 @@ function generateBlocksJson() {
552511 '<?php return ' +
553512 json2php . make ( {
554513 linebreak : '\n' ,
555- indent : ' ' ,
514+ indent : '\t ' ,
556515 shortArraySyntax : false ,
557516 } ) ( blocks ) +
558517 ';' ;
0 commit comments