From c43d0013d700f871582987de9c5959c448ddd90b Mon Sep 17 00:00:00 2001 From: DongYun Kang Date: Thu, 16 Apr 2026 22:19:45 +0100 Subject: [PATCH 1/5] feat: support extractComments in swcMinify --- README.md | 4 +- src/utils.js | 187 ++++++++++++- test/__snapshots__/minify-option.test.js.snap | 263 +++++++++++++++++- test/minify-option.test.js | 50 +++- types/utils.d.ts | 16 ++ 5 files changed, 502 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 76effca..444e7ce 100644 --- a/README.md +++ b/README.md @@ -762,7 +762,9 @@ module.exports = { > **Warning** > -> The `extractComments` option is not supported, and all comments will be removed by default. This will be fixed in future +> `extractComments` is supported when `@swc/core` provides the `extractComments` minify option. +> Only serializable extract conditions are supported: booleans, `"some"`, `"all"`, string patterns, `RegExp` values without flags, or object conditions that resolve to those forms. +> Function conditions and flagged regular expressions are not supported. **webpack.config.js** diff --git a/src/utils.js b/src/utils.js index a744c9b..8737916 100644 --- a/src/utils.js +++ b/src/utils.js @@ -5,6 +5,8 @@ /** @typedef {import("./index.js").MinimizedResult} MinimizedResult */ /** @typedef {import("./index.js").CustomOptions} CustomOptions */ /** @typedef {import("./index.js").RawSourceMap} RawSourceMap */ +/** @typedef {import("@swc/core").JsMinifyOptions & { extractComments?: false | true | "some" | "all" | { regex: string } }} SwcMinifyOptionsWithExtractComments */ +/** @typedef {import("@swc/core").Output & { extractedComments?: string[] }} SwcMinifyOutput */ /** * @template T @@ -77,10 +79,9 @@ async function terserMinify( minimizerOptions, extractComments, ) { - // eslint-disable-next-line jsdoc/no-restricted-syntax /** * @param {unknown} value value - * @returns {value is object} true when value is object or function + * @returns {boolean} true when value is object or function */ const isObject = (value) => { const type = typeof value; @@ -333,10 +334,9 @@ async function uglifyJsMinify( minimizerOptions, extractComments, ) { - // eslint-disable-next-line jsdoc/no-restricted-syntax /** * @param {unknown} value value - * @returns {value is object} true when value is object or function + * @returns {boolean} true when value is object or function */ const isObject = (value) => { const type = typeof value; @@ -555,12 +555,145 @@ uglifyJsMinify.supportsWorkerThreads = () => true; * @param {Input} input input * @param {RawSourceMap=} sourceMap source map * @param {CustomOptions=} minimizerOptions options + * @param {ExtractCommentsOptions=} extractComments extract comments option * @returns {Promise} minimized result */ -async function swcMinify(input, sourceMap, minimizerOptions) { +async function swcMinify(input, sourceMap, minimizerOptions, extractComments) { + /** + * @param {unknown} value value + * @returns {boolean} true when value is object or function + */ + const isObject = (value) => { + const type = typeof value; + + // eslint-disable-next-line no-eq-null, eqeqeq + return value != null && (type === "object" || type === "function"); + }; + + /** + * @param {unknown} extractCommentsOptions extract comments option + * @returns {Error} error for unsupported extract comments option + */ + const createExtractCommentsError = (extractCommentsOptions) => + new Error( + `The 'extractComments' option for 'swcMinify' only supports booleans, "some", "all", string patterns, RegExp values without flags, or object conditions that resolve to those forms. Received: ${extractCommentsOptions instanceof RegExp ? extractCommentsOptions.toString() : typeof extractCommentsOptions}.`, + ); + + /** + * @param {unknown} extractCommentsOptions extract comments option + * @returns {{ extractComments: false | true | "some" | "all" | { regex: string }, useDefaultPreserveComments: boolean }} normalized swc extract comments options + */ + const normalizeExtractComments = (extractCommentsOptions) => { + if (typeof extractCommentsOptions === "boolean") { + return { + extractComments: extractCommentsOptions, + useDefaultPreserveComments: !extractCommentsOptions, + }; + } + + if (typeof extractCommentsOptions === "string") { + return { + extractComments: + extractCommentsOptions === "some" || extractCommentsOptions === "all" + ? extractCommentsOptions + : { regex: extractCommentsOptions }, + useDefaultPreserveComments: false, + }; + } + + if (extractCommentsOptions instanceof RegExp) { + if (extractCommentsOptions.flags) { + throw createExtractCommentsError(extractCommentsOptions); + } + + return { + extractComments: { regex: extractCommentsOptions.source }, + useDefaultPreserveComments: false, + }; + } + + if (typeof extractCommentsOptions === "function") { + throw createExtractCommentsError(extractCommentsOptions); + } + + if (extractCommentsOptions && isObject(extractCommentsOptions)) { + const { condition = "some" } = /** @type {{ condition?: unknown }} */ ( + extractCommentsOptions + ); + + if (typeof condition === "boolean") { + return { + extractComments: condition ? "some" : false, + useDefaultPreserveComments: false, + }; + } + + if (typeof condition === "string") { + return { + extractComments: + condition === "some" || condition === "all" + ? condition + : { regex: condition }, + useDefaultPreserveComments: false, + }; + } + + if (condition instanceof RegExp) { + if (condition.flags) { + throw createExtractCommentsError(condition); + } + + return { + extractComments: { regex: condition.source }, + useDefaultPreserveComments: false, + }; + } + + throw createExtractCommentsError(condition); + } + + return { + extractComments: false, + useDefaultPreserveComments: false, + }; + }; + + /** + * @param {typeof import("@swc/core")} swc swc module + * @returns {boolean} true when the installed swc build supports comment extraction + */ + const hasExtractCommentsSupport = (swc) => { + try { + if (typeof swc.minifySync !== "function") { + return false; + } + + const result = /** @type {SwcMinifyOutput} */ ( + swc.minifySync( + "/*! swc */var foo = 1;", + /** @type {SwcMinifyOptionsWithExtractComments} */ ({ + compress: false, + mangle: false, + format: { + comments: false, + }, + extractComments: true, + }), + ) + ); + + return ( + Array.isArray(result.extractedComments) && + result.extractedComments[0] === "/*! swc */" + ); + } catch (_error) { + return false; + } + }; + /** * @param {PredefinedOptions & import("@swc/core").JsMinifyOptions=} swcOptions swc options - * @returns {import("@swc/core").JsMinifyOptions & { sourceMap: undefined | boolean } & { compress: import("@swc/core").TerserCompressOptions }} built swc options + * @returns {SwcMinifyOptionsWithExtractComments & { sourceMap: undefined | boolean } & { compress: import("@swc/core").TerserCompressOptions }} built swc options */ const buildSwcOptions = (swcOptions = {}) => // Need deep copy objects to avoid https://github.com/terser/terser/issues/366 @@ -579,6 +712,7 @@ async function swcMinify(input, sourceMap, minimizerOptions) { : typeof swcOptions.mangle === "boolean" ? swcOptions.mangle : { ...swcOptions.mangle }, + format: { ...swcOptions.format }, // ecma: swcOptions.ecma, // keep_classnames: swcOptions.keep_classnames, // keep_fnames: swcOptions.keep_fnames, @@ -599,12 +733,48 @@ async function swcMinify(input, sourceMap, minimizerOptions) { // Copy `swc` options const swcOptions = buildSwcOptions(minimizerOptions); + const normalizedExtractComments = normalizeExtractComments(extractComments); + + if (!swcOptions.format) { + swcOptions.format = {}; + } // Let `swc` generate a SourceMap if (sourceMap) { swcOptions.sourceMap = true; } + if ( + normalizedExtractComments.useDefaultPreserveComments && + typeof swcOptions.format.comments === "undefined" + ) { + swcOptions.format.comments = "some"; + } + + if (normalizedExtractComments.extractComments !== false) { + if (!hasExtractCommentsSupport(swc)) { + let swcVersion; + + try { + ({ version: swcVersion } = require("@swc/core/package.json")); + } catch (_error) { + // Ignore + } + + return { + errors: [ + new Error( + `The 'extractComments' option for 'swcMinify' requires an @swc/core build with comment extraction support${swcVersion ? ` (found ${swcVersion})` : ""}. Please upgrade @swc/core.`, + ), + ], + }; + } + + /** @type {SwcMinifyOptionsWithExtractComments} */ ( + swcOptions + ).extractComments = normalizedExtractComments.extractComments; + } + if (swcOptions.compress) { // More optimizations if (typeof swcOptions.compress.ecma === "undefined") { @@ -621,7 +791,9 @@ async function swcMinify(input, sourceMap, minimizerOptions) { } const [[filename, code]] = Object.entries(input); - const result = await swc.minify(code, swcOptions); + const result = /** @type {SwcMinifyOutput} */ ( + await swc.minify(code, swcOptions) + ); let map; @@ -637,6 +809,7 @@ async function swcMinify(input, sourceMap, minimizerOptions) { return { code: result.code, map, + extractedComments: result.extractedComments || [], }; } diff --git a/test/__snapshots__/minify-option.test.js.snap b/test/__snapshots__/minify-option.test.js.snap index a145112..4e0c355 100644 --- a/test/__snapshots__/minify-option.test.js.snap +++ b/test/__snapshots__/minify-option.test.js.snap @@ -15,6 +15,24 @@ Array [ ] `; +exports[`minify option should report an error when the \`extractComments\` option for \`swcMinify\` uses a function condition: assets 1`] = ` +Object { + "203.203.js": "Error: ENOENT: no such file or directory, open '/Users/kdy1/.codex/worktrees/72b5/terser-webpack-plugin/test/helpers/dist/203.203.js'", + "main.js": "Error: ENOENT: no such file or directory, open '/Users/kdy1/.codex/worktrees/72b5/terser-webpack-plugin/test/helpers/dist/main.js'", +} +`; + +exports[`minify option should report an error when the \`extractComments\` option for \`swcMinify\` uses a function condition: errors 1`] = ` +Array [ + "Error: 203.203.js from Terser plugin +The 'extractComments' option for 'swcMinify' only supports booleans, \\"some\\", \\"all\\", string patterns, RegExp values without flags, or object conditions that resolve to those forms. Received: function.", + "Error: main.js from Terser plugin +The 'extractComments' option for 'swcMinify' only supports booleans, \\"some\\", \\"all\\", string patterns, RegExp values without flags, or object conditions that resolve to those forms. Received: function.", +] +`; + +exports[`minify option should report an error when the \`extractComments\` option for \`swcMinify\` uses a function condition: warnings 1`] = `Array []`; + exports[`minify option should snapshot with extracting comments: assets 1`] = ` Object { "main.js": "/*! For license information please see main.js.LICENSE.txt */ @@ -189,7 +207,10 @@ exports[`minify option should work using when the \`minify\` option is \`swcMini exports[`minify option should work using when the \`minify\` option is \`swcMinify\` and allows to set \`swc\` options: assets 1`] = ` Object { - "main.js": "(()=>{var __webpack_modules__={921(module){module.exports=function(){console.log(7)}}},__webpack_module_cache__={};!function __webpack_require__(moduleId){var cachedModule=__webpack_module_cache__[moduleId];if(void 0!==cachedModule)return cachedModule.exports;var module=__webpack_module_cache__[moduleId]={exports:{}};return __webpack_modules__[moduleId](module,module.exports,__webpack_require__),module.exports}(921)})();", + "main.js": "/*! For license information please see main.js.LICENSE.txt */ +(()=>{var __webpack_modules__={921(module){module.exports=function(){console.log(7)}}},__webpack_module_cache__={};!function __webpack_require__(moduleId){var cachedModule=__webpack_module_cache__[moduleId];if(void 0!==cachedModule)return cachedModule.exports;var module=__webpack_module_cache__[moduleId]={exports:{}};return __webpack_modules__[moduleId](module,module.exports,__webpack_require__),module.exports}(921)})();", + "main.js.LICENSE.txt": "/* @preserve*/ +", } `; @@ -197,11 +218,221 @@ exports[`minify option should work using when the \`minify\` option is \`swcMini exports[`minify option should work using when the \`minify\` option is \`swcMinify\` and allows to set \`swc\` options: warnings 1`] = `Array []`; +exports[`minify option should work using when the \`minify\` option is \`swcMinify\` and extract comments by default: assets 1`] = ` +Object { + "203.203.js": "/*! For license information please see 203.203.js.LICENSE.txt */ +(self.webpackChunkterser_webpack_plugin=self.webpackChunkterser_webpack_plugin||[]).push([[203],{203(e){e.exports=Math.random()}}]);", + "203.203.js.LICENSE.txt": "/*! Legal Comment */ + +/** @license Copyright 2112 Moon. **/ +", + "main.js": "/*! For license information please see main.js.LICENSE.txt */ +(()=>{var e,t,r,o={855(e,t,r){r.e(203).then(r.t.bind(r,203,23)),e.exports=Math.random()}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,a),r.exports}a.m=o,c=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(e,t){if(1&t&&(e=this(e)),8&t||\\"object\\"==typeof e&&e&&(4&t&&e.__esModule||16&t&&\\"function\\"==typeof e.then))return e;var r=Object.create(null);a.r(r);var o={};i=i||[null,c({}),c([]),c(c)];for(var n=2&t&&e;(\\"object\\"==typeof n||\\"function\\"==typeof n)&&!~i.indexOf(n);n=c(n))Object.getOwnPropertyNames(n).forEach(t=>o[t]=()=>e[t]);return o.default=()=>e,a.d(r,o),r},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce((t,r)=>(a.f[r](e,t),t),[])),a.u=e=>\\"\\"+e+\\".\\"+e+\\".js\\",a.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u={},a.l=(e,t,r,o)=>{if(u[e])return void u[e].push(t);if(void 0!==r)for(var n,i,c=document.getElementsByTagName(\\"script\\"),p=0;p{n.onerror=n.onload=null,clearTimeout(f);var o=u[e];if(delete u[e],n.parentNode&&n.parentNode.removeChild(n),o&&o.forEach(e=>e(r)),t)return t(r)},f=setTimeout(s.bind(null,void 0,{type:\\"timeout\\",target:n}),12e4);n.onerror=s.bind(null,n.onerror),n.onload=s.bind(null,n.onload),i&&document.head.appendChild(n)},a.r=e=>{\\"u\\">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},a.g.importScripts&&(p=a.g.location+\\"\\");var i,c,u,p,l=a.g.document;if(!p&&l&&(l.currentScript&&\\"SCRIPT\\"===l.currentScript.tagName.toUpperCase()&&(p=l.currentScript.src),!p)){var s=l.getElementsByTagName(\\"script\\");if(s.length)for(var f=s.length-1;f>-1&&(!p||!/^http(s?):/.test(p));)p=s[f--].src}if(!p)throw Error(\\"Automatic publicPath is not supported in this browser\\");a.p=p=p.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),e={792:0},a.f.j=(t,r)=>{var o=a.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=e[t]=[r,n]);r.push(o[2]=n);var i=a.p+a.u(t),c=Error();a.l(i,r=>{if(a.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&(\\"load\\"===r.type?\\"missing\\":r.type),i=r&&r.target&&r.target.src;c.message=\\"Loading chunk \\"+t+\` failed. +(\`+n+\\": \\"+i+\\")\\",c.name=\\"ChunkLoadError\\",c.type=n,c.request=i,o[1](c)}},\\"chunk-\\"+t,t)}},t=(t,r)=>{var o,n,[i,c,u]=r,p=0;if(i.some(t=>0!==e[t])){for(o in c)a.o(c,o)&&(a.m[o]=c[o]);u&&u(a)}for(t&&t(r);p{var e,t,r,o={855(e,t,r){r.e(203).then(r.t.bind(r,203,23)),e.exports=Math.random()}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,a),r.exports}a.m=o,c=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(e,t){if(1&t&&(e=this(e)),8&t||\\"object\\"==typeof e&&e&&(4&t&&e.__esModule||16&t&&\\"function\\"==typeof e.then))return e;var r=Object.create(null);a.r(r);var o={};i=i||[null,c({}),c([]),c(c)];for(var n=2&t&&e;(\\"object\\"==typeof n||\\"function\\"==typeof n)&&!~i.indexOf(n);n=c(n))Object.getOwnPropertyNames(n).forEach(t=>o[t]=()=>e[t]);return o.default=()=>e,a.d(r,o),r},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce((t,r)=>(a.f[r](e,t),t),[])),a.u=e=>\\"\\"+e+\\".\\"+e+\\".js\\",a.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u={},a.l=(e,t,r,o)=>{if(u[e])return void u[e].push(t);if(void 0!==r)for(var n,i,c=document.getElementsByTagName(\\"script\\"),p=0;p{n.onerror=n.onload=null,clearTimeout(f);var o=u[e];if(delete u[e],n.parentNode&&n.parentNode.removeChild(n),o&&o.forEach(e=>e(r)),t)return t(r)},f=setTimeout(s.bind(null,void 0,{type:\\"timeout\\",target:n}),12e4);n.onerror=s.bind(null,n.onerror),n.onload=s.bind(null,n.onload),i&&document.head.appendChild(n)},a.r=e=>{\\"u\\">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},a.g.importScripts&&(p=a.g.location+\\"\\");var i,c,u,p,l=a.g.document;if(!p&&l&&(l.currentScript&&\\"SCRIPT\\"===l.currentScript.tagName.toUpperCase()&&(p=l.currentScript.src),!p)){var s=l.getElementsByTagName(\\"script\\");if(s.length)for(var f=s.length-1;f>-1&&(!p||!/^http(s?):/.test(p));)p=s[f--].src}if(!p)throw Error(\\"Automatic publicPath is not supported in this browser\\");a.p=p=p.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),e={792:0},a.f.j=(t,r)=>{var o=a.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=e[t]=[r,n]);r.push(o[2]=n);var i=a.p+a.u(t),c=Error();a.l(i,r=>{if(a.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&(\\"load\\"===r.type?\\"missing\\":r.type),i=r&&r.target&&r.target.src;c.message=\\"Loading chunk \\"+t+\` failed. +(\`+n+\\": \\"+i+\\")\\",c.name=\\"ChunkLoadError\\",c.type=n,c.request=i,o[1](c)}},\\"chunk-\\"+t,t)}},t=(t,r)=>{var o,n,[i,c,u]=r,p=0;if(i.some(t=>0!==e[t])){for(o in c)a.o(c,o)&&(a.m[o]=c[o]);u&&u(a)}for(t&&t(r);p{var r={921(r){r.exports=function(){console.log(7)}}},o={};!function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports}(921)})(); + "main.js": "/*! For license information please see main.js.LICENSE.txt */ +(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};!function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports}(921)})(); //# sourceMappingURL=main.js.map", - "main.js.map": "{\\"version\\":3,\\"file\\":\\"main.js\\",\\"mappings\\":\\"oBAKAA,EAAOC,OAAO,CAAG,WAEfC,QAAQC,GAAG,CAACC,EACd,C,GCPIC,EAA2B,CAAC,GCENC,SDCjBA,EAAoBC,CAAQ,EAEpC,IAAIC,EAAeH,CAAwB,CAACE,EAAS,CACrD,GAAIC,KAAiBC,IAAjBD,EACH,OAAOA,EAAaP,OAAO,CAG5B,IAAID,EAASK,CAAwB,CAACE,EAAS,CAAG,CAGjDN,QAAS,CAAC,CACX,EAMA,OAHAS,CAAmB,CAACH,EAAS,CAACP,EAAQA,EAAOC,OAAO,CAAEK,GAG/CN,EAAOC,OAAO,EClBwB,I\\",\\"sources\\":[\\"webpack://terser-webpack-plugin/./test/fixtures/entry.js\\",\\"webpack://terser-webpack-plugin/webpack/bootstrap\\",\\"webpack://terser-webpack-plugin/webpack/startup\\"],\\"sourcesContent\\":[\\"// foo\\\\n/* @preserve*/\\\\n// bar\\\\nconst a = 2 + 2;\\\\n\\\\nmodule.exports = function Foo() {\\\\n const b = 2 + 2;\\\\n console.log(b + 1 + 2);\\\\n};\\\\n\\",\\"// The module cache\\\\nvar __webpack_module_cache__ = {};\\\\n\\\\n// The require function\\\\nfunction __webpack_require__(moduleId) {\\\\n\\\\t// Check if module is in cache\\\\n\\\\tvar cachedModule = __webpack_module_cache__[moduleId];\\\\n\\\\tif (cachedModule !== undefined) {\\\\n\\\\t\\\\treturn cachedModule.exports;\\\\n\\\\t}\\\\n\\\\t// Create a new module (and put it into the cache)\\\\n\\\\tvar module = __webpack_module_cache__[moduleId] = {\\\\n\\\\t\\\\t// no module.id needed\\\\n\\\\t\\\\t// no module.loaded needed\\\\n\\\\t\\\\texports: {}\\\\n\\\\t};\\\\n\\\\n\\\\t// Execute the module function\\\\n\\\\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\\\\n\\\\n\\\\t// Return the exports of the module\\\\n\\\\treturn module.exports;\\\\n}\\\\n\\\\n\\",\\"// startup\\\\n// Load entry module and return exports\\\\n// This entry module is referenced by other modules so it can't be inlined\\\\nvar __webpack_exports__ = __webpack_require__(921);\\\\n\\"],\\"names\\":[\\"module\\",\\"exports\\",\\"console\\",\\"log\\",\\"b\\",\\"__webpack_module_cache__\\",\\"__webpack_require__\\",\\"moduleId\\",\\"cachedModule\\",\\"undefined\\",\\"__webpack_modules__\\"],\\"sourceRoot\\":\\"\\"}", + "main.js.LICENSE.txt": "/* @preserve*/ +", + "main.js.map": "{\\"version\\":3,\\"file\\":\\"main.js\\",\\"mappings\\":\\";oBAKAA,EAAOC,OAAO,CAAG,WAEfC,QAAQC,GAAG,CAACC,EACd,C,GCPIC,EAA2B,CAAC,GCENC,SDCjBA,EAAoBC,CAAQ,EAEpC,IAAIC,EAAeH,CAAwB,CAACE,EAAS,CACrD,GAAIC,KAAiBC,IAAjBD,EACH,OAAOA,EAAaP,OAAO,CAG5B,IAAID,EAASK,CAAwB,CAACE,EAAS,CAAG,CAGjDN,QAAS,CAAC,CACX,EAMA,OAHAS,CAAmB,CAACH,EAAS,CAACP,EAAQA,EAAOC,OAAO,CAAEK,GAG/CN,EAAOC,OAAO,EClBwB,I\\",\\"sources\\":[\\"webpack://terser-webpack-plugin/./test/fixtures/entry.js\\",\\"webpack://terser-webpack-plugin/webpack/bootstrap\\",\\"webpack://terser-webpack-plugin/webpack/startup\\"],\\"sourcesContent\\":[\\"// foo\\\\n/* @preserve*/\\\\n// bar\\\\nconst a = 2 + 2;\\\\n\\\\nmodule.exports = function Foo() {\\\\n const b = 2 + 2;\\\\n console.log(b + 1 + 2);\\\\n};\\\\n\\",\\"// The module cache\\\\nvar __webpack_module_cache__ = {};\\\\n\\\\n// The require function\\\\nfunction __webpack_require__(moduleId) {\\\\n\\\\t// Check if module is in cache\\\\n\\\\tvar cachedModule = __webpack_module_cache__[moduleId];\\\\n\\\\tif (cachedModule !== undefined) {\\\\n\\\\t\\\\treturn cachedModule.exports;\\\\n\\\\t}\\\\n\\\\t// Create a new module (and put it into the cache)\\\\n\\\\tvar module = __webpack_module_cache__[moduleId] = {\\\\n\\\\t\\\\t// no module.id needed\\\\n\\\\t\\\\t// no module.loaded needed\\\\n\\\\t\\\\texports: {}\\\\n\\\\t};\\\\n\\\\n\\\\t// Execute the module function\\\\n\\\\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\\\\n\\\\n\\\\t// Return the exports of the module\\\\n\\\\treturn module.exports;\\\\n}\\\\n\\\\n\\",\\"// startup\\\\n// Load entry module and return exports\\\\n// This entry module is referenced by other modules so it can't be inlined\\\\nvar __webpack_exports__ = __webpack_require__(921);\\\\n\\"],\\"names\\":[\\"module\\",\\"exports\\",\\"console\\",\\"log\\",\\"b\\",\\"__webpack_module_cache__\\",\\"__webpack_require__\\",\\"moduleId\\",\\"cachedModule\\",\\"undefined\\",\\"__webpack_modules__\\"],\\"sourceRoot\\":\\"\\"}", } `; @@ -209,6 +440,27 @@ exports[`minify option should work using when the \`minify\` option is \`swcMini exports[`minify option should work using when the \`minify\` option is \`swcMinify\` and generate source maps: warnings 1`] = `Array []`; +exports[`minify option should work using when the \`minify\` option is \`swcMinify\` and keep legal comments when extract comments is disabled: assets 1`] = ` +Object { + "203.203.js": "(self.webpackChunkterser_webpack_plugin=self.webpackChunkterser_webpack_plugin||[]).push([[203],{203(e){/*! Legal Comment *//** @license Copyright 2112 Moon. **/e.exports=Math.random()}}]);", + "main.js": "(()=>{var e,t,r,o={855(e,t,r){r.e(203).then(r.t.bind(r,203,23)),/*! Legal Comment *//** + * @preserve Copyright 2009 SomeThirdParty. + * Here is the full license text and copyright + * notice for this file. Note that the notice can span several + * lines and is only terminated by the closing star and slash: + *//** + * Utility functions for the foo package. + * @license Apache-2.0 + *//*! Legal Foo */// @lic +e.exports=Math.random()}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,a),r.exports}a.m=o,c=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(e,t){if(1&t&&(e=this(e)),8&t||\\"object\\"==typeof e&&e&&(4&t&&e.__esModule||16&t&&\\"function\\"==typeof e.then))return e;var r=Object.create(null);a.r(r);var o={};i=i||[null,c({}),c([]),c(c)];for(var n=2&t&&e;(\\"object\\"==typeof n||\\"function\\"==typeof n)&&!~i.indexOf(n);n=c(n))Object.getOwnPropertyNames(n).forEach(t=>o[t]=()=>e[t]);return o.default=()=>e,a.d(r,o),r},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce((t,r)=>(a.f[r](e,t),t),[])),a.u=e=>\\"\\"+e+\\".\\"+e+\\".js\\",a.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u={},a.l=(e,t,r,o)=>{if(u[e])return void u[e].push(t);if(void 0!==r)for(var n,i,c=document.getElementsByTagName(\\"script\\"),p=0;p{n.onerror=n.onload=null,clearTimeout(f);var o=u[e];if(delete u[e],n.parentNode&&n.parentNode.removeChild(n),o&&o.forEach(e=>e(r)),t)return t(r)},f=setTimeout(s.bind(null,void 0,{type:\\"timeout\\",target:n}),12e4);n.onerror=s.bind(null,n.onerror),n.onload=s.bind(null,n.onload),i&&document.head.appendChild(n)},a.r=e=>{\\"u\\">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},a.g.importScripts&&(p=a.g.location+\\"\\");var i,c,u,p,l=a.g.document;if(!p&&l&&(l.currentScript&&\\"SCRIPT\\"===l.currentScript.tagName.toUpperCase()&&(p=l.currentScript.src),!p)){var s=l.getElementsByTagName(\\"script\\");if(s.length)for(var f=s.length-1;f>-1&&(!p||!/^http(s?):/.test(p));)p=s[f--].src}if(!p)throw Error(\\"Automatic publicPath is not supported in this browser\\");a.p=p=p.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),e={792:0},a.f.j=(t,r)=>{var o=a.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=e[t]=[r,n]);r.push(o[2]=n);var i=a.p+a.u(t),c=Error();a.l(i,r=>{if(a.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&(\\"load\\"===r.type?\\"missing\\":r.type),i=r&&r.target&&r.target.src;c.message=\\"Loading chunk \\"+t+\` failed. +(\`+n+\\": \\"+i+\\")\\",c.name=\\"ChunkLoadError\\",c.type=n,c.request=i,o[1](c)}},\\"chunk-\\"+t,t)}},t=(t,r)=>{var o,n,[i,c,u]=r,p=0;if(i.some(t=>0!==e[t])){for(o in c)a.o(c,o)&&(a.m[o]=c[o]);u&&u(a)}for(t&&t(r);p{var r={921(r){r.exports=function(){console.log(7)}}},o={};!function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports}(921)})();", + "main.js": "/*! For license information please see main.js.LICENSE.txt */ +(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};!function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports}(921)})();", + "main.js.LICENSE.txt": "/* @preserve*/ +", } `; diff --git a/test/minify-option.test.js b/test/minify-option.test.js index de56150..62687d9 100644 --- a/test/minify-option.test.js +++ b/test/minify-option.test.js @@ -692,9 +692,7 @@ describe("minify option", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); }); - // TODO fix it after `swc` do the new release with support extract comments - // eslint-disable-next-line jest/no-disabled-tests - it.skip("should work using when the `minify` option is `swcMinify` and extract comments by default", async () => { + it("should work using when the `minify` option is `swcMinify` and extract comments by default", async () => { const compiler = getCompiler({ entry: path.resolve(__dirname, "./fixtures/comments.js"), }); @@ -710,9 +708,28 @@ describe("minify option", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); }); - // TODO fix it after `swc` do the new release with support extract comments - // eslint-disable-next-line jest/no-disabled-tests - it.skip("should work using when the `minify` option is `swcMinify` and keep legal comments when extract comments is disabled", async () => { + it("should work using when the `minify` option is `swcMinify` and extract comments using object options", async () => { + const compiler = getCompiler({ + entry: path.resolve(__dirname, "./fixtures/comments.js"), + }); + + new TerserPlugin({ + minify: TerserPlugin.swcMinify, + extractComments: { + condition: "all", + filename: "licenses.txt", + banner: "For license information please see licenses.txt", + }, + }).apply(compiler); + + const stats = await compile(compiler); + + expect(readsAssets(compiler, stats)).toMatchSnapshot("assets"); + expect(getErrors(stats)).toMatchSnapshot("errors"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + }); + + it("should work using when the `minify` option is `swcMinify` and keep legal comments when extract comments is disabled", async () => { const compiler = getCompiler({ entry: path.resolve(__dirname, "./fixtures/comments.js"), }); @@ -729,6 +746,27 @@ describe("minify option", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); }); + it("should report an error when the `extractComments` option for `swcMinify` uses a function condition", async () => { + const compiler = getCompiler({ + entry: path.resolve(__dirname, "./fixtures/comments.js"), + bail: false, + }); + + new TerserPlugin({ + minify: TerserPlugin.swcMinify, + parallel: false, + extractComments: { + condition: () => true, + }, + }).apply(compiler); + + const stats = await compile(compiler); + + expect(readsAssets(compiler, stats)).toMatchSnapshot("assets"); + expect(getErrors(stats)).toMatchSnapshot("errors"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + }); + it("should work using when the `minify` option is `esbuildMinify`", async () => { const compiler = getCompiler(); diff --git a/types/utils.d.ts b/types/utils.d.ts index 056bd38..98a22e8 100644 --- a/types/utils.d.ts +++ b/types/utils.d.ts @@ -10,6 +10,20 @@ export type Input = import("./index.js").Input; export type MinimizedResult = import("./index.js").MinimizedResult; export type CustomOptions = import("./index.js").CustomOptions; export type RawSourceMap = import("./index.js").RawSourceMap; +export type SwcMinifyOptionsWithExtractComments = + import("@swc/core").JsMinifyOptions & { + extractComments?: + | false + | true + | "some" + | "all" + | { + regex: string; + }; + }; +export type SwcMinifyOutput = import("@swc/core").Output & { + extractedComments?: string[]; +}; export type PredefinedOptions = import("./index.js").PredefinedOptions; export type ExtractedComments = string[]; /** @@ -63,12 +77,14 @@ export function memoize(fn: FunctionReturning): FunctionReturning; * @param {Input} input input * @param {RawSourceMap=} sourceMap source map * @param {CustomOptions=} minimizerOptions options + * @param {ExtractCommentsOptions=} extractComments extract comments option * @returns {Promise} minimized result */ export function swcMinify( input: Input, sourceMap?: RawSourceMap | undefined, minimizerOptions?: CustomOptions | undefined, + extractComments?: ExtractCommentsOptions | undefined, ): Promise; export namespace swcMinify { /** From b3939e4ca17383312dd03528dd76fadae843fcfc Mon Sep 17 00:00:00 2001 From: DongYun Kang Date: Sun, 19 Apr 2026 22:35:55 +0900 Subject: [PATCH 2/5] chore: require @swc/core 1.15.30 for swcMinify --- README.md | 2 +- package-lock.json | 173 +++++++++++++++++++++++++++------------------- package.json | 2 +- src/utils.js | 71 +++++++++---------- 4 files changed, 140 insertions(+), 108 deletions(-) diff --git a/README.md b/README.md index 444e7ce..b8267fb 100644 --- a/README.md +++ b/README.md @@ -762,7 +762,7 @@ module.exports = { > **Warning** > -> `extractComments` is supported when `@swc/core` provides the `extractComments` minify option. +> `extractComments` is supported with `@swc/core >= 1.15.30`. > Only serializable extract conditions are supported: booleans, `"some"`, `"all"`, string patterns, `RegExp` values without flags, or object conditions that resolve to those forms. > Function conditions and flagged regular expressions are not supported. diff --git a/package-lock.json b/package-lock.json index 0972255..97d8947 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "@babel/preset-env": "^7.24.7", "@commitlint/cli": "^17.7.1", "@commitlint/config-conventional": "^17.7.0", - "@swc/core": "^1.3.102", + "@swc/core": "^1.15.30", "@types/node": "^24.2.1", "@types/serialize-javascript": "^5.0.2", "@types/uglify-js": "^3.17.5", @@ -131,7 +131,6 @@ "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", @@ -3953,16 +3952,15 @@ } }, "node_modules/@swc/core": { - "version": "1.15.18", - "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.15.18.tgz", - "integrity": "sha512-z87aF9GphWp//fnkRsqvtY+inMVPgYW3zSlXH1kJFvRT5H/wiAn+G32qW5l3oEk63KSF1x3Ov0BfHCObAmT8RA==", + "version": "1.15.30", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.15.30.tgz", + "integrity": "sha512-R8VQbQY1BZcbIF2p3gjlTCwAQzx1A194ugWfwld5y+WgVVWqVKm7eURGGOVbQVubgKWzidP2agomBbg96rZilQ==", "dev": true, "hasInstallScript": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@swc/counter": "^0.1.3", - "@swc/types": "^0.1.25" + "@swc/types": "^0.1.26" }, "engines": { "node": ">=10" @@ -3972,16 +3970,18 @@ "url": "https://opencollective.com/swc" }, "optionalDependencies": { - "@swc/core-darwin-arm64": "1.15.18", - "@swc/core-darwin-x64": "1.15.18", - "@swc/core-linux-arm-gnueabihf": "1.15.18", - "@swc/core-linux-arm64-gnu": "1.15.18", - "@swc/core-linux-arm64-musl": "1.15.18", - "@swc/core-linux-x64-gnu": "1.15.18", - "@swc/core-linux-x64-musl": "1.15.18", - "@swc/core-win32-arm64-msvc": "1.15.18", - "@swc/core-win32-ia32-msvc": "1.15.18", - "@swc/core-win32-x64-msvc": "1.15.18" + "@swc/core-darwin-arm64": "1.15.30", + "@swc/core-darwin-x64": "1.15.30", + "@swc/core-linux-arm-gnueabihf": "1.15.30", + "@swc/core-linux-arm64-gnu": "1.15.30", + "@swc/core-linux-arm64-musl": "1.15.30", + "@swc/core-linux-ppc64-gnu": "1.15.30", + "@swc/core-linux-s390x-gnu": "1.15.30", + "@swc/core-linux-x64-gnu": "1.15.30", + "@swc/core-linux-x64-musl": "1.15.30", + "@swc/core-win32-arm64-msvc": "1.15.30", + "@swc/core-win32-ia32-msvc": "1.15.30", + "@swc/core-win32-x64-msvc": "1.15.30" }, "peerDependencies": { "@swc/helpers": ">=0.5.17" @@ -3993,9 +3993,9 @@ } }, "node_modules/@swc/core-darwin-arm64": { - "version": "1.15.18", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.15.18.tgz", - "integrity": "sha512-+mIv7uBuSaywN3C9LNuWaX1jJJ3SKfiJuE6Lr3bd+/1Iv8oMU7oLBjYMluX1UrEPzwN2qCdY6Io0yVicABoCwQ==", + "version": "1.15.30", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.15.30.tgz", + "integrity": "sha512-VvpP+vq08HmGYewMWvrdsxh9s2lthz/808zXm8Yu5kaqeR8Yia2b0eYXleHQ3VAjoStUDk6LzTheBW9KXYQdMA==", "cpu": [ "arm64" ], @@ -4010,9 +4010,9 @@ } }, "node_modules/@swc/core-darwin-x64": { - "version": "1.15.18", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.15.18.tgz", - "integrity": "sha512-wZle0eaQhnzxWX5V/2kEOI6Z9vl/lTFEC6V4EWcn+5pDjhemCpQv9e/TDJ0GIoiClX8EDWRvuZwh+Z3dhL1NAg==", + "version": "1.15.30", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.15.30.tgz", + "integrity": "sha512-WiJA0hiZI3nwQAO6mu5RqigtWGDtth4Hiq6rbZxAaQyhIcqKIg5IoMRc1Y071lrNJn29eEDMC86Rq58xgUxlDg==", "cpu": [ "x64" ], @@ -4027,9 +4027,9 @@ } }, "node_modules/@swc/core-linux-arm-gnueabihf": { - "version": "1.15.18", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.15.18.tgz", - "integrity": "sha512-ao61HGXVqrJFHAcPtF4/DegmwEkVCo4HApnotLU8ognfmU8x589z7+tcf3hU+qBiU1WOXV5fQX6W9Nzs6hjxDw==", + "version": "1.15.30", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.15.30.tgz", + "integrity": "sha512-YANuFUo48kIT6plJgCD0keae9HFXfjxsbvsgevqc0hr/07X/p7sAWTFOGYEc2SXcASaK7UvuQqzlbW8pr7R79g==", "cpu": [ "arm" ], @@ -4044,13 +4044,16 @@ } }, "node_modules/@swc/core-linux-arm64-gnu": { - "version": "1.15.18", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.15.18.tgz", - "integrity": "sha512-3xnctOBLIq3kj8PxOCgPrGjBLP/kNOddr6f5gukYt/1IZxsITQaU9TDyjeX6jG+FiCIHjCuWuffsyQDL5Ew1bg==", + "version": "1.15.30", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.15.30.tgz", + "integrity": "sha512-VndG8jaR4ugY6u+iVOT0Q+d2fZd7sLgjPgN8W/Le+3EbZKl+cRfFxV7Eoz4gfLqhmneZPdcIzf9T3LkgkmqNLg==", "cpu": [ "arm64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -4061,13 +4064,56 @@ } }, "node_modules/@swc/core-linux-arm64-musl": { - "version": "1.15.18", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.15.18.tgz", - "integrity": "sha512-0a+Lix+FSSHBSBOA0XznCcHo5/1nA6oLLjcnocvzXeqtdjnPb+SvchItHI+lfeiuj1sClYPDvPMLSLyXFaiIKw==", + "version": "1.15.30", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.15.30.tgz", + "integrity": "sha512-1SYGs2l0Yyyi0pR/P/NKz/x0kqxkoiw+BXeJjLUdecSk/KasncWlJrc6hOvFSgKHOBrzgM5jwuluKtlT8dnrcA==", "cpu": [ "arm64" ], "dev": true, + "libc": [ + "musl" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-ppc64-gnu": { + "version": "1.15.30", + "resolved": "https://registry.npmjs.org/@swc/core-linux-ppc64-gnu/-/core-linux-ppc64-gnu-1.15.30.tgz", + "integrity": "sha512-TXREtiXeRhbfDFbmhnkIsXpKfzbfT73YkV2ZF6w0sfxgjC5zI2ZAbaCOq25qxvegofj2K93DtOpm9RLaBgqR2g==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-s390x-gnu": { + "version": "1.15.30", + "resolved": "https://registry.npmjs.org/@swc/core-linux-s390x-gnu/-/core-linux-s390x-gnu-1.15.30.tgz", + "integrity": "sha512-DCR2YYeyd6DQE4OuDhImouuNcjXEiEdnn1Y0DyGteugPEDvVuvYk8Xddi+4o2SgWH6jiW8/I+3emZvbep1NC+g==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -4078,13 +4124,16 @@ } }, "node_modules/@swc/core-linux-x64-gnu": { - "version": "1.15.18", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.15.18.tgz", - "integrity": "sha512-wG9J8vReUlpaHz4KOD/5UE1AUgirimU4UFT9oZmupUDEofxJKYb1mTA/DrMj0s78bkBiNI+7Fo2EgPuvOJfuAA==", + "version": "1.15.30", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.15.30.tgz", + "integrity": "sha512-5Pizw3NgfOJ5BJOBK8TIRa59xFW2avESTOBDPTAYwZYa1JNDs+KMF9lUfjJiJLM5HiMs/wPheA9eiT0q9m2AoA==", "cpu": [ "x64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -4095,13 +4144,16 @@ } }, "node_modules/@swc/core-linux-x64-musl": { - "version": "1.15.18", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.15.18.tgz", - "integrity": "sha512-4nwbVvCphKzicwNWRmvD5iBaZj8JYsRGa4xOxJmOyHlMDpsvvJ2OR2cODlvWyGFH6BYL1MfIAK3qph3hp0Az6g==", + "version": "1.15.30", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.15.30.tgz", + "integrity": "sha512-qyqydP/wyH8alcIP4a2hnGSjHLJjm9H7yDFup+CPy9oTahFgLLwnNcv5UHXqO2Qs3AIND+cls5f/Bb6hqpxdgA==", "cpu": [ "x64" ], "dev": true, + "libc": [ + "musl" + ], "license": "Apache-2.0 AND MIT", "optional": true, "os": [ @@ -4112,9 +4164,9 @@ } }, "node_modules/@swc/core-win32-arm64-msvc": { - "version": "1.15.18", - "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.15.18.tgz", - "integrity": "sha512-zk0RYO+LjiBCat2RTMHzAWaMky0cra9loH4oRrLKLLNuL+jarxKLFDA8xTZWEkCPLjUTwlRN7d28eDLLMgtUcQ==", + "version": "1.15.30", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.15.30.tgz", + "integrity": "sha512-CaQENgDHVGOg1mSF5sQVgvfFHG9kjMor2rkLMLeLOkfZYNj13ppnJ9+lfaBZLZUMMbnlGQnavCJb8PVBUOso7Q==", "cpu": [ "arm64" ], @@ -4129,9 +4181,9 @@ } }, "node_modules/@swc/core-win32-ia32-msvc": { - "version": "1.15.18", - "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.15.18.tgz", - "integrity": "sha512-yVuTrZ0RccD5+PEkpcLOBAuPbYBXS6rslENvIXfvJGXSdX5QGi1ehC4BjAMl5FkKLiam4kJECUI0l7Hq7T1vwg==", + "version": "1.15.30", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.15.30.tgz", + "integrity": "sha512-30VdLeGk6fugiUs/kUdJ/pAg7z/zpvVbR11RH60jZ0Z42WIeIniYx0rLEWN7h/pKJ3CopqsQ3RsogCAkRKiA2g==", "cpu": [ "ia32" ], @@ -4146,9 +4198,9 @@ } }, "node_modules/@swc/core-win32-x64-msvc": { - "version": "1.15.18", - "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.15.18.tgz", - "integrity": "sha512-7NRmE4hmUQNCbYU3Hn9Tz57mK9Qq4c97ZS+YlamlK6qG9Fb5g/BB3gPDe0iLlJkns/sYv2VWSkm8c3NmbEGjbg==", + "version": "1.15.30", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.15.30.tgz", + "integrity": "sha512-4iObHPR+Q4oDY110EF5SF5eIaaVJNpMdG9C0q3Q92BsJ5y467uHz7sYQhP60WYlLFsLQ1el2YrIPUItUAQGOKg==", "cpu": [ "x64" ], @@ -4170,9 +4222,9 @@ "license": "Apache-2.0" }, "node_modules/@swc/types": { - "version": "0.1.25", - "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.25.tgz", - "integrity": "sha512-iAoY/qRhNH8a/hBvm3zKj9qQ4oc2+3w1unPJa2XvTK3XjeLXtzcCingVPw/9e5mn1+0yPqxcBGp9Jf0pkfMb1g==", + "version": "0.1.26", + "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.26.tgz", + "integrity": "sha512-lyMwd7WGgG79RS7EERZV3T8wMdmPq3xwyg+1nmAM64kIhx5yl+juO2PYIHb7vTiPgPCj8LYjsNV2T5wiQHUEaw==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -4278,7 +4330,6 @@ "integrity": "sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/estree": "*", "@types/json-schema": "*" @@ -4399,7 +4450,6 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-24.11.0.tgz", "integrity": "sha512-fPxQqz4VTgPI/IQ+lj9r0h+fDR66bzoeMGHp8ASee+32OSGIkeASsoZuJixsQoVef1QJbeubcPBxKk22QVoWdw==", "license": "MIT", - "peer": true, "dependencies": { "undici-types": "~7.16.0" } @@ -4472,7 +4522,6 @@ "integrity": "sha512-Jz9ZztpB37dNC+HU2HI28Bs9QXpzCz+y/twHOwhyrIRdbuVDxSytJNDl6z/aAKlaRIwC7y8wJdkBv7FxYGgi0A==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/regexpp": "^4.12.2", "@typescript-eslint/scope-manager": "8.56.1", @@ -4512,7 +4561,6 @@ "integrity": "sha512-klQbnPAAiGYFyI02+znpBRLyjL4/BrBd0nyWkdC0s/6xFLkXYQ8OoRrSkqacS1ddVxf/LDyODIKbQ5TgKAf/Fg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.56.1", "@typescript-eslint/types": "8.56.1", @@ -4990,7 +5038,6 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz", "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -5104,7 +5151,6 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz", "integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==", "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -5699,7 +5745,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -6750,7 +6795,6 @@ "integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -6848,7 +6892,6 @@ "integrity": "sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "import-fresh": "^3.3.0", "js-yaml": "^4.1.0", @@ -8184,7 +8227,6 @@ "integrity": "sha512-VmQ+sifHUbI/IcSopBCF/HO3YiHQx/AVd3UVyYL6weuwW+HvON9VYn5l6Zl1WZzPWXPNZrSQpxwkkZ/VuvJZzg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -8274,7 +8316,6 @@ "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", "dev": true, "license": "MIT", - "peer": true, "bin": { "eslint-config-prettier": "bin/cli.js" }, @@ -9207,7 +9248,6 @@ "integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -11122,7 +11162,6 @@ "integrity": "sha512-Yn0mADZB89zTtjkPJEXwrac3LHudkQMR+Paqa8uxJHCBr9agxztUifWCyiYrjhMPBoUVBjyny0I7XH6ozDr7QQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/core": "^27.5.1", "import-local": "^3.0.2", @@ -14778,7 +14817,6 @@ "integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -16912,7 +16950,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -17061,7 +17098,6 @@ "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -17286,7 +17322,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -17681,7 +17716,6 @@ "integrity": "sha512-LLBBA4oLmT7sZdHiYE/PeVuifOxYyE2uL/V+9VQP7YSYdJU7bSf7H8bZRRxW8kEPMkmVjnrXmoR3oejIdX0xbg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/eslint-scope": "^3.7.7", "@types/estree": "^1.0.8", @@ -17731,7 +17765,6 @@ "integrity": "sha512-NLhDfH/h4O6UOy+0LSso42xvYypClINuMNBVVzX4vX98TmTaTUxwRbXdhucbFMd2qLaCTcLq/PdYrvi8onw90w==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@discoveryjs/json-ext": "^0.5.0", "@webpack-cli/configtest": "^1.2.0", @@ -18022,7 +18055,6 @@ "integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -18333,7 +18365,6 @@ "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==", "dev": true, "license": "MIT", - "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/package.json b/package.json index 16f9982..ec00f57 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "@babel/preset-env": "^7.24.7", "@commitlint/cli": "^17.7.1", "@commitlint/config-conventional": "^17.7.0", - "@swc/core": "^1.3.102", + "@swc/core": "^1.15.30", "@types/node": "^24.2.1", "@types/serialize-javascript": "^5.0.2", "@types/uglify-js": "^3.17.5", diff --git a/src/utils.js b/src/utils.js index 8737916..39a88b7 100644 --- a/src/utils.js +++ b/src/utils.js @@ -659,36 +659,37 @@ async function swcMinify(input, sourceMap, minimizerOptions, extractComments) { }; /** - * @param {typeof import("@swc/core")} swc swc module + * @param {string | undefined} version swc version * @returns {boolean} true when the installed swc build supports comment extraction */ - const hasExtractCommentsSupport = (swc) => { - try { - if (typeof swc.minifySync !== "function") { - return false; - } + const hasExtractCommentsSupport = (version) => { + if (!version) { + return false; + } - const result = /** @type {SwcMinifyOutput} */ ( - swc.minifySync( - "/*! swc */var foo = 1;", - /** @type {SwcMinifyOptionsWithExtractComments} */ ({ - compress: false, - mangle: false, - format: { - comments: false, - }, - extractComments: true, - }), - ) - ); + /** + * @param {string} value version string + * @returns {number[]} normalized semver parts + */ + const normalizeVersion = (value) => + value + .split("-")[0] + .split(".") + .map((item) => Number.parseInt(item, 10) || 0); + const currentVersion = normalizeVersion(version); + const minimumVersion = normalizeVersion("1.15.30"); + + for (let i = 0; i < minimumVersion.length; i++) { + if ((currentVersion[i] || 0) > minimumVersion[i]) { + return true; + } - return ( - Array.isArray(result.extractedComments) && - result.extractedComments[0] === "/*! swc */" - ); - } catch (_error) { - return false; + if ((currentVersion[i] || 0) < minimumVersion[i]) { + return false; + } } + + return true; }; /** @@ -731,6 +732,14 @@ async function swcMinify(input, sourceMap, minimizerOptions, extractComments) { return { errors: [/** @type {Error} */ (err)] }; } + let swcVersion; + + try { + ({ version: swcVersion } = require("@swc/core/package.json")); + } catch (_error) { + // Ignore + } + // Copy `swc` options const swcOptions = buildSwcOptions(minimizerOptions); const normalizedExtractComments = normalizeExtractComments(extractComments); @@ -752,19 +761,11 @@ async function swcMinify(input, sourceMap, minimizerOptions, extractComments) { } if (normalizedExtractComments.extractComments !== false) { - if (!hasExtractCommentsSupport(swc)) { - let swcVersion; - - try { - ({ version: swcVersion } = require("@swc/core/package.json")); - } catch (_error) { - // Ignore - } - + if (!hasExtractCommentsSupport(swcVersion)) { return { errors: [ new Error( - `The 'extractComments' option for 'swcMinify' requires an @swc/core build with comment extraction support${swcVersion ? ` (found ${swcVersion})` : ""}. Please upgrade @swc/core.`, + `The 'extractComments' option for 'swcMinify' requires @swc/core >= 1.15.30${swcVersion ? ` (found ${swcVersion})` : ""}. Please upgrade @swc/core.`, ), ], }; From d98960a658293959920d6a76ee42a9bc267056b2 Mon Sep 17 00:00:00 2001 From: DongYun Kang Date: Sun, 19 Apr 2026 22:45:17 +0900 Subject: [PATCH 3/5] refactor: remove swcMinify version gate --- src/utils.js | 52 ---------------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/src/utils.js b/src/utils.js index 39a88b7..004292c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -658,40 +658,6 @@ async function swcMinify(input, sourceMap, minimizerOptions, extractComments) { }; }; - /** - * @param {string | undefined} version swc version - * @returns {boolean} true when the installed swc build supports comment extraction - */ - const hasExtractCommentsSupport = (version) => { - if (!version) { - return false; - } - - /** - * @param {string} value version string - * @returns {number[]} normalized semver parts - */ - const normalizeVersion = (value) => - value - .split("-")[0] - .split(".") - .map((item) => Number.parseInt(item, 10) || 0); - const currentVersion = normalizeVersion(version); - const minimumVersion = normalizeVersion("1.15.30"); - - for (let i = 0; i < minimumVersion.length; i++) { - if ((currentVersion[i] || 0) > minimumVersion[i]) { - return true; - } - - if ((currentVersion[i] || 0) < minimumVersion[i]) { - return false; - } - } - - return true; - }; - /** * @param {PredefinedOptions & import("@swc/core").JsMinifyOptions=} swcOptions swc options * @returns {SwcMinifyOptionsWithExtractComments & { sourceMap: undefined | boolean } & { compress: import("@swc/core").TerserCompressOptions }} built swc options @@ -732,14 +698,6 @@ async function swcMinify(input, sourceMap, minimizerOptions, extractComments) { return { errors: [/** @type {Error} */ (err)] }; } - let swcVersion; - - try { - ({ version: swcVersion } = require("@swc/core/package.json")); - } catch (_error) { - // Ignore - } - // Copy `swc` options const swcOptions = buildSwcOptions(minimizerOptions); const normalizedExtractComments = normalizeExtractComments(extractComments); @@ -761,16 +719,6 @@ async function swcMinify(input, sourceMap, minimizerOptions, extractComments) { } if (normalizedExtractComments.extractComments !== false) { - if (!hasExtractCommentsSupport(swcVersion)) { - return { - errors: [ - new Error( - `The 'extractComments' option for 'swcMinify' requires @swc/core >= 1.15.30${swcVersion ? ` (found ${swcVersion})` : ""}. Please upgrade @swc/core.`, - ), - ], - }; - } - /** @type {SwcMinifyOptionsWithExtractComments} */ ( swcOptions ).extractComments = normalizedExtractComments.extractComments; From 60e2351bb7159cf5ae1bf91785c6a424f69c4dd1 Mon Sep 17 00:00:00 2001 From: DongYun Kang Date: Sun, 19 Apr 2026 22:48:09 +0900 Subject: [PATCH 4/5] test: normalize asset paths in snapshots --- test/__snapshots__/minify-option.test.js.snap | 4 ++-- test/helpers/readAsset.js | 21 ++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/test/__snapshots__/minify-option.test.js.snap b/test/__snapshots__/minify-option.test.js.snap index 4e0c355..dfc896f 100644 --- a/test/__snapshots__/minify-option.test.js.snap +++ b/test/__snapshots__/minify-option.test.js.snap @@ -17,8 +17,8 @@ Array [ exports[`minify option should report an error when the \`extractComments\` option for \`swcMinify\` uses a function condition: assets 1`] = ` Object { - "203.203.js": "Error: ENOENT: no such file or directory, open '/Users/kdy1/.codex/worktrees/72b5/terser-webpack-plugin/test/helpers/dist/203.203.js'", - "main.js": "Error: ENOENT: no such file or directory, open '/Users/kdy1/.codex/worktrees/72b5/terser-webpack-plugin/test/helpers/dist/main.js'", + "203.203.js": "Error: ENOENT: no such file or directory, open 'test/helpers/dist/203.203.js'", + "main.js": "Error: ENOENT: no such file or directory, open 'test/helpers/dist/main.js'", } `; diff --git a/test/helpers/readAsset.js b/test/helpers/readAsset.js index 268ff28..f2af904 100644 --- a/test/helpers/readAsset.js +++ b/test/helpers/readAsset.js @@ -1,5 +1,24 @@ import path from "path"; +/** + * @param {string} value value + * @returns {string} value without cwd + */ +function removeCWD(value) { + const isWin = process.platform === "win32"; + let normalizedValue = value; + let cwd = process.cwd(); + + if (isWin) { + normalizedValue = normalizedValue.replace(/\\/g, "/"); + cwd = cwd.replace(/\\/g, "/"); + } + + const cwdPrefix = `${cwd}/`; + + return normalizedValue.split(cwdPrefix).join(""); +} + /** * @param {string} asset asset name * @param {import("webpack").Compiler} compiler compiler @@ -22,7 +41,7 @@ export default (asset, compiler, stats) => { try { data = usedFs.readFileSync(path.join(outputPath, targetFile)).toString(); } catch (error) { - data = error.toString(); + data = removeCWD(error.toString()); } return data; From 406e7cbc59b8761dc93aef5d82c1748dadb9f8b5 Mon Sep 17 00:00:00 2001 From: DongYun Kang Date: Wed, 22 Apr 2026 11:38:46 +0900 Subject: [PATCH 5/5] test: stabilize webpack hash snapshots --- test/TerserPlugin.test.js | 26 ++++-- test/__snapshots__/TerserPlugin.test.js.snap | 80 +++---------------- .../extractComments-option.test.js.snap | 52 ++++++------ test/__snapshots__/minify-option.test.js.snap | 8 +- test/__snapshots__/test-option.test.js.snap | 64 +++++++-------- test/helpers/countPlugins.js | 15 +++- test/helpers/normalizeBuildOutput.js | 12 +++ test/helpers/readAssets.js | 5 +- 8 files changed, 118 insertions(+), 144 deletions(-) create mode 100644 test/helpers/normalizeBuildOutput.js diff --git a/test/TerserPlugin.test.js b/test/TerserPlugin.test.js index be1122f..9b7dd07 100644 --- a/test/TerserPlugin.test.js +++ b/test/TerserPlugin.test.js @@ -25,6 +25,8 @@ import { jest.setTimeout(30000); +const terserPluginName = "TerserPlugin"; + expect.addSnapshotSerializer({ test: (value) => { // For string that are valid JSON @@ -153,13 +155,19 @@ describe("TerserPlugin", () => { }, ]); - const emptyPluginCount = countPlugins(multiCompiler.compilers[0]); - const expectedPluginCount = countPlugins(multiCompiler.compilers[1]); + const emptyPluginCount = countPlugins( + multiCompiler.compilers[0], + terserPluginName, + ); + const expectedPluginCount = countPlugins( + multiCompiler.compilers[1], + terserPluginName, + ); expect(emptyPluginCount).not.toEqual(expectedPluginCount); for (const compiler of multiCompiler.compilers.slice(2)) { - const pluginCount = countPlugins(compiler); + const pluginCount = countPlugins(compiler, terserPluginName); expect(pluginCount).not.toEqual(emptyPluginCount); expect(pluginCount).toEqual(expectedPluginCount); @@ -262,13 +270,19 @@ describe("TerserPlugin", () => { }, ]); - const emptyPluginCount = countPlugins(multiCompiler.compilers[0]); - const expectedPluginCount = countPlugins(multiCompiler.compilers[1]); + const emptyPluginCount = countPlugins( + multiCompiler.compilers[0], + terserPluginName, + ); + const expectedPluginCount = countPlugins( + multiCompiler.compilers[1], + terserPluginName, + ); expect(emptyPluginCount).not.toEqual(expectedPluginCount); for (const compiler of multiCompiler.compilers.slice(2)) { - const pluginCount = countPlugins(compiler); + const pluginCount = countPlugins(compiler, terserPluginName); expect(pluginCount).not.toEqual(emptyPluginCount); expect(pluginCount).toEqual(expectedPluginCount); diff --git a/test/__snapshots__/TerserPlugin.test.js.snap b/test/__snapshots__/TerserPlugin.test.js.snap index 510369d..c89e5dc 100644 --- a/test/__snapshots__/TerserPlugin.test.js.snap +++ b/test/__snapshots__/TerserPlugin.test.js.snap @@ -57,11 +57,11 @@ exports[`TerserPlugin should emit an error on a broken code in parallel mode: wa exports[`TerserPlugin should regenerate hash: assets 1`] = ` Object { - "389.389.0217a88dbfe5de109e59.js": "\\"use strict\\";(self.webpackChunkterser_webpack_plugin=self.webpackChunkterser_webpack_plugin||[]).push([[389],{389(e,s,p){p.r(s),p.d(s,{default:()=>c});const c=\\"async-dep\\"}}]);", - "AsyncImportExport.59fa0f8610c254ee3627.js": "(()=>{\\"use strict\\";var e,r,t={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((r,t)=>(n.f[t](e,r),r),[])),n.u=e=>e+\\".\\"+e+\\".0217a88dbfe5de109e59.js\\",n.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r=\\"terser-webpack-plugin:\\",n.l=(t,o,a,i)=>{if(e[t])e[t].push(o);else{var c,l;if(void 0!==a)for(var u=document.getElementsByTagName(\\"script\\"),s=0;s{c.onerror=c.onload=null,clearTimeout(f);var n=e[t];if(delete e[t],c.parentNode&&c.parentNode.removeChild(c),n&&n.forEach(e=>e(o)),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:\\"timeout\\",target:c}),12e4);c.onerror=d.bind(null,c.onerror),c.onload=d.bind(null,c.onload),l&&document.head.appendChild(c)}},n.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+\\"\\");var r=n.g.document;if(!e&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName(\\"script\\");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),n.p=e})(),(()=>{var e={988:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise((t,n)=>o=e[r]=[t,n]);t.push(o[2]=a);var i=n.p+n.u(r),c=new Error;n.l(i,t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&(\\"load\\"===t.type?\\"missing\\":t.type),i=t&&t.target&&t.target.src;c.message=\\"Loading chunk \\"+r+\\" failed.\\\\n(\\"+a+\\": \\"+i+\\")\\",c.name=\\"ChunkLoadError\\",c.type=a,c.request=i,o[1](c)}},\\"chunk-\\"+r,r)}};var r=(r,t)=>{var o,a,[i,c,l]=t,u=0;if(i.some(r=>0!==e[r])){for(o in c)n.o(c,o)&&(n.m[o]=c[o]);if(l)l(n)}for(r&&r(t);u{console.log(\\"Good\\")})})();", - "importExport.99516598f0f48417cbb9.js": "(()=>{\\"use strict\\";function o(){const o=\`baz\${Math.random()}\`;return()=>({a:\\"foobar\\"+o,b:\\"foo\\",baz:o})}console.log(o())})();", - "js.e6d921fb046a3426b75b.js": "(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};(function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports})(921)})();", - "mjs.46bcd65d7e1972401425.js": "(()=>{\\"use strict\\";function o(){console.log(11)}o()})();", + "389.389.[hash].js": "\\"use strict\\";(self.webpackChunkterser_webpack_plugin=self.webpackChunkterser_webpack_plugin||[]).push([[389],{389(e,s,p){p.r(s),p.d(s,{default:()=>c});const c=\\"async-dep\\"}}]);", + "AsyncImportExport.[hash].js": "(()=>{\\"use strict\\";var e,r,t={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((r,t)=>(n.f[t](e,r),r),[])),n.u=e=>e+\\".\\"+e+\\".[hash].js\\",n.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r=\\"terser-webpack-plugin:\\",n.l=(t,o,a,i)=>{if(e[t])e[t].push(o);else{var c,l;if(void 0!==a)for(var u=document.getElementsByTagName(\\"script\\"),s=0;s{c.onerror=c.onload=null,clearTimeout(f);var n=e[t];if(delete e[t],c.parentNode&&c.parentNode.removeChild(c),n&&n.forEach(e=>e(o)),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:\\"timeout\\",target:c}),12e4);c.onerror=d.bind(null,c.onerror),c.onload=d.bind(null,c.onload),l&&document.head.appendChild(c)}},n.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+\\"\\");var r=n.g.document;if(!e&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName(\\"script\\");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),n.p=e})(),(()=>{var e={988:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise((t,n)=>o=e[r]=[t,n]);t.push(o[2]=a);var i=n.p+n.u(r),c=new Error;n.l(i,t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&(\\"load\\"===t.type?\\"missing\\":t.type),i=t&&t.target&&t.target.src;c.message=\\"Loading chunk \\"+r+\\" failed.\\\\n(\\"+a+\\": \\"+i+\\")\\",c.name=\\"ChunkLoadError\\",c.type=a,c.request=i,o[1](c)}},\\"chunk-\\"+r,r)}};var r=(r,t)=>{var o,a,[i,c,l]=t,u=0;if(i.some(r=>0!==e[r])){for(o in c)n.o(c,o)&&(n.m[o]=c[o]);if(l)l(n)}for(r&&r(t);u{console.log(\\"Good\\")})})();", + "importExport.[hash].js": "(()=>{\\"use strict\\";function o(){const o=\`baz\${Math.random()}\`;return()=>({a:\\"foobar\\"+o,b:\\"foo\\",baz:o})}console.log(o())})();", + "js.[hash].js": "(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};(function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports})(921)})();", + "mjs.[hash].js": "(()=>{\\"use strict\\";function o(){console.log(11)}o()})();", } `; @@ -140,8 +140,8 @@ exports[`TerserPlugin should work and do not use memory cache when the "cache" o exports[`TerserPlugin should work and generate real content hash: assets 1`] = ` Object { - "389.0217a88dbfe5de109e59.b01799069058bcd7bec8.2037266127009e9b15b6.js": "\\"use strict\\";(self.webpackChunkterser_webpack_plugin=self.webpackChunkterser_webpack_plugin||[]).push([[389],{389(e,s,p){p.r(s),p.d(s,{default:()=>c});const c=\\"async-dep\\"}}]);", - "app.de830e38f3def24aea37.35369e53cb4b3ef481d2.2037266127009e9b15b6.js": "(()=>{\\"use strict\\";var e,r,t={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((r,t)=>(n.f[t](e,r),r),[])),n.u=e=>e+\\".0217a88dbfe5de109e59.b01799069058bcd7bec8.\\"+n.h()+\\".js\\",n.h=()=>\\"2037266127009e9b15b6\\",n.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r=\\"terser-webpack-plugin:\\",n.l=(t,o,a,i)=>{if(e[t])e[t].push(o);else{var c,l;if(void 0!==a)for(var u=document.getElementsByTagName(\\"script\\"),s=0;s{c.onerror=c.onload=null,clearTimeout(f);var n=e[t];if(delete e[t],c.parentNode&&c.parentNode.removeChild(c),n&&n.forEach(e=>e(o)),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:\\"timeout\\",target:c}),12e4);c.onerror=d.bind(null,c.onerror),c.onload=d.bind(null,c.onload),l&&document.head.appendChild(c)}},n.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+\\"\\");var r=n.g.document;if(!e&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName(\\"script\\");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),n.p=e})(),(()=>{var e={524:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise((t,n)=>o=e[r]=[t,n]);t.push(o[2]=a);var i=n.p+n.u(r),c=new Error;n.l(i,t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&(\\"load\\"===t.type?\\"missing\\":t.type),i=t&&t.target&&t.target.src;c.message=\\"Loading chunk \\"+r+\\" failed.\\\\n(\\"+a+\\": \\"+i+\\")\\",c.name=\\"ChunkLoadError\\",c.type=a,c.request=i,o[1](c)}},\\"chunk-\\"+r,r)}};var r=(r,t)=>{var o,a,[i,c,l]=t,u=0;if(i.some(r=>0!==e[r])){for(o in c)n.o(c,o)&&(n.m[o]=c[o]);if(l)l(n)}for(r&&r(t);u{console.log(\\"Good\\")})})();", + "389.[hash].[hash].[hash].js": "\\"use strict\\";(self.webpackChunkterser_webpack_plugin=self.webpackChunkterser_webpack_plugin||[]).push([[389],{389(e,s,p){p.r(s),p.d(s,{default:()=>c});const c=\\"async-dep\\"}}]);", + "app.[hash].[hash].[hash].js": "(()=>{\\"use strict\\";var e,r,t={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((r,t)=>(n.f[t](e,r),r),[])),n.u=e=>e+\\".[hash].[hash].\\"+n.h()+\\".js\\",n.h=()=>\\"[hash]\\",n.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r=\\"terser-webpack-plugin:\\",n.l=(t,o,a,i)=>{if(e[t])e[t].push(o);else{var c,l;if(void 0!==a)for(var u=document.getElementsByTagName(\\"script\\"),s=0;s{c.onerror=c.onload=null,clearTimeout(f);var n=e[t];if(delete e[t],c.parentNode&&c.parentNode.removeChild(c),n&&n.forEach(e=>e(o)),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:\\"timeout\\",target:c}),12e4);c.onerror=d.bind(null,c.onerror),c.onload=d.bind(null,c.onload),l&&document.head.appendChild(c)}},n.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+\\"\\");var r=n.g.document;if(!e&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName(\\"script\\");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),n.p=e})(),(()=>{var e={524:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise((t,n)=>o=e[r]=[t,n]);t.push(o[2]=a);var i=n.p+n.u(r),c=new Error;n.l(i,t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&(\\"load\\"===t.type?\\"missing\\":t.type),i=t&&t.target&&t.target.src;c.message=\\"Loading chunk \\"+r+\\" failed.\\\\n(\\"+a+\\": \\"+i+\\")\\",c.name=\\"ChunkLoadError\\",c.type=a,c.request=i,o[1](c)}},\\"chunk-\\"+r,r)}};var r=(r,t)=>{var o,a,[i,c,l]=t,u=0;if(i.some(r=>0!==e[r])){for(o in c)n.o(c,o)&&(n.m[o]=c[o]);if(l)l(n)}for(r&&r(t);u{console.log(\\"Good\\")})})();", } `; @@ -449,38 +449,7 @@ Object { exports[`TerserPlugin should work in multi compiler mode with the one plugin: compiler plugin count 1`] = ` Object { - "additionalPass": 0, - "afterCompile": 0, - "afterDone": 0, - "afterEmit": 1, - "afterEnvironment": 0, - "afterPlugins": 0, - "afterResolvers": 0, - "assetEmitted": 0, - "beforeCompile": 0, - "beforeRun": 1, - "compilation": 55, - "compile": 1, - "contextModuleFactory": 0, - "done": 1, - "emit": 0, - "emitRecords": 0, - "entryOption": 1, - "environment": 0, - "failed": 0, - "finishMake": 0, - "infrastructureLog": 0, - "initialize": 0, - "invalid": 1, - "make": 1, - "normalModuleFactory": 0, - "readRecords": 0, - "run": 0, - "shouldEmit": 1, - "shutdown": 0, - "thisCompilation": 7, - "watchClose": 0, - "watchRun": 0, + "compilation": 1, } `; @@ -569,38 +538,7 @@ Object { exports[`TerserPlugin should work in multi compiler mode: compiler plugin count 1`] = ` Object { - "additionalPass": 0, - "afterCompile": 0, - "afterDone": 0, - "afterEmit": 1, - "afterEnvironment": 0, - "afterPlugins": 0, - "afterResolvers": 0, - "assetEmitted": 0, - "beforeCompile": 0, - "beforeRun": 1, - "compilation": 55, - "compile": 1, - "contextModuleFactory": 0, - "done": 1, - "emit": 0, - "emitRecords": 0, - "entryOption": 1, - "environment": 0, - "failed": 0, - "finishMake": 0, - "infrastructureLog": 0, - "initialize": 0, - "invalid": 1, - "make": 1, - "normalModuleFactory": 0, - "readRecords": 0, - "run": 0, - "shouldEmit": 1, - "shutdown": 0, - "thisCompilation": 7, - "watchClose": 0, - "watchRun": 0, + "compilation": 1, } `; diff --git a/test/__snapshots__/extractComments-option.test.js.snap b/test/__snapshots__/extractComments-option.test.js.snap index 0159f80..18b9af9 100644 --- a/test/__snapshots__/extractComments-option.test.js.snap +++ b/test/__snapshots__/extractComments-option.test.js.snap @@ -4570,10 +4570,10 @@ exports[`extractComments option should match snapshot for a "function" value: wa exports[`extractComments option should match snapshot for comment file when filename is nested: assets 1`] = ` Object { - "nested/directory/203.js?3249e8a906476528f9b6": "/*! For license information please see ../../one.js */ + "nested/directory/203.js?[hash]": "/*! For license information please see ../../one.js */ (self.webpackChunkterser_webpack_plugin=self.webpackChunkterser_webpack_plugin||[]).push([[203],{203(e){e.exports=Math.random()}}]);", - "nested/directory/one.js?ba64021067d934c863a4": "/*! For license information please see ../../one.js */ -(()=>{var e,t,r,o,n={855(e,t,r){r.e(203).then(r.t.bind(r,203,23)),e.exports=Math.random()}},a={};function i(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return n[e](r,r.exports,i),r.exports}i.m=n,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(r,o){if(1&o&&(r=this(r)),8&o)return r;if(\\"object\\"==typeof r&&r){if(4&o&&r.__esModule)return r;if(16&o&&\\"function\\"==typeof r.then)return r}var n=Object.create(null);i.r(n);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&o&&r;(\\"object\\"==typeof c||\\"function\\"==typeof c)&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach(e=>a[e]=()=>r[e]);return a.default=()=>r,i.d(n,a),n},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce((t,r)=>(i.f[r](e,t),t),[])),i.u=e=>\\"nested/directory/\\"+e+\\".js?3249e8a906476528f9b6\\",i.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},o=\\"terser-webpack-plugin:\\",i.l=(e,t,n,a)=>{if(r[e])r[e].push(t);else{var c,u;if(void 0!==n)for(var l=document.getElementsByTagName(\\"script\\"),p=0;p{c.onerror=c.onload=null,clearTimeout(d);var n=r[e];if(delete r[e],c.parentNode&&c.parentNode.removeChild(c),n&&n.forEach(e=>e(o)),t)return t(o)},d=setTimeout(f.bind(null,void 0,{type:\\"timeout\\",target:c}),12e4);c.onerror=f.bind(null,c.onerror),c.onload=f.bind(null,c.onload),u&&document.head.appendChild(c)}},i.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+\\"\\");var t=i.g.document;if(!e&&t&&(t.currentScript&&\\"SCRIPT\\"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName(\\"script\\");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),i.p=e+\\"../../\\"})(),(()=>{var e={101:0};i.f.j=(t,r)=>{var o=i.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=e[t]=[r,n]);r.push(o[2]=n);var a=i.p+i.u(t),c=new Error;i.l(a,r=>{if(i.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&(\\"load\\"===r.type?\\"missing\\":r.type),a=r&&r.target&&r.target.src;c.message=\\"Loading chunk \\"+t+\\" failed.\\\\n(\\"+n+\\": \\"+a+\\")\\",c.name=\\"ChunkLoadError\\",c.type=n,c.request=a,o[1](c)}},\\"chunk-\\"+t,t)}};var t=(t,r)=>{var o,n,[a,c,u]=r,l=0;if(a.some(t=>0!==e[t])){for(o in c)i.o(c,o)&&(i.m[o]=c[o]);if(u)u(i)}for(t&&t(r);l{var e,t,r,o,n={855(e,t,r){r.e(203).then(r.t.bind(r,203,23)),e.exports=Math.random()}},a={};function i(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return n[e](r,r.exports,i),r.exports}i.m=n,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(r,o){if(1&o&&(r=this(r)),8&o)return r;if(\\"object\\"==typeof r&&r){if(4&o&&r.__esModule)return r;if(16&o&&\\"function\\"==typeof r.then)return r}var n=Object.create(null);i.r(n);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&o&&r;(\\"object\\"==typeof c||\\"function\\"==typeof c)&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach(e=>a[e]=()=>r[e]);return a.default=()=>r,i.d(n,a),n},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce((t,r)=>(i.f[r](e,t),t),[])),i.u=e=>\\"nested/directory/\\"+e+\\".js?[hash]\\",i.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},o=\\"terser-webpack-plugin:\\",i.l=(e,t,n,a)=>{if(r[e])r[e].push(t);else{var c,u;if(void 0!==n)for(var l=document.getElementsByTagName(\\"script\\"),p=0;p{c.onerror=c.onload=null,clearTimeout(d);var n=r[e];if(delete r[e],c.parentNode&&c.parentNode.removeChild(c),n&&n.forEach(e=>e(o)),t)return t(o)},d=setTimeout(f.bind(null,void 0,{type:\\"timeout\\",target:c}),12e4);c.onerror=f.bind(null,c.onerror),c.onload=f.bind(null,c.onload),u&&document.head.appendChild(c)}},i.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+\\"\\");var t=i.g.document;if(!e&&t&&(t.currentScript&&\\"SCRIPT\\"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName(\\"script\\");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),i.p=e+\\"../../\\"})(),(()=>{var e={101:0};i.f.j=(t,r)=>{var o=i.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=e[t]=[r,n]);r.push(o[2]=n);var a=i.p+i.u(t),c=new Error;i.l(a,r=>{if(i.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&(\\"load\\"===r.type?\\"missing\\":r.type),a=r&&r.target&&r.target.src;c.message=\\"Loading chunk \\"+t+\\" failed.\\\\n(\\"+n+\\": \\"+a+\\")\\",c.name=\\"ChunkLoadError\\",c.type=n,c.request=a,o[1](c)}},\\"chunk-\\"+t,t)}};var t=(t,r)=>{var o,n,[a,c,u]=r,l=0;if(a.some(t=>0!==e[t])){for(o in c)i.o(c,o)&&(i.m[o]=c[o]);if(u)u(i)}for(t&&t(r);l{var r={250(r){r.exports=Math.random()}},t={};(function o(e){var a=t[e];if(void 0!==a)return a.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,o),n.exports})(250)})();", - "filename/one.js.LICENSE.txt?17eefb908f3e94ecb3c9": "/*! Legal Comment */ + "filename/one.js.LICENSE.txt?[hash]": "/*! Legal Comment */ /*! Legal Foo */ @@ -5560,9 +5560,9 @@ Object { // @lic ", - "filename/one.js?17eefb908f3e94ecb3c9": "/*! For license information please see one.js.LICENSE.txt?17eefb908f3e94ecb3c9 */ -(()=>{var e,t,r,o,n={855(e,t,r){r.e(203).then(r.t.bind(r,203,23)),e.exports=Math.random()}},a={};function i(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return n[e](r,r.exports,i),r.exports}i.m=n,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(r,o){if(1&o&&(r=this(r)),8&o)return r;if(\\"object\\"==typeof r&&r){if(4&o&&r.__esModule)return r;if(16&o&&\\"function\\"==typeof r.then)return r}var n=Object.create(null);i.r(n);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&o&&r;(\\"object\\"==typeof c||\\"function\\"==typeof c)&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach(e=>a[e]=()=>r[e]);return a.default=()=>r,i.d(n,a),n},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce((t,r)=>(i.f[r](e,t),t),[])),i.u=e=>\\"chunks/\\"+e+\\".\\"+e+\\".js?3249e8a906476528f9b6\\",i.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},o=\\"terser-webpack-plugin:\\",i.l=(e,t,n,a)=>{if(r[e])r[e].push(t);else{var c,u;if(void 0!==n)for(var l=document.getElementsByTagName(\\"script\\"),p=0;p{c.onerror=c.onload=null,clearTimeout(d);var n=r[e];if(delete r[e],c.parentNode&&c.parentNode.removeChild(c),n&&n.forEach(e=>e(o)),t)return t(o)},d=setTimeout(f.bind(null,void 0,{type:\\"timeout\\",target:c}),12e4);c.onerror=f.bind(null,c.onerror),c.onload=f.bind(null,c.onload),u&&document.head.appendChild(c)}},i.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+\\"\\");var t=i.g.document;if(!e&&t&&(t.currentScript&&\\"SCRIPT\\"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName(\\"script\\");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),i.p=e+\\"../\\"})(),(()=>{var e={101:0};i.f.j=(t,r)=>{var o=i.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=e[t]=[r,n]);r.push(o[2]=n);var a=i.p+i.u(t),c=new Error;i.l(a,r=>{if(i.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&(\\"load\\"===r.type?\\"missing\\":r.type),a=r&&r.target&&r.target.src;c.message=\\"Loading chunk \\"+t+\\" failed.\\\\n(\\"+n+\\": \\"+a+\\")\\",c.name=\\"ChunkLoadError\\",c.type=n,c.request=a,o[1](c)}},\\"chunk-\\"+t,t)}};var t=(t,r)=>{var o,n,[a,c,u]=r,l=0;if(a.some(t=>0!==e[t])){for(o in c)i.o(c,o)&&(i.m[o]=c[o]);if(u)u(i)}for(t&&t(r);l{var e,t,r,o,n={855(e,t,r){r.e(203).then(r.t.bind(r,203,23)),e.exports=Math.random()}},a={};function i(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return n[e](r,r.exports,i),r.exports}i.m=n,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(r,o){if(1&o&&(r=this(r)),8&o)return r;if(\\"object\\"==typeof r&&r){if(4&o&&r.__esModule)return r;if(16&o&&\\"function\\"==typeof r.then)return r}var n=Object.create(null);i.r(n);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&o&&r;(\\"object\\"==typeof c||\\"function\\"==typeof c)&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach(e=>a[e]=()=>r[e]);return a.default=()=>r,i.d(n,a),n},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce((t,r)=>(i.f[r](e,t),t),[])),i.u=e=>\\"chunks/\\"+e+\\".\\"+e+\\".js?[hash]\\",i.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},o=\\"terser-webpack-plugin:\\",i.l=(e,t,n,a)=>{if(r[e])r[e].push(t);else{var c,u;if(void 0!==n)for(var l=document.getElementsByTagName(\\"script\\"),p=0;p{c.onerror=c.onload=null,clearTimeout(d);var n=r[e];if(delete r[e],c.parentNode&&c.parentNode.removeChild(c),n&&n.forEach(e=>e(o)),t)return t(o)},d=setTimeout(f.bind(null,void 0,{type:\\"timeout\\",target:c}),12e4);c.onerror=f.bind(null,c.onerror),c.onload=f.bind(null,c.onload),u&&document.head.appendChild(c)}},i.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+\\"\\");var t=i.g.document;if(!e&&t&&(t.currentScript&&\\"SCRIPT\\"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName(\\"script\\");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),i.p=e+\\"../\\"})(),(()=>{var e={101:0};i.f.j=(t,r)=>{var o=i.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=e[t]=[r,n]);r.push(o[2]=n);var a=i.p+i.u(t),c=new Error;i.l(a,r=>{if(i.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&(\\"load\\"===r.type?\\"missing\\":r.type),a=r&&r.target&&r.target.src;c.message=\\"Loading chunk \\"+t+\\" failed.\\\\n(\\"+n+\\": \\"+a+\\")\\",c.name=\\"ChunkLoadError\\",c.type=n,c.request=a,o[1](c)}},\\"chunk-\\"+t,t)}};var t=(t,r)=>{var o,n,[a,c,u]=r,l=0;if(a.some(t=>0!==e[t])){for(o in c)i.o(c,o)&&(i.m[o]=c[o]);if(u)u(i)}for(t&&t(r);l{var r={35(r){r.exports=Math.random()}},t={};(function o(e){var a=t[e];if(void 0!==a)return a.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,o),n.exports})(35)})();", - "filename/two.js.LICENSE.txt?e8d9a68751e3cf4918f0": "/** + "filename/two.js.LICENSE.txt?[hash]": "/** * Information. * @license MIT */ ", - "filename/two.js?e8d9a68751e3cf4918f0": "/*! For license information please see two.js.LICENSE.txt?e8d9a68751e3cf4918f0 */ + "filename/two.js?[hash]": "/*! For license information please see two.js.LICENSE.txt?[hash] */ (()=>{var r={12(r){r.exports=Math.random()}},t={};(function o(e){var a=t[e];if(void 0!==a)return a.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,o),n.exports})(12)})();", } `; @@ -5594,14 +5594,14 @@ Object { /** @license Copyright 2112 Moon. **/ ", - "chunks/203.203.js?3249e8a906476528f9b6": "/*! License information can be found in chunks/203.203.js.LICENSE.txt?query=&filebase=203.203.js */ + "chunks/203.203.js?[hash]": "/*! License information can be found in chunks/203.203.js.LICENSE.txt?query=&filebase=203.203.js */ (self.webpackChunkterser_webpack_plugin=self.webpackChunkterser_webpack_plugin||[]).push([[203],{203(e){e.exports=Math.random()}}]);", "filename/four.js.LICENSE.txt?query=&filebase=four.js": "/** * Duplicate comment in difference files. * @license MIT */ ", - "filename/four.js?3ac83d899c8141aaca3b": "/*! License information can be found in filename/four.js.LICENSE.txt?query=&filebase=four.js */ + "filename/four.js?[hash]": "/*! License information can be found in filename/four.js.LICENSE.txt?query=&filebase=four.js */ (()=>{var r={250(r){r.exports=Math.random()}},t={};(function o(e){var a=t[e];if(void 0!==a)return a.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,o),n.exports})(250)})();", "filename/one.js.LICENSE.txt?query=&filebase=one.js": "/*! Legal Comment */ @@ -5621,8 +5621,8 @@ Object { // @lic ", - "filename/one.js?17eefb908f3e94ecb3c9": "/*! License information can be found in filename/one.js.LICENSE.txt?query=&filebase=one.js */ -(()=>{var e,t,r,o,n={855(e,t,r){r.e(203).then(r.t.bind(r,203,23)),e.exports=Math.random()}},a={};function i(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return n[e](r,r.exports,i),r.exports}i.m=n,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(r,o){if(1&o&&(r=this(r)),8&o)return r;if(\\"object\\"==typeof r&&r){if(4&o&&r.__esModule)return r;if(16&o&&\\"function\\"==typeof r.then)return r}var n=Object.create(null);i.r(n);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&o&&r;(\\"object\\"==typeof c||\\"function\\"==typeof c)&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach(e=>a[e]=()=>r[e]);return a.default=()=>r,i.d(n,a),n},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce((t,r)=>(i.f[r](e,t),t),[])),i.u=e=>\\"chunks/\\"+e+\\".\\"+e+\\".js?3249e8a906476528f9b6\\",i.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},o=\\"terser-webpack-plugin:\\",i.l=(e,t,n,a)=>{if(r[e])r[e].push(t);else{var c,u;if(void 0!==n)for(var l=document.getElementsByTagName(\\"script\\"),p=0;p{c.onerror=c.onload=null,clearTimeout(d);var n=r[e];if(delete r[e],c.parentNode&&c.parentNode.removeChild(c),n&&n.forEach(e=>e(o)),t)return t(o)},d=setTimeout(f.bind(null,void 0,{type:\\"timeout\\",target:c}),12e4);c.onerror=f.bind(null,c.onerror),c.onload=f.bind(null,c.onload),u&&document.head.appendChild(c)}},i.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+\\"\\");var t=i.g.document;if(!e&&t&&(t.currentScript&&\\"SCRIPT\\"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName(\\"script\\");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),i.p=e+\\"../\\"})(),(()=>{var e={101:0};i.f.j=(t,r)=>{var o=i.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=e[t]=[r,n]);r.push(o[2]=n);var a=i.p+i.u(t),c=new Error;i.l(a,r=>{if(i.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&(\\"load\\"===r.type?\\"missing\\":r.type),a=r&&r.target&&r.target.src;c.message=\\"Loading chunk \\"+t+\\" failed.\\\\n(\\"+n+\\": \\"+a+\\")\\",c.name=\\"ChunkLoadError\\",c.type=n,c.request=a,o[1](c)}},\\"chunk-\\"+t,t)}};var t=(t,r)=>{var o,n,[a,c,u]=r,l=0;if(a.some(t=>0!==e[t])){for(o in c)i.o(c,o)&&(i.m[o]=c[o]);if(u)u(i)}for(t&&t(r);l{var e,t,r,o,n={855(e,t,r){r.e(203).then(r.t.bind(r,203,23)),e.exports=Math.random()}},a={};function i(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return n[e](r,r.exports,i),r.exports}i.m=n,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(r,o){if(1&o&&(r=this(r)),8&o)return r;if(\\"object\\"==typeof r&&r){if(4&o&&r.__esModule)return r;if(16&o&&\\"function\\"==typeof r.then)return r}var n=Object.create(null);i.r(n);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&o&&r;(\\"object\\"==typeof c||\\"function\\"==typeof c)&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach(e=>a[e]=()=>r[e]);return a.default=()=>r,i.d(n,a),n},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce((t,r)=>(i.f[r](e,t),t),[])),i.u=e=>\\"chunks/\\"+e+\\".\\"+e+\\".js?[hash]\\",i.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},o=\\"terser-webpack-plugin:\\",i.l=(e,t,n,a)=>{if(r[e])r[e].push(t);else{var c,u;if(void 0!==n)for(var l=document.getElementsByTagName(\\"script\\"),p=0;p{c.onerror=c.onload=null,clearTimeout(d);var n=r[e];if(delete r[e],c.parentNode&&c.parentNode.removeChild(c),n&&n.forEach(e=>e(o)),t)return t(o)},d=setTimeout(f.bind(null,void 0,{type:\\"timeout\\",target:c}),12e4);c.onerror=f.bind(null,c.onerror),c.onload=f.bind(null,c.onload),u&&document.head.appendChild(c)}},i.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+\\"\\");var t=i.g.document;if(!e&&t&&(t.currentScript&&\\"SCRIPT\\"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName(\\"script\\");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),i.p=e+\\"../\\"})(),(()=>{var e={101:0};i.f.j=(t,r)=>{var o=i.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=e[t]=[r,n]);r.push(o[2]=n);var a=i.p+i.u(t),c=new Error;i.l(a,r=>{if(i.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&(\\"load\\"===r.type?\\"missing\\":r.type),a=r&&r.target&&r.target.src;c.message=\\"Loading chunk \\"+t+\\" failed.\\\\n(\\"+n+\\": \\"+a+\\")\\",c.name=\\"ChunkLoadError\\",c.type=n,c.request=a,o[1](c)}},\\"chunk-\\"+t,t)}};var t=(t,r)=>{var o,n,[a,c,u]=r,l=0;if(a.some(t=>0!==e[t])){for(o in c)i.o(c,o)&&(i.m[o]=c[o]);if(u)u(i)}for(t&&t(r);l{var r={35(r){r.exports=Math.random()}},t={};(function o(e){var a=t[e];if(void 0!==a)return a.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,o),n.exports})(35)})();", "filename/two.js.LICENSE.txt?query=&filebase=two.js": "/** * Information. * @license MIT */ ", - "filename/two.js?e8d9a68751e3cf4918f0": "/*! License information can be found in filename/two.js.LICENSE.txt?query=&filebase=two.js */ + "filename/two.js?[hash]": "/*! License information can be found in filename/two.js.LICENSE.txt?query=&filebase=two.js */ (()=>{var r={12(r){r.exports=Math.random()}},t={};(function o(e){var a=t[e];if(void 0!==a)return a.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,o),n.exports})(12)})();", } `; @@ -5655,14 +5655,14 @@ Object { /** @license Copyright 2112 Moon. **/ ", - "chunks/203.203.js?3249e8a906476528f9b6": "/*! For license information please see 203.203.js.LICENSE.txt */ + "chunks/203.203.js?[hash]": "/*! For license information please see 203.203.js.LICENSE.txt */ (self.webpackChunkterser_webpack_plugin=self.webpackChunkterser_webpack_plugin||[]).push([[203],{203(e){e.exports=Math.random()}}]);", "filename/four.js.LICENSE.txt": "/** * Duplicate comment in difference files. * @license MIT */ ", - "filename/four.js?3ac83d899c8141aaca3b": "/*! For license information please see four.js.LICENSE.txt */ + "filename/four.js?[hash]": "/*! For license information please see four.js.LICENSE.txt */ (()=>{var r={250(r){r.exports=Math.random()}},t={};(function o(e){var a=t[e];if(void 0!==a)return a.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,o),n.exports})(250)})();", "filename/one.js.LICENSE.txt": "/*! Legal Comment */ @@ -5682,8 +5682,8 @@ Object { // @lic ", - "filename/one.js?17eefb908f3e94ecb3c9": "/*! For license information please see one.js.LICENSE.txt */ -(()=>{var e,t,r,o,n={855(e,t,r){r.e(203).then(r.t.bind(r,203,23)),e.exports=Math.random()}},a={};function i(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return n[e](r,r.exports,i),r.exports}i.m=n,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(r,o){if(1&o&&(r=this(r)),8&o)return r;if(\\"object\\"==typeof r&&r){if(4&o&&r.__esModule)return r;if(16&o&&\\"function\\"==typeof r.then)return r}var n=Object.create(null);i.r(n);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&o&&r;(\\"object\\"==typeof c||\\"function\\"==typeof c)&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach(e=>a[e]=()=>r[e]);return a.default=()=>r,i.d(n,a),n},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce((t,r)=>(i.f[r](e,t),t),[])),i.u=e=>\\"chunks/\\"+e+\\".\\"+e+\\".js?3249e8a906476528f9b6\\",i.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},o=\\"terser-webpack-plugin:\\",i.l=(e,t,n,a)=>{if(r[e])r[e].push(t);else{var c,u;if(void 0!==n)for(var l=document.getElementsByTagName(\\"script\\"),p=0;p{c.onerror=c.onload=null,clearTimeout(d);var n=r[e];if(delete r[e],c.parentNode&&c.parentNode.removeChild(c),n&&n.forEach(e=>e(o)),t)return t(o)},d=setTimeout(f.bind(null,void 0,{type:\\"timeout\\",target:c}),12e4);c.onerror=f.bind(null,c.onerror),c.onload=f.bind(null,c.onload),u&&document.head.appendChild(c)}},i.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+\\"\\");var t=i.g.document;if(!e&&t&&(t.currentScript&&\\"SCRIPT\\"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName(\\"script\\");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),i.p=e+\\"../\\"})(),(()=>{var e={101:0};i.f.j=(t,r)=>{var o=i.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=e[t]=[r,n]);r.push(o[2]=n);var a=i.p+i.u(t),c=new Error;i.l(a,r=>{if(i.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&(\\"load\\"===r.type?\\"missing\\":r.type),a=r&&r.target&&r.target.src;c.message=\\"Loading chunk \\"+t+\\" failed.\\\\n(\\"+n+\\": \\"+a+\\")\\",c.name=\\"ChunkLoadError\\",c.type=n,c.request=a,o[1](c)}},\\"chunk-\\"+t,t)}};var t=(t,r)=>{var o,n,[a,c,u]=r,l=0;if(a.some(t=>0!==e[t])){for(o in c)i.o(c,o)&&(i.m[o]=c[o]);if(u)u(i)}for(t&&t(r);l{var e,t,r,o,n={855(e,t,r){r.e(203).then(r.t.bind(r,203,23)),e.exports=Math.random()}},a={};function i(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return n[e](r,r.exports,i),r.exports}i.m=n,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(r,o){if(1&o&&(r=this(r)),8&o)return r;if(\\"object\\"==typeof r&&r){if(4&o&&r.__esModule)return r;if(16&o&&\\"function\\"==typeof r.then)return r}var n=Object.create(null);i.r(n);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&o&&r;(\\"object\\"==typeof c||\\"function\\"==typeof c)&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach(e=>a[e]=()=>r[e]);return a.default=()=>r,i.d(n,a),n},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce((t,r)=>(i.f[r](e,t),t),[])),i.u=e=>\\"chunks/\\"+e+\\".\\"+e+\\".js?[hash]\\",i.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},o=\\"terser-webpack-plugin:\\",i.l=(e,t,n,a)=>{if(r[e])r[e].push(t);else{var c,u;if(void 0!==n)for(var l=document.getElementsByTagName(\\"script\\"),p=0;p{c.onerror=c.onload=null,clearTimeout(d);var n=r[e];if(delete r[e],c.parentNode&&c.parentNode.removeChild(c),n&&n.forEach(e=>e(o)),t)return t(o)},d=setTimeout(f.bind(null,void 0,{type:\\"timeout\\",target:c}),12e4);c.onerror=f.bind(null,c.onerror),c.onload=f.bind(null,c.onload),u&&document.head.appendChild(c)}},i.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+\\"\\");var t=i.g.document;if(!e&&t&&(t.currentScript&&\\"SCRIPT\\"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName(\\"script\\");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),i.p=e+\\"../\\"})(),(()=>{var e={101:0};i.f.j=(t,r)=>{var o=i.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=e[t]=[r,n]);r.push(o[2]=n);var a=i.p+i.u(t),c=new Error;i.l(a,r=>{if(i.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&(\\"load\\"===r.type?\\"missing\\":r.type),a=r&&r.target&&r.target.src;c.message=\\"Loading chunk \\"+t+\\" failed.\\\\n(\\"+n+\\": \\"+a+\\")\\",c.name=\\"ChunkLoadError\\",c.type=n,c.request=a,o[1](c)}},\\"chunk-\\"+t,t)}};var t=(t,r)=>{var o,n,[a,c,u]=r,l=0;if(a.some(t=>0!==e[t])){for(o in c)i.o(c,o)&&(i.m[o]=c[o]);if(u)u(i)}for(t&&t(r);l{var r={35(r){r.exports=Math.random()}},t={};(function o(e){var a=t[e];if(void 0!==a)return a.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,o),n.exports})(35)})();", "filename/two.js.LICENSE.txt": "/** * Information. * @license MIT */ ", - "filename/two.js?e8d9a68751e3cf4918f0": "/*! For license information please see two.js.LICENSE.txt */ + "filename/two.js?[hash]": "/*! For license information please see two.js.LICENSE.txt */ (()=>{var r={12(r){r.exports=Math.random()}},t={};(function o(e){var a=t[e];if(void 0!==a)return a.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,o),n.exports})(12)})();", } `; diff --git a/test/__snapshots__/minify-option.test.js.snap b/test/__snapshots__/minify-option.test.js.snap index dfc896f..94a3605 100644 --- a/test/__snapshots__/minify-option.test.js.snap +++ b/test/__snapshots__/minify-option.test.js.snap @@ -168,13 +168,13 @@ exports[`minify option should work using when the \`minify\` option is \`esbuild exports[`minify option should work using when the \`minify\` option is \`jsonMinify\` and allows to set \`JSON.stringify\` options: assets 1`] = ` Object { - "71be2c5d019f14d29bdd.json": "{ + "[hash].json": "{ \\"foo\\": \\"bar\\", \\"bar\\": [ \\"baz\\" ] }", - "main.js": "(()=>{var t={437(t,r,e){\\"use strict\\";t.exports=e.p+\\"71be2c5d019f14d29bdd.json\\"}},r={};function e(o){var n=r[o];if(void 0!==n)return n.exports;var c=r[o]={exports:{}};return t[o](c,c.exports,e),c.exports}e.m=t,e.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(t){if(\\"object\\"==typeof window)return window}}(),e.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r),(()=>{var t;e.g.importScripts&&(t=e.g.location+\\"\\");var r=e.g.document;if(!t&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(t=r.currentScript.src),!t)){var o=r.getElementsByTagName(\\"script\\");if(o.length)for(var n=o.length-1;n>-1&&(!t||!/^http(s?):/.test(t));)t=o[n--].src}if(!t)throw new Error(\\"Automatic publicPath is not supported in this browser\\");t=t.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),e.p=t})(),e.b=\\"undefined\\"!=typeof document&&document.baseURI||self.location.href,console.log(new URL(e(437),e.b))})();", + "main.js": "(()=>{var t={437(t,r,e){\\"use strict\\";t.exports=e.p+\\"[hash].json\\"}},r={};function e(o){var n=r[o];if(void 0!==n)return n.exports;var c=r[o]={exports:{}};return t[o](c,c.exports,e),c.exports}e.m=t,e.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(t){if(\\"object\\"==typeof window)return window}}(),e.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r),(()=>{var t;e.g.importScripts&&(t=e.g.location+\\"\\");var r=e.g.document;if(!t&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(t=r.currentScript.src),!t)){var o=r.getElementsByTagName(\\"script\\");if(o.length)for(var n=o.length-1;n>-1&&(!t||!/^http(s?):/.test(t));)t=o[n--].src}if(!t)throw new Error(\\"Automatic publicPath is not supported in this browser\\");t=t.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),e.p=t})(),e.b=\\"undefined\\"!=typeof document&&document.baseURI||self.location.href,console.log(new URL(e(437),e.b))})();", } `; @@ -186,8 +186,8 @@ exports[`minify option should work using when the \`minify\` option is \`jsonMin exports[`minify option should work using when the \`minify\` option is \`jsonMinify\`: assets 1`] = ` Object { - "60491a50c1e5dd7216b6.json": "{\\"foo\\":\\"bar\\",\\"bar\\":[\\"baz\\"]}", - "main.js": "(()=>{var t={437(t,r,e){\\"use strict\\";t.exports=e.p+\\"60491a50c1e5dd7216b6.json\\"}},r={};function e(o){var n=r[o];if(void 0!==n)return n.exports;var c=r[o]={exports:{}};return t[o](c,c.exports,e),c.exports}e.m=t,e.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(t){if(\\"object\\"==typeof window)return window}}(),e.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r),(()=>{var t;e.g.importScripts&&(t=e.g.location+\\"\\");var r=e.g.document;if(!t&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(t=r.currentScript.src),!t)){var o=r.getElementsByTagName(\\"script\\");if(o.length)for(var n=o.length-1;n>-1&&(!t||!/^http(s?):/.test(t));)t=o[n--].src}if(!t)throw new Error(\\"Automatic publicPath is not supported in this browser\\");t=t.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),e.p=t})(),e.b=\\"undefined\\"!=typeof document&&document.baseURI||self.location.href,console.log(new URL(e(437),e.b))})();", + "[hash].json": "{\\"foo\\":\\"bar\\",\\"bar\\":[\\"baz\\"]}", + "main.js": "(()=>{var t={437(t,r,e){\\"use strict\\";t.exports=e.p+\\"[hash].json\\"}},r={};function e(o){var n=r[o];if(void 0!==n)return n.exports;var c=r[o]={exports:{}};return t[o](c,c.exports,e),c.exports}e.m=t,e.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(t){if(\\"object\\"==typeof window)return window}}(),e.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r),(()=>{var t;e.g.importScripts&&(t=e.g.location+\\"\\");var r=e.g.document;if(!t&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(t=r.currentScript.src),!t)){var o=r.getElementsByTagName(\\"script\\");if(o.length)for(var n=o.length-1;n>-1&&(!t||!/^http(s?):/.test(t));)t=o[n--].src}if(!t)throw new Error(\\"Automatic publicPath is not supported in this browser\\");t=t.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),e.p=t})(),e.b=\\"undefined\\"!=typeof document&&document.baseURI||self.location.href,console.log(new URL(e(437),e.b))})();", } `; diff --git a/test/__snapshots__/test-option.test.js.snap b/test/__snapshots__/test-option.test.js.snap index 465ce14..ed7299f 100644 --- a/test/__snapshots__/test-option.test.js.snap +++ b/test/__snapshots__/test-option.test.js.snap @@ -2,11 +2,11 @@ exports[`test option should match snapshot and uglify "mjs": assets 1`] = ` Object { - "389.389.mjs?ver=af4451db5c1e9c707647": "\\"use strict\\";(self.webpackChunkterser_webpack_plugin=self.webpackChunkterser_webpack_plugin||[]).push([[389],{389(e,s,p){p.r(s),p.d(s,{default:()=>c});const c=\\"async-dep\\"}}]);", - "AsyncImportExport.mjs?var=af4451db5c1e9c707647": "(()=>{\\"use strict\\";var e,r,t={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((r,t)=>(n.f[t](e,r),r),[])),n.u=e=>e+\\".\\"+e+\\".mjs?ver=\\"+n.h(),n.h=()=>\\"af4451db5c1e9c707647\\",n.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r=\\"terser-webpack-plugin:\\",n.l=(t,o,a,i)=>{if(e[t])e[t].push(o);else{var l,c;if(void 0!==a)for(var u=document.getElementsByTagName(\\"script\\"),s=0;s{l.onerror=l.onload=null,clearTimeout(f);var n=e[t];if(delete e[t],l.parentNode&&l.parentNode.removeChild(l),n&&n.forEach(e=>e(o)),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:\\"timeout\\",target:l}),12e4);l.onerror=d.bind(null,l.onerror),l.onload=d.bind(null,l.onload),c&&document.head.appendChild(l)}},n.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+\\"\\");var r=n.g.document;if(!e&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName(\\"script\\");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),n.p=e})(),(()=>{var e={988:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise((t,n)=>o=e[r]=[t,n]);t.push(o[2]=a);var i=n.p+n.u(r),l=new Error;n.l(i,t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&(\\"load\\"===t.type?\\"missing\\":t.type),i=t&&t.target&&t.target.src;l.message=\\"Loading chunk \\"+r+\\" failed.\\\\n(\\"+a+\\": \\"+i+\\")\\",l.name=\\"ChunkLoadError\\",l.type=a,l.request=i,o[1](l)}},\\"chunk-\\"+r,r)}};var r=(r,t)=>{var o,a,[i,l,c]=t,u=0;if(i.some(r=>0!==e[r])){for(o in l)n.o(l,o)&&(n.m[o]=l[o]);if(c)c(n)}for(r&&r(t);u{console.log(\\"Good\\")})})();", - "importExport.mjs?var=af4451db5c1e9c707647": "(()=>{\\"use strict\\";function o(){const o=\`baz\${Math.random()}\`;return()=>({a:\\"foobar\\"+o,b:\\"foo\\",baz:o})}console.log(o())})();", - "js.mjs?var=af4451db5c1e9c707647": "(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};(function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports})(921)})();", - "mjs.mjs?var=af4451db5c1e9c707647": "(()=>{\\"use strict\\";function o(){console.log(11)}o()})();", + "389.389.mjs?ver=[hash]": "\\"use strict\\";(self.webpackChunkterser_webpack_plugin=self.webpackChunkterser_webpack_plugin||[]).push([[389],{389(e,s,p){p.r(s),p.d(s,{default:()=>c});const c=\\"async-dep\\"}}]);", + "AsyncImportExport.mjs?var=[hash]": "(()=>{\\"use strict\\";var e,r,t={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((r,t)=>(n.f[t](e,r),r),[])),n.u=e=>e+\\".\\"+e+\\".mjs?ver=\\"+n.h(),n.h=()=>\\"[hash]\\",n.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r=\\"terser-webpack-plugin:\\",n.l=(t,o,a,i)=>{if(e[t])e[t].push(o);else{var l,c;if(void 0!==a)for(var u=document.getElementsByTagName(\\"script\\"),s=0;s{l.onerror=l.onload=null,clearTimeout(f);var n=e[t];if(delete e[t],l.parentNode&&l.parentNode.removeChild(l),n&&n.forEach(e=>e(o)),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:\\"timeout\\",target:l}),12e4);l.onerror=d.bind(null,l.onerror),l.onload=d.bind(null,l.onload),c&&document.head.appendChild(l)}},n.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+\\"\\");var r=n.g.document;if(!e&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName(\\"script\\");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),n.p=e})(),(()=>{var e={988:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise((t,n)=>o=e[r]=[t,n]);t.push(o[2]=a);var i=n.p+n.u(r),l=new Error;n.l(i,t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&(\\"load\\"===t.type?\\"missing\\":t.type),i=t&&t.target&&t.target.src;l.message=\\"Loading chunk \\"+r+\\" failed.\\\\n(\\"+a+\\": \\"+i+\\")\\",l.name=\\"ChunkLoadError\\",l.type=a,l.request=i,o[1](l)}},\\"chunk-\\"+r,r)}};var r=(r,t)=>{var o,a,[i,l,c]=t,u=0;if(i.some(r=>0!==e[r])){for(o in l)n.o(l,o)&&(n.m[o]=l[o]);if(c)c(n)}for(r&&r(t);u{console.log(\\"Good\\")})})();", + "importExport.mjs?var=[hash]": "(()=>{\\"use strict\\";function o(){const o=\`baz\${Math.random()}\`;return()=>({a:\\"foobar\\"+o,b:\\"foo\\",baz:o})}console.log(o())})();", + "js.mjs?var=[hash]": "(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};(function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports})(921)})();", + "mjs.mjs?var=[hash]": "(()=>{\\"use strict\\";function o(){console.log(11)}o()})();", } `; @@ -16,7 +16,7 @@ exports[`test option should match snapshot and uglify "mjs": warnings 1`] = `Arr exports[`test option should match snapshot for a single "test" value ({String}): assets 1`] = ` Object { - "389.389.js?ver=0855048f323b055bd9d2": "\\"use strict\\"; + "389.389.js?ver=[hash]": "\\"use strict\\"; (self[\\"webpackChunkterser_webpack_plugin\\"] = self[\\"webpackChunkterser_webpack_plugin\\"] || []).push([[389],{ /***/ 389 @@ -32,7 +32,7 @@ __webpack_require__.r(__webpack_exports__); /***/ } }]);", - "AsyncImportExport.js?var=0855048f323b055bd9d2": "/******/ (() => { // webpackBootstrap + "AsyncImportExport.js?var=[hash]": "/******/ (() => { // webpackBootstrap /******/ \\"use strict\\"; /******/ var __webpack_modules__ = ({}); /************************************************************************/ @@ -100,7 +100,7 @@ __webpack_require__.r(__webpack_exports__); /******/ /******/ /* webpack/runtime/getFullHash */ /******/ (() => { -/******/ __webpack_require__.h = () => (\\"0855048f323b055bd9d2\\") +/******/ __webpack_require__.h = () => (\\"[hash]\\") /******/ })(); /******/ /******/ /* webpack/runtime/global */ @@ -299,7 +299,7 @@ __webpack_require__.e(/* import() */ 389).then(__webpack_require__.bind(__webpac /******/ })() ;", - "importExport.js?var=0855048f323b055bd9d2": "/******/ (() => { // webpackBootstrap + "importExport.js?var=[hash]": "/******/ (() => { // webpackBootstrap /******/ \\"use strict\\"; // UNUSED EXPORTS: default @@ -329,8 +329,8 @@ console.log(Foo()); /******/ })() ;", - "js.js?var=0855048f323b055bd9d2": "(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};(function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports})(921)})();", - "mjs.js?var=0855048f323b055bd9d2": "/******/ (() => { // webpackBootstrap + "js.js?var=[hash]": "(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};(function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports})(921)})();", + "mjs.js?var=[hash]": "/******/ (() => { // webpackBootstrap /******/ \\"use strict\\"; // foo // bar @@ -356,7 +356,7 @@ exports[`test option should match snapshot for a single "test" value ({String}): exports[`test option should match snapshot for a single \`test\` value ({RegExp}): assets 1`] = ` Object { - "389.389.js?ver=0855048f323b055bd9d2": "\\"use strict\\"; + "389.389.js?ver=[hash]": "\\"use strict\\"; (self[\\"webpackChunkterser_webpack_plugin\\"] = self[\\"webpackChunkterser_webpack_plugin\\"] || []).push([[389],{ /***/ 389 @@ -372,7 +372,7 @@ __webpack_require__.r(__webpack_exports__); /***/ } }]);", - "AsyncImportExport.js?var=0855048f323b055bd9d2": "/******/ (() => { // webpackBootstrap + "AsyncImportExport.js?var=[hash]": "/******/ (() => { // webpackBootstrap /******/ \\"use strict\\"; /******/ var __webpack_modules__ = ({}); /************************************************************************/ @@ -440,7 +440,7 @@ __webpack_require__.r(__webpack_exports__); /******/ /******/ /* webpack/runtime/getFullHash */ /******/ (() => { -/******/ __webpack_require__.h = () => (\\"0855048f323b055bd9d2\\") +/******/ __webpack_require__.h = () => (\\"[hash]\\") /******/ })(); /******/ /******/ /* webpack/runtime/global */ @@ -639,7 +639,7 @@ __webpack_require__.e(/* import() */ 389).then(__webpack_require__.bind(__webpac /******/ })() ;", - "importExport.js?var=0855048f323b055bd9d2": "/******/ (() => { // webpackBootstrap + "importExport.js?var=[hash]": "/******/ (() => { // webpackBootstrap /******/ \\"use strict\\"; // UNUSED EXPORTS: default @@ -669,8 +669,8 @@ console.log(Foo()); /******/ })() ;", - "js.js?var=0855048f323b055bd9d2": "(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};(function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports})(921)})();", - "mjs.js?var=0855048f323b055bd9d2": "(()=>{\\"use strict\\";function o(){console.log(11)}o()})();", + "js.js?var=[hash]": "(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};(function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports})(921)})();", + "mjs.js?var=[hash]": "(()=>{\\"use strict\\";function o(){console.log(11)}o()})();", } `; @@ -680,7 +680,7 @@ exports[`test option should match snapshot for a single \`test\` value ({RegExp} exports[`test option should match snapshot for multiple "test" values ({RegExp}): assets 1`] = ` Object { - "389.389.js?ver=0855048f323b055bd9d2": "\\"use strict\\"; + "389.389.js?ver=[hash]": "\\"use strict\\"; (self[\\"webpackChunkterser_webpack_plugin\\"] = self[\\"webpackChunkterser_webpack_plugin\\"] || []).push([[389],{ /***/ 389 @@ -696,8 +696,8 @@ __webpack_require__.r(__webpack_exports__); /***/ } }]);", - "AsyncImportExport.js?var=0855048f323b055bd9d2": "(()=>{\\"use strict\\";var e,r,t={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((r,t)=>(n.f[t](e,r),r),[])),n.u=e=>e+\\".\\"+e+\\".js?ver=\\"+n.h(),n.h=()=>\\"0855048f323b055bd9d2\\",n.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r=\\"terser-webpack-plugin:\\",n.l=(t,o,a,i)=>{if(e[t])e[t].push(o);else{var l,c;if(void 0!==a)for(var u=document.getElementsByTagName(\\"script\\"),s=0;s{l.onerror=l.onload=null,clearTimeout(f);var n=e[t];if(delete e[t],l.parentNode&&l.parentNode.removeChild(l),n&&n.forEach(e=>e(o)),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:\\"timeout\\",target:l}),12e4);l.onerror=d.bind(null,l.onerror),l.onload=d.bind(null,l.onload),c&&document.head.appendChild(l)}},n.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+\\"\\");var r=n.g.document;if(!e&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName(\\"script\\");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),n.p=e})(),(()=>{var e={988:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise((t,n)=>o=e[r]=[t,n]);t.push(o[2]=a);var i=n.p+n.u(r),l=new Error;n.l(i,t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&(\\"load\\"===t.type?\\"missing\\":t.type),i=t&&t.target&&t.target.src;l.message=\\"Loading chunk \\"+r+\\" failed.\\\\n(\\"+a+\\": \\"+i+\\")\\",l.name=\\"ChunkLoadError\\",l.type=a,l.request=i,o[1](l)}},\\"chunk-\\"+r,r)}};var r=(r,t)=>{var o,a,[i,l,c]=t,u=0;if(i.some(r=>0!==e[r])){for(o in l)n.o(l,o)&&(n.m[o]=l[o]);if(c)c(n)}for(r&&r(t);u{console.log(\\"Good\\")})})();", - "importExport.js?var=0855048f323b055bd9d2": "/******/ (() => { // webpackBootstrap + "AsyncImportExport.js?var=[hash]": "(()=>{\\"use strict\\";var e,r,t={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((r,t)=>(n.f[t](e,r),r),[])),n.u=e=>e+\\".\\"+e+\\".js?ver=\\"+n.h(),n.h=()=>\\"[hash]\\",n.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r=\\"terser-webpack-plugin:\\",n.l=(t,o,a,i)=>{if(e[t])e[t].push(o);else{var l,c;if(void 0!==a)for(var u=document.getElementsByTagName(\\"script\\"),s=0;s{l.onerror=l.onload=null,clearTimeout(f);var n=e[t];if(delete e[t],l.parentNode&&l.parentNode.removeChild(l),n&&n.forEach(e=>e(o)),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:\\"timeout\\",target:l}),12e4);l.onerror=d.bind(null,l.onerror),l.onload=d.bind(null,l.onload),c&&document.head.appendChild(l)}},n.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+\\"\\");var r=n.g.document;if(!e&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName(\\"script\\");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),n.p=e})(),(()=>{var e={988:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise((t,n)=>o=e[r]=[t,n]);t.push(o[2]=a);var i=n.p+n.u(r),l=new Error;n.l(i,t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&(\\"load\\"===t.type?\\"missing\\":t.type),i=t&&t.target&&t.target.src;l.message=\\"Loading chunk \\"+r+\\" failed.\\\\n(\\"+a+\\": \\"+i+\\")\\",l.name=\\"ChunkLoadError\\",l.type=a,l.request=i,o[1](l)}},\\"chunk-\\"+r,r)}};var r=(r,t)=>{var o,a,[i,l,c]=t,u=0;if(i.some(r=>0!==e[r])){for(o in l)n.o(l,o)&&(n.m[o]=l[o]);if(c)c(n)}for(r&&r(t);u{console.log(\\"Good\\")})})();", + "importExport.js?var=[hash]": "/******/ (() => { // webpackBootstrap /******/ \\"use strict\\"; // UNUSED EXPORTS: default @@ -727,8 +727,8 @@ console.log(Foo()); /******/ })() ;", - "js.js?var=0855048f323b055bd9d2": "(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};(function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports})(921)})();", - "mjs.js?var=0855048f323b055bd9d2": "(()=>{\\"use strict\\";function o(){console.log(11)}o()})();", + "js.js?var=[hash]": "(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};(function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports})(921)})();", + "mjs.js?var=[hash]": "(()=>{\\"use strict\\";function o(){console.log(11)}o()})();", } `; @@ -738,7 +738,7 @@ exports[`test option should match snapshot for multiple "test" values ({RegExp}) exports[`test option should match snapshot for multiple "test" values ({String}): assets 1`] = ` Object { - "389.389.js?ver=0855048f323b055bd9d2": "\\"use strict\\"; + "389.389.js?ver=[hash]": "\\"use strict\\"; (self[\\"webpackChunkterser_webpack_plugin\\"] = self[\\"webpackChunkterser_webpack_plugin\\"] || []).push([[389],{ /***/ 389 @@ -754,8 +754,8 @@ __webpack_require__.r(__webpack_exports__); /***/ } }]);", - "AsyncImportExport.js?var=0855048f323b055bd9d2": "(()=>{\\"use strict\\";var e,r,t={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((r,t)=>(n.f[t](e,r),r),[])),n.u=e=>e+\\".\\"+e+\\".js?ver=\\"+n.h(),n.h=()=>\\"0855048f323b055bd9d2\\",n.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r=\\"terser-webpack-plugin:\\",n.l=(t,o,a,i)=>{if(e[t])e[t].push(o);else{var l,c;if(void 0!==a)for(var u=document.getElementsByTagName(\\"script\\"),s=0;s{l.onerror=l.onload=null,clearTimeout(f);var n=e[t];if(delete e[t],l.parentNode&&l.parentNode.removeChild(l),n&&n.forEach(e=>e(o)),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:\\"timeout\\",target:l}),12e4);l.onerror=d.bind(null,l.onerror),l.onload=d.bind(null,l.onload),c&&document.head.appendChild(l)}},n.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+\\"\\");var r=n.g.document;if(!e&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName(\\"script\\");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),n.p=e})(),(()=>{var e={988:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise((t,n)=>o=e[r]=[t,n]);t.push(o[2]=a);var i=n.p+n.u(r),l=new Error;n.l(i,t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&(\\"load\\"===t.type?\\"missing\\":t.type),i=t&&t.target&&t.target.src;l.message=\\"Loading chunk \\"+r+\\" failed.\\\\n(\\"+a+\\": \\"+i+\\")\\",l.name=\\"ChunkLoadError\\",l.type=a,l.request=i,o[1](l)}},\\"chunk-\\"+r,r)}};var r=(r,t)=>{var o,a,[i,l,c]=t,u=0;if(i.some(r=>0!==e[r])){for(o in l)n.o(l,o)&&(n.m[o]=l[o]);if(c)c(n)}for(r&&r(t);u{console.log(\\"Good\\")})})();", - "importExport.js?var=0855048f323b055bd9d2": "/******/ (() => { // webpackBootstrap + "AsyncImportExport.js?var=[hash]": "(()=>{\\"use strict\\";var e,r,t={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((r,t)=>(n.f[t](e,r),r),[])),n.u=e=>e+\\".\\"+e+\\".js?ver=\\"+n.h(),n.h=()=>\\"[hash]\\",n.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r=\\"terser-webpack-plugin:\\",n.l=(t,o,a,i)=>{if(e[t])e[t].push(o);else{var l,c;if(void 0!==a)for(var u=document.getElementsByTagName(\\"script\\"),s=0;s{l.onerror=l.onload=null,clearTimeout(f);var n=e[t];if(delete e[t],l.parentNode&&l.parentNode.removeChild(l),n&&n.forEach(e=>e(o)),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:\\"timeout\\",target:l}),12e4);l.onerror=d.bind(null,l.onerror),l.onload=d.bind(null,l.onload),c&&document.head.appendChild(l)}},n.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+\\"\\");var r=n.g.document;if(!e&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName(\\"script\\");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),n.p=e})(),(()=>{var e={988:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise((t,n)=>o=e[r]=[t,n]);t.push(o[2]=a);var i=n.p+n.u(r),l=new Error;n.l(i,t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&(\\"load\\"===t.type?\\"missing\\":t.type),i=t&&t.target&&t.target.src;l.message=\\"Loading chunk \\"+r+\\" failed.\\\\n(\\"+a+\\": \\"+i+\\")\\",l.name=\\"ChunkLoadError\\",l.type=a,l.request=i,o[1](l)}},\\"chunk-\\"+r,r)}};var r=(r,t)=>{var o,a,[i,l,c]=t,u=0;if(i.some(r=>0!==e[r])){for(o in l)n.o(l,o)&&(n.m[o]=l[o]);if(c)c(n)}for(r&&r(t);u{console.log(\\"Good\\")})})();", + "importExport.js?var=[hash]": "/******/ (() => { // webpackBootstrap /******/ \\"use strict\\"; // UNUSED EXPORTS: default @@ -785,8 +785,8 @@ console.log(Foo()); /******/ })() ;", - "js.js?var=0855048f323b055bd9d2": "(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};(function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports})(921)})();", - "mjs.js?var=0855048f323b055bd9d2": "/******/ (() => { // webpackBootstrap + "js.js?var=[hash]": "(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};(function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports})(921)})();", + "mjs.js?var=[hash]": "/******/ (() => { // webpackBootstrap /******/ \\"use strict\\"; // foo // bar @@ -812,11 +812,11 @@ exports[`test option should match snapshot for multiple "test" values ({String}) exports[`test option should match snapshot with empty value: assets 1`] = ` Object { - "389.389.js?ver=0855048f323b055bd9d2": "\\"use strict\\";(self.webpackChunkterser_webpack_plugin=self.webpackChunkterser_webpack_plugin||[]).push([[389],{389(e,s,p){p.r(s),p.d(s,{default:()=>c});const c=\\"async-dep\\"}}]);", - "AsyncImportExport.js?var=0855048f323b055bd9d2": "(()=>{\\"use strict\\";var e,r,t={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((r,t)=>(n.f[t](e,r),r),[])),n.u=e=>e+\\".\\"+e+\\".js?ver=\\"+n.h(),n.h=()=>\\"0855048f323b055bd9d2\\",n.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r=\\"terser-webpack-plugin:\\",n.l=(t,o,a,i)=>{if(e[t])e[t].push(o);else{var l,c;if(void 0!==a)for(var u=document.getElementsByTagName(\\"script\\"),s=0;s{l.onerror=l.onload=null,clearTimeout(f);var n=e[t];if(delete e[t],l.parentNode&&l.parentNode.removeChild(l),n&&n.forEach(e=>e(o)),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:\\"timeout\\",target:l}),12e4);l.onerror=d.bind(null,l.onerror),l.onload=d.bind(null,l.onload),c&&document.head.appendChild(l)}},n.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+\\"\\");var r=n.g.document;if(!e&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName(\\"script\\");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),n.p=e})(),(()=>{var e={988:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise((t,n)=>o=e[r]=[t,n]);t.push(o[2]=a);var i=n.p+n.u(r),l=new Error;n.l(i,t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&(\\"load\\"===t.type?\\"missing\\":t.type),i=t&&t.target&&t.target.src;l.message=\\"Loading chunk \\"+r+\\" failed.\\\\n(\\"+a+\\": \\"+i+\\")\\",l.name=\\"ChunkLoadError\\",l.type=a,l.request=i,o[1](l)}},\\"chunk-\\"+r,r)}};var r=(r,t)=>{var o,a,[i,l,c]=t,u=0;if(i.some(r=>0!==e[r])){for(o in l)n.o(l,o)&&(n.m[o]=l[o]);if(c)c(n)}for(r&&r(t);u{console.log(\\"Good\\")})})();", - "importExport.js?var=0855048f323b055bd9d2": "(()=>{\\"use strict\\";function o(){const o=\`baz\${Math.random()}\`;return()=>({a:\\"foobar\\"+o,b:\\"foo\\",baz:o})}console.log(o())})();", - "js.js?var=0855048f323b055bd9d2": "(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};(function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports})(921)})();", - "mjs.js?var=0855048f323b055bd9d2": "(()=>{\\"use strict\\";function o(){console.log(11)}o()})();", + "389.389.js?ver=[hash]": "\\"use strict\\";(self.webpackChunkterser_webpack_plugin=self.webpackChunkterser_webpack_plugin||[]).push([[389],{389(e,s,p){p.r(s),p.d(s,{default:()=>c});const c=\\"async-dep\\"}}]);", + "AsyncImportExport.js?var=[hash]": "(()=>{\\"use strict\\";var e,r,t={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((r,t)=>(n.f[t](e,r),r),[])),n.u=e=>e+\\".\\"+e+\\".js?ver=\\"+n.h(),n.h=()=>\\"[hash]\\",n.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r=\\"terser-webpack-plugin:\\",n.l=(t,o,a,i)=>{if(e[t])e[t].push(o);else{var l,c;if(void 0!==a)for(var u=document.getElementsByTagName(\\"script\\"),s=0;s{l.onerror=l.onload=null,clearTimeout(f);var n=e[t];if(delete e[t],l.parentNode&&l.parentNode.removeChild(l),n&&n.forEach(e=>e(o)),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:\\"timeout\\",target:l}),12e4);l.onerror=d.bind(null,l.onerror),l.onload=d.bind(null,l.onload),c&&document.head.appendChild(l)}},n.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+\\"\\");var r=n.g.document;if(!e&&r&&(r.currentScript&&\\"SCRIPT\\"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName(\\"script\\");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error(\\"Automatic publicPath is not supported in this browser\\");e=e.replace(/^blob:/,\\"\\").replace(/#.*$/,\\"\\").replace(/\\\\?.*$/,\\"\\").replace(/\\\\/[^\\\\/]+$/,\\"/\\"),n.p=e})(),(()=>{var e={988:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise((t,n)=>o=e[r]=[t,n]);t.push(o[2]=a);var i=n.p+n.u(r),l=new Error;n.l(i,t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&(\\"load\\"===t.type?\\"missing\\":t.type),i=t&&t.target&&t.target.src;l.message=\\"Loading chunk \\"+r+\\" failed.\\\\n(\\"+a+\\": \\"+i+\\")\\",l.name=\\"ChunkLoadError\\",l.type=a,l.request=i,o[1](l)}},\\"chunk-\\"+r,r)}};var r=(r,t)=>{var o,a,[i,l,c]=t,u=0;if(i.some(r=>0!==e[r])){for(o in l)n.o(l,o)&&(n.m[o]=l[o]);if(c)c(n)}for(r&&r(t);u{console.log(\\"Good\\")})})();", + "importExport.js?var=[hash]": "(()=>{\\"use strict\\";function o(){const o=\`baz\${Math.random()}\`;return()=>({a:\\"foobar\\"+o,b:\\"foo\\",baz:o})}console.log(o())})();", + "js.js?var=[hash]": "(()=>{var r={921(r){r.exports=function(){console.log(7)}}},o={};(function t(e){var n=o[e];if(void 0!==n)return n.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,t),s.exports})(921)})();", + "mjs.js?var=[hash]": "(()=>{\\"use strict\\";function o(){console.log(11)}o()})();", } `; diff --git a/test/helpers/countPlugins.js b/test/helpers/countPlugins.js index bf012de..3083917 100644 --- a/test/helpers/countPlugins.js +++ b/test/helpers/countPlugins.js @@ -1,13 +1,20 @@ /** * @param {object} root0 options * @param {import("tapable").Hook[]} root0.hooks hooks + * @param {string=} pluginName plugin name filter * @returns {number} count of plugins */ -export default function countPlugins({ hooks }) { +export default function countPlugins({ hooks }, pluginName) { return Object.keys(hooks).reduce((aggregate, name) => { - aggregate[name] = Array.isArray(hooks[name].taps) - ? hooks[name].taps.length - : 0; + const taps = Array.isArray(hooks[name].taps) ? hooks[name].taps : []; + const count = pluginName + ? taps.filter((tap) => tap.name === pluginName).length + : taps.length; + + if (!pluginName || count > 0) { + aggregate[name] = count; + } + return aggregate; }, {}); } diff --git a/test/helpers/normalizeBuildOutput.js b/test/helpers/normalizeBuildOutput.js new file mode 100644 index 0000000..d7314c6 --- /dev/null +++ b/test/helpers/normalizeBuildOutput.js @@ -0,0 +1,12 @@ +const WEBPACK_HASH_PATTERN = /\b[a-f0-9]{20,64}\b/giu; + +/** + * Snapshot tests should assert build structure, not unstable webpack digests. + * CI runs pull request merge commits and older Node.js jobs resolve a slightly + * different dependency tree, so raw hash values are expected to drift. + * @param {string} value value + * @returns {string} value with normalized webpack hashes + */ +export default function normalizeBuildOutput(value) { + return value.replace(WEBPACK_HASH_PATTERN, "[hash]"); +} diff --git a/test/helpers/readAssets.js b/test/helpers/readAssets.js index 054357c..cdd9ad6 100644 --- a/test/helpers/readAssets.js +++ b/test/helpers/readAssets.js @@ -1,3 +1,4 @@ +import normalizeBuildOutput from "./normalizeBuildOutput"; import readAsset from "./readAsset"; /** @@ -9,7 +10,9 @@ export default function readAssets(compiler, stats) { const assets = {}; for (const asset of Object.keys(stats.compilation.assets)) { - assets[asset] = readAsset(asset, compiler, stats); + assets[normalizeBuildOutput(asset)] = normalizeBuildOutput( + readAsset(asset, compiler, stats), + ); } return assets;