@@ -348,37 +348,26 @@ const scriptModulePolyfills = [
348348const target = [ 'es2020' ] ;
349349const builds = [ ] ;
350350
351+ // Production builds produce minified files (index.min.js);
352+ // development builds produce unminified files (index.js).
353+ // The PHP registration class selects the appropriate file at runtime
354+ // via SCRIPT_DEBUG, and skips registration if the file doesn't exist.
355+ const outFileName = isProduction ? 'index.min.js' : 'index.js' ;
356+
351357for ( const polyfill of classicScriptPolyfills ) {
352358 const outputDir = path . join ( outputBase , 'scripts' , polyfill . name ) ;
353359
354- // Minified
355- builds . push (
356- build ( {
357- entryPoints : [ polyfill . entry ] ,
358- outfile : path . join ( outputDir , 'index.min.js' ) ,
359- bundle : true ,
360- format : 'iife' ,
361- globalName : polyfill . globalName ,
362- target,
363- platform : 'browser' ,
364- minify : true ,
365- sourcemap : isProduction ,
366- plugins : [ polyfillExternalsPlugin ( 'iife' , polyfill . packageName ) ] ,
367- } )
368- ) ;
369-
370- // Non-minified
371360 builds . push (
372361 build ( {
373362 entryPoints : [ polyfill . entry ] ,
374- outfile : path . join ( outputDir , 'index.js' ) ,
363+ outfile : path . join ( outputDir , outFileName ) ,
375364 bundle : true ,
376365 format : 'iife' ,
377366 globalName : polyfill . globalName ,
378367 target,
379368 platform : 'browser' ,
380- minify : false ,
381- sourcemap : ! isProduction ,
369+ minify : isProduction ,
370+ sourcemap : true ,
382371 plugins : [ polyfillExternalsPlugin ( 'iife' , polyfill . packageName ) ] ,
383372 } )
384373 ) ;
@@ -387,34 +376,16 @@ for ( const polyfill of classicScriptPolyfills ) {
387376for ( const polyfill of scriptModulePolyfills ) {
388377 const outputDir = path . join ( outputBase , 'modules' , polyfill . name ) ;
389378
390- const entryPoint = polyfill . entry ;
391-
392- // Minified
393- builds . push (
394- build ( {
395- entryPoints : [ entryPoint ] ,
396- outfile : path . join ( outputDir , 'index.min.js' ) ,
397- bundle : true ,
398- format : 'esm' ,
399- target,
400- platform : 'browser' ,
401- minify : true ,
402- sourcemap : isProduction ,
403- plugins : [ polyfillExternalsPlugin ( 'esm' , polyfill . packageName ) ] ,
404- } )
405- ) ;
406-
407- // Non-minified
408379 builds . push (
409380 build ( {
410- entryPoints : [ entryPoint ] ,
411- outfile : path . join ( outputDir , 'index.js' ) ,
381+ entryPoints : [ polyfill . entry ] ,
382+ outfile : path . join ( outputDir , outFileName ) ,
412383 bundle : true ,
413384 format : 'esm' ,
414385 target,
415386 platform : 'browser' ,
416- minify : false ,
417- sourcemap : ! isProduction ,
387+ minify : isProduction ,
388+ sourcemap : true ,
418389 plugins : [ polyfillExternalsPlugin ( 'esm' , polyfill . packageName ) ] ,
419390 } )
420391 ) ;
0 commit comments