Skip to content

Build/Test Tools: Optimize uglify:core and copy:files glob patterns in Grunt tasks.#10809

Closed
westonruter wants to merge 2 commits intoWordPress:trunkfrom
westonruter:trac-64563
Closed

Build/Test Tools: Optimize uglify:core and copy:files glob patterns in Grunt tasks.#10809
westonruter wants to merge 2 commits intoWordPress:trunkfrom
westonruter:trac-64563

Conversation

@westonruter
Copy link
Member

@westonruter westonruter commented Jan 28, 2026

The uglify:core task utilizes a negative glob pattern !**/*.min.js to prevent re-minifying already minified files. In development builds (npm run build:dev), this pattern operates relative to the src/ directory. Consequently, the glob expansion scans the entire src/ directory tree, including wp-content.

For environments where wp-content contains deep directory structures—such as plugins with node_modules dependencies—this traversal becomes prohibitively slow, causing the build process to hang.

This change scopes the exclusion pattern to !{wp-admin,wp-includes}/**/*.min.js, limiting the file scan to the relevant core directories and preventing unnecessary recursion into wp-content.

Trac ticket: https://core.trac.wordpress.org/ticket/64563


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Drafted Commit Message

Build/Test Tools: Optimize uglify:core and copy:files glob patterns in Grunt tasks.

The uglify:core and copy:files tasks utilized broad negative glob patterns (!**/*.min.js and !**/*.map) to exclude files from processing. The glob expansion scans the entire src/ directory tree, including wp-content. For environments where wp-content contains deep directory structures (such as plugins with node_modules dependencies) this traversal becomes prohibitively slow, causing the build process to hang.

This change scopes the exclusion patterns to specific directories (e.g. wp-admin, wp-includes, default themes, and Akismet), limiting the file scan to relevant core paths and preventing unnecessary recursion into wp-content.

In one dev environment, this reduces npm run build:dev from 43s to 9s, and npm run build from 51s to 13s.

Developed in #10809

Follow up to [61475].

Props westonruter, jonsurrell.
See #63606.
Fixes #64563.

The `uglify:core` task utilizes a negative glob pattern `!**/*.min.js` to prevent re-minifying already minified files. In development builds (`npm run build:dev`), this pattern operates relative to the `src/` directory. Consequently, the glob expansion scans the entire `src/` directory tree, including `wp-content`.

For environments where `wp-content` contains deep directory structures—such as plugins with `node_modules` dependencies—this traversal becomes prohibitively slow, causing the build process to hang.

This change scopes the exclusion pattern to `!{wp-admin,wp-includes}/**/*.min.js`, limiting the file scan to the relevant core directories and preventing unnecessary recursion into `wp-content`.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@github-actions
Copy link

github-actions bot commented Jan 28, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props westonruter, jonsurrell.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

This comment was marked as outdated.

Copy link
Member

@sirreal sirreal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't personally have this problem, but I was able to reproduce the slowdown by adding more plugins to my development checkout and this change fixes it.

It makes sense to only exclude things which are candidates for inclusion in the first place 🙂

The `copy:files` task utilizes a negative glob pattern `!**/*.map` to exclude source map files from the build. In development builds, this pattern operates relative to the `src/` directory. Consequently, the glob expansion scans the entire `src/` directory tree, including `wp-content`.

For environments where `wp-content` contains deep directory structures—such as plugins with `node_modules` dependencies—this traversal becomes prohibitively slow.

This change scopes the exclusion pattern to `!{wp-admin,wp-includes,wp-content/themes/twenty*,wp-content/plugins/akismet}/**/*.map`, limiting the file scan to the relevant core directories and preventing unnecessary recursion into `wp-content`.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@westonruter
Copy link
Member Author

I asked Gemini if there were any other opportunities to improve performance similarly in Gruntfile.js, and it identified another glob pattern in copy:files. Indeed, when I run npm run build I find it hangs for a long time at:

Running "copy:files" (copy) task

However, with c413206 the time to build is dramatically improved:

Before: 51.102s
After: 13.805s

@westonruter westonruter changed the title Build/Test Tools: Optimize uglify:core glob pattern. Build/Test Tools: Optimize uglify:core and copy:files glob patterns. Jan 28, 2026
@westonruter westonruter changed the title Build/Test Tools: Optimize uglify:core and copy:files glob patterns. Build/Test Tools: Optimize uglify:core and copy:files glob patterns in Grunt tasks. Jan 28, 2026
pento pushed a commit that referenced this pull request Jan 28, 2026
…ns in Grunt tasks.

The `uglify:core` and `copy:files` tasks utilized broad negative glob patterns (`!**/*.min.js` and `!**/*.map`) to exclude files from processing. The glob expansion scans the entire `src/` directory tree, including `wp-content`. For environments where `wp-content` contains deep directory structures (such as plugins with `node_modules` dependencies) this traversal becomes prohibitively slow, causing the build process to hang.

This change scopes the exclusion patterns to specific directories (e.g. `wp-admin`, `wp-includes`, default themes, and Akismet), limiting the file scan to relevant core paths and preventing unnecessary recursion into `wp-content`.

In one dev environment, this reduces `npm run build:dev` from 43s to 9s, and `npm run build` from 51s to 13s.

Developed in #10809

Follow up to [61475].

Props westonruter, jonsurrell.
See #63606.
Fixes #64563.


git-svn-id: https://develop.svn.wordpress.org/trunk@61545 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions
Copy link

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61545
GitHub commit: 4ef8507

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Jan 28, 2026
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Jan 28, 2026
…ns in Grunt tasks.

The `uglify:core` and `copy:files` tasks utilized broad negative glob patterns (`!**/*.min.js` and `!**/*.map`) to exclude files from processing. The glob expansion scans the entire `src/` directory tree, including `wp-content`. For environments where `wp-content` contains deep directory structures (such as plugins with `node_modules` dependencies) this traversal becomes prohibitively slow, causing the build process to hang.

This change scopes the exclusion patterns to specific directories (e.g. `wp-admin`, `wp-includes`, default themes, and Akismet), limiting the file scan to relevant core paths and preventing unnecessary recursion into `wp-content`.

In one dev environment, this reduces `npm run build:dev` from 43s to 9s, and `npm run build` from 51s to 13s.

Developed in WordPress/wordpress-develop#10809

Follow up to [61475].

Props westonruter, jonsurrell.
See #63606.
Fixes #64563.

Built from https://develop.svn.wordpress.org/trunk@61545


git-svn-id: http://core.svn.wordpress.org/trunk@60856 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants