The issue proposes a straightforward change to handle missing unminified files gracefully.
The issue addresses a problem where PHP templates unconditionally use SCRIPT_DEBUG to load unminified files, which may not exist in production. The solution is to add a file_exists check in 4 templates to fall back to minified files when unminified versions are missing. The requirements are clear, and the implementation is self-contained.
wp-build generates both minified (.min.js) and unminified (.js) assets for every entry point. The unminified copies exist solely for SCRIPT_DEBUG — in normal operation, 100% of them go unused. For plugins shipping via WordPress.org, this doubles (or more) the JavaScript footprint of the build/ directory.
As a concrete example: one project's build/ directory ships ~2.7 MB of unminified JS alongside ~1.2 MB of minified equivalents. The unminified files account for ~61,000 lines of code that serve no purpose in production.
The generated PHP registration templates also assume unminified files are always present on disk:
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
When plugin authors exclude unminified files from their distributions (the natural fix for the size problem), SCRIPT_DEBUG = true causes registered script URLs to point to non-existent files, breaking functionality.
Add a --no-script-debug flag to wp-build that:
.js / .css counterparts to the .min.js / .min.css files, saving build time and disk space.has_debug_assets) in constants.php so the generated PHP registration templates know whether unminified files exist, rather than relying on runtime file_exists() checks.has_debug_assets before choosing the unminified path. When SCRIPT_DEBUG is true but has_debug_assets is false, the templates fall back to the minified file gracefully.This affects the CLI, the build pipeline, and 4 PHP templates:
script-registration.php.templatemodule-registration.php.templateroutes-registration.php.templatestyle-registration.php.templateThe pattern in each template becomes:
$extension = '.min.js';
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG &&
Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!