Repository navigation
Cache webpack builds and drop the dev server reload - #3763
Conversation
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>
|
Warning Review limit reachedYou'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. View limit details
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. |
There was a problem hiding this comment.
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-cachewrites nonode_modules/.cache/webpack, so the release script's--no-cacheworks as described.- Two plain
npm run buildruns after that took 4.6s then 0.5s, andjs/andcss/matched the clean build byte for byte. - Appending a
console.logtojs/src/dashboard.jsand runningbuild:jsput it injs/formidable_dashboard.js; reverting removed it. A new rule in_addon-compat.scssshowed up incss/frm_admin.cssafterbuild:cssand was gone after the revert. - Editing
.babelrcthrew the cache away (rebuild went from ~0.35s to ~3s), so thebuildDependenciesentry works. Thejsandcssconfig names match the--config-namevalues. node --check webpack.dev.jspasses. I did not startnpm 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.
Speeds up
npm run buildfor AI-driven development, where an agent rebuilds once after each edit. Follows up on #3026, whose changes reached master through #2999.Changes
webpack.config.js. A rebuild only reprocesses files that changed. Editingwebpack.config.jsor.babelrcthrows the cache away. The cache lives innode_modules/.cache/webpack, which is already ignored.bin/build-plugin.shnow runsnpm run build -- --no-cache, so release zips are always built from scratch.build:jsandbuild:cssscripts for rebuilding one side only.webpack.dev.jsand its prompt fromnpm run serve. When enabled it watched every.jsand.phpfile in everyformidable*plugin folder, triggered a reload per file during bulk edits, and its../formidable*/**/*.jsglob also matchedjs/src, so the page could reload before webpack finished building. CSS injection is unchanged.Timings (local, production mode)
npm run build, nothing changednpm run buildafter editing one JS source filenpm run build, first run with an empty cacheNotes
@wordpress/babel-plugin-makepotstep in.babelrcwriteslanguages/formidable-js.potwhile 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 bybin/zip-plugin.sh, and release builds skip the cache, so releases are unaffected.Testing
npm run build -- --no-cacheand save a copy ofjs/*.jsandcss/.npm run buildtwice. The second run should take about a second, and its output should match the copy from step 1 byte for byte (diff -r).js/src/dashboard.jsand runnpm run build. The line should appear injs/formidable_dashboard.js. Revert it and rebuild. The line should be gone.resources/scss/admin/components/_addon-compat.scssand runnpm run build:css. The rule should appear incss/frm_admin.css. Revert it and rebuild. The rule should be gone.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