diff --git a/README.md b/README.md index 92b03d3..344d6ba 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,8 @@ module.exports = { // For `@swc/html`: // + // Options - https://github.com/swc-project/bindings/blob/main/packages/html/index.ts#L5 + // // new HtmlMinimizerPlugin({ // minify: HtmlMinimizerPlugin.swcMinify, // minimizerOptions: {} @@ -450,6 +452,8 @@ module.exports = { ### `swc/html` +Available [`options`](https://github.com/swc-project/bindings/blob/main/packages/html/index.ts#L5). + ```js const HtmlMinimizerPlugin = require("html-minimizer-webpack-plugin"); const CopyPlugin = require("copy-webpack-plugin"); @@ -479,7 +483,7 @@ module.exports = { new HtmlMinimizerPlugin({ minify: HtmlMinimizerPlugin.swcMinify, minimizerOptions: { - // Options + // Options - https://github.com/swc-project/bindings/blob/main/packages/html/index.ts#L5 }, }), ], diff --git a/package-lock.json b/package-lock.json index ba9bd60..f26d13e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "@babel/preset-env": "^7.18.9", "@commitlint/cli": "^17.1.2", "@commitlint/config-conventional": "^17.1.0", - "@swc/html": "^0.0.16", + "@swc/html": "^0.0.17", "@types/serialize-javascript": "^5.0.2", "@webpack-contrib/eslint-config-webpack": "^3.0.0", "babel-jest": "^29.1.2", @@ -3249,33 +3249,33 @@ } }, "node_modules/@swc/html": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html/-/html-0.0.16.tgz", - "integrity": "sha512-RQsFRnSqM3aUKaEAzlwkD1C0kFYrjIJoLG0QP4OPONW9wJsnzoEMaVaeBw+4T0ujW3ms6cTn0zMCzXGARGUwsA==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html/-/html-0.0.17.tgz", + "integrity": "sha512-UDnxPMsya0iQ7f+GScIb+etP0+BcMQS/IPzkdiJQdYtVcSjfIA0oxuyu9zthrkFJPwscDeKWiLkXzwxuHZI3Hg==", "dev": true, "engines": { "node": ">=14" }, "optionalDependencies": { - "@swc/html-android-arm-eabi": "0.0.16", - "@swc/html-android-arm64": "0.0.16", - "@swc/html-darwin-arm64": "0.0.16", - "@swc/html-darwin-x64": "0.0.16", - "@swc/html-freebsd-x64": "0.0.16", - "@swc/html-linux-arm-gnueabihf": "0.0.16", - "@swc/html-linux-arm64-gnu": "0.0.16", - "@swc/html-linux-arm64-musl": "0.0.16", - "@swc/html-linux-x64-gnu": "0.0.16", - "@swc/html-linux-x64-musl": "0.0.16", - "@swc/html-win32-arm64-msvc": "0.0.16", - "@swc/html-win32-ia32-msvc": "0.0.16", - "@swc/html-win32-x64-msvc": "0.0.16" + "@swc/html-android-arm-eabi": "0.0.17", + "@swc/html-android-arm64": "0.0.17", + "@swc/html-darwin-arm64": "0.0.17", + "@swc/html-darwin-x64": "0.0.17", + "@swc/html-freebsd-x64": "0.0.17", + "@swc/html-linux-arm-gnueabihf": "0.0.17", + "@swc/html-linux-arm64-gnu": "0.0.17", + "@swc/html-linux-arm64-musl": "0.0.17", + "@swc/html-linux-x64-gnu": "0.0.17", + "@swc/html-linux-x64-musl": "0.0.17", + "@swc/html-win32-arm64-msvc": "0.0.17", + "@swc/html-win32-ia32-msvc": "0.0.17", + "@swc/html-win32-x64-msvc": "0.0.17" } }, "node_modules/@swc/html-android-arm-eabi": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-android-arm-eabi/-/html-android-arm-eabi-0.0.16.tgz", - "integrity": "sha512-1ImmIhsWO1blNkHWdMBnktqL+wdgu3ndXpRLq0j45pUjFb58izV5T04bQFDEIqV+bkVFmrGwQiJL2iXI/sw31w==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-android-arm-eabi/-/html-android-arm-eabi-0.0.17.tgz", + "integrity": "sha512-O4SAT1JpANEpO7SU/5TNzOlDT4UvM06Pe7N7pQGMn41dqUUteaDbXOS6SLywgIZHuaqaeKlnJTPQZFC7GaY5Ig==", "cpu": [ "arm" ], @@ -3289,9 +3289,9 @@ } }, "node_modules/@swc/html-android-arm64": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-android-arm64/-/html-android-arm64-0.0.16.tgz", - "integrity": "sha512-OAvZY+gUCJLODYZ70p176YVGRt7QvxRo3JV1yA3/PlMuXkOsewZP9pS2WscHLM2AUAQ+7A67OnK/b6REzs/KnA==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-android-arm64/-/html-android-arm64-0.0.17.tgz", + "integrity": "sha512-kXnfCgUIrbQDeiSiOFJHhD9dlXq5SY4pM40Yjt8HAN49Y2tjTx+/J4g3RVq3HlYrobanj2U51ItksSyZVE6QDw==", "cpu": [ "arm64" ], @@ -3305,9 +3305,9 @@ } }, "node_modules/@swc/html-darwin-arm64": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-darwin-arm64/-/html-darwin-arm64-0.0.16.tgz", - "integrity": "sha512-GAavmlsLDQZj4xyul3eCiPuGk5lwnIupD9Fa4alriL5itiLFLMnb4MTMLzRyiRQMwoAauIRcA+LYGRZw+ighww==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-darwin-arm64/-/html-darwin-arm64-0.0.17.tgz", + "integrity": "sha512-kRSU7/idMrBiRXa3kiC9gAISL3getpIFZrCuyX28V24sbfYrSbvNaySXlf8JNyFH7pt4ZZ2Ree5/Exr1R1PncA==", "cpu": [ "arm64" ], @@ -3321,9 +3321,9 @@ } }, "node_modules/@swc/html-darwin-x64": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-darwin-x64/-/html-darwin-x64-0.0.16.tgz", - "integrity": "sha512-oa04657AK/2Vg+l14NAUNDVeG8htjtojajY1ovgDIdNfj8LIyahAnm6K6YcbpfVEiOTfghJP0yAuQwQWcSHFHQ==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-darwin-x64/-/html-darwin-x64-0.0.17.tgz", + "integrity": "sha512-mVnM1oRKxLxSoXyuBOlmzbqjeb2zcdVGrsbHtIAHw2wxtFB9Wpb7XEIv18dmgsGRGaOV+5wK+CsmX3NMPLnLxQ==", "cpu": [ "x64" ], @@ -3337,9 +3337,9 @@ } }, "node_modules/@swc/html-freebsd-x64": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-freebsd-x64/-/html-freebsd-x64-0.0.16.tgz", - "integrity": "sha512-5kwT3Rsn0KvgW+er8cJBIKgrQHR6DXqtvRj4k/6m5KX4SbkinJcVAagF9ph9g1dP1mw2sgPgiRs8kd7ihpKGzw==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-freebsd-x64/-/html-freebsd-x64-0.0.17.tgz", + "integrity": "sha512-ed1wRoIqIvK7wSTf8jtX17oQLQbpw/5ytS0AKjiznlYUEUnIH8WTJayMeFxjHACktYqAaKFIJiIxUGHeQLjMXg==", "cpu": [ "x64" ], @@ -3353,9 +3353,9 @@ } }, "node_modules/@swc/html-linux-arm-gnueabihf": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-linux-arm-gnueabihf/-/html-linux-arm-gnueabihf-0.0.16.tgz", - "integrity": "sha512-CPGkQ+72nwEMczc52DzwveYuVTrAPpFLwrdCJibSyaf8V7kfYP3eXEll5mXX5Tr/HVnz+FdvQK+orjamTMTEpA==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-linux-arm-gnueabihf/-/html-linux-arm-gnueabihf-0.0.17.tgz", + "integrity": "sha512-nGrWlWkvMUKNRIJMngsESYAEo5BoA/0R24Ste9rd6i2ICDJme4QlIyj9+Kj5O0DIJ4czVeCuuuD61Fs2A2Y2ag==", "cpu": [ "arm" ], @@ -3369,9 +3369,9 @@ } }, "node_modules/@swc/html-linux-arm64-gnu": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-linux-arm64-gnu/-/html-linux-arm64-gnu-0.0.16.tgz", - "integrity": "sha512-Lsh6XDSgyZhaAXfAXK3Ucgfi2ZPN49hG+wGfKkjsJ1C29eXQOndJxCviCngVjDkM3ke2eWk8KKCW4ep4Ytnmcg==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-linux-arm64-gnu/-/html-linux-arm64-gnu-0.0.17.tgz", + "integrity": "sha512-JzWazdmVtk+FwyTMCwY2VuN/jevFmWbLXI/hqFR8nOiO39hv4h9/f/R/JEYjh8GU4diy3I/+m+yzTDJ5yKbWUw==", "cpu": [ "arm64" ], @@ -3385,9 +3385,9 @@ } }, "node_modules/@swc/html-linux-arm64-musl": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-linux-arm64-musl/-/html-linux-arm64-musl-0.0.16.tgz", - "integrity": "sha512-3HEyniU5g/2CjYxjaW55Hxzu0xSbuLW9s/hZnkSewLeDJkrMLHDj1Pjoj+XzOi7k/U/dfE063VYSd5MwGyIcUA==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-linux-arm64-musl/-/html-linux-arm64-musl-0.0.17.tgz", + "integrity": "sha512-Y+gDz9AG9sTA65/fhydMdzT1dyDf1OlCwauxDRxJzWVKYD1N5bf35wzPCPRZXDN65X8hHYPlaQreqoPO/T/U6g==", "cpu": [ "arm64" ], @@ -3401,9 +3401,9 @@ } }, "node_modules/@swc/html-linux-x64-gnu": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-linux-x64-gnu/-/html-linux-x64-gnu-0.0.16.tgz", - "integrity": "sha512-+kmyvdsUIf7Gqx1cw5rK7cG9y6vJJ7rChBFU6FzCKyueNcFpdxnnMHoWNb0vrGt1VALeE3eDUo913hv7Q2qxZw==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-linux-x64-gnu/-/html-linux-x64-gnu-0.0.17.tgz", + "integrity": "sha512-/ErQQP9cqXFVuccbpQLLqc6cpibwHnQ2dQ8TS+tSW4a/JM7IfEnW9BnJzDWBnexOJ1NZZePXhD0durhUhSOa/g==", "cpu": [ "x64" ], @@ -3417,9 +3417,9 @@ } }, "node_modules/@swc/html-linux-x64-musl": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-linux-x64-musl/-/html-linux-x64-musl-0.0.16.tgz", - "integrity": "sha512-NUIHODMEmAf2IWpuHKgLP+WYY6jFEA4NWiX4MyOC5wkiqNb1Mcpv+wXonh+hHOoajHl3TegtMmi0soF4iP33fQ==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-linux-x64-musl/-/html-linux-x64-musl-0.0.17.tgz", + "integrity": "sha512-zsXN8bxqek9rrY2Sqo3B7odc1Ga7JEPBSFn4dSvx/YTrs52OQzjZgc/zhhCjEQYKlEkP2nmCIY3+MotKg6hNXQ==", "cpu": [ "x64" ], @@ -3433,9 +3433,9 @@ } }, "node_modules/@swc/html-win32-arm64-msvc": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-win32-arm64-msvc/-/html-win32-arm64-msvc-0.0.16.tgz", - "integrity": "sha512-MBvZsKYNidw3HqM47QMY2YxUjI1ganiYMZTlHy0KG3iG6k9sL3BEK9za1wUT2xSrhgOgJQRZ4AUmYG7H9aExCg==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-win32-arm64-msvc/-/html-win32-arm64-msvc-0.0.17.tgz", + "integrity": "sha512-w9yB61Nw919o7/vaD/2Wlb1fD08Le9NHUhErXoZPlMa8pxbLo7L8UZcyDy+rEeFqI0D7hGQWaHPQ/+MZSIHULg==", "cpu": [ "arm64" ], @@ -3449,9 +3449,9 @@ } }, "node_modules/@swc/html-win32-ia32-msvc": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-win32-ia32-msvc/-/html-win32-ia32-msvc-0.0.16.tgz", - "integrity": "sha512-2qfxt3S3umlWIENpLW7Op1pBSp1iKGmPWvScX32cYSpZssyBxuD5odAj2iEBQDU1BgWzghrpCSqFi9WJoCkpmQ==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-win32-ia32-msvc/-/html-win32-ia32-msvc-0.0.17.tgz", + "integrity": "sha512-LarMPrJO78johJAtIYD+i6s6LxGBdV/g49K9kSfOa5pVNPIuYbklovtDBfHRl6AgHaWyudq/5n+WG3YeKFyD5Q==", "cpu": [ "ia32" ], @@ -3465,9 +3465,9 @@ } }, "node_modules/@swc/html-win32-x64-msvc": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-win32-x64-msvc/-/html-win32-x64-msvc-0.0.16.tgz", - "integrity": "sha512-xCZk4Vb32GzsWnu1ogb7/X7QFjfOjOQcaOBi4K/Nkcl5n6uePNSni1Ij50+bpS3MP8Iw+SKThb/Eh9X0OCVKUA==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-win32-x64-msvc/-/html-win32-x64-msvc-0.0.17.tgz", + "integrity": "sha512-zZvQyxAHd4vvItvXOo8BDib4FBL1h71ttQ9Q/k4k9Vn9czFaZRoSQlO1qPQ/bKV+c/xfQv2KNmHk04iSnTOA8Q==", "cpu": [ "x64" ], @@ -15266,114 +15266,114 @@ } }, "@swc/html": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html/-/html-0.0.16.tgz", - "integrity": "sha512-RQsFRnSqM3aUKaEAzlwkD1C0kFYrjIJoLG0QP4OPONW9wJsnzoEMaVaeBw+4T0ujW3ms6cTn0zMCzXGARGUwsA==", - "dev": true, - "requires": { - "@swc/html-android-arm-eabi": "0.0.16", - "@swc/html-android-arm64": "0.0.16", - "@swc/html-darwin-arm64": "0.0.16", - "@swc/html-darwin-x64": "0.0.16", - "@swc/html-freebsd-x64": "0.0.16", - "@swc/html-linux-arm-gnueabihf": "0.0.16", - "@swc/html-linux-arm64-gnu": "0.0.16", - "@swc/html-linux-arm64-musl": "0.0.16", - "@swc/html-linux-x64-gnu": "0.0.16", - "@swc/html-linux-x64-musl": "0.0.16", - "@swc/html-win32-arm64-msvc": "0.0.16", - "@swc/html-win32-ia32-msvc": "0.0.16", - "@swc/html-win32-x64-msvc": "0.0.16" + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html/-/html-0.0.17.tgz", + "integrity": "sha512-UDnxPMsya0iQ7f+GScIb+etP0+BcMQS/IPzkdiJQdYtVcSjfIA0oxuyu9zthrkFJPwscDeKWiLkXzwxuHZI3Hg==", + "dev": true, + "requires": { + "@swc/html-android-arm-eabi": "0.0.17", + "@swc/html-android-arm64": "0.0.17", + "@swc/html-darwin-arm64": "0.0.17", + "@swc/html-darwin-x64": "0.0.17", + "@swc/html-freebsd-x64": "0.0.17", + "@swc/html-linux-arm-gnueabihf": "0.0.17", + "@swc/html-linux-arm64-gnu": "0.0.17", + "@swc/html-linux-arm64-musl": "0.0.17", + "@swc/html-linux-x64-gnu": "0.0.17", + "@swc/html-linux-x64-musl": "0.0.17", + "@swc/html-win32-arm64-msvc": "0.0.17", + "@swc/html-win32-ia32-msvc": "0.0.17", + "@swc/html-win32-x64-msvc": "0.0.17" } }, "@swc/html-android-arm-eabi": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-android-arm-eabi/-/html-android-arm-eabi-0.0.16.tgz", - "integrity": "sha512-1ImmIhsWO1blNkHWdMBnktqL+wdgu3ndXpRLq0j45pUjFb58izV5T04bQFDEIqV+bkVFmrGwQiJL2iXI/sw31w==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-android-arm-eabi/-/html-android-arm-eabi-0.0.17.tgz", + "integrity": "sha512-O4SAT1JpANEpO7SU/5TNzOlDT4UvM06Pe7N7pQGMn41dqUUteaDbXOS6SLywgIZHuaqaeKlnJTPQZFC7GaY5Ig==", "dev": true, "optional": true }, "@swc/html-android-arm64": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-android-arm64/-/html-android-arm64-0.0.16.tgz", - "integrity": "sha512-OAvZY+gUCJLODYZ70p176YVGRt7QvxRo3JV1yA3/PlMuXkOsewZP9pS2WscHLM2AUAQ+7A67OnK/b6REzs/KnA==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-android-arm64/-/html-android-arm64-0.0.17.tgz", + "integrity": "sha512-kXnfCgUIrbQDeiSiOFJHhD9dlXq5SY4pM40Yjt8HAN49Y2tjTx+/J4g3RVq3HlYrobanj2U51ItksSyZVE6QDw==", "dev": true, "optional": true }, "@swc/html-darwin-arm64": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-darwin-arm64/-/html-darwin-arm64-0.0.16.tgz", - "integrity": "sha512-GAavmlsLDQZj4xyul3eCiPuGk5lwnIupD9Fa4alriL5itiLFLMnb4MTMLzRyiRQMwoAauIRcA+LYGRZw+ighww==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-darwin-arm64/-/html-darwin-arm64-0.0.17.tgz", + "integrity": "sha512-kRSU7/idMrBiRXa3kiC9gAISL3getpIFZrCuyX28V24sbfYrSbvNaySXlf8JNyFH7pt4ZZ2Ree5/Exr1R1PncA==", "dev": true, "optional": true }, "@swc/html-darwin-x64": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-darwin-x64/-/html-darwin-x64-0.0.16.tgz", - "integrity": "sha512-oa04657AK/2Vg+l14NAUNDVeG8htjtojajY1ovgDIdNfj8LIyahAnm6K6YcbpfVEiOTfghJP0yAuQwQWcSHFHQ==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-darwin-x64/-/html-darwin-x64-0.0.17.tgz", + "integrity": "sha512-mVnM1oRKxLxSoXyuBOlmzbqjeb2zcdVGrsbHtIAHw2wxtFB9Wpb7XEIv18dmgsGRGaOV+5wK+CsmX3NMPLnLxQ==", "dev": true, "optional": true }, "@swc/html-freebsd-x64": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-freebsd-x64/-/html-freebsd-x64-0.0.16.tgz", - "integrity": "sha512-5kwT3Rsn0KvgW+er8cJBIKgrQHR6DXqtvRj4k/6m5KX4SbkinJcVAagF9ph9g1dP1mw2sgPgiRs8kd7ihpKGzw==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-freebsd-x64/-/html-freebsd-x64-0.0.17.tgz", + "integrity": "sha512-ed1wRoIqIvK7wSTf8jtX17oQLQbpw/5ytS0AKjiznlYUEUnIH8WTJayMeFxjHACktYqAaKFIJiIxUGHeQLjMXg==", "dev": true, "optional": true }, "@swc/html-linux-arm-gnueabihf": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-linux-arm-gnueabihf/-/html-linux-arm-gnueabihf-0.0.16.tgz", - "integrity": "sha512-CPGkQ+72nwEMczc52DzwveYuVTrAPpFLwrdCJibSyaf8V7kfYP3eXEll5mXX5Tr/HVnz+FdvQK+orjamTMTEpA==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-linux-arm-gnueabihf/-/html-linux-arm-gnueabihf-0.0.17.tgz", + "integrity": "sha512-nGrWlWkvMUKNRIJMngsESYAEo5BoA/0R24Ste9rd6i2ICDJme4QlIyj9+Kj5O0DIJ4czVeCuuuD61Fs2A2Y2ag==", "dev": true, "optional": true }, "@swc/html-linux-arm64-gnu": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-linux-arm64-gnu/-/html-linux-arm64-gnu-0.0.16.tgz", - "integrity": "sha512-Lsh6XDSgyZhaAXfAXK3Ucgfi2ZPN49hG+wGfKkjsJ1C29eXQOndJxCviCngVjDkM3ke2eWk8KKCW4ep4Ytnmcg==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-linux-arm64-gnu/-/html-linux-arm64-gnu-0.0.17.tgz", + "integrity": "sha512-JzWazdmVtk+FwyTMCwY2VuN/jevFmWbLXI/hqFR8nOiO39hv4h9/f/R/JEYjh8GU4diy3I/+m+yzTDJ5yKbWUw==", "dev": true, "optional": true }, "@swc/html-linux-arm64-musl": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-linux-arm64-musl/-/html-linux-arm64-musl-0.0.16.tgz", - "integrity": "sha512-3HEyniU5g/2CjYxjaW55Hxzu0xSbuLW9s/hZnkSewLeDJkrMLHDj1Pjoj+XzOi7k/U/dfE063VYSd5MwGyIcUA==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-linux-arm64-musl/-/html-linux-arm64-musl-0.0.17.tgz", + "integrity": "sha512-Y+gDz9AG9sTA65/fhydMdzT1dyDf1OlCwauxDRxJzWVKYD1N5bf35wzPCPRZXDN65X8hHYPlaQreqoPO/T/U6g==", "dev": true, "optional": true }, "@swc/html-linux-x64-gnu": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-linux-x64-gnu/-/html-linux-x64-gnu-0.0.16.tgz", - "integrity": "sha512-+kmyvdsUIf7Gqx1cw5rK7cG9y6vJJ7rChBFU6FzCKyueNcFpdxnnMHoWNb0vrGt1VALeE3eDUo913hv7Q2qxZw==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-linux-x64-gnu/-/html-linux-x64-gnu-0.0.17.tgz", + "integrity": "sha512-/ErQQP9cqXFVuccbpQLLqc6cpibwHnQ2dQ8TS+tSW4a/JM7IfEnW9BnJzDWBnexOJ1NZZePXhD0durhUhSOa/g==", "dev": true, "optional": true }, "@swc/html-linux-x64-musl": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-linux-x64-musl/-/html-linux-x64-musl-0.0.16.tgz", - "integrity": "sha512-NUIHODMEmAf2IWpuHKgLP+WYY6jFEA4NWiX4MyOC5wkiqNb1Mcpv+wXonh+hHOoajHl3TegtMmi0soF4iP33fQ==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-linux-x64-musl/-/html-linux-x64-musl-0.0.17.tgz", + "integrity": "sha512-zsXN8bxqek9rrY2Sqo3B7odc1Ga7JEPBSFn4dSvx/YTrs52OQzjZgc/zhhCjEQYKlEkP2nmCIY3+MotKg6hNXQ==", "dev": true, "optional": true }, "@swc/html-win32-arm64-msvc": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-win32-arm64-msvc/-/html-win32-arm64-msvc-0.0.16.tgz", - "integrity": "sha512-MBvZsKYNidw3HqM47QMY2YxUjI1ganiYMZTlHy0KG3iG6k9sL3BEK9za1wUT2xSrhgOgJQRZ4AUmYG7H9aExCg==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-win32-arm64-msvc/-/html-win32-arm64-msvc-0.0.17.tgz", + "integrity": "sha512-w9yB61Nw919o7/vaD/2Wlb1fD08Le9NHUhErXoZPlMa8pxbLo7L8UZcyDy+rEeFqI0D7hGQWaHPQ/+MZSIHULg==", "dev": true, "optional": true }, "@swc/html-win32-ia32-msvc": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-win32-ia32-msvc/-/html-win32-ia32-msvc-0.0.16.tgz", - "integrity": "sha512-2qfxt3S3umlWIENpLW7Op1pBSp1iKGmPWvScX32cYSpZssyBxuD5odAj2iEBQDU1BgWzghrpCSqFi9WJoCkpmQ==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-win32-ia32-msvc/-/html-win32-ia32-msvc-0.0.17.tgz", + "integrity": "sha512-LarMPrJO78johJAtIYD+i6s6LxGBdV/g49K9kSfOa5pVNPIuYbklovtDBfHRl6AgHaWyudq/5n+WG3YeKFyD5Q==", "dev": true, "optional": true }, "@swc/html-win32-x64-msvc": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/@swc/html-win32-x64-msvc/-/html-win32-x64-msvc-0.0.16.tgz", - "integrity": "sha512-xCZk4Vb32GzsWnu1ogb7/X7QFjfOjOQcaOBi4K/Nkcl5n6uePNSni1Ij50+bpS3MP8Iw+SKThb/Eh9X0OCVKUA==", + "version": "0.0.17", + "resolved": "https://registry.npmjs.org/@swc/html-win32-x64-msvc/-/html-win32-x64-msvc-0.0.17.tgz", + "integrity": "sha512-zZvQyxAHd4vvItvXOo8BDib4FBL1h71ttQ9Q/k4k9Vn9czFaZRoSQlO1qPQ/bKV+c/xfQv2KNmHk04iSnTOA8Q==", "dev": true, "optional": true }, diff --git a/package.json b/package.json index 5c62bbb..8120271 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "@babel/preset-env": "^7.18.9", "@commitlint/cli": "^17.1.2", "@commitlint/config-conventional": "^17.1.0", - "@swc/html": "^0.0.16", + "@swc/html": "^0.0.17", "@types/serialize-javascript": "^5.0.2", "@webpack-contrib/eslint-config-webpack": "^3.0.0", "babel-jest": "^29.1.2", diff --git a/src/utils.js b/src/utils.js index 9e110e2..7601c75 100644 --- a/src/utils.js +++ b/src/utils.js @@ -113,12 +113,30 @@ async function swcMinify(input, minimizerOptions = {}) { // eslint-disable-next-line global-require, import/no-extraneous-dependencies, import/no-unresolved const swcMinifier = require("@swc/html"); - const [[, code]] = Object.entries(input); - const result = await swcMinifier.minify(Buffer.from(code), { + // TODO `import("@swc/html").Options` + const options = /** @type {*} */ ({ ...minimizerOptions, }); - return { code: result }; + const [[, code]] = Object.entries(input); + const result = await swcMinifier.minify(Buffer.from(code), options); + + let errors; + + if (typeof result.errors !== "undefined") { + errors = result.errors.map((diagnostic) => { + const error = new Error(diagnostic.message); + + // @ts-ignore + error.span = diagnostic.span; + // @ts-ignore + error.level = diagnostic.level; + + return error; + }); + } + + return { code: result.code, errors }; } module.exports = { throttleAll, htmlMinifierTerser, swcMinify }; diff --git a/test/__snapshots__/minify-option.test.js.snap b/test/__snapshots__/minify-option.test.js.snap index 3039945..1de1b9c 100644 --- a/test/__snapshots__/minify-option.test.js.snap +++ b/test/__snapshots__/minify-option.test.js.snap @@ -71,29 +71,64 @@ exports[`"minify" option should work minify function: warnings 1`] = `[]`; exports[`"minify" option should work with 'swcMinify' and options: assets 1`] = ` { - "simple.html": "
My first paragraph.
-My first paragraph.