feat/vite js build v2 - #13331
Draft
RayBB wants to merge 5 commits into
Draft
Conversation
…ation Fixes found by the strict code-quality review of the webpack→Vite commit: - Fix scripts/js-build-parity.sh, which recovered webpack.config.js via `git show HEAD:` even though that file was deleted by the same commit. It now resolves the most recent ref that still contains the file (walking `git log --all --follow`), overridable via WP_GIT_REF. - Extract duplicated options from vite-js.config.mjs / vite-js-iife.config.mjs into vite-js-shared.mjs (commonBuildOptions, parameterized jsBuildMarker). - Derive VITE_VERSION from the installed vite package instead of a hardcoded "keep in sync with package.json" constant. - Move the transform plugins (jquery $ injection, jquery-ui AMD deps) and the chunk-name contract into vite-js-plugins.mjs with new unit tests (tests/unit/js/vite-js-plugins.test.js); widen jest's transform regex to cover .mjs and add a moduleNameMapper entry for the plugin module. - Remove the 58 dead webpackChunkName comments left in the JS source (chunk names are driven by CHUNK_NAME_MAP, not the comments). - Fix dangling css-vite-migration.md references in the migration docs and update the plan doc's status from "plan only" to executed. - Add code-quality-review-findings.md tracking the review items. Verified: parity harness PARITY OK, jest 583/583, eslint clean, make js. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
…marker The Makefile's post-build shell loop prepended the AGPLv3 LibreJS magnet comment to every JS file. Both Vite configs now emit the header/footer themselves via output.postBanner/postFooter (applied after minification, so the comments survive), with shared constants in vite-js-shared.mjs. Also drops the "built by Vite" marker entirely (and the jsBuildMarker plugin, the manual VITE_VERSION constant, and the parity harness's marker check), and uses rolldownOptions as the canonical Vite 8 option name. Verified: parity harness PARITY OK, jest 583/583, make js. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Vite 8 (rolldown) lowers syntax with Oxc and minifies JS with its native Oxc-based minifier; CSS is minified by LightningCSS. esbuild is no longer installed or used by the project — only remaining trace is vite's optional peer dependency in the lockfile. Updates comments in vite-js-shared.mjs, vite-css.config.mjs, index.js, and the migration/README docs. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
The two regex-based source-mutation plugins from the Vite migration are gone,
making all jQuery usage explicit and grep-able:
- injectJqueryGlobals() deleted: an AST-based eslint `no-undef` scan found 31
source files + 4 test files that genuinely reference unbound `$`/`jQuery`
(the regexes were also injecting unused imports into 5 files via strings,
regex literals, and comments). Each now has `import $ from 'jquery';`
(index.js gets both `$` and `jQuery`), and `$`/`jQuery` were removed from
eslint globals so unbound usage is a `no-undef` error again.
- jqueryUiAmdDeps() deleted: replaced by four explicit wrapper modules
(jquery-ui-{tabs,dialog,autocomplete,sortable}.js) that list each widget's
AMD deps in topological order, preserving per-widget tree-shaking (a single
explicit module had previously been rejected for forcing a 79 KB shared
chunk onto every widget page). The 7 importing files use the wrappers, and
new unit tests pin the wrappers to the installed jquery-ui package so an
upgrade that changes the AMD graph fails loudly.
- Adds docs/ai/jquery-usage.md, an inventory of the remaining jQuery surface
(33 source files; 8 use $.ajax, 7 depend on jquery-ui widgets, 6 use
colorbox) to seed the eventual jQuery removal work.
Verified: js-build-parity PARITY OK, jest 581/581, eslint clean, make js works.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #
Technical
Testing
Screenshot
Stakeholders