Skip to content

Cache webpack builds and drop the dev server reload - #3763

Merged
Crabcyborg merged 1 commit into
masterfrom
perf/webpack-build-cache
Nov 27, 2026
Merged

Crabcyborg merged 1 commit into
masterfrom
perf/webpack-build-cache

Conversation

@Crabcyborg

Copy link
Copy Markdown
Contributor

Speeds up npm run build for AI-driven development, where an agent rebuilds once after each edit. Follows up on #3026, whose changes reached master through #2999.

Changes

  • Webpack filesystem cache in webpack.config.js. A rebuild only reprocesses files that changed. Editing webpack.config.js or .babelrc throws the cache away. The cache lives in node_modules/.cache/webpack, which is already ignored.
  • Release builds skip the cache. bin/build-plugin.sh now runs npm run build -- --no-cache, so release zips are always built from scratch.
  • build:js and build:css scripts for rebuilding one side only.
  • Removed the opt-in JS/PHP full page reload from webpack.dev.js and its prompt from npm run serve. When enabled it watched every .js and .php file in every formidable* plugin folder, triggered a reload per file during bulk edits, and its ../formidable*/**/*.js glob also matched js/src, so the page could reload before webpack finished building. CSS injection is unchanged.

Timings (local, production mode)

Build Before After
npm run build, nothing changed ~23s ~1s
npm run build after editing one JS source file ~23s ~1.8s
npm run build, first run with an empty cache ~23s ~17s to 34s

Notes

  • The @wordpress/babel-plugin-makepot step in .babelrc writes languages/formidable-js.pot while transpiling. Cached modules are not transpiled again, so that file can come out incomplete on a cached build. It is gitignored and excluded from the release zip by bin/zip-plugin.sh, and release builds skip the cache, so releases are unaffected.
  • There is no JS test coverage for the build config. Verification was manual, see below.

Testing

  1. Run npm run build -- --no-cache and save a copy of js/*.js and css/.
  2. Run npm run build twice. The second run should take about a second, and its output should match the copy from step 1 byte for byte (diff -r).
  3. Add a line to js/src/dashboard.js and run npm run build. The line should appear in js/formidable_dashboard.js. Revert it and rebuild. The line should be gone.
  4. Add a rule to resources/scss/admin/components/_addon-compat.scss and run npm run build:css. The rule should appear in css/frm_admin.css. Revert it and rebuild. The rule should be gone.
  5. Run npm run serve. It should only prompt for the site domain.

Steps 1 to 4 were run locally. Step 5 was checked only for syntax (node --check), not by starting the server.

🤖 Generated with Claude Code

Enable the webpack filesystem cache so a rebuild only reprocesses
changed files. A full build drops from about 23s to about 1s with
no changes, and under 2s after a source edit. The release script
passes --no-cache so release zips are always built from scratch.

Add build:js and build:css scripts for one-sided rebuilds.

Remove the opt-in JS/PHP full page reload from the dev server. It
watched every .js and .php file in every formidable* plugin and
could reload before webpack finished.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 23 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2a91b45 and 25b883c.

Files selected for processing: 4

  • bin/build-plugin.sh
  • package.json
  • webpack.config.js
  • webpack.dev.js
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 27, 2026

@franky-the-going-merry franky-the-going-merry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approve. Nothing blocking.

Ran the PR's own test steps at head 25b883c, using a scratch checkout of the branch with node_modules linked from a sibling checkout (package versions match):

  • npm run build -- --no-cache writes no node_modules/.cache/webpack, so the release script's --no-cache works as described.
  • Two plain npm run build runs after that took 4.6s then 0.5s, and js/ and css/ matched the clean build byte for byte.
  • Appending a console.log to js/src/dashboard.js and running build:js put it in js/formidable_dashboard.js; reverting removed it. A new rule in _addon-compat.scss showed up in css/frm_admin.css after build:css and was gone after the revert.
  • Editing .babelrc threw the cache away (rebuild went from ~0.35s to ~3s), so the buildDependencies entry works. The js and css config names match the --config-name values.
  • node --check webpack.dev.js passes. I did not start npm run serve, same as the PR description says.

CI: no workflow other than the release script runs the production webpack build, so the cache doesn't touch CI. The only build:dev in CI is WordPress core's own and unrelated. Compiled js//css/ are not part of the diff and don't need regenerating here. Generic review found no correctness issues.

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 27, 2026
@Crabcyborg
Crabcyborg merged commit 32b46de into master Nov 27, 2026
62 checks passed
@Crabcyborg
Crabcyborg deleted the perf/webpack-build-cache branch November 27, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant