Build/Test Tools: Optimize uglify:core and copy:files glob patterns in Grunt tasks.#10809
Build/Test Tools: Optimize uglify:core and copy:files glob patterns in Grunt tasks.#10809westonruter wants to merge 2 commits intoWordPress:trunkfrom
uglify:core and copy:files glob patterns in Grunt tasks.#10809Conversation
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>
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
This comment was marked as outdated.
This comment was marked as outdated.
sirreal
left a comment
There was a problem hiding this comment.
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>
|
I asked Gemini if there were any other opportunities to improve performance similarly in
However, with c413206 the time to build is dramatically improved: Before: 51.102s |
uglify:core glob pattern.uglify:core and copy:files glob patterns.
uglify:core and copy:files glob patterns.uglify:core and copy:files glob patterns in Grunt tasks.
…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
…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
The
uglify:coretask utilizes a negative glob pattern!**/*.min.jsto prevent re-minifying already minified files. In development builds (npm run build:dev), this pattern operates relative to thesrc/directory. Consequently, the glob expansion scans the entiresrc/directory tree, includingwp-content.For environments where
wp-contentcontains deep directory structures—such as plugins withnode_modulesdependencies—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 intowp-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:coreandcopy:filesglob patterns in Grunt tasks.The
uglify:coreandcopy:filestasks utilized broad negative glob patterns (!**/*.min.jsand!**/*.map) to exclude files from processing. The glob expansion scans the entiresrc/directory tree, includingwp-content. For environments wherewp-contentcontains deep directory structures (such as plugins withnode_modulesdependencies) 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 intowp-content.In one dev environment, this reduces
npm run build:devfrom 43s to 9s, andnpm run buildfrom 51s to 13s.Developed in #10809
Follow up to [61475].
Props westonruter, jonsurrell.
See #63606.
Fixes #64563.