papegaaij opened a new pull request, #1836: URL: https://github.com/apache/wicket/pull/1836
> **Stacked on #1833.** This pull request targets `skip-minified-files-in-optimizer`, so the diff shows only the esbuild change. Once #1833 is merged, it moves to `master` and gets rebased there. The JavaScript and CSS that `wicket-core` and `wicket-extensions` ship were minified by `resources-optimizer-maven-plugin`, which runs Closure Compiler. Its 2.7 releases need Java 21, which already holds `wicket-10.x` back on 2.6. The output had no source maps, lost its license header and was never exercised by the QUnit suites, and Closure injected `$jscomp` polyfills into `wicket-veil.min.js`. `wicket-native-websocket-core` and `wicket-devutils` shipped their resources unminified. A small Node project in `build-tools/minify` now does the job with esbuild: - The root build installs Node and esbuild there through `frontend-maven-plugin`, the plugin the JavaScript tests already use. - Each module that ships JavaScript or CSS binds the managed `minify` execution to `process-classes`. This covers `wicket-core`, `wicket-extensions`, `wicket-devutils` and `wicket-native-websocket-core`. - `minify.mjs` writes `foo.min.js` / `foo.min.css` and a linked `.map`, with the sources embedded, next to every resource. It skips `jquery*.js` and files that are already minified, so a build without `clean` doesn't minify its own output (#1832). - The JavaScript target is `es2020`. - Wicket's own files carry a one-line ASF license banner. Third-party files keep their original notice. The minified files keep their names, so `ResourceSettings` and the resource references behave as before. ### What applications see - The minified content differs from Closure's. Sizes are within a few hundred bytes after gzip, and `wicket-veil.min.js` shrinks by 3.4 KB. - Each `.min` file links to a source map. The default `SecurePackageResourceGuard` already serves `*.map`, so browser developer tools show the original source. This adds about 320 KB to the `wicket-core` jar and 125 KB to the `wicket-extensions` jar. - esbuild does not rename variables visible to a direct `eval`, so an autocomplete `onselect` handler that refers to `input` now works minified as well. - `wicket-native-websocket-core` and `wicket-devutils` now ship `.min` files, served when minified resources are enabled. Building one module with `-pl` on a fresh clone needs the root built once first (`mvn -N generate-resources`), which installs Node and esbuild. ### Testing - `mvn clean verify -Pjs-test` passes over the full reactor, including the rat and pom enforcer checks. - `mvn clean install -DskipTests -Pfast` followed by `mvn install -DskipTests -Pfast` without `clean`: both runs minify the same 30 files and produce 63 `.min.*` files with identical checksums. No `*.min.min.*` files appear in `target/classes` or the jars. - Both QUnit suites pass when run once against the minified files in place of the sources: 189 tests on the jQuery engine and 188 on the plain-JavaScript one, the same counts as against the sources. - All top-level names in the non-wrapped scripts survive minification. `MultiFileUploadField.min.js` keeps its third-party notice, and CSS `url()` references stay relative. ### Open for reviewers - **Browser target.** `es2020` stands in until the project settles on a baseline. - **Node in every build.** The default build, and so the release build, now downloads Node and esbuild. The versions are pinned through `package-lock.json`. - **`wicket-10.x`.** A backport would also end the Closure pin there, but it changes build tooling on a maintenance line. ### Follow-ups, not in this pull request - Run the QUnit suites in CI against the minified files as well. - Strip `sourceMappingURL` comments in `ConcatBundleResource`. A bundle concatenates several minified files, so it would carry several of them, and the browser applies the last one to the whole bundle. Fixes #1835 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
