This is an automated email from the ASF dual-hosted git repository. papegaaij pushed a commit to branch esbuild-minification in repository https://gitbox.apache.org/repos/asf/wicket.git
commit f78a357a6170bef5b6ea1ec530ef8a748e44faad Author: Emond Papegaaij <[email protected]> AuthorDate: Fri Nov 6 16:12:21 2026 +0100 Minify JavaScript and CSS with esbuild instead of the resources optimizer 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, 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. It writes foo.min.js / foo.min.css and a linked foo.min.js.map, with the sources embedded, next to every resource except jquery*.js and files that are already minified. 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; wicket-veil.min.js shrinks by 3.4 KB. - Each .min file links to a source map, which 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. GitHub issue #1835 Co-Authored-By: Claude Opus 5.5 <[email protected]> --- .github/dependabot.yml | 6 + build-tools/minify/minify.mjs | 97 ++++ build-tools/minify/package-lock.json | 498 +++++++++++++++++++++ build-tools/minify/package.json | 13 + pom.xml | 95 ++-- wicket-assembly-all.xml | 3 + wicket-core/pom.xml | 10 +- wicket-devutils/pom.xml | 14 + wicket-extensions/pom.xml | 10 +- .../wicket-native-websocket-core/pom.xml | 15 + 10 files changed, 725 insertions(+), 36 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 597b23dae1..848e54cbb1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -33,6 +33,12 @@ updates: day: "sunday" open-pull-requests-limit: 20 + - package-ecosystem: "npm" + directory: "/build-tools/minify/" + schedule: + interval: "weekly" + day: "sunday" + - package-ecosystem: "github-actions" directory: "/" schedule: diff --git a/build-tools/minify/minify.mjs b/build-tools/minify/minify.mjs new file mode 100644 index 0000000000..9d1bc5a418 --- /dev/null +++ b/build-tools/minify/minify.mjs @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Writes a minified foo.min.js / foo.min.css, with a linked source map, next to every + * foo.js / foo.css below the given directories. Wicket serves the .min variant when + * ResourceSettings#getUseMinifiedResources() is on. + * + * Usage: node minify.mjs <directory>... + */ + +import { readdir, readFile } from 'node:fs/promises'; +import { basename, dirname, extname, join } from 'node:path'; + +let esbuild; +try { + esbuild = await import('esbuild'); +} catch (e) { + console.error('esbuild is not installed in ' + import.meta.dirname + '. Build the root ' + + 'project once (mvn -N generate-resources) to install it, then rerun this module.'); + process.exit(1); +} + +const JS_TARGET = 'es2020'; + +const ASF_BANNER = '/*! Licensed to the Apache Software Foundation (ASF) under the Apache ' + + 'License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 */'; + +const LEADING_COMMENT = /^\s*(\/\*[\s\S]*?\*\/)/; + +function isSource(name) { + const ext = extname(name); + return (ext === '.js' || ext === '.css') + && !name.endsWith('.min' + ext) + && !/^jquery.*\.js$/.test(name); +} + +async function findSources(dir) { + const entries = await readdir(dir, { recursive: true, withFileTypes: true }); + return entries + .filter(entry => entry.isFile() && isSource(entry.name)) + .map(entry => join(entry.parentPath, entry.name)); +} + +// Third-party files keep their own notice; Wicket's own get a one-line form of the ASF header. +async function banner(file) { + const source = await readFile(file, 'utf8'); + const match = LEADING_COMMENT.exec(source); + if (match === null) { + return ''; + } + if (match[1].includes('Licensed to the Apache Software Foundation')) { + return ASF_BANNER; + } + return match[1].replace(/^\/\*(?!!)/, '/*!'); +} + +async function minify(file) { + const ext = extname(file); + const loader = ext.substring(1); + await esbuild.build({ + entryPoints: [file], + outfile: join(dirname(file), basename(file, ext) + '.min' + ext), + loader: { [ext]: loader }, + minify: true, + target: loader === 'js' ? JS_TARGET : undefined, + sourcemap: 'linked', + sourcesContent: true, + legalComments: 'inline', + banner: { [loader]: await banner(file) }, + logLevel: 'warning' + }); +} + +const dirs = process.argv.slice(2); +if (dirs.length === 0) { + console.error('Usage: node minify.mjs <directory>...'); + process.exit(2); +} + +const files = (await Promise.all(dirs.map(findSources))).flat(); +await Promise.all(files.map(minify)); +console.log('Minified ' + files.length + ' file(s) in ' + dirs.join(', ')); diff --git a/build-tools/minify/package-lock.json b/build-tools/minify/package-lock.json new file mode 100644 index 0000000000..17a68ed94b --- /dev/null +++ b/build-tools/minify/package-lock.json @@ -0,0 +1,498 @@ +{ + "name": "wicket-minify", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "wicket-minify", + "license": "Apache-2.0", + "devDependencies": { + "esbuild": "0.28.2" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.2", + "@esbuild/android-arm": "0.28.2", + "@esbuild/android-arm64": "0.28.2", + "@esbuild/android-x64": "0.28.2", + "@esbuild/darwin-arm64": "0.28.2", + "@esbuild/darwin-x64": "0.28.2", + "@esbuild/freebsd-arm64": "0.28.2", + "@esbuild/freebsd-x64": "0.28.2", + "@esbuild/linux-arm": "0.28.2", + "@esbuild/linux-arm64": "0.28.2", + "@esbuild/linux-ia32": "0.28.2", + "@esbuild/linux-loong64": "0.28.2", + "@esbuild/linux-mips64el": "0.28.2", + "@esbuild/linux-ppc64": "0.28.2", + "@esbuild/linux-riscv64": "0.28.2", + "@esbuild/linux-s390x": "0.28.2", + "@esbuild/linux-x64": "0.28.2", + "@esbuild/netbsd-arm64": "0.28.2", + "@esbuild/netbsd-x64": "0.28.2", + "@esbuild/openbsd-arm64": "0.28.2", + "@esbuild/openbsd-x64": "0.28.2", + "@esbuild/openharmony-arm64": "0.28.2", + "@esbuild/sunos-x64": "0.28.2", + "@esbuild/win32-arm64": "0.28.2", + "@esbuild/win32-ia32": "0.28.2", + "@esbuild/win32-x64": "0.28.2" + } + } + } +} diff --git a/build-tools/minify/package.json b/build-tools/minify/package.json new file mode 100644 index 0000000000..d764f0d56b --- /dev/null +++ b/build-tools/minify/package.json @@ -0,0 +1,13 @@ +{ + "name": "wicket-minify", + "description": "Produces the .min.js and .min.css variants of the resources Apache Wicket ships", + "private": true, + "license": "Apache-2.0", + "type": "module", + "devDependencies": { + "esbuild": "0.28.2" + }, + "scripts": { + "minify": "node minify.mjs" + } +} diff --git a/pom.xml b/pom.xml index c07252217a..d08656bb3e 100644 --- a/pom.xml +++ b/pom.xml @@ -206,6 +206,7 @@ <!-- Maven plugins --> <apache-rat-plugin.version>0.18</apache-rat-plugin.version> <build-helper-maven-plugin.version>3.6.2</build-helper-maven-plugin.version> + <frontend-maven-plugin.version>2.0.2</frontend-maven-plugin.version> <japicmp-maven-plugin.version>0.26.5</japicmp-maven-plugin.version> <maven-archetype-plugin.version>3.4.1</maven-archetype-plugin.version> <maven-bundle-plugin.version>6.2.0</maven-bundle-plugin.version> @@ -227,7 +228,12 @@ <maven-source-plugin.version>3.4.0</maven-source-plugin.version> <maven-toolchains-plugin.version>3.3.0</maven-toolchains-plugin.version> <maven-war-plugin.version>3.5.1</maven-war-plugin.version> - <resources-optimizer-maven-plugin.version>2.7.9</resources-optimizer-maven-plugin.version> + + <!-- Node runs the esbuild minifier in build-tools/minify; installed there by the root build --> + <node.version>v24.15.0</node.version> + <npm.version>11.12.1</npm.version> + <!-- Correct for modules one level below the root; deeper modules override it --> + <minify.directory>${project.basedir}/../build-tools/minify</minify.directory> <osgi.dynamicimport.package /> <osgi.export.package>*</osgi.export.package> @@ -877,9 +883,60 @@ <artifactId>apache-rat-plugin</artifactId> <inherited>false</inherited> </plugin> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <inherited>false</inherited> + <executions> + <execution> + <id>install-node-and-npm</id> + <inherited>false</inherited> + <goals> + <goal>install-node-and-npm</goal> + </goals> + <configuration> + <installDirectory>${project.basedir}/build-tools/minify</installDirectory> + <nodeVersion>${node.version}</nodeVersion> + <npmVersion>${npm.version}</npmVersion> + </configuration> + </execution> + <execution> + <id>npm-ci</id> + <inherited>false</inherited> + <goals> + <goal>npm</goal> + </goals> + <configuration> + <arguments>ci</arguments> + <installDirectory>${project.basedir}/build-tools/minify</installDirectory> + <workingDirectory>${project.basedir}/build-tools/minify</workingDirectory> + </configuration> + </execution> + </executions> + </plugin> </plugins> <pluginManagement> <plugins> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>${frontend-maven-plugin.version}</version> + <executions> + <execution> + <id>minify</id> + <goals> + <goal>npm</goal> + </goals> + <!-- Bound to process-classes by each module that ships JavaScript or CSS --> + <phase>none</phase> + <configuration> + <arguments>run minify -- ${project.build.outputDirectory}</arguments> + <installDirectory>${minify.directory}</installDirectory> + <workingDirectory>${minify.directory}</workingDirectory> + </configuration> + </execution> + </executions> + </plugin> <plugin> <groupId>com.github.siom79.japicmp</groupId> <artifactId>japicmp-maven-plugin</artifactId> @@ -1298,11 +1355,12 @@ <pluginExecutions> <pluginExecution> <pluginExecutionFilter> - <groupId>org.primefaces.extensions</groupId> - <artifactId>resources-optimizer-maven-plugin</artifactId> - <versionRange>[1.3.0,)</versionRange> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <versionRange>[2.0.0,)</versionRange> <goals> - <goal>optimize</goal> + <goal>install-node-and-npm</goal> + <goal>npm</goal> </goals> </pluginExecutionFilter> <action> @@ -1371,33 +1429,6 @@ <artifactId>jacoco-maven-plugin</artifactId> <version>${jacoco.version}</version> </plugin> - <plugin> - <groupId>org.primefaces.extensions</groupId> - <artifactId>resources-optimizer-maven-plugin</artifactId> - <version>${resources-optimizer-maven-plugin.version}</version> - <configuration> - <suffix>.min</suffix> - <inputDir>${project.build.directory}/classes</inputDir> - <useDataUri>false</useDataUri> - <languageIn>ECMASCRIPT_2015</languageIn> - <resourcesSets> - <resourcesSet> - <excludes> - <exclude>**/jquery*.js</exclude> - <exclude>**/*.min.js</exclude> - <exclude>**/*.min.css</exclude> - </excludes> - </resourcesSet> - </resourcesSets> - </configuration> - <executions> - <execution> - <goals> - <goal>optimize</goal> - </goals> - </execution> - </executions> - </plugin> </plugins> </pluginManagement> </build> diff --git a/wicket-assembly-all.xml b/wicket-assembly-all.xml index 92fdf7fa6b..e1bcec18d1 100644 --- a/wicket-assembly-all.xml +++ b/wicket-assembly-all.xml @@ -61,8 +61,11 @@ <include>*.xml</include> <include>wicket/**</include> <include>wicket-*/**</include> + <include>build-tools/**</include> </includes> <excludes> + <exclude>build-tools/**/node/**</exclude> + <exclude>build-tools/**/node_modules/**</exclude> <exclude>**/wicket/target/**</exclude> <exclude>**/wicket-*/target/**</exclude> <exclude>**/.classpath/**</exclude> diff --git a/wicket-core/pom.xml b/wicket-core/pom.xml index d838aa0d0e..f980d22e10 100644 --- a/wicket-core/pom.xml +++ b/wicket-core/pom.xml @@ -173,8 +173,14 @@ org.apache.wicket.validation.validator;-noimport:=true <build> <plugins> <plugin> - <groupId>org.primefaces.extensions</groupId> - <artifactId>resources-optimizer-maven-plugin</artifactId> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <executions> + <execution> + <id>minify</id> + <phase>process-classes</phase> + </execution> + </executions> </plugin> </plugins> </build> diff --git a/wicket-devutils/pom.xml b/wicket-devutils/pom.xml index 319f51f1fa..c99b316e65 100644 --- a/wicket-devutils/pom.xml +++ b/wicket-devutils/pom.xml @@ -49,4 +49,18 @@ <artifactId>wicket-tester</artifactId> </dependency> </dependencies> + <build> + <plugins> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <executions> + <execution> + <id>minify</id> + <phase>process-classes</phase> + </execution> + </executions> + </plugin> + </plugins> + </build> </project> diff --git a/wicket-extensions/pom.xml b/wicket-extensions/pom.xml index 6dee56fbea..35656549d5 100644 --- a/wicket-extensions/pom.xml +++ b/wicket-extensions/pom.xml @@ -93,8 +93,14 @@ org.apache.wicket.extensions.wizard.dynamic;-noimport:=true <build> <plugins> <plugin> - <groupId>org.primefaces.extensions</groupId> - <artifactId>resources-optimizer-maven-plugin</artifactId> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <executions> + <execution> + <id>minify</id> + <phase>process-classes</phase> + </execution> + </executions> </plugin> </plugins> </build> diff --git a/wicket-native-websocket/wicket-native-websocket-core/pom.xml b/wicket-native-websocket/wicket-native-websocket-core/pom.xml index c1f759b5eb..42b8dfc34e 100644 --- a/wicket-native-websocket/wicket-native-websocket-core/pom.xml +++ b/wicket-native-websocket/wicket-native-websocket-core/pom.xml @@ -32,6 +32,7 @@ <properties> <osgi.export.package>org.apache.wicket.protocol.ws*;-noimport:=true</osgi.export.package> <osgi.import.package>!java*,!kotlin*,!sun.nio.ch,org.slf4j*;version="[1.7,3)",*</osgi.import.package> + <minify.directory>${project.basedir}/../../build-tools/minify</minify.directory> </properties> <dependencies> <dependency> @@ -43,4 +44,18 @@ <artifactId>wicket-tester</artifactId> </dependency> </dependencies> + <build> + <plugins> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <executions> + <execution> + <id>minify</id> + <phase>process-classes</phase> + </execution> + </executions> + </plugin> + </plugins> + </build> </project>
