[wp-trac] [WordPress Trac] #64563: Grunt uglify:core task hangs when wp-content has many files
WordPress Trac
noreply at wordpress.org
Wed Jan 28 06:49:21 UTC 2026
#64563: Grunt uglify:core task hangs when wp-content has many files
------------------------------+--------------------
Reporter: westonruter | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 7.0
Component: Build/Test Tools | Version:
Severity: normal | Keywords:
Focuses: javascript |
------------------------------+--------------------
For a long time, I've struggled with `npm run build:dev` (see
[https://wordpress.slack.com/archives/C02RQBWTW/p1753664888615839 Slack
thread]). When I run the command, it would always seem to hang at:
> Running "uglify:core" (uglify) task
I got so fed up with having to wait so long at that task, that I started
resorting to
[https://gist.github.com/westonruter/183bd7847539f5d74dc21f4b98b660ec
using symlinks] to avoid having to do a build altogether.
A note on my development environment setup: I clone the repos for the
plugins and themes I work on into the `wp-content` of my wordpress-develop
clone which I use for core development.
I got fed up and decided to put Gemini CLI on the problem and it came up
with this fix:
{{{#!diff
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -926,7 +926,7 @@ module.exports = function(grunt) {
'wp-
includes/js/tinymce/plugins/wp*/plugin.js',
// Exceptions.
- '!**/*.min.js',
+ '!{wp-admin,wp-
includes}/**/*.min.js',
'!wp-admin/js/custom-header.js',
// Why? We should minify this.
'!wp-admin/js/farbtastic.js',
'!wp-includes/js/wp-emoji-
loader.js', // This is a module. See the emoji-loader task below.
}}}
The hang was caused by a broad exclusion pattern in the `uglify:core` task
within `Gruntfile.js`. Its explanation makes perfect sense:
> When you run `npm run build:dev`, the `cwd` (current working directory)
for the build tasks is set to `src/`.
>
> The original pattern `!**/*.min.js` told Grunt to exclude any minified
files found anywhere inside the `src/` directory. To fulfill this request,
the globbing engine had to scan every single folder and file within `src/`
to see if they matched.
>
> Because your `src/wp-content/` directory contains several plugins (like
the `jetpack-monorepo`) with massive `node_modules` folders containing
hundreds of thousands of files, Grunt would hang for a long time just
trying to find all those files to ensure they were excluded.
>
> By changing the pattern to `!{wp-admin,wp-includes}/**/*.min.js`, I
restricted that exclusion search to only the core `wp-admin` and `wp-
includes` directories. This allows Grunt to completely skip scanning the
`wp-content` directory, which resolves the hang.
== Impact ==
When running `npm run build:dev`:
Before: '''43.032s'''
After: '''9.393s'''
This is now >4.5 times faster, a >78% reduction in execution time!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64563>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list