From e7c55831de4c7903b63ca3efe413087984823457 Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Tue, 26 Apr 2022 09:34:51 -0700 Subject: [PATCH 01/38] hoist regexp literals in SourceMapDerToolPlugin --- lib/SourceMapDevToolPlugin.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/SourceMapDevToolPlugin.js b/lib/SourceMapDevToolPlugin.js index fc5a3dcf287..ce67713d6a4 100644 --- a/lib/SourceMapDevToolPlugin.js +++ b/lib/SourceMapDevToolPlugin.js @@ -47,13 +47,21 @@ const validate = createSchemaValidation( * @property {ItemCacheFacade} cacheItem cache item */ +const METACHARACTERS_REGEXP = /[-[\]\\/{}()*+?.^$|]/g; +const CONTENT_HASH_DETECT_REGEXP = /\[contenthash(:\w+)?\]/; +const CSS_AND_JS_MODULE_EXTENSIONS_REGEXP = /\.((c|m)?js|css)($|\?)/i; +const CSS_EXTENSION_DETECT_REGEXP = /\.css($|\?)/i; +const MAP_URL_COMMENT_REGEXP = /\[map\]/g; +const URL_COMMENT_REGEXP = /\[url\]/g; +const URL_FORMATTING_REGEXP = /^\n\/\/(.*)$/; + /** * Escapes regular expression metacharacters * @param {string} str String to quote * @returns {string} Escaped string */ const quoteMeta = str => { - return str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&"); + return str.replace(METACHARACTERS_REGEXP, "\\$&"); }; /** @@ -152,7 +160,7 @@ class SourceMapDevToolPlugin { const fallbackModuleFilenameTemplate = this.fallbackModuleFilenameTemplate; const requestShortener = compiler.requestShortener; const options = this.options; - options.test = options.test || /\.((c|m)?js|css)($|\?)/i; + options.test = options.test || CSS_AND_JS_MODULE_EXTENSIONS_REGEXP; const matchObject = ModuleFilenameHelpers.matchObject.bind( undefined, @@ -409,7 +417,7 @@ class SourceMapDevToolPlugin { sourceMap.file = file; const usesContentHash = sourceMapFilename && - /\[contenthash(:\w+)?\]/.test(sourceMapFilename); + CONTENT_HASH_DETECT_REGEXP.test(sourceMapFilename); // If SourceMap and asset uses contenthash, avoid a circular dependency by hiding hash in `file` if (usesContentHash && task.assetInfo.contenthash) { @@ -430,11 +438,11 @@ class SourceMapDevToolPlugin { let currentSourceMappingURLComment = sourceMappingURLComment; if ( currentSourceMappingURLComment !== false && - /\.css($|\?)/i.test(file) + CSS_EXTENSION_DETECT_REGEXP.test(file) ) { currentSourceMappingURLComment = currentSourceMappingURLComment.replace( - /^\n\/\/(.*)$/, + URL_FORMATTING_REGEXP, "\n/*$1*/" ); } @@ -516,9 +524,9 @@ class SourceMapDevToolPlugin { const asset = new ConcatSource( new RawSource(source), currentSourceMappingURLComment - .replace(/\[map\]/g, () => sourceMapString) + .replace(MAP_URL_COMMENT_REGEXP, () => sourceMapString) .replace( - /\[url\]/g, + URL_COMMENT_REGEXP, () => `data:application/json;charset=utf-8;base64,${Buffer.from( sourceMapString, From 5e31761419bf9c1c4080d375da0ef4d85f684bcf Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Tue, 26 Apr 2022 13:46:26 -0700 Subject: [PATCH 02/38] reset state for stateful regexp --- lib/SourceMapDevToolPlugin.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/SourceMapDevToolPlugin.js b/lib/SourceMapDevToolPlugin.js index ce67713d6a4..49ebabc9b30 100644 --- a/lib/SourceMapDevToolPlugin.js +++ b/lib/SourceMapDevToolPlugin.js @@ -55,6 +55,17 @@ const MAP_URL_COMMENT_REGEXP = /\[map\]/g; const URL_COMMENT_REGEXP = /\[url\]/g; const URL_FORMATTING_REGEXP = /^\n\/\/(.*)$/; +/** + * Reset's .lastIndex of stateful Regular Expressions + * For when `test` or `exec` is called on them + * @param {RegExp} regexp Stateful Regular Expression to be reset + * @returns {void} + * + */ +const resetRegexpState = regexp => { + regexp.lastIndex = -1; +}; + /** * Escapes regular expression metacharacters * @param {string} str String to quote @@ -419,6 +430,8 @@ class SourceMapDevToolPlugin { sourceMapFilename && CONTENT_HASH_DETECT_REGEXP.test(sourceMapFilename); + resetRegexpState(CONTENT_HASH_DETECT_REGEXP); + // If SourceMap and asset uses contenthash, avoid a circular dependency by hiding hash in `file` if (usesContentHash && task.assetInfo.contenthash) { const contenthash = task.assetInfo.contenthash; @@ -436,9 +449,12 @@ class SourceMapDevToolPlugin { /** @type {string | false} */ let currentSourceMappingURLComment = sourceMappingURLComment; + let cssExtensionDetected = + CSS_EXTENSION_DETECT_REGEXP.test(file); + resetRegexpState(CSS_EXTENSION_DETECT_REGEXP); if ( currentSourceMappingURLComment !== false && - CSS_EXTENSION_DETECT_REGEXP.test(file) + cssExtensionDetected ) { currentSourceMappingURLComment = currentSourceMappingURLComment.replace( From 8d66aa7bc63b2d2efa59c7b70eb0d6f526a06b45 Mon Sep 17 00:00:00 2001 From: Akhil G Krishnan Date: Mon, 7 Nov 2022 15:09:11 +0530 Subject: [PATCH 03/38] Bump the loader-utils version to 2.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 769674d939d..e4ccc601e14 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "less": "^4.0.0", "less-loader": "^8.0.0", "lint-staged": "^11.0.0", - "loader-utils": "^2.0.0", + "loader-utils": "^2.0.3", "lodash": "^4.17.19", "lodash-es": "^4.17.15", "memfs": "^3.2.0", From 139d1b4ff0a150ada8aa188a6a11432674865d42 Mon Sep 17 00:00:00 2001 From: Akhil G Krishnan Date: Thu, 10 Nov 2022 15:25:12 +0530 Subject: [PATCH 04/38] Yarn lock updated --- yarn.lock | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/yarn.lock b/yarn.lock index 951cf8d49d0..19e410685b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4163,6 +4163,15 @@ loader-utils@^2.0.0: emojis-list "^3.0.0" json5 "^2.1.2" +loader-utils@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.3.tgz#d4b15b8504c63d1fc3f2ade52d41bc8459d6ede1" + integrity sha512-THWqIsn8QRnvLl0shHYVBN9syumU8pYWEHPTmkiVGd+7K5eFNVSY6AJhRvgGF70gg1Dz+l/k8WicvFCxdEs60A== + dependencies: + big.js "^5.2.2" + emojis-list "^3.0.0" + json5 "^2.1.2" + locate-path@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" From 960a025f1d219b512da2b8b7d365fa5f6148ed61 Mon Sep 17 00:00:00 2001 From: Akhil G Krishnan Date: Thu, 10 Nov 2022 15:31:00 +0530 Subject: [PATCH 05/38] Yarn lint issue fix --- yarn.lock | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/yarn.lock b/yarn.lock index 19e410685b4..14ea915aa37 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4154,16 +4154,7 @@ loader-utils@^1.1.0, loader-utils@^1.4.0: emojis-list "^3.0.0" json5 "^1.0.1" -loader-utils@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0" - integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ== - dependencies: - big.js "^5.2.2" - emojis-list "^3.0.0" - json5 "^2.1.2" - -loader-utils@^2.0.3: +loader-utils@^2.0.0, loader-utils@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.3.tgz#d4b15b8504c63d1fc3f2ade52d41bc8459d6ede1" integrity sha512-THWqIsn8QRnvLl0shHYVBN9syumU8pYWEHPTmkiVGd+7K5eFNVSY6AJhRvgGF70gg1Dz+l/k8WicvFCxdEs60A== From 04c2737a2987a8f757ead83b680db08f79816325 Mon Sep 17 00:00:00 2001 From: "yanyuhao.joy" Date: Fri, 18 Nov 2022 16:32:49 +0800 Subject: [PATCH 06/38] chore: Remove redundant semicolons after onScriptComplete function close: #16346add route match --- lib/runtime/LoadScriptRuntimeModule.js | 3 +- .../StatsTestCases.basictest.js.snap | 116 +++++++++--------- 2 files changed, 59 insertions(+), 60 deletions(-) diff --git a/lib/runtime/LoadScriptRuntimeModule.js b/lib/runtime/LoadScriptRuntimeModule.js index b483e977cca..4781bab8be1 100644 --- a/lib/runtime/LoadScriptRuntimeModule.js +++ b/lib/runtime/LoadScriptRuntimeModule.js @@ -146,8 +146,7 @@ class LoadScriptRuntimeModule extends HelperRuntimeModule { )});`, "if(prev) return prev(event);" ]) - ) + - ";", + ), `var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), ${loadTimeout});`, "script.onerror = onScriptComplete.bind(null, script.onerror);", "script.onload = onScriptComplete.bind(null, script.onload);", diff --git a/test/__snapshots__/StatsTestCases.basictest.js.snap b/test/__snapshots__/StatsTestCases.basictest.js.snap index 6e0bc633064..792fb84f001 100644 --- a/test/__snapshots__/StatsTestCases.basictest.js.snap +++ b/test/__snapshots__/StatsTestCases.basictest.js.snap @@ -3,12 +3,12 @@ exports[`StatsTestCases should print correct stats for aggressive-splitting-entry 1`] = ` "fitting: PublicPath: auto - asset fitting-7287b3126510b3ba1197.js 16.1 KiB [emitted] [immutable] + asset fitting-27df06fdbf7adbff38d6.js 16.1 KiB [emitted] [immutable] asset fitting-50595d23e8f97d7ccd2a.js 1.9 KiB [emitted] [immutable] asset fitting-5bc77880fdc9e2bf09ee.js 1.9 KiB [emitted] [immutable] asset fitting-72afdc913f6cf884b457.js 1.08 KiB [emitted] [immutable] - Entrypoint main 19.9 KiB = fitting-50595d23e8f97d7ccd2a.js 1.9 KiB fitting-5bc77880fdc9e2bf09ee.js 1.9 KiB fitting-7287b3126510b3ba1197.js 16.1 KiB - chunk (runtime: main) fitting-7287b3126510b3ba1197.js 1.87 KiB (javascript) 8.65 KiB (runtime) [entry] [rendered] + Entrypoint main 19.9 KiB = fitting-50595d23e8f97d7ccd2a.js 1.9 KiB fitting-5bc77880fdc9e2bf09ee.js 1.9 KiB fitting-27df06fdbf7adbff38d6.js 16.1 KiB + chunk (runtime: main) fitting-27df06fdbf7adbff38d6.js 1.87 KiB (javascript) 8.65 KiB (runtime) [entry] [rendered] > ./index main runtime modules 8.65 KiB 11 modules cacheable modules 1.87 KiB @@ -30,12 +30,12 @@ exports[`StatsTestCases should print correct stats for aggressive-splitting-entr content-change: PublicPath: auto - asset content-change-8d02d3f29ce2746961bb.js 16.1 KiB [emitted] [immutable] + asset content-change-ea14516bfb79836da4ae.js 16.1 KiB [emitted] [immutable] asset content-change-50595d23e8f97d7ccd2a.js 1.9 KiB [emitted] [immutable] asset content-change-5bc77880fdc9e2bf09ee.js 1.9 KiB [emitted] [immutable] asset content-change-72afdc913f6cf884b457.js 1.08 KiB [emitted] [immutable] - Entrypoint main 19.9 KiB = content-change-50595d23e8f97d7ccd2a.js 1.9 KiB content-change-5bc77880fdc9e2bf09ee.js 1.9 KiB content-change-8d02d3f29ce2746961bb.js 16.1 KiB - chunk (runtime: main) content-change-8d02d3f29ce2746961bb.js 1.87 KiB (javascript) 8.66 KiB (runtime) [entry] [rendered] + Entrypoint main 19.9 KiB = content-change-50595d23e8f97d7ccd2a.js 1.9 KiB content-change-5bc77880fdc9e2bf09ee.js 1.9 KiB content-change-ea14516bfb79836da4ae.js 16.1 KiB + chunk (runtime: main) content-change-ea14516bfb79836da4ae.js 1.87 KiB (javascript) 8.66 KiB (runtime) [entry] [rendered] > ./index main runtime modules 8.66 KiB 11 modules cacheable modules 1.87 KiB @@ -58,7 +58,7 @@ content-change: exports[`StatsTestCases should print correct stats for aggressive-splitting-on-demand 1`] = ` "PublicPath: auto -asset 47d8091c27bf6f3a2e25.js 11.6 KiB [emitted] [immutable] (name: main) +asset abdecc928f4f9878244e.js 11.6 KiB [emitted] [immutable] (name: main) asset 3fc6535262efa7e4fa3b.js 1.91 KiB [emitted] [immutable] asset 56815935c535fbc0e462.js 1.91 KiB [emitted] [immutable] asset 2b8c8882bd4326b27013.js 1.9 KiB [emitted] [immutable] @@ -70,12 +70,12 @@ asset f79c60cc3faba968a476.js 1.9 KiB [emitted] [immutable] asset 7294786e49319a98f5af.js 1010 bytes [emitted] [immutable] asset c5861419d7f3f6ea6c19.js 1010 bytes [emitted] [immutable] asset f897ac9956540163d002.js 1010 bytes [emitted] [immutable] -Entrypoint main 11.6 KiB = 47d8091c27bf6f3a2e25.js +Entrypoint main 11.6 KiB = abdecc928f4f9878244e.js chunk (runtime: main) 5bc77880fdc9e2bf09ee.js 1.76 KiB [rendered] [recorded] aggressive splitted > ./c ./d ./e ./index.js 3:0-30 ./c.js 899 bytes [built] [code generated] ./d.js 899 bytes [built] [code generated] -chunk (runtime: main) 47d8091c27bf6f3a2e25.js (main) 248 bytes (javascript) 6.31 KiB (runtime) [entry] [rendered] +chunk (runtime: main) abdecc928f4f9878244e.js (main) 248 bytes (javascript) 6.31 KiB (runtime) [entry] [rendered] > ./index main runtime modules 6.31 KiB 7 modules ./index.js 248 bytes [built] [code generated] @@ -191,9 +191,9 @@ webpack x.x.x compiled successfully in X ms" `; exports[`StatsTestCases should print correct stats for async-commons-chunk 1`] = ` -"chunk (runtime: main) main.js (main) 515 bytes (javascript) 6 KiB (runtime) >{460}< >{847}< >{996}< [entry] [rendered] +"chunk (runtime: main) main.js (main) 515 bytes (javascript) 5.99 KiB (runtime) >{460}< >{847}< >{996}< [entry] [rendered] > ./ main - runtime modules 6 KiB 7 modules + runtime modules 5.99 KiB 7 modules ./index.js 515 bytes [built] [code generated] chunk (runtime: main) 460.js 21 bytes <{179}> ={847}= [rendered] > ./index.js 17:1-21:3 @@ -220,9 +220,9 @@ exports[`StatsTestCases should print correct stats for async-commons-chunk-auto > ./g ./a.js 6:0-47 dependent modules 20 bytes [dependent] 1 module ./g.js 45 bytes [built] [code generated] - chunk (runtime: main) disabled/main.js (main) 147 bytes (javascript) 6.65 KiB (runtime) [entry] [rendered] + chunk (runtime: main) disabled/main.js (main) 147 bytes (javascript) 6.64 KiB (runtime) [entry] [rendered] > ./ main - runtime modules 6.65 KiB 9 modules + runtime modules 6.64 KiB 9 modules ./index.js 147 bytes [built] [code generated] chunk (runtime: main) disabled/async-b.js (async-b) 196 bytes [rendered] > ./b ./index.js 2:0-47 @@ -290,9 +290,9 @@ default: chunk (runtime: main) default/769.js (id hint: vendors) 20 bytes [rendered] split chunk (cache group: defaultVendors) > ./c ./index.js 3:0-47 ./node_modules/z.js 20 bytes [built] [code generated] - chunk (runtime: a) default/a.js (a) 245 bytes (javascript) 6.65 KiB (runtime) [entry] [rendered] + chunk (runtime: a) default/a.js (a) 245 bytes (javascript) 6.64 KiB (runtime) [entry] [rendered] > ./a a - runtime modules 6.65 KiB 9 modules + runtime modules 6.64 KiB 9 modules dependent modules 60 bytes [dependent] 3 modules ./a.js + 1 modules 185 bytes [built] [code generated] chunk (runtime: main) default/async-a.js (async-a) 185 bytes [rendered] @@ -753,8 +753,8 @@ exports[`StatsTestCases should print correct stats for concat-and-sideeffects 1` `; exports[`StatsTestCases should print correct stats for context-independence 1`] = ` -"asset main-c9ce622840ffef9b8560.js 12.7 KiB [emitted] [immutable] (name: main) - sourceMap main-c9ce622840ffef9b8560.js.map 11 KiB [emitted] [dev] (auxiliary name: main) +"asset main-5fe8293e1c67cc6234cb.js 12.7 KiB [emitted] [immutable] (name: main) + sourceMap main-5fe8293e1c67cc6234cb.js.map 11 KiB [emitted] [dev] (auxiliary name: main) asset 695-4dd37417c69a0af66bac.js 455 bytes [emitted] [immutable] sourceMap 695-4dd37417c69a0af66bac.js.map 342 bytes [emitted] [dev] runtime modules 6.59 KiB 9 modules @@ -769,8 +769,8 @@ built modules 500 bytes [built] ./a/chunk.js + 1 modules (in Xdir/context-independence/a) 66 bytes [built] [code generated] webpack x.x.x compiled successfully in X ms -asset main-c9ce622840ffef9b8560.js 12.7 KiB [emitted] [immutable] (name: main) - sourceMap main-c9ce622840ffef9b8560.js.map 11 KiB [emitted] [dev] (auxiliary name: main) +asset main-5fe8293e1c67cc6234cb.js 12.7 KiB [emitted] [immutable] (name: main) + sourceMap main-5fe8293e1c67cc6234cb.js.map 11 KiB [emitted] [dev] (auxiliary name: main) asset 695-4dd37417c69a0af66bac.js 455 bytes [emitted] [immutable] sourceMap 695-4dd37417c69a0af66bac.js.map 342 bytes [emitted] [dev] runtime modules 6.59 KiB 9 modules @@ -785,7 +785,7 @@ built modules 500 bytes [built] ./b/chunk.js + 1 modules (in Xdir/context-independence/b) 66 bytes [built] [code generated] webpack x.x.x compiled successfully in X ms -asset main-6fe9478fbece50724f14.js 14.8 KiB [emitted] [immutable] (name: main) +asset main-7c4bd4d93894bc8263e9.js 14.8 KiB [emitted] [immutable] (name: main) asset 695-828eb5c7418e1b8270bb.js 1.5 KiB [emitted] [immutable] runtime modules 6.59 KiB 9 modules orphan modules 19 bytes [orphan] 1 module @@ -799,7 +799,7 @@ built modules 500 bytes [built] ./a/chunk.js + 1 modules (in Xdir/context-independence/a) 66 bytes [built] [code generated] webpack x.x.x compiled successfully in X ms -asset main-6fe9478fbece50724f14.js 14.8 KiB [emitted] [immutable] (name: main) +asset main-7c4bd4d93894bc8263e9.js 14.8 KiB [emitted] [immutable] (name: main) asset 695-828eb5c7418e1b8270bb.js 1.5 KiB [emitted] [immutable] runtime modules 6.59 KiB 9 modules orphan modules 19 bytes [orphan] 1 module @@ -813,7 +813,7 @@ built modules 500 bytes [built] ./b/chunk.js + 1 modules (in Xdir/context-independence/b) 66 bytes [built] [code generated] webpack x.x.x compiled successfully in X ms -asset main-dab0773b873a912c8caa.js 13.7 KiB [emitted] [immutable] (name: main) +asset main-7dd3306e33267a41ff55.js 13.7 KiB [emitted] [immutable] (name: main) asset 695-ace208366ce0ce2556ef.js 1.01 KiB [emitted] [immutable] runtime modules 6.59 KiB 9 modules orphan modules 19 bytes [orphan] 1 module @@ -827,7 +827,7 @@ built modules 500 bytes [built] ./a/chunk.js + 1 modules (in Xdir/context-independence/a) 66 bytes [built] [code generated] webpack x.x.x compiled successfully in X ms -asset main-dab0773b873a912c8caa.js 13.7 KiB [emitted] [immutable] (name: main) +asset main-7dd3306e33267a41ff55.js 13.7 KiB [emitted] [immutable] (name: main) asset 695-ace208366ce0ce2556ef.js 1.01 KiB [emitted] [immutable] runtime modules 6.59 KiB 9 modules orphan modules 19 bytes [orphan] 1 module @@ -1179,7 +1179,7 @@ webpack x.x.x compiled with 2 warnings in X ms" `; exports[`StatsTestCases should print correct stats for immutable 1`] = ` -"asset 3d65ee71fc9f53a687bd.js 13.3 KiB [emitted] [immutable] (name: main) +"asset 5d45ce8c58c0be47d4b1.js 13.3 KiB [emitted] [immutable] (name: main) asset 22c24a3b26d46118dc06.js 809 bytes [emitted] [immutable]" `; @@ -1269,10 +1269,10 @@ webpack x.x.x compiled successfully in X ms assets by chunk 895 bytes (id hint: all) asset c-all-b_js-d2d64fdaadbf1936503b.js 502 bytes [emitted] [immutable] (id hint: all) asset c-all-c_js-0552c7cbb8c1a12b6b9c.js 393 bytes [emitted] [immutable] (id hint: all) -asset c-runtime~main-51dac241c7dc65379790.js 13.5 KiB [emitted] [immutable] (name: runtime~main) +asset c-runtime~main-39696e33891b24e372db.js 13.5 KiB [emitted] [immutable] (name: runtime~main) asset c-main-463838c803f48fe97bb6.js 680 bytes [emitted] [immutable] (name: main) asset c-vendors-node_modules_vendor_js-7320f018dbab7e34ead5.js 185 bytes [emitted] [immutable] (id hint: vendors) -Entrypoint main 14.6 KiB = c-runtime~main-51dac241c7dc65379790.js 13.5 KiB c-all-c_js-0552c7cbb8c1a12b6b9c.js 393 bytes c-main-463838c803f48fe97bb6.js 680 bytes +Entrypoint main 14.6 KiB = c-runtime~main-39696e33891b24e372db.js 13.5 KiB c-all-c_js-0552c7cbb8c1a12b6b9c.js 393 bytes c-main-463838c803f48fe97bb6.js 680 bytes runtime modules 8.66 KiB 13 modules cacheable modules 101 bytes ./c.js 61 bytes [built] [code generated] @@ -1298,8 +1298,8 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin 2 chunks: asset bundle2.js 12.5 KiB [emitted] (name: main) asset 459.bundle2.js 664 bytes [emitted] (name: c) - chunk (runtime: main) bundle2.js (main) 101 bytes (javascript) 7.69 KiB (runtime) >{459}< [entry] [rendered] - runtime modules 7.69 KiB 10 modules + chunk (runtime: main) bundle2.js (main) 101 bytes (javascript) 7.68 KiB (runtime) >{459}< [entry] [rendered] + runtime modules 7.68 KiB 10 modules ./index.js 101 bytes [built] [code generated] chunk (runtime: main) 459.bundle2.js (c) 118 bytes <{179}> <{459}> >{459}< [rendered] dependent modules 44 bytes [dependent] @@ -1314,8 +1314,8 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin asset bundle3.js 12.5 KiB [emitted] (name: main) asset 459.bundle3.js 528 bytes [emitted] (name: c) asset 524.bundle3.js 206 bytes [emitted] - chunk (runtime: main) bundle3.js (main) 101 bytes (javascript) 7.69 KiB (runtime) >{459}< [entry] [rendered] - runtime modules 7.69 KiB 10 modules + chunk (runtime: main) bundle3.js (main) 101 bytes (javascript) 7.68 KiB (runtime) >{459}< [entry] [rendered] + runtime modules 7.68 KiB 10 modules ./index.js 101 bytes [built] [code generated] chunk (runtime: main) 459.bundle3.js (c) 74 bytes <{179}> >{524}< [rendered] ./a.js 22 bytes [built] [code generated] @@ -1331,8 +1331,8 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin asset 459.bundle4.js 392 bytes [emitted] (name: c) asset 394.bundle4.js 206 bytes [emitted] asset 524.bundle4.js 206 bytes [emitted] - chunk (runtime: main) bundle4.js (main) 101 bytes (javascript) 7.69 KiB (runtime) >{394}< >{459}< [entry] [rendered] - runtime modules 7.69 KiB 10 modules + chunk (runtime: main) bundle4.js (main) 101 bytes (javascript) 7.68 KiB (runtime) >{394}< >{459}< [entry] [rendered] + runtime modules 7.68 KiB 10 modules ./index.js 101 bytes [built] [code generated] chunk (runtime: main) 394.bundle4.js 44 bytes <{179}> [rendered] ./a.js 22 bytes [built] [code generated] @@ -1494,13 +1494,13 @@ Chunk Group b 549 bytes (21 KiB) = b.js 549 bytes (2.png 21 KiB) chunk (runtime: main) b.js (b) 67 bytes [rendered] ./node_modules/a/2.png 49 bytes [dependent] [built] [code generated] [1 asset] ./node_modules/b/index.js 18 bytes [built] [code generated] -chunk (runtime: main) main.js (main) 82 bytes (javascript) 6.29 KiB (runtime) [entry] [rendered] - runtime modules 6.29 KiB 8 modules +chunk (runtime: main) main.js (main) 82 bytes (javascript) 6.28 KiB (runtime) [entry] [rendered] + runtime modules 6.28 KiB 8 modules ./index.js 82 bytes [built] [code generated] chunk (runtime: main) a.js (a) 134 bytes [rendered] ./node_modules/a/2.png 49 bytes [dependent] [built] [code generated] [1 asset] ./node_modules/a/index.js + 1 modules 85 bytes [built] [code generated] [1 asset] -runtime modules 6.29 KiB 8 modules +runtime modules 6.28 KiB 8 modules orphan modules 49 bytes [orphan] 1 module modules with assets 234 bytes modules by path ./node_modules/a/ 134 bytes @@ -1695,7 +1695,7 @@ webpack x.x.x compiled with 2 errors in X ms" `; exports[`StatsTestCases should print correct stats for named-chunk-groups 1`] = ` -"Chunk Group main 11.7 KiB = a-main.js +"Chunk Group main 11.6 KiB = a-main.js Chunk Group async-a 1.07 KiB = a-52.js 257 bytes a-async-a.js 836 bytes Chunk Group async-b 1.07 KiB = a-52.js 257 bytes a-async-b.js 836 bytes Chunk Group async-c 1.45 KiB = a-vendors.js 744 bytes a-async-c.js 741 bytes @@ -1722,7 +1722,7 @@ chunk (runtime: main) a-async-a.js (async-a) 175 bytes [rendered] ./a.js 175 bytes [built] [code generated] webpack x.x.x compiled successfully -Entrypoint main 11.7 KiB = b-main.js +Entrypoint main 11.6 KiB = b-main.js Chunk Group async-a 1.07 KiB = b-52.js 257 bytes b-async-a.js 836 bytes Chunk Group async-b 1.07 KiB = b-52.js 257 bytes b-async-b.js 836 bytes Chunk Group async-c 1.45 KiB = b-vendors.js 744 bytes b-async-c.js 741 bytes @@ -1946,7 +1946,7 @@ asset 460.js 323 bytes [emitted] asset 524.js 206 bytes [emitted] asset 996.js 138 bytes [emitted] Entrypoint main 303 KiB = main.js -runtime modules 6 KiB 7 modules +runtime modules 5.99 KiB 7 modules cacheable modules 293 KiB ./index.js 52 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -1963,7 +1963,7 @@ asset 460.js 323 bytes [emitted] asset 524.js 206 bytes [emitted] asset 996.js 138 bytes [emitted] Entrypoint main [big] 303 KiB = main.js -runtime modules 6 KiB 7 modules +runtime modules 5.99 KiB 7 modules cacheable modules 293 KiB ./index.js 52 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -2022,7 +2022,7 @@ asset 460.js 323 bytes [emitted] asset 524.js 206 bytes [emitted] asset 996.js 138 bytes [emitted] Entrypoint main [big] 303 KiB = main.js -runtime modules 6 KiB 7 modules +runtime modules 5.99 KiB 7 modules cacheable modules 293 KiB ./index.js 52 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -2130,7 +2130,7 @@ asset 460.js 323 bytes {460} [emitted] asset 524.js 206 bytes {524} [emitted] asset 996.js 138 bytes {996} [emitted] Entrypoint main 10.2 KiB = main.js -chunk {179} (runtime: main) main.js (main) 73 bytes (javascript) 6 KiB (runtime) >{460}< >{996}< [entry] [rendered] +chunk {179} (runtime: main) main.js (main) 73 bytes (javascript) 5.99 KiB (runtime) >{460}< >{996}< [entry] [rendered] > ./index main chunk {460} (runtime: main) 460.js 54 bytes <{179}> >{524}< [rendered] > ./c [10] ./index.js 3:0-16 @@ -2138,7 +2138,7 @@ chunk {524} (runtime: main) 524.js 44 bytes <{460}> [rendered] > [460] ./c.js 1:0-52 chunk {996} (runtime: main) 996.js 22 bytes <{179}> [rendered] > ./b [10] ./index.js 2:0-16 -runtime modules 6 KiB +runtime modules 5.99 KiB webpack/runtime/ensure chunk 326 bytes {179} [code generated] [no exports] [used exports unknown] @@ -2228,7 +2228,7 @@ LOG from webpack.FileSystemInfo Directory info in cache: 0 timestamps 0 hashes 0 timestamp hash combinations Managed items info in cache: 0 items -1970-04-20 12:42:42: webpack x.x.x compiled successfully in X ms (5966d7136f537890a286)" +1970-04-20 12:42:42: webpack x.x.x compiled successfully in X ms (440eb519eb0c4246cce1)" `; exports[`StatsTestCases should print correct stats for preset-errors-only 1`] = `""`; @@ -2307,7 +2307,7 @@ asset main.js 10.2 KiB [emitted] (name: main) asset 460.js 323 bytes [emitted] asset 524.js 206 bytes [emitted] asset 996.js 138 bytes [emitted] -runtime modules 6 KiB 7 modules +runtime modules 5.99 KiB 7 modules cacheable modules 193 bytes ./index.js 51 bytes [built] [code generated] ./a.js 22 bytes [built] [code generated] @@ -2330,7 +2330,7 @@ exports[`StatsTestCases should print correct stats for preset-normal-performance asset 460.js 323 bytes [emitted] asset 524.js 206 bytes [emitted] asset 996.js 138 bytes [emitted] -runtime modules 6 KiB 7 modules +runtime modules 5.99 KiB 7 modules cacheable modules 293 KiB ./index.js 52 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -2358,7 +2358,7 @@ exports[`StatsTestCases should print correct stats for preset-normal-performance asset 460.js 355 bytes [emitted] 1 related asset asset 524.js 238 bytes [emitted] 1 related asset asset 996.js 170 bytes [emitted] 1 related asset -runtime modules 6 KiB 7 modules +runtime modules 5.99 KiB 7 modules cacheable modules 293 KiB ./index.js 52 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -2406,9 +2406,9 @@ asset 460.js 323 bytes {460} [emitted] asset 524.js 206 bytes {524} [emitted] asset 996.js 138 bytes {996} [emitted] Entrypoint main 10.2 KiB = main.js -chunk {179} (runtime: main) main.js (main) 73 bytes (javascript) 6 KiB (runtime) >{460}< >{996}< [entry] [rendered] +chunk {179} (runtime: main) main.js (main) 73 bytes (javascript) 5.99 KiB (runtime) >{460}< >{996}< [entry] [rendered] > ./index main - runtime modules 6 KiB + runtime modules 5.99 KiB webpack/runtime/ensure chunk 326 bytes {179} [code generated] [no exports] [used exports unknown] @@ -2604,7 +2604,7 @@ LOG from webpack.FileSystemInfo Directory info in cache: 0 timestamps 0 hashes 0 timestamp hash combinations Managed items info in cache: 0 items -1970-04-20 12:42:42: webpack x.x.x compiled successfully in X ms (5966d7136f537890a286)" +1970-04-20 12:42:42: webpack x.x.x compiled successfully in X ms (440eb519eb0c4246cce1)" `; exports[`StatsTestCases should print correct stats for real-content-hash 1`] = ` @@ -3030,15 +3030,15 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp production (webpack x.x.x) compiled successfully in X ms development: - asset development-a.js 15.9 KiB [emitted] (name: a) - asset development-b.js 15.9 KiB [emitted] (name: b) + asset development-a.js 15.8 KiB [emitted] (name: a) + asset development-b.js 15.8 KiB [emitted] (name: b) asset development-dw_js.js 2.11 KiB [emitted] asset development-dx_js.js 2.11 KiB [emitted] asset development-dy_js.js 2.11 KiB [emitted] asset development-dz_js.js 2.11 KiB [emitted] asset development-c.js 1.13 KiB [emitted] (name: c) - chunk (runtime: a) development-a.js (a) 605 bytes (javascript) 6.58 KiB (runtime) [entry] [rendered] - runtime modules 6.58 KiB 9 modules + chunk (runtime: a) development-a.js (a) 605 bytes (javascript) 6.57 KiB (runtime) [entry] [rendered] + runtime modules 6.57 KiB 9 modules cacheable modules 605 bytes ./a.js 261 bytes [built] [code generated] [used exports unknown] @@ -3050,8 +3050,8 @@ development: [used exports unknown] ./reexport.js 37 bytes [dependent] [built] [code generated] [used exports unknown] - chunk (runtime: b) development-b.js (b) 605 bytes (javascript) 6.58 KiB (runtime) [entry] [rendered] - runtime modules 6.58 KiB 9 modules + chunk (runtime: b) development-b.js (b) 605 bytes (javascript) 6.57 KiB (runtime) [entry] [rendered] + runtime modules 6.57 KiB 9 modules cacheable modules 605 bytes ./b.js 261 bytes [built] [code generated] [used exports unknown] @@ -3086,7 +3086,7 @@ development: [used exports unknown] ./module.js?chunk 122 bytes [dependent] [built] [code generated] [used exports unknown] - runtime modules 13.2 KiB 18 modules + runtime modules 13.1 KiB 18 modules cacheable modules 1.15 KiB ./a.js 261 bytes [built] [code generated] [used exports unknown] @@ -3495,9 +3495,9 @@ exports[`StatsTestCases should print correct stats for split-chunks 1`] = ` chunk (runtime: main) default/769.js (id hint: vendors) 20 bytes <{179}> ={282}= ={383}= ={568}= ={767}= [rendered] split chunk (cache group: defaultVendors) > ./c ./index.js 3:0-47 ./node_modules/z.js 20 bytes [built] [code generated] - chunk (runtime: a) default/a.js (a) 245 bytes (javascript) 6.65 KiB (runtime) >{137}< >{568}< [entry] [rendered] + chunk (runtime: a) default/a.js (a) 245 bytes (javascript) 6.64 KiB (runtime) >{137}< >{568}< [entry] [rendered] > ./a a - runtime modules 6.65 KiB 9 modules + runtime modules 6.64 KiB 9 modules dependent modules 60 bytes [dependent] 3 modules ./a.js + 1 modules 185 bytes [built] [code generated] chunk (runtime: main) default/async-a.js (async-a) 185 bytes <{179}> ={282}= ={767}= ={954}= >{137}< >{568}< [rendered] From 7e8260a86cc3b8183dd76572981f7aa5f1b485ee Mon Sep 17 00:00:00 2001 From: Piotr Wysocki <86244209+piwysocki@users.noreply.github.com> Date: Sun, 20 Nov 2022 14:41:35 +0100 Subject: [PATCH 07/38] ci: test workflow - bump actions/cache --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 11a4dbe2a81..9dfebc27c2a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: node-version: 17.x cache: "yarn" - run: yarn --frozen-lockfile - - uses: actions/cache@v1 + - uses: actions/cache@v3 with: path: .eslintcache key: lint-${{ env.GITHUB_SHA }} @@ -62,7 +62,7 @@ jobs: - run: yarn --frozen-lockfile - run: yarn link --frozen-lockfile || true - run: yarn link webpack --frozen-lockfile - - uses: actions/cache@v1 + - uses: actions/cache@v3 with: path: .jest-cache key: jest-unit-${{ env.GITHUB_SHA }} @@ -101,7 +101,7 @@ jobs: - run: yarn --frozen-lockfile - run: yarn link --frozen-lockfile || true - run: yarn link webpack --frozen-lockfile - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: .jest-cache key: jest-integration-${{ env.GITHUB_SHA }} From 2112f9bc7d7659607f8dda22b31ed85f3adc3bb6 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 5 Jan 2023 10:50:51 -0800 Subject: [PATCH 08/38] Replace TypeScript logo in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c712d27fd7a..23c8a88f40a 100644 --- a/README.md +++ b/README.md @@ -161,7 +161,7 @@ or are automatically applied via regex from your webpack configuration. | Name | Status | Install Size | Description | | :--------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------: | :------------: | :------------------------------------------------------------------------------------------------ | | | ![babel-npm] | ![babel-size] | Loads ES2015+ code and transpiles to ES5 using Babel | -| | ![type-npm] | ![type-size] | Loads TypeScript like JavaScript | +| | ![type-npm] | ![type-size] | Loads TypeScript like JavaScript | | | ![coffee-npm] | ![coffee-size] | Loads CoffeeScript like JavaScript | [babel-npm]: https://img.shields.io/npm/v/babel-loader.svg From ea5e86459ecda94846804f7159d485a55dac9ca6 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 5 Jan 2023 10:59:27 -0800 Subject: [PATCH 09/38] Fix HTML5 logo in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c712d27fd7a..8dd012864ef 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ or are automatically applied via regex from your webpack configuration. | Name | Status | Install Size | Description | | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------: | :--------------: | :-------------------------------------------------------------------------------------- | -| | ![html-npm] | ![html-size] | Exports HTML as string, requires references to static resources | +| | ![html-npm] | ![html-size] | Exports HTML as string, requires references to static resources | | | ![pug-npm] | ![pug-size] | Loads Pug templates and returns a function | | | ![pug3-npm] | ![pug3-size] | Compiles Pug to a function or HTML string, useful for use with Vue, React, Angular | | | ![md-npm] | ![md-size] | Compiles Markdown to HTML | From 6011163450ae85c1d2d27ebb49aac211c75d7f01 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 5 Jan 2023 11:01:28 -0800 Subject: [PATCH 10/38] Fix formatting --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 23c8a88f40a..0d372c369af 100644 --- a/README.md +++ b/README.md @@ -158,11 +158,11 @@ or are automatically applied via regex from your webpack configuration. #### Transpiling -| Name | Status | Install Size | Description | -| :--------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------: | :------------: | :------------------------------------------------------------------------------------------------ | -| | ![babel-npm] | ![babel-size] | Loads ES2015+ code and transpiles to ES5 using Babel | -| | ![type-npm] | ![type-size] | Loads TypeScript like JavaScript | -| | ![coffee-npm] | ![coffee-size] | Loads CoffeeScript like JavaScript | +| Name | Status | Install Size | Description | +| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------: | :------------: | :------------------------------------------------------------------------------------------------ | +| | ![babel-npm] | ![babel-size] | Loads ES2015+ code and transpiles to ES5 using Babel | +| | ![type-npm] | ![type-size] | Loads TypeScript like JavaScript | +| | ![coffee-npm] | ![coffee-size] | Loads CoffeeScript like JavaScript | [babel-npm]: https://img.shields.io/npm/v/babel-loader.svg [babel-size]: https://packagephobia.com/badge?p=babel-loader From d957cdf918213857b71755c902621a4345ab3e90 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 5 Jan 2023 11:01:52 -0800 Subject: [PATCH 11/38] Fix formatting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8dd012864ef..652a3898c00 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ or are automatically applied via regex from your webpack configuration. | Name | Status | Install Size | Description | | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------: | :--------------: | :-------------------------------------------------------------------------------------- | -| | ![html-npm] | ![html-size] | Exports HTML as string, requires references to static resources | +| | ![html-npm] | ![html-size] | Exports HTML as string, requires references to static resources | | | ![pug-npm] | ![pug-size] | Loads Pug templates and returns a function | | | ![pug3-npm] | ![pug3-size] | Compiles Pug to a function or HTML string, useful for use with Vue, React, Angular | | | ![md-npm] | ![md-size] | Compiles Markdown to HTML | From 3d227acb6a8ee19ff6136a976c6b6197f95bab8d Mon Sep 17 00:00:00 2001 From: pengbo43 Date: Fri, 13 Jan 2023 10:25:28 +0800 Subject: [PATCH 12/38] chore: enabledLibraryTypes push opt --- lib/container/ContainerPlugin.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/container/ContainerPlugin.js b/lib/container/ContainerPlugin.js index 528fad6acad..b1cd3510f3d 100644 --- a/lib/container/ContainerPlugin.js +++ b/lib/container/ContainerPlugin.js @@ -64,7 +64,9 @@ class ContainerPlugin { const { name, exposes, shareScope, filename, library, runtime } = this._options; - compiler.options.output.enabledLibraryTypes.push(library.type); + if(!compiler.options.output.enabledLibraryTypes.includes(library.type)) { + compiler.options.output.enabledLibraryTypes.push(library.type); + } compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => { const dep = new ContainerEntryDependency(name, exposes, shareScope); From eec7f623ce726185c63ad355d2a12d523ac25ef5 Mon Sep 17 00:00:00 2001 From: pengbo43 Date: Mon, 16 Jan 2023 10:08:24 +0800 Subject: [PATCH 13/38] chore: lint error --- lib/container/ContainerPlugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/container/ContainerPlugin.js b/lib/container/ContainerPlugin.js index b1cd3510f3d..833091047eb 100644 --- a/lib/container/ContainerPlugin.js +++ b/lib/container/ContainerPlugin.js @@ -64,7 +64,7 @@ class ContainerPlugin { const { name, exposes, shareScope, filename, library, runtime } = this._options; - if(!compiler.options.output.enabledLibraryTypes.includes(library.type)) { + if (!compiler.options.output.enabledLibraryTypes.includes(library.type)) { compiler.options.output.enabledLibraryTypes.push(library.type); } From dcc3e7164eb8757effec79928181b88d79a9e7bf Mon Sep 17 00:00:00 2001 From: Ryan Wilson-Perkin Date: Tue, 7 Feb 2023 17:54:09 -0500 Subject: [PATCH 14/38] Serialize code generator data to support generated assets AssetGenerator calls out in a TODO-comment that the filename, assetInfo, and fullContentHash values must be captured in the 'data' object that's populated during code generation in order to be accessible in the AssetModulesPlugin. It notes that it must store them in the code generation results because it will be cached, but that appears to be incorrect as data is a simple Map that's instantiated within the NormalModule and not captured anywhere that would be cached. As a result, configurations that use the asset/resource type and make changes to assets between cached builds will result in a runtime error as Webpack is able to access the file from cache but isn't able to access the expected values from the data object. This solution captures the data object as a property of the NormalModule and hooks in to the existing serialize/deserialize functionality in order to make this value available across cached builds. --- lib/NormalModule.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/NormalModule.js b/lib/NormalModule.js index 4d1264f9b3c..3afa2336a61 100644 --- a/lib/NormalModule.js +++ b/lib/NormalModule.js @@ -330,6 +330,8 @@ class NormalModule extends Module { this._isEvaluatingSideEffects = false; /** @type {WeakSet | undefined} */ this._addedSideEffectsBailout = undefined; + /** @type {Map} */ + this._codeGeneratorData = new Map(); } /** @@ -1188,11 +1190,9 @@ class NormalModule extends Module { runtimeRequirements.add(RuntimeGlobals.thisAsExports); } - /** @type {Map} */ - let data; + /** @type {function(): Map} */ const getData = () => { - if (data === undefined) data = new Map(); - return data; + return this._codeGeneratorData; }; const sources = new Map(); @@ -1223,7 +1223,7 @@ class NormalModule extends Module { const resultEntry = { sources, runtimeRequirements, - data + data: this._codeGeneratorData, }; return resultEntry; } @@ -1371,6 +1371,7 @@ class NormalModule extends Module { write(this.error); write(this._lastSuccessfulBuildMeta); write(this._forceBuild); + write(this._codeGeneratorData); super.serialize(context); } @@ -1403,6 +1404,7 @@ class NormalModule extends Module { this.error = read(); this._lastSuccessfulBuildMeta = read(); this._forceBuild = read(); + this._codeGeneratorData = read(); super.deserialize(context); } } From dfaa3b401e2730d719c66fdd9652c0c3feda043b Mon Sep 17 00:00:00 2001 From: Ryan Wilson-Perkin Date: Tue, 7 Feb 2023 18:11:50 -0500 Subject: [PATCH 15/38] lint: remove trailing comma --- lib/NormalModule.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/NormalModule.js b/lib/NormalModule.js index 3afa2336a61..b3fababd63f 100644 --- a/lib/NormalModule.js +++ b/lib/NormalModule.js @@ -1223,7 +1223,7 @@ class NormalModule extends Module { const resultEntry = { sources, runtimeRequirements, - data: this._codeGeneratorData, + data: this._codeGeneratorData }; return resultEntry; } From 4d561a658020778d412367bb9744e5ca3007105b Mon Sep 17 00:00:00 2001 From: Ryan Wilson-Perkin Date: Thu, 16 Feb 2023 01:11:36 -0500 Subject: [PATCH 16/38] Add test for behaviour of filesystem-cached assets with loaders --- test/Compiler-filesystem-caching.test.js | 152 +++++++++++++++++++++++ test/fixtures/empty-svg-loader.js | 1 + test/fixtures/file.svg | 1 + test/fixtures/uses-asset.js | 1 + 4 files changed, 155 insertions(+) create mode 100644 test/Compiler-filesystem-caching.test.js create mode 100644 test/fixtures/empty-svg-loader.js create mode 100644 test/fixtures/file.svg create mode 100644 test/fixtures/uses-asset.js diff --git a/test/Compiler-filesystem-caching.test.js b/test/Compiler-filesystem-caching.test.js new file mode 100644 index 00000000000..cad5f679208 --- /dev/null +++ b/test/Compiler-filesystem-caching.test.js @@ -0,0 +1,152 @@ +"use strict"; + +require("./helpers/warmup-webpack"); + +const path = require("path"); +const fs = require("graceful-fs"); +const rimraf = require("rimraf"); + +let fixtureCount = 0; + +describe("Compiler (filesystem caching)", () => { + jest.setTimeout(5000); + + const tempFixturePath = path.join( + __dirname, + "fixtures", + "temp-filesystem-cache-fixture" + ); + + function compile(entry, onSuccess, onError) { + const webpack = require(".."); + const options = webpack.config.getNormalizedWebpackOptions({}); + options.cache = { + type: "filesystem", + cacheDirectory: path.join(tempFixturePath, "cache") + }; + options.entry = entry; + options.context = path.join(__dirname, "fixtures"); + options.output.path = path.join(tempFixturePath, "dist"); + options.output.filename = "bundle.js"; + options.output.pathinfo = true; + options.module = { + rules: [ + { + test: /\.svg$/, + type: "asset/resource", + use: { + loader: require.resolve("./fixtures/empty-svg-loader") + } + } + ] + }; + + function runCompiler(onSuccess, onError) { + const c = webpack(options); + c.hooks.compilation.tap( + "CompilerCachingTest", + compilation => (compilation.bail = true) + ); + c.run((err, stats) => { + if (err) throw err; + expect(typeof stats).toBe("object"); + stats = stats.toJson({ + modules: true, + reasons: true + }); + expect(typeof stats).toBe("object"); + expect(stats).toHaveProperty("errors"); + expect(Array.isArray(stats.errors)).toBe(true); + if (stats.errors.length > 0) { + onError(new Error(JSON.stringify(stats.errors, null, 4))); + } + c.close(() => { + onSuccess(stats); + }); + }); + } + + runCompiler(onSuccess, onError); + + return { + runAgain: runCompiler + }; + } + + function cleanup() { + rimraf.sync(`${tempFixturePath}*`); + } + + beforeAll(cleanup); + afterAll(cleanup); + + function createTempFixture() { + const fixturePath = `${tempFixturePath}-${fixtureCount}`; + const usesAssetFilepath = path.join(fixturePath, "uses-asset.js"); + const svgFilepath = path.join(fixturePath, "file.svg"); + + // Remove previous copy if present + rimraf.sync(fixturePath); + + // Copy over file since we"ll be modifying some of them + fs.mkdirSync(fixturePath); + fs.copyFileSync( + path.join(__dirname, "fixtures", "uses-asset.js"), + usesAssetFilepath + ); + fs.copyFileSync(path.join(__dirname, "fixtures", "file.svg"), svgFilepath); + + fixtureCount++; + return { + rootPath: fixturePath, + usesAssetFilepath: usesAssetFilepath, + svgFilepath: svgFilepath + }; + } + + it("should compile again when cached asset has changed but loader output remains the same", done => { + const tempFixture = createTempFixture(); + + const onError = error => done(error); + + const helper = compile( + tempFixture.usesAssetFilepath, + stats => { + // Not cached the first time + expect(stats.assets[0].name).toBe("bundle.js"); + expect(stats.assets[0].emitted).toBe(true); + + expect(stats.assets[1].name).toMatch(/\w+\.svg$/); + expect(stats.assets[0].emitted).toBe(true); + + helper.runAgain(stats => { + // Cached the second run + expect(stats.assets[0].name).toBe("bundle.js"); + expect(stats.assets[0].emitted).toBe(false); + + expect(stats.assets[1].name).toMatch(/\w+\.svg$/); + expect(stats.assets[0].emitted).toBe(false); + + const svgContent = fs + .readFileSync(tempFixture.svgFilepath) + .toString() + .replace("icon-square-small", "icon-square-smaller"); + + fs.writeFileSync(tempFixture.svgFilepath, svgContent); + + helper.runAgain(stats => { + // Still cached after file modification because loader always returns empty + expect(stats.assets[0].name).toBe("bundle.js"); + expect(stats.assets[0].emitted).toBe(false); + + expect(stats.assets[1].name).toMatch(/\w+\.svg$/); + expect(stats.assets[0].emitted).toBe(false); + + done(); + }, onError); + }, onError); + }, + onError + ); + }); +}); diff --git a/test/fixtures/empty-svg-loader.js b/test/fixtures/empty-svg-loader.js new file mode 100644 index 00000000000..0a599e7d5d6 --- /dev/null +++ b/test/fixtures/empty-svg-loader.js @@ -0,0 +1 @@ +module.exports = () => ""; diff --git a/test/fixtures/file.svg b/test/fixtures/file.svg new file mode 100644 index 00000000000..d7b7e40b4f8 --- /dev/null +++ b/test/fixtures/file.svg @@ -0,0 +1 @@ +icon-square-small diff --git a/test/fixtures/uses-asset.js b/test/fixtures/uses-asset.js new file mode 100644 index 00000000000..b3532c8b7fc --- /dev/null +++ b/test/fixtures/uses-asset.js @@ -0,0 +1 @@ +import SVG from './file.svg'; From 387fb142542d6086b42cc1f6f08f195b8556cd9f Mon Sep 17 00:00:00 2001 From: Peter Goldberg Date: Fri, 24 Feb 2023 12:38:01 -0500 Subject: [PATCH 17/38] add missing loaders to moduleFilenameTemplate function call --- lib/ModuleFilenameHelpers.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ModuleFilenameHelpers.js b/lib/ModuleFilenameHelpers.js index 2b6afc114db..c9efe915e2c 100644 --- a/lib/ModuleFilenameHelpers.js +++ b/lib/ModuleFilenameHelpers.js @@ -162,6 +162,7 @@ ModuleFilenameHelpers.createFilename = ( resource: resource, resourcePath: memoize(resourcePath), absoluteResourcePath: memoize(absoluteResourcePath), + loaders: memoize(loaders), allLoaders: memoize(allLoaders), query: memoize(query), moduleId: memoize(moduleId), From cfdb1dfe59b33bf7441b8a8e4fc58d75e4f54cee Mon Sep 17 00:00:00 2001 From: Ryan Wilson-Perkin Date: Fri, 24 Feb 2023 16:17:15 -0500 Subject: [PATCH 18/38] Improve performance of hashRegExp lookup For applications with a very large number of assets, the cost of invoking a single regular expression with many many values in a group becomes very high. By changing to a list of regular expressions (with helper methods for maintaining the original design) we can get a large performance improvement. --- lib/optimize/RealContentHashPlugin.js | 58 ++++++++++++++++++++------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/lib/optimize/RealContentHashPlugin.js b/lib/optimize/RealContentHashPlugin.js index 7ab9c46fb8b..ba058b753a2 100644 --- a/lib/optimize/RealContentHashPlugin.js +++ b/lib/optimize/RealContentHashPlugin.js @@ -178,10 +178,43 @@ class RealContentHashPlugin { } } if (hashToAssets.size === 0) return; - const hashRegExp = new RegExp( - Array.from(hashToAssets.keys(), quoteMeta).join("|"), - "g" + const hashRegExps = Array.from(hashToAssets.keys(), quoteMeta).map( + hash => new RegExp(hash, "g") ); + + /** + * @param {string} str string to be matched against all hashRegExps + * @returns {string[] | null} matches found + */ + const hashMatch = str => { + /** @type {string[]} */ + const results = []; + for (const hashRegExp of hashRegExps) { + const matches = str.match(hashRegExp); + if (matches) { + matches.forEach(match => results.push(match)); + } + } + if (results.length) { + return results; + } else { + return null; + } + }; + + /** + * @param {string} str string to be replaced with all hashRegExps + * @param {function(string): string} fn replacement function to use when a hash is found + * @returns {string} replaced content + */ + const hashReplace = (str, fn) => { + let result = str; + for (const hashRegExp of hashRegExps) { + result = result.replace(hashRegExp, fn); + } + return result; + }; + await Promise.all( assetsWithInfo.map(async asset => { const { name, source, content, hashes } = asset; @@ -198,7 +231,7 @@ class RealContentHashPlugin { await cacheAnalyse.providePromise(name, etag, () => { const referencedHashes = new Set(); let ownHashes = new Set(); - const inContent = content.match(hashRegExp); + const inContent = hashMatch(content); if (inContent) { for (const hash of inContent) { if (hashes.has(hash)) { @@ -298,7 +331,7 @@ ${referencingAssets identifier, etag, () => { - const newContent = asset.content.replace(hashRegExp, hash => + const newContent = hashReplace(asset.content, hash => hashToNewHash.get(hash) ); return new RawSource(newContent); @@ -323,15 +356,12 @@ ${referencingAssets identifier, etag, () => { - const newContent = asset.content.replace( - hashRegExp, - hash => { - if (asset.ownHashes.has(hash)) { - return ""; - } - return hashToNewHash.get(hash); + const newContent = hashReplace(asset.content, hash => { + if (asset.ownHashes.has(hash)) { + return ""; } - ); + return hashToNewHash.get(hash); + }); return new RawSource(newContent); } ); @@ -374,7 +404,7 @@ ${referencingAssets await Promise.all( assetsWithInfo.map(async asset => { await computeNewContent(asset); - const newName = asset.name.replace(hashRegExp, hash => + const newName = hashReplace(asset.name, hash => hashToNewHash.get(hash) ); From cb028265e727807a32f3adde51606345ce193c74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s-Combarro?= Date: Wed, 1 Mar 2023 15:35:55 +0400 Subject: [PATCH 19/38] Added `assert/strict` built-in --- lib/node/NodeTargetPlugin.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node/NodeTargetPlugin.js b/lib/node/NodeTargetPlugin.js index 33f785babff..adea6ab7801 100644 --- a/lib/node/NodeTargetPlugin.js +++ b/lib/node/NodeTargetPlugin.js @@ -11,6 +11,7 @@ const ExternalsPlugin = require("../ExternalsPlugin"); const builtins = [ "assert", + "assert/strict", "async_hooks", "buffer", "child_process", From 5f34acfbc074da6cc09f48944d7f2b4273ffb3f8 Mon Sep 17 00:00:00 2001 From: Adam Skoufis Date: Tue, 7 Mar 2023 09:39:54 +1100 Subject: [PATCH 20/38] feat: Add `target` to `LoaderContext` type --- declarations/LoaderContext.d.ts | 6 ++++++ types.d.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/declarations/LoaderContext.d.ts b/declarations/LoaderContext.d.ts index 3e9341423a7..f93a0890d2d 100644 --- a/declarations/LoaderContext.d.ts +++ b/declarations/LoaderContext.d.ts @@ -212,6 +212,12 @@ export interface LoaderRunnerLoaderContext { * Example: "/abc/resource.js?query#frag" */ resource: string; + + /** + * Target of compilation. + * Example: "web" + */ + target: string; } type AdditionalData = { diff --git a/types.d.ts b/types.d.ts index 251d0adfd3d..78da415cff2 100644 --- a/types.d.ts +++ b/types.d.ts @@ -6595,6 +6595,12 @@ declare interface LoaderRunnerLoaderContext { * Example: "/abc/resource.js?query#frag" */ resource: string; + + /** + * Target of compilation. + * Example: "web" + */ + target: string; } declare class LoaderTargetPlugin { constructor(target: string); From 07283fabc43a440db046037f7231ee362f31a21c Mon Sep 17 00:00:00 2001 From: David Michon Date: Tue, 7 Mar 2023 16:15:36 -0800 Subject: [PATCH 21/38] Respect output.hashSalt in RealContentHashPlugin Fix #16788 Update RealContentHashPlugin to initialize hash instances with the value of `output.hashSalt`, if provided. --- lib/optimize/RealContentHashPlugin.js | 3 ++ test/configCases/contenthash/salt/img.jpg | 0 test/configCases/contenthash/salt/index.js | 5 ++ .../contenthash/salt/test.config.js | 24 ++++++++++ .../contenthash/salt/webpack.config.js | 48 +++++++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 test/configCases/contenthash/salt/img.jpg create mode 100644 test/configCases/contenthash/salt/index.js create mode 100644 test/configCases/contenthash/salt/test.config.js create mode 100644 test/configCases/contenthash/salt/webpack.config.js diff --git a/lib/optimize/RealContentHashPlugin.js b/lib/optimize/RealContentHashPlugin.js index 7ab9c46fb8b..9ceb157781d 100644 --- a/lib/optimize/RealContentHashPlugin.js +++ b/lib/optimize/RealContentHashPlugin.js @@ -363,6 +363,9 @@ ${referencingAssets let newHash = hooks.updateHash.call(assetsContent, oldHash); if (!newHash) { const hash = createHash(this._hashFunction); + if (compilation.outputOptions.hashSalt) { + hash.update(compilation.outputOptions.hashSalt); + } for (const content of assetsContent) { hash.update(content); } diff --git a/test/configCases/contenthash/salt/img.jpg b/test/configCases/contenthash/salt/img.jpg new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/configCases/contenthash/salt/index.js b/test/configCases/contenthash/salt/index.js new file mode 100644 index 00000000000..2d2b98703ee --- /dev/null +++ b/test/configCases/contenthash/salt/index.js @@ -0,0 +1,5 @@ +import img from "./img.jpg"; + +it("should compile", () => { + expect(typeof img).toBe("string"); +}); diff --git a/test/configCases/contenthash/salt/test.config.js b/test/configCases/contenthash/salt/test.config.js new file mode 100644 index 00000000000..530c9147c05 --- /dev/null +++ b/test/configCases/contenthash/salt/test.config.js @@ -0,0 +1,24 @@ +const findOutputFiles = require("../../../helpers/findOutputFiles"); + +const allAssets = new Set(); +const allBundles = new Set(); + +module.exports = { + findBundle: function(i, options) { + const bundle = findOutputFiles(options, new RegExp(`^bundle${i}`))[0]; + allBundles.add(/\.([^.]+)\./.exec(bundle)[1]); + + const assets = findOutputFiles(options, /^img/); + for (const asset of assets) { + allAssets.add(asset); + } + + return `./${bundle}`; + }, + afterExecute: () => { + // Since there are exactly 2 unique values of output.hashSalt, + // there should be exactly 2 unique output hashes for each file. + expect(allBundles.size).toBe(2); + expect(allAssets.size).toBe(2); + } +}; diff --git a/test/configCases/contenthash/salt/webpack.config.js b/test/configCases/contenthash/salt/webpack.config.js new file mode 100644 index 00000000000..1ec1c83b9d9 --- /dev/null +++ b/test/configCases/contenthash/salt/webpack.config.js @@ -0,0 +1,48 @@ +/** @type {import("../../../../").Configuration[]} */ +module.exports = [ + { + output: { + filename: "bundle0.[contenthash].js", + assetModuleFilename: "[name].[contenthash][ext]", + hashSalt: "1" + }, + module: { + rules: [ + { + test: /\.jpg$/, + type: "asset/resource" + } + ] + } + }, + { + output: { + filename: "bundle1.[contenthash].js", + assetModuleFilename: "[name].[contenthash][ext]", + hashSalt: "1" + }, + module: { + rules: [ + { + test: /\.jpg$/, + type: "asset/resource" + } + ] + } + }, + { + output: { + filename: "bundle2.[contenthash].js", + assetModuleFilename: "[name].[contenthash][ext]", + hashSalt: "2" + }, + module: { + rules: [ + { + test: /\.jpg$/, + type: "asset/resource" + } + ] + } + } +]; From 67af5ec1f05fb7cf06be6acf27353aef105ddcbc Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Wed, 8 Mar 2023 21:17:35 +0300 Subject: [PATCH 22/38] chore(release): 5.76.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2a604bfd149..beeb121133f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webpack", - "version": "5.75.0", + "version": "5.76.0", "author": "Tobias Koppers @sokra", "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.", "license": "MIT", From 52b1b0e4ada7c11e7f1b4f3d69b50684938c684e Mon Sep 17 00:00:00 2001 From: Ryan Wilson-Perkin Date: Fri, 10 Mar 2023 10:04:26 -0500 Subject: [PATCH 23/38] Revert "Improve performance of hashRegExp lookup" --- lib/optimize/RealContentHashPlugin.js | 58 +++++++-------------------- 1 file changed, 14 insertions(+), 44 deletions(-) diff --git a/lib/optimize/RealContentHashPlugin.js b/lib/optimize/RealContentHashPlugin.js index c7e19754e73..9ceb157781d 100644 --- a/lib/optimize/RealContentHashPlugin.js +++ b/lib/optimize/RealContentHashPlugin.js @@ -178,43 +178,10 @@ class RealContentHashPlugin { } } if (hashToAssets.size === 0) return; - const hashRegExps = Array.from(hashToAssets.keys(), quoteMeta).map( - hash => new RegExp(hash, "g") + const hashRegExp = new RegExp( + Array.from(hashToAssets.keys(), quoteMeta).join("|"), + "g" ); - - /** - * @param {string} str string to be matched against all hashRegExps - * @returns {string[] | null} matches found - */ - const hashMatch = str => { - /** @type {string[]} */ - const results = []; - for (const hashRegExp of hashRegExps) { - const matches = str.match(hashRegExp); - if (matches) { - matches.forEach(match => results.push(match)); - } - } - if (results.length) { - return results; - } else { - return null; - } - }; - - /** - * @param {string} str string to be replaced with all hashRegExps - * @param {function(string): string} fn replacement function to use when a hash is found - * @returns {string} replaced content - */ - const hashReplace = (str, fn) => { - let result = str; - for (const hashRegExp of hashRegExps) { - result = result.replace(hashRegExp, fn); - } - return result; - }; - await Promise.all( assetsWithInfo.map(async asset => { const { name, source, content, hashes } = asset; @@ -231,7 +198,7 @@ class RealContentHashPlugin { await cacheAnalyse.providePromise(name, etag, () => { const referencedHashes = new Set(); let ownHashes = new Set(); - const inContent = hashMatch(content); + const inContent = content.match(hashRegExp); if (inContent) { for (const hash of inContent) { if (hashes.has(hash)) { @@ -331,7 +298,7 @@ ${referencingAssets identifier, etag, () => { - const newContent = hashReplace(asset.content, hash => + const newContent = asset.content.replace(hashRegExp, hash => hashToNewHash.get(hash) ); return new RawSource(newContent); @@ -356,12 +323,15 @@ ${referencingAssets identifier, etag, () => { - const newContent = hashReplace(asset.content, hash => { - if (asset.ownHashes.has(hash)) { - return ""; + const newContent = asset.content.replace( + hashRegExp, + hash => { + if (asset.ownHashes.has(hash)) { + return ""; + } + return hashToNewHash.get(hash); } - return hashToNewHash.get(hash); - }); + ); return new RawSource(newContent); } ); @@ -407,7 +377,7 @@ ${referencingAssets await Promise.all( assetsWithInfo.map(async asset => { await computeNewContent(asset); - const newName = hashReplace(asset.name, hash => + const newName = asset.name.replace(hashRegExp, hash => hashToNewHash.get(hash) ); From 1cce945dd6c3576d37d3940a0233fd087ce3f6ff Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Fri, 10 Mar 2023 23:39:10 +0200 Subject: [PATCH 24/38] chore(release): 5.76.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index beeb121133f..5e3ff54f9ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webpack", - "version": "5.76.0", + "version": "5.76.1", "author": "Tobias Koppers @sokra", "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.", "license": "MIT", From 27b6dce48f75469906d9aeecad06b4e05d1edc93 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 11 Mar 2023 08:19:40 +0530 Subject: [PATCH 25/38] fix: improve types for `webpack-sources` --- declarations.d.ts | 12 +++++++++++- types.d.ts | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/declarations.d.ts b/declarations.d.ts index ea7c1ab6154..ea8207f8ed2 100644 --- a/declarations.d.ts +++ b/declarations.d.ts @@ -246,10 +246,20 @@ declare module "@webassemblyjs/ast" { declare module "webpack-sources" { export type MapOptions = { columns?: boolean; module?: boolean }; + export type RawSourceMap = { + version: number; + sources: string[]; + names: string[]; + sourceRoot?: string; + sourcesContent?: string[]; + mappings: string; + file: string; + }; + export abstract class Source { size(): number; - map(options?: MapOptions): Object; + map(options?: MapOptions): RawSourceMap | null; sourceAndMap(options?: MapOptions): { source: string | Buffer; diff --git a/types.d.ts b/types.d.ts index ded8f2f4908..ab6dabf5736 100644 --- a/types.d.ts +++ b/types.d.ts @@ -8934,6 +8934,15 @@ declare class RawSource extends Source { constructor(source: string | Buffer, convertToString?: boolean); isBuffer(): boolean; } +declare interface RawSourceMap { + version: number; + sources: string[]; + names: string[]; + sourceRoot?: string; + sourcesContent?: string[]; + mappings: string; + file: string; +} declare class ReadFileCompileWasmPlugin { constructor(options?: any); options: any; @@ -10643,7 +10652,7 @@ declare abstract class SortableSet extends Set { declare class Source { constructor(); size(): number; - map(options?: MapOptions): Object; + map(options?: MapOptions): null | RawSourceMap; sourceAndMap(options?: MapOptions): { source: string | Buffer; map: Object }; updateHash(hash: Hash): void; source(): string | Buffer; From b99aa598e0775200246abfbba4482f4088f3a6e5 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 11 Mar 2023 10:20:50 +0530 Subject: [PATCH 26/38] fix: improve `resolveResourceErrorHints` error message --- lib/NormalModuleFactory.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/NormalModuleFactory.js b/lib/NormalModuleFactory.js index 4cb2cb65d5d..1711f94b07e 100644 --- a/lib/NormalModuleFactory.js +++ b/lib/NormalModuleFactory.js @@ -838,10 +838,10 @@ class NormalModuleFactory extends ModuleFactory { (err2, hints) => { if (err2) { err.message += ` -An fatal error happened during resolving additional hints for this error: ${err2.message}`; +A fatal error happened during resolving additional hints for this error: ${err2.message}`; err.stack += ` -An fatal error happened during resolving additional hints for this error: +A fatal error happened during resolving additional hints for this error: ${err2.stack}`; return callback(err); } From 98375f6c9516ab0e2ca381c9c82e903f36df1faa Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 28 Sep 2022 08:17:06 +0530 Subject: [PATCH 27/38] fix: respect NODE_PATH env variable --- bin/webpack.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/webpack.js b/bin/webpack.js index fead38bf4b1..aadab30c0d0 100755 --- a/bin/webpack.js +++ b/bin/webpack.js @@ -53,6 +53,19 @@ const isInstalled = packageName => { } } while (dir !== (dir = path.dirname(dir))); + // https://github.com/nodejs/node/blob/v18.9.1/lib/internal/modules/cjs/loader.js#L1274 + // eslint-disable-next-line no-warning-comments + // @ts-ignore + for (const internalPath of require("module").globalPaths) { + try { + if (fs.statSync(path.join(internalPath, packageName)).isDirectory()) { + return true; + } + } catch (_error) { + // Nothing + } + } + return false; }; From cf15e67cc3094177aee718496533d232d4ad0c36 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 11 Mar 2023 16:51:52 +0530 Subject: [PATCH 28/38] fix: do not import non javascript chunks --- lib/esm/ModuleChunkFormatPlugin.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/esm/ModuleChunkFormatPlugin.js b/lib/esm/ModuleChunkFormatPlugin.js index e17d1053063..f0266bc0f61 100644 --- a/lib/esm/ModuleChunkFormatPlugin.js +++ b/lib/esm/ModuleChunkFormatPlugin.js @@ -11,6 +11,7 @@ const HotUpdateChunk = require("../HotUpdateChunk"); const Template = require("../Template"); const { getAllChunks } = require("../javascript/ChunkHelpers"); const { + chunkHasJs, getCompilationHooks, getChunkFilenameTemplate } = require("../javascript/JavascriptModulesPlugin"); @@ -147,7 +148,11 @@ class ModuleChunkFormatPlugin { undefined ); for (const chunk of chunks) { - if (loadedChunks.has(chunk)) continue; + if ( + loadedChunks.has(chunk) || + !chunkHasJs(chunk, chunkGraph) + ) + continue; loadedChunks.add(chunk); startupSource.add( `import * as __webpack_chunk_${index}__ from ${JSON.stringify( From 09047244b3ebdf69fb5d1027fdb989b31b031d58 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 12 Mar 2023 07:27:19 +0530 Subject: [PATCH 29/38] fix: limit progress bar length to 40 when no columns provided --- lib/node/nodeConsole.js | 6 ++---- test/ProgressPlugin.test.js | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/node/nodeConsole.js b/lib/node/nodeConsole.js index 83b068b9aa7..dbb74d807b9 100644 --- a/lib/node/nodeConsole.js +++ b/lib/node/nodeConsole.js @@ -38,10 +38,8 @@ module.exports = ({ colors, appendOnly, stream }) => { const writeStatusMessage = () => { if (!currentStatusMessage) return; - const l = stream.columns; - const args = l - ? truncateArgs(currentStatusMessage, l - 1) - : currentStatusMessage; + const l = process.stderr.columns || 40; + const args = truncateArgs(currentStatusMessage, l - 1); const str = args.join(" "); const coloredStr = `\u001b[1m${str}\u001b[39m\u001b[22m`; stream.write(`\x1b[2K\r${coloredStr}`); diff --git a/test/ProgressPlugin.test.js b/test/ProgressPlugin.test.js index 9f1a32c4d7e..00fc7594296 100644 --- a/test/ProgressPlugin.test.js +++ b/test/ProgressPlugin.test.js @@ -218,7 +218,7 @@ describe("ProgressPlugin", function () { const logs = getLogs(stderr.toString()); expect(logs.length).toBeGreaterThan(20); - expect(_.maxBy(logs, "length").length).toBeGreaterThan(50); + expect(_.maxBy(logs, "length").length).not.toBeGreaterThan(40); }); }); From 8e7ac44fbd3bb9ed6648104d63c67715b882bb4f Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 12 Mar 2023 07:57:40 +0530 Subject: [PATCH 30/38] docs: update examples --- examples/chunkhash/README.md | 2 +- examples/chunkhash/webpack.config.js | 2 +- examples/coffee-script/webpack.config.js | 2 +- examples/common-chunk-grandchildren/README.md | 2 +- examples/common-chunk-grandchildren/webpack.config.js | 2 +- examples/dll-app-and-vendor/0-vendor/README.md | 2 +- examples/dll-app-and-vendor/0-vendor/webpack.config.js | 2 +- examples/dll-user/README.md | 2 +- examples/dll-user/webpack.config.js | 2 +- examples/dll/README.md | 2 +- examples/dll/webpack.config.js | 2 +- examples/explicit-vendor-chunk/README.md | 4 ++-- examples/explicit-vendor-chunk/webpack.config.js | 4 ++-- examples/externals/README.md | 2 +- examples/externals/webpack.config.js | 2 +- examples/extra-async-chunk-advanced/README.md | 2 +- examples/extra-async-chunk-advanced/webpack.config.js | 2 +- examples/extra-async-chunk/webpack.config.js | 2 +- examples/harmony-library/README.md | 2 +- examples/harmony-library/webpack.config.js | 2 +- examples/harmony-unused/webpack.config.js | 2 +- examples/http2-aggressive-splitting/README.md | 2 +- examples/http2-aggressive-splitting/webpack.config.js | 2 +- examples/hybrid-routing/README.md | 2 +- examples/hybrid-routing/webpack.config.js | 2 +- examples/loader/webpack.config.js | 2 +- examples/many-pages/README.md | 2 +- examples/many-pages/webpack.config.js | 2 +- examples/multi-compiler/README.md | 4 ++-- examples/multi-compiler/webpack.config.js | 4 ++-- examples/multi-part-library/README.md | 2 +- examples/multi-part-library/webpack.config.js | 2 +- examples/multiple-entry-points/README.md | 2 +- examples/multiple-entry-points/webpack.config.js | 2 +- examples/two-explicit-vendor-chunks/README.md | 2 +- examples/two-explicit-vendor-chunks/webpack.config.js | 2 +- examples/wasm-complex/webpack.config.js | 2 +- examples/wasm-simple/webpack.config.js | 2 +- 38 files changed, 42 insertions(+), 42 deletions(-) diff --git a/examples/chunkhash/README.md b/examples/chunkhash/README.md index 3527107f0d5..669b7d68036 100644 --- a/examples/chunkhash/README.md +++ b/examples/chunkhash/README.md @@ -20,7 +20,7 @@ import("./async2"); ```javascript var path = require("path"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: { main: "./example" }, diff --git a/examples/chunkhash/webpack.config.js b/examples/chunkhash/webpack.config.js index cc34d5591f9..d913bc14962 100644 --- a/examples/chunkhash/webpack.config.js +++ b/examples/chunkhash/webpack.config.js @@ -1,6 +1,6 @@ var path = require("path"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: { main: "./example" }, diff --git a/examples/coffee-script/webpack.config.js b/examples/coffee-script/webpack.config.js index 845f9f4c190..91c59cf45a7 100644 --- a/examples/coffee-script/webpack.config.js +++ b/examples/coffee-script/webpack.config.js @@ -1,5 +1,5 @@ module.exports = { - // mode: "development || "production", + // mode: "development" || "production", module: { rules: [ { diff --git a/examples/common-chunk-grandchildren/README.md b/examples/common-chunk-grandchildren/README.md index ec028a663ec..5d2c035e90b 100644 --- a/examples/common-chunk-grandchildren/README.md +++ b/examples/common-chunk-grandchildren/README.md @@ -86,7 +86,7 @@ module.exports = function() { const path = require("path"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: { main: ["./example.js"] }, diff --git a/examples/common-chunk-grandchildren/webpack.config.js b/examples/common-chunk-grandchildren/webpack.config.js index e8c14e818d9..ea9fdf2323e 100644 --- a/examples/common-chunk-grandchildren/webpack.config.js +++ b/examples/common-chunk-grandchildren/webpack.config.js @@ -2,7 +2,7 @@ const path = require("path"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: { main: ["./example.js"] }, diff --git a/examples/dll-app-and-vendor/0-vendor/README.md b/examples/dll-app-and-vendor/0-vendor/README.md index 03f49db1171..6381a62a31a 100644 --- a/examples/dll-app-and-vendor/0-vendor/README.md +++ b/examples/dll-app-and-vendor/0-vendor/README.md @@ -13,7 +13,7 @@ var path = require("path"); var webpack = require("../../../"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", context: __dirname, entry: ["example-vendor"], output: { diff --git a/examples/dll-app-and-vendor/0-vendor/webpack.config.js b/examples/dll-app-and-vendor/0-vendor/webpack.config.js index 3572be39ce8..5a9099cdb5c 100644 --- a/examples/dll-app-and-vendor/0-vendor/webpack.config.js +++ b/examples/dll-app-and-vendor/0-vendor/webpack.config.js @@ -2,7 +2,7 @@ var path = require("path"); var webpack = require("../../../"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", context: __dirname, entry: ["example-vendor"], output: { diff --git a/examples/dll-user/README.md b/examples/dll-user/README.md index 3b7937fd2ba..0ca2eaa94a2 100644 --- a/examples/dll-user/README.md +++ b/examples/dll-user/README.md @@ -10,7 +10,7 @@ This is the _user_ bundle, which uses the manifest from [dll-reference example]( var path = require("path"); var webpack = require("../../"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", plugins: [ new webpack.DllReferencePlugin({ context: path.join(__dirname, "..", "dll"), diff --git a/examples/dll-user/webpack.config.js b/examples/dll-user/webpack.config.js index 7d058b6d535..c8d0d5210ad 100644 --- a/examples/dll-user/webpack.config.js +++ b/examples/dll-user/webpack.config.js @@ -1,7 +1,7 @@ var path = require("path"); var webpack = require("../../"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", plugins: [ new webpack.DllReferencePlugin({ context: path.join(__dirname, "..", "dll"), diff --git a/examples/dll/README.md b/examples/dll/README.md index 056b9c6e7fd..fb673d48888 100644 --- a/examples/dll/README.md +++ b/examples/dll/README.md @@ -10,7 +10,7 @@ This is the _reference_ bundle (with the manifests) for [dll user example](https var path = require("path"); var webpack = require("../../"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", resolve: { extensions: [".js", ".jsx"] }, diff --git a/examples/dll/webpack.config.js b/examples/dll/webpack.config.js index 8b13d6ca13d..6db3df6266c 100644 --- a/examples/dll/webpack.config.js +++ b/examples/dll/webpack.config.js @@ -1,7 +1,7 @@ var path = require("path"); var webpack = require("../../"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", resolve: { extensions: [".js", ".jsx"] }, diff --git a/examples/explicit-vendor-chunk/README.md b/examples/explicit-vendor-chunk/README.md index e950d72896f..3683157c664 100644 --- a/examples/explicit-vendor-chunk/README.md +++ b/examples/explicit-vendor-chunk/README.md @@ -6,7 +6,7 @@ var webpack = require("../../"); module.exports = [ { name: "vendor", - // mode: "development || "production", + // mode: "development" || "production", entry: ["./vendor", "./vendor2"], output: { path: path.resolve(__dirname, "dist"), @@ -23,7 +23,7 @@ module.exports = [ { name: "app", - // mode: "development || "production", + // mode: "development" || "production", dependencies: ["vendor"], entry: { pageA: "./pageA", diff --git a/examples/explicit-vendor-chunk/webpack.config.js b/examples/explicit-vendor-chunk/webpack.config.js index 621a95494a0..e2b4a2911d8 100644 --- a/examples/explicit-vendor-chunk/webpack.config.js +++ b/examples/explicit-vendor-chunk/webpack.config.js @@ -3,7 +3,7 @@ var webpack = require("../../"); module.exports = [ { name: "vendor", - // mode: "development || "production", + // mode: "development" || "production", entry: ["./vendor", "./vendor2"], output: { path: path.resolve(__dirname, "dist"), @@ -20,7 +20,7 @@ module.exports = [ { name: "app", - // mode: "development || "production", + // mode: "development" || "production", dependencies: ["vendor"], entry: { pageA: "./pageA", diff --git a/examples/externals/README.md b/examples/externals/README.md index fb7ce0a4b41..6c22cd52992 100644 --- a/examples/externals/README.md +++ b/examples/externals/README.md @@ -28,7 +28,7 @@ exports.exampleValue = subtract(add(42, 2), 2); ```javascript module.exports = { - // mode: "development || "production", + // mode: "development" || "production", output: { libraryTarget: "umd" }, diff --git a/examples/externals/webpack.config.js b/examples/externals/webpack.config.js index 8210f6627a5..6a9400effbd 100644 --- a/examples/externals/webpack.config.js +++ b/examples/externals/webpack.config.js @@ -1,5 +1,5 @@ module.exports = { - // mode: "development || "production", + // mode: "development" || "production", output: { libraryTarget: "umd" }, diff --git a/examples/extra-async-chunk-advanced/README.md b/examples/extra-async-chunk-advanced/README.md index 5efbc1aacf7..ef6f66d7857 100644 --- a/examples/extra-async-chunk-advanced/README.md +++ b/examples/extra-async-chunk-advanced/README.md @@ -23,7 +23,7 @@ require.ensure(["./a", "./e"], function(require) { ```javascript module.exports = { - // mode: "development || "production", + // mode: "development" || "production", optimization: { splitChunks: { minSize: 0 // This example is too small diff --git a/examples/extra-async-chunk-advanced/webpack.config.js b/examples/extra-async-chunk-advanced/webpack.config.js index f256bc78706..bf11207f017 100644 --- a/examples/extra-async-chunk-advanced/webpack.config.js +++ b/examples/extra-async-chunk-advanced/webpack.config.js @@ -1,5 +1,5 @@ module.exports = { - // mode: "development || "production", + // mode: "development" || "production", optimization: { splitChunks: { minSize: 0 // This example is too small diff --git a/examples/extra-async-chunk/webpack.config.js b/examples/extra-async-chunk/webpack.config.js index f256bc78706..bf11207f017 100644 --- a/examples/extra-async-chunk/webpack.config.js +++ b/examples/extra-async-chunk/webpack.config.js @@ -1,5 +1,5 @@ module.exports = { - // mode: "development || "production", + // mode: "development" || "production", optimization: { splitChunks: { minSize: 0 // This example is too small diff --git a/examples/harmony-library/README.md b/examples/harmony-library/README.md index 200a873cc00..3cd76f2032d 100644 --- a/examples/harmony-library/README.md +++ b/examples/harmony-library/README.md @@ -3,7 +3,7 @@ ```javascript var path = require("path"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: "./example", output: { path: path.join(__dirname, "dist"), diff --git a/examples/harmony-library/webpack.config.js b/examples/harmony-library/webpack.config.js index 5700c38ed4b..a88f40e0fc9 100644 --- a/examples/harmony-library/webpack.config.js +++ b/examples/harmony-library/webpack.config.js @@ -1,6 +1,6 @@ var path = require("path"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: "./example", output: { path: path.join(__dirname, "dist"), diff --git a/examples/harmony-unused/webpack.config.js b/examples/harmony-unused/webpack.config.js index 1aa1e0e591c..f370f58a23b 100644 --- a/examples/harmony-unused/webpack.config.js +++ b/examples/harmony-unused/webpack.config.js @@ -1,5 +1,5 @@ module.exports = { - // mode: "development || "production", + // mode: "development" || "production", optimization: { concatenateModules: false } diff --git a/examples/http2-aggressive-splitting/README.md b/examples/http2-aggressive-splitting/README.md index ed36d015293..c6ee2ff2234 100644 --- a/examples/http2-aggressive-splitting/README.md +++ b/examples/http2-aggressive-splitting/README.md @@ -20,7 +20,7 @@ The backward compatibility (non-HTTP2 client) improves with bigger `maxSize`, as var path = require("path"); var webpack = require("../../"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", cache: true, // better performance for the AggressiveSplittingPlugin entry: "./example", output: { diff --git a/examples/http2-aggressive-splitting/webpack.config.js b/examples/http2-aggressive-splitting/webpack.config.js index 5150993a1b2..ae4ddd0538b 100644 --- a/examples/http2-aggressive-splitting/webpack.config.js +++ b/examples/http2-aggressive-splitting/webpack.config.js @@ -1,7 +1,7 @@ var path = require("path"); var webpack = require("../../"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", cache: true, // better performance for the AggressiveSplittingPlugin entry: "./example", output: { diff --git a/examples/hybrid-routing/README.md b/examples/hybrid-routing/README.md index 70b36a2ec46..a2894268521 100644 --- a/examples/hybrid-routing/README.md +++ b/examples/hybrid-routing/README.md @@ -3,7 +3,7 @@ ```javascript var path = require("path"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: { // The entry points for the pages // They also contains router diff --git a/examples/hybrid-routing/webpack.config.js b/examples/hybrid-routing/webpack.config.js index f3e69bbd346..73a3e850c38 100644 --- a/examples/hybrid-routing/webpack.config.js +++ b/examples/hybrid-routing/webpack.config.js @@ -1,6 +1,6 @@ var path = require("path"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: { // The entry points for the pages // They also contains router diff --git a/examples/loader/webpack.config.js b/examples/loader/webpack.config.js index 73f1713f0e0..b6d7cd8b90c 100644 --- a/examples/loader/webpack.config.js +++ b/examples/loader/webpack.config.js @@ -1,5 +1,5 @@ module.exports = { - // mode: "development || "production", + // mode: "development" || "production", module: { rules: [ { diff --git a/examples/many-pages/README.md b/examples/many-pages/README.md index 61c13962dbd..7a69d80b58c 100644 --- a/examples/many-pages/README.md +++ b/examples/many-pages/README.md @@ -26,7 +26,7 @@ Note: decreasing `maxInitial/AsyncRequest` will increase duplication further to ``` module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: { pageA: "./pages/a", pageB: "./pages/b", diff --git a/examples/many-pages/webpack.config.js b/examples/many-pages/webpack.config.js index b5ce749f624..72b9ab5cdf1 100644 --- a/examples/many-pages/webpack.config.js +++ b/examples/many-pages/webpack.config.js @@ -1,5 +1,5 @@ module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: { pageA: "./pages/a", pageB: "./pages/b", diff --git a/examples/multi-compiler/README.md b/examples/multi-compiler/README.md index 530e4ef4ec6..399f74df5a1 100644 --- a/examples/multi-compiler/README.md +++ b/examples/multi-compiler/README.md @@ -15,7 +15,7 @@ var webpack = require("../../"); module.exports = [ { name: "mobile", - // mode: "development || "production", + // mode: "development" || "production", entry: "./example", output: { path: path.join(__dirname, "dist"), @@ -30,7 +30,7 @@ module.exports = [ { name: "desktop", - // mode: "development || "production", + // mode: "development" || "production", entry: "./example", output: { path: path.join(__dirname, "dist"), diff --git a/examples/multi-compiler/webpack.config.js b/examples/multi-compiler/webpack.config.js index 4fc3088639a..369cfa0c0b9 100644 --- a/examples/multi-compiler/webpack.config.js +++ b/examples/multi-compiler/webpack.config.js @@ -3,7 +3,7 @@ var webpack = require("../../"); module.exports = [ { name: "mobile", - // mode: "development || "production", + // mode: "development" || "production", entry: "./example", output: { path: path.join(__dirname, "dist"), @@ -18,7 +18,7 @@ module.exports = [ { name: "desktop", - // mode: "development || "production", + // mode: "development" || "production", entry: "./example", output: { path: path.join(__dirname, "dist"), diff --git a/examples/multi-part-library/README.md b/examples/multi-part-library/README.md index 393e854c01d..988d6653fcc 100644 --- a/examples/multi-part-library/README.md +++ b/examples/multi-part-library/README.md @@ -17,7 +17,7 @@ Note: When your library has dependencies that should not be included in the comp ```javascript var path = require("path"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: { alpha: "./alpha", beta: "./beta" diff --git a/examples/multi-part-library/webpack.config.js b/examples/multi-part-library/webpack.config.js index f79be11fe71..47537625b61 100644 --- a/examples/multi-part-library/webpack.config.js +++ b/examples/multi-part-library/webpack.config.js @@ -1,6 +1,6 @@ var path = require("path"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: { alpha: "./alpha", beta: "./beta" diff --git a/examples/multiple-entry-points/README.md b/examples/multiple-entry-points/README.md index 0d49ec5ce9b..e371212c5bc 100644 --- a/examples/multiple-entry-points/README.md +++ b/examples/multiple-entry-points/README.md @@ -51,7 +51,7 @@ require.ensure(["./shared"], function(require) { ```javascript module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: { pageA: "./pageA", pageB: "./pageB" diff --git a/examples/multiple-entry-points/webpack.config.js b/examples/multiple-entry-points/webpack.config.js index 4df8e07d565..a4fdc01c909 100644 --- a/examples/multiple-entry-points/webpack.config.js +++ b/examples/multiple-entry-points/webpack.config.js @@ -1,5 +1,5 @@ module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: { pageA: "./pageA", pageB: "./pageB" diff --git a/examples/two-explicit-vendor-chunks/README.md b/examples/two-explicit-vendor-chunks/README.md index ac68dea231f..523bac6b4bf 100644 --- a/examples/two-explicit-vendor-chunks/README.md +++ b/examples/two-explicit-vendor-chunks/README.md @@ -3,7 +3,7 @@ ```javascript var path = require("path"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: { vendor1: ["./vendor1"], vendor2: ["./vendor2"], diff --git a/examples/two-explicit-vendor-chunks/webpack.config.js b/examples/two-explicit-vendor-chunks/webpack.config.js index 582fdd0dbb2..68a018fbfbd 100644 --- a/examples/two-explicit-vendor-chunks/webpack.config.js +++ b/examples/two-explicit-vendor-chunks/webpack.config.js @@ -1,6 +1,6 @@ var path = require("path"); module.exports = { - // mode: "development || "production", + // mode: "development" || "production", entry: { vendor1: ["./vendor1"], vendor2: ["./vendor2"], diff --git a/examples/wasm-complex/webpack.config.js b/examples/wasm-complex/webpack.config.js index ee188b60683..13de5cdac2f 100644 --- a/examples/wasm-complex/webpack.config.js +++ b/examples/wasm-complex/webpack.config.js @@ -1,5 +1,5 @@ module.exports = { - // mode: "development || "production", + // mode: "development" || "production", output: { publicPath: "dist/" }, diff --git a/examples/wasm-simple/webpack.config.js b/examples/wasm-simple/webpack.config.js index 70ba131d8c3..990ea91fc6f 100644 --- a/examples/wasm-simple/webpack.config.js +++ b/examples/wasm-simple/webpack.config.js @@ -1,5 +1,5 @@ module.exports = { - // mode: "development || "production", + // mode: "development" || "production", output: { webassemblyModuleFilename: "[hash].wasm", publicPath: "dist/" From 94f880407a9645b18a8d65a15e8fd6a5f07fc165 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 12 Mar 2023 15:55:43 +0530 Subject: [PATCH 31/38] test: update ProgressPlugin test cases --- lib/node/nodeConsole.js | 2 +- test/ProgressPlugin.test.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/node/nodeConsole.js b/lib/node/nodeConsole.js index dbb74d807b9..3365f6bda20 100644 --- a/lib/node/nodeConsole.js +++ b/lib/node/nodeConsole.js @@ -38,7 +38,7 @@ module.exports = ({ colors, appendOnly, stream }) => { const writeStatusMessage = () => { if (!currentStatusMessage) return; - const l = process.stderr.columns || 40; + const l = stream.columns || 40; const args = truncateArgs(currentStatusMessage, l - 1); const str = args.join(" "); const coloredStr = `\u001b[1m${str}\u001b[39m\u001b[22m`; diff --git a/test/ProgressPlugin.test.js b/test/ProgressPlugin.test.js index 00fc7594296..f8d2aecac0a 100644 --- a/test/ProgressPlugin.test.js +++ b/test/ProgressPlugin.test.js @@ -242,6 +242,7 @@ describe("ProgressPlugin", function () { activeModules: true }); + process.stderr.columns = 70; return RunCompilerAsync(compiler).then(() => { const logs = stderr.toString(); @@ -255,6 +256,7 @@ describe("ProgressPlugin", function () { it("should get the custom handler text from the log", () => { const compiler = createSimpleCompilerWithCustomHandler(); + process.stderr.columns = 70; return RunCompilerAsync(compiler).then(() => { const logs = stderr.toString(); expect(logs).toEqual( From 44256c25cf2ff608943028dff64cd50322eb9283 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 12 Mar 2023 07:35:49 +0530 Subject: [PATCH 32/38] fix: add missing semicolon in `AutoPublicPathRuntimeModule` --- lib/runtime/AutoPublicPathRuntimeModule.js | 2 +- .../StatsTestCases.basictest.js.snap | 44 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/runtime/AutoPublicPathRuntimeModule.js b/lib/runtime/AutoPublicPathRuntimeModule.js index a672408621a..fa962f15947 100644 --- a/lib/runtime/AutoPublicPathRuntimeModule.js +++ b/lib/runtime/AutoPublicPathRuntimeModule.js @@ -43,7 +43,7 @@ class AutoPublicPathRuntimeModule extends RuntimeModule { "if (!scriptUrl && document) {", Template.indent([ `if (document.currentScript)`, - Template.indent(`scriptUrl = document.currentScript.src`), + Template.indent(`scriptUrl = document.currentScript.src;`), "if (!scriptUrl) {", Template.indent([ 'var scripts = document.getElementsByTagName("script");', diff --git a/test/__snapshots__/StatsTestCases.basictest.js.snap b/test/__snapshots__/StatsTestCases.basictest.js.snap index 792fb84f001..d78fcc0a466 100644 --- a/test/__snapshots__/StatsTestCases.basictest.js.snap +++ b/test/__snapshots__/StatsTestCases.basictest.js.snap @@ -318,9 +318,9 @@ vendors: > ./g ./a.js 6:0-47 dependent modules 20 bytes [dependent] 1 module ./g.js 45 bytes [built] [code generated] - chunk (runtime: main) vendors/main.js (main) 147 bytes (javascript) 6.64 KiB (runtime) [entry] [rendered] + chunk (runtime: main) vendors/main.js (main) 147 bytes (javascript) 6.65 KiB (runtime) [entry] [rendered] > ./ main - runtime modules 6.64 KiB 9 modules + runtime modules 6.65 KiB 9 modules ./index.js 147 bytes [built] [code generated] chunk (runtime: a, b, c) vendors/vendors.js (vendors) (id hint: vendors) 60 bytes [initial] [rendered] split chunk (cache group: vendors) (name: vendors) > ./a a @@ -621,9 +621,9 @@ chunk (runtime: main) d_js-e_js.bundle.js 60 bytes <{c_js}> [rendered] cjs self exports reference ./e.js 2:0-14 X ms -> X ms -> X ms (resolving: X ms, restoring: X ms, integration: X ms, building: X ms, storing: X ms) -chunk (runtime: main) bundle.js (main) 73 bytes (javascript) 6 KiB (runtime) >{b_js}< >{c_js}< [entry] [rendered] +chunk (runtime: main) bundle.js (main) 73 bytes (javascript) 6.01 KiB (runtime) >{b_js}< >{c_js}< [entry] [rendered] > ./index main - runtime modules 6 KiB 7 modules + runtime modules 6.01 KiB 7 modules cacheable modules 73 bytes ./a.js 22 bytes [dependent] [built] [code generated] cjs self exports reference ./a.js 1:0-14 @@ -640,8 +640,8 @@ webpack x.x.x compiled successfully in X ms" exports[`StatsTestCases should print correct stats for circular-correctness 1`] = ` "chunk (runtime: main) 128.bundle.js (b) 49 bytes <{179}> <{459}> >{459}< [rendered] ./module-b.js 49 bytes [built] [code generated] -chunk (runtime: main) bundle.js (main) 98 bytes (javascript) 7.68 KiB (runtime) >{128}< >{786}< [entry] [rendered] - runtime modules 7.68 KiB 10 modules +chunk (runtime: main) bundle.js (main) 98 bytes (javascript) 7.69 KiB (runtime) >{128}< >{786}< [entry] [rendered] + runtime modules 7.69 KiB 10 modules ./index.js 98 bytes [built] [code generated] chunk (runtime: main) 459.bundle.js (c) 98 bytes <{128}> <{786}> >{128}< >{786}< [rendered] ./module-c.js 98 bytes [built] [code generated] @@ -1703,9 +1703,9 @@ chunk (runtime: main) a-52.js 149 bytes [rendered] split chunk (cache group: def > ./a ./index.js 1:0-47 > ./b ./index.js 2:0-47 ./shared.js 149 bytes [built] [code generated] -chunk (runtime: main) a-main.js (main) 146 bytes (javascript) 6.9 KiB (runtime) [entry] [rendered] +chunk (runtime: main) a-main.js (main) 146 bytes (javascript) 6.91 KiB (runtime) [entry] [rendered] > ./ main - runtime modules 6.9 KiB 10 modules + runtime modules 6.91 KiB 10 modules ./index.js 146 bytes [built] [code generated] chunk (runtime: main) a-vendors.js (vendors) (id hint: vendors) 40 bytes [rendered] split chunk (cache group: vendors) (name: vendors) > ./c ./index.js 3:0-47 @@ -1730,9 +1730,9 @@ chunk (runtime: main) b-52.js 149 bytes [rendered] split chunk (cache group: def > ./a ./index.js 1:0-47 > ./b ./index.js 2:0-47 ./shared.js 149 bytes [built] [code generated] -chunk (runtime: main) b-main.js (main) 146 bytes (javascript) 6.9 KiB (runtime) [entry] [rendered] +chunk (runtime: main) b-main.js (main) 146 bytes (javascript) 6.91 KiB (runtime) [entry] [rendered] > ./ main - runtime modules 6.9 KiB 10 modules + runtime modules 6.91 KiB 10 modules ./index.js 146 bytes [built] [code generated] chunk (runtime: main) b-vendors.js (vendors) (id hint: vendors) 40 bytes [rendered] split chunk (cache group: vendors) (name: vendors) > ./c ./index.js 3:0-47 @@ -2157,7 +2157,7 @@ runtime modules 5.99 KiB webpack/runtime/load script 1.36 KiB {179} [code generated] [no exports] [used exports unknown] - webpack/runtime/publicPath 867 bytes {179} [code generated] + webpack/runtime/publicPath 868 bytes {179} [code generated] [no exports] [used exports unknown] cacheable modules 193 bytes @@ -2228,7 +2228,7 @@ LOG from webpack.FileSystemInfo Directory info in cache: 0 timestamps 0 hashes 0 timestamp hash combinations Managed items info in cache: 0 items -1970-04-20 12:42:42: webpack x.x.x compiled successfully in X ms (440eb519eb0c4246cce1)" +1970-04-20 12:42:42: webpack x.x.x compiled successfully in X ms (470e5df7d5fc05a2cfff)" `; exports[`StatsTestCases should print correct stats for preset-errors-only 1`] = `""`; @@ -2427,7 +2427,7 @@ chunk {179} (runtime: main) main.js (main) 73 bytes (javascript) 5.99 KiB (runti webpack/runtime/load script 1.36 KiB {179} [code generated] [no exports] [used exports unknown] - webpack/runtime/publicPath 867 bytes {179} [code generated] + webpack/runtime/publicPath 868 bytes {179} [code generated] [no exports] [used exports unknown] cacheable modules 73 bytes @@ -2604,7 +2604,7 @@ LOG from webpack.FileSystemInfo Directory info in cache: 0 timestamps 0 hashes 0 timestamp hash combinations Managed items info in cache: 0 items -1970-04-20 12:42:42: webpack x.x.x compiled successfully in X ms (440eb519eb0c4246cce1)" +1970-04-20 12:42:42: webpack x.x.x compiled successfully in X ms (5966d7136f537890a286)" `; exports[`StatsTestCases should print correct stats for real-content-hash 1`] = ` @@ -2956,8 +2956,8 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp asset production-dy_js.js 1.14 KiB [emitted] asset production-dz_js.js 1.14 KiB [emitted] asset production-c.js 93 bytes [emitted] (name: c) - chunk (runtime: a) production-a.js (a) 605 bytes (javascript) 6.57 KiB (runtime) [entry] [rendered] - runtime modules 6.57 KiB 9 modules + chunk (runtime: a) production-a.js (a) 605 bytes (javascript) 6.58 KiB (runtime) [entry] [rendered] + runtime modules 6.58 KiB 9 modules cacheable modules 605 bytes ./a.js 261 bytes [built] [code generated] [no exports used] @@ -2969,8 +2969,8 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp [only some exports used: x] ./reexport.js 37 bytes [dependent] [built] [code generated] [only some exports used: x] - chunk (runtime: b) production-b.js (b) 605 bytes (javascript) 6.57 KiB (runtime) [entry] [rendered] - runtime modules 6.57 KiB 9 modules + chunk (runtime: b) production-b.js (b) 605 bytes (javascript) 6.58 KiB (runtime) [entry] [rendered] + runtime modules 6.58 KiB 9 modules cacheable modules 605 bytes ./b.js 261 bytes [built] [code generated] [no exports used] @@ -3005,7 +3005,7 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp ./dz.js 46 bytes [built] [code generated] ./module.js?chunk 122 bytes [dependent] [built] [code generated] [only some exports used: identity, w, x, z] - runtime modules 13.1 KiB 18 modules + runtime modules 13.2 KiB 18 modules cacheable modules 1.15 KiB ./a.js 261 bytes [built] [code generated] [no exports used] @@ -3193,7 +3193,7 @@ global: `; exports[`StatsTestCases should print correct stats for scope-hoisting-bailouts 1`] = ` -"runtime modules 6.82 KiB 10 modules +"runtime modules 6.83 KiB 10 modules built modules 615 bytes [built] code generated modules 530 bytes [code generated] ./index.js 150 bytes [built] [code generated] @@ -3724,7 +3724,7 @@ name-too-long: name-too-long (webpack x.x.x) compiled successfully custom-chunks-filter: - Entrypoint main 11.4 KiB = custom-chunks-filter/main.js + Entrypoint main 11.5 KiB = custom-chunks-filter/main.js Entrypoint a 12.5 KiB = custom-chunks-filter/a.js Entrypoint b 8.14 KiB = custom-chunks-filter/282.js 414 bytes custom-chunks-filter/954.js 414 bytes custom-chunks-filter/568.js 414 bytes custom-chunks-filter/767.js 414 bytes custom-chunks-filter/b.js 6.52 KiB Entrypoint c 8.14 KiB = custom-chunks-filter/282.js 414 bytes custom-chunks-filter/769.js 414 bytes custom-chunks-filter/568.js 414 bytes custom-chunks-filter/767.js 414 bytes custom-chunks-filter/c.js 6.52 KiB @@ -3790,7 +3790,7 @@ custom-chunks-filter: custom-chunks-filter (webpack x.x.x) compiled successfully custom-chunks-filter-in-cache-groups: - Entrypoint main 11.2 KiB = custom-chunks-filter-in-cache-groups/main.js + Entrypoint main 11.3 KiB = custom-chunks-filter-in-cache-groups/main.js Entrypoint a 14.5 KiB = custom-chunks-filter-in-cache-groups/176.js 864 bytes custom-chunks-filter-in-cache-groups/a.js 13.7 KiB Entrypoint b 8.45 KiB = custom-chunks-filter-in-cache-groups/vendors.js 1.05 KiB custom-chunks-filter-in-cache-groups/b.js 7.4 KiB Entrypoint c 8.45 KiB = custom-chunks-filter-in-cache-groups/vendors.js 1.05 KiB custom-chunks-filter-in-cache-groups/c.js 7.4 KiB From 976320d0b4605be99e3ca1819c4471a46c42924e Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 14 Mar 2023 18:45:18 +0530 Subject: [PATCH 33/38] test: update StatsTestCases snapshots --- .../StatsTestCases.basictest.js.snap | 112 +++++++++--------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/test/__snapshots__/StatsTestCases.basictest.js.snap b/test/__snapshots__/StatsTestCases.basictest.js.snap index d78fcc0a466..5d327daad15 100644 --- a/test/__snapshots__/StatsTestCases.basictest.js.snap +++ b/test/__snapshots__/StatsTestCases.basictest.js.snap @@ -191,9 +191,9 @@ webpack x.x.x compiled successfully in X ms" `; exports[`StatsTestCases should print correct stats for async-commons-chunk 1`] = ` -"chunk (runtime: main) main.js (main) 515 bytes (javascript) 5.99 KiB (runtime) >{460}< >{847}< >{996}< [entry] [rendered] +"chunk (runtime: main) main.js (main) 515 bytes (javascript) 6 KiB (runtime) >{460}< >{847}< >{996}< [entry] [rendered] > ./ main - runtime modules 5.99 KiB 7 modules + runtime modules 6 KiB 7 modules ./index.js 515 bytes [built] [code generated] chunk (runtime: main) 460.js 21 bytes <{179}> ={847}= [rendered] > ./index.js 17:1-21:3 @@ -220,9 +220,9 @@ exports[`StatsTestCases should print correct stats for async-commons-chunk-auto > ./g ./a.js 6:0-47 dependent modules 20 bytes [dependent] 1 module ./g.js 45 bytes [built] [code generated] - chunk (runtime: main) disabled/main.js (main) 147 bytes (javascript) 6.64 KiB (runtime) [entry] [rendered] + chunk (runtime: main) disabled/main.js (main) 147 bytes (javascript) 6.65 KiB (runtime) [entry] [rendered] > ./ main - runtime modules 6.64 KiB 9 modules + runtime modules 6.65 KiB 9 modules ./index.js 147 bytes [built] [code generated] chunk (runtime: main) disabled/async-b.js (async-b) 196 bytes [rendered] > ./b ./index.js 2:0-47 @@ -290,9 +290,9 @@ default: chunk (runtime: main) default/769.js (id hint: vendors) 20 bytes [rendered] split chunk (cache group: defaultVendors) > ./c ./index.js 3:0-47 ./node_modules/z.js 20 bytes [built] [code generated] - chunk (runtime: a) default/a.js (a) 245 bytes (javascript) 6.64 KiB (runtime) [entry] [rendered] + chunk (runtime: a) default/a.js (a) 245 bytes (javascript) 6.65 KiB (runtime) [entry] [rendered] > ./a a - runtime modules 6.64 KiB 9 modules + runtime modules 6.65 KiB 9 modules dependent modules 60 bytes [dependent] 3 modules ./a.js + 1 modules 185 bytes [built] [code generated] chunk (runtime: main) default/async-a.js (async-a) 185 bytes [rendered] @@ -318,9 +318,9 @@ vendors: > ./g ./a.js 6:0-47 dependent modules 20 bytes [dependent] 1 module ./g.js 45 bytes [built] [code generated] - chunk (runtime: main) vendors/main.js (main) 147 bytes (javascript) 6.65 KiB (runtime) [entry] [rendered] + chunk (runtime: main) vendors/main.js (main) 147 bytes (javascript) 6.64 KiB (runtime) [entry] [rendered] > ./ main - runtime modules 6.65 KiB 9 modules + runtime modules 6.64 KiB 9 modules ./index.js 147 bytes [built] [code generated] chunk (runtime: a, b, c) vendors/vendors.js (vendors) (id hint: vendors) 60 bytes [initial] [rendered] split chunk (cache group: vendors) (name: vendors) > ./a a @@ -621,9 +621,9 @@ chunk (runtime: main) d_js-e_js.bundle.js 60 bytes <{c_js}> [rendered] cjs self exports reference ./e.js 2:0-14 X ms -> X ms -> X ms (resolving: X ms, restoring: X ms, integration: X ms, building: X ms, storing: X ms) -chunk (runtime: main) bundle.js (main) 73 bytes (javascript) 6.01 KiB (runtime) >{b_js}< >{c_js}< [entry] [rendered] +chunk (runtime: main) bundle.js (main) 73 bytes (javascript) 6 KiB (runtime) >{b_js}< >{c_js}< [entry] [rendered] > ./index main - runtime modules 6.01 KiB 7 modules + runtime modules 6 KiB 7 modules cacheable modules 73 bytes ./a.js 22 bytes [dependent] [built] [code generated] cjs self exports reference ./a.js 1:0-14 @@ -640,8 +640,8 @@ webpack x.x.x compiled successfully in X ms" exports[`StatsTestCases should print correct stats for circular-correctness 1`] = ` "chunk (runtime: main) 128.bundle.js (b) 49 bytes <{179}> <{459}> >{459}< [rendered] ./module-b.js 49 bytes [built] [code generated] -chunk (runtime: main) bundle.js (main) 98 bytes (javascript) 7.69 KiB (runtime) >{128}< >{786}< [entry] [rendered] - runtime modules 7.69 KiB 10 modules +chunk (runtime: main) bundle.js (main) 98 bytes (javascript) 7.68 KiB (runtime) >{128}< >{786}< [entry] [rendered] + runtime modules 7.68 KiB 10 modules ./index.js 98 bytes [built] [code generated] chunk (runtime: main) 459.bundle.js (c) 98 bytes <{128}> <{786}> >{128}< >{786}< [rendered] ./module-c.js 98 bytes [built] [code generated] @@ -1298,8 +1298,8 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin 2 chunks: asset bundle2.js 12.5 KiB [emitted] (name: main) asset 459.bundle2.js 664 bytes [emitted] (name: c) - chunk (runtime: main) bundle2.js (main) 101 bytes (javascript) 7.68 KiB (runtime) >{459}< [entry] [rendered] - runtime modules 7.68 KiB 10 modules + chunk (runtime: main) bundle2.js (main) 101 bytes (javascript) 7.69 KiB (runtime) >{459}< [entry] [rendered] + runtime modules 7.69 KiB 10 modules ./index.js 101 bytes [built] [code generated] chunk (runtime: main) 459.bundle2.js (c) 118 bytes <{179}> <{459}> >{459}< [rendered] dependent modules 44 bytes [dependent] @@ -1314,8 +1314,8 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin asset bundle3.js 12.5 KiB [emitted] (name: main) asset 459.bundle3.js 528 bytes [emitted] (name: c) asset 524.bundle3.js 206 bytes [emitted] - chunk (runtime: main) bundle3.js (main) 101 bytes (javascript) 7.68 KiB (runtime) >{459}< [entry] [rendered] - runtime modules 7.68 KiB 10 modules + chunk (runtime: main) bundle3.js (main) 101 bytes (javascript) 7.69 KiB (runtime) >{459}< [entry] [rendered] + runtime modules 7.69 KiB 10 modules ./index.js 101 bytes [built] [code generated] chunk (runtime: main) 459.bundle3.js (c) 74 bytes <{179}> >{524}< [rendered] ./a.js 22 bytes [built] [code generated] @@ -1331,8 +1331,8 @@ exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin asset 459.bundle4.js 392 bytes [emitted] (name: c) asset 394.bundle4.js 206 bytes [emitted] asset 524.bundle4.js 206 bytes [emitted] - chunk (runtime: main) bundle4.js (main) 101 bytes (javascript) 7.68 KiB (runtime) >{394}< >{459}< [entry] [rendered] - runtime modules 7.68 KiB 10 modules + chunk (runtime: main) bundle4.js (main) 101 bytes (javascript) 7.69 KiB (runtime) >{394}< >{459}< [entry] [rendered] + runtime modules 7.69 KiB 10 modules ./index.js 101 bytes [built] [code generated] chunk (runtime: main) 394.bundle4.js 44 bytes <{179}> [rendered] ./a.js 22 bytes [built] [code generated] @@ -1494,13 +1494,13 @@ Chunk Group b 549 bytes (21 KiB) = b.js 549 bytes (2.png 21 KiB) chunk (runtime: main) b.js (b) 67 bytes [rendered] ./node_modules/a/2.png 49 bytes [dependent] [built] [code generated] [1 asset] ./node_modules/b/index.js 18 bytes [built] [code generated] -chunk (runtime: main) main.js (main) 82 bytes (javascript) 6.28 KiB (runtime) [entry] [rendered] - runtime modules 6.28 KiB 8 modules +chunk (runtime: main) main.js (main) 82 bytes (javascript) 6.29 KiB (runtime) [entry] [rendered] + runtime modules 6.29 KiB 8 modules ./index.js 82 bytes [built] [code generated] chunk (runtime: main) a.js (a) 134 bytes [rendered] ./node_modules/a/2.png 49 bytes [dependent] [built] [code generated] [1 asset] ./node_modules/a/index.js + 1 modules 85 bytes [built] [code generated] [1 asset] -runtime modules 6.28 KiB 8 modules +runtime modules 6.29 KiB 8 modules orphan modules 49 bytes [orphan] 1 module modules with assets 234 bytes modules by path ./node_modules/a/ 134 bytes @@ -1695,7 +1695,7 @@ webpack x.x.x compiled with 2 errors in X ms" `; exports[`StatsTestCases should print correct stats for named-chunk-groups 1`] = ` -"Chunk Group main 11.6 KiB = a-main.js +"Chunk Group main 11.7 KiB = a-main.js Chunk Group async-a 1.07 KiB = a-52.js 257 bytes a-async-a.js 836 bytes Chunk Group async-b 1.07 KiB = a-52.js 257 bytes a-async-b.js 836 bytes Chunk Group async-c 1.45 KiB = a-vendors.js 744 bytes a-async-c.js 741 bytes @@ -1703,9 +1703,9 @@ chunk (runtime: main) a-52.js 149 bytes [rendered] split chunk (cache group: def > ./a ./index.js 1:0-47 > ./b ./index.js 2:0-47 ./shared.js 149 bytes [built] [code generated] -chunk (runtime: main) a-main.js (main) 146 bytes (javascript) 6.91 KiB (runtime) [entry] [rendered] +chunk (runtime: main) a-main.js (main) 146 bytes (javascript) 6.9 KiB (runtime) [entry] [rendered] > ./ main - runtime modules 6.91 KiB 10 modules + runtime modules 6.9 KiB 10 modules ./index.js 146 bytes [built] [code generated] chunk (runtime: main) a-vendors.js (vendors) (id hint: vendors) 40 bytes [rendered] split chunk (cache group: vendors) (name: vendors) > ./c ./index.js 3:0-47 @@ -1722,7 +1722,7 @@ chunk (runtime: main) a-async-a.js (async-a) 175 bytes [rendered] ./a.js 175 bytes [built] [code generated] webpack x.x.x compiled successfully -Entrypoint main 11.6 KiB = b-main.js +Entrypoint main 11.7 KiB = b-main.js Chunk Group async-a 1.07 KiB = b-52.js 257 bytes b-async-a.js 836 bytes Chunk Group async-b 1.07 KiB = b-52.js 257 bytes b-async-b.js 836 bytes Chunk Group async-c 1.45 KiB = b-vendors.js 744 bytes b-async-c.js 741 bytes @@ -1730,9 +1730,9 @@ chunk (runtime: main) b-52.js 149 bytes [rendered] split chunk (cache group: def > ./a ./index.js 1:0-47 > ./b ./index.js 2:0-47 ./shared.js 149 bytes [built] [code generated] -chunk (runtime: main) b-main.js (main) 146 bytes (javascript) 6.91 KiB (runtime) [entry] [rendered] +chunk (runtime: main) b-main.js (main) 146 bytes (javascript) 6.9 KiB (runtime) [entry] [rendered] > ./ main - runtime modules 6.91 KiB 10 modules + runtime modules 6.9 KiB 10 modules ./index.js 146 bytes [built] [code generated] chunk (runtime: main) b-vendors.js (vendors) (id hint: vendors) 40 bytes [rendered] split chunk (cache group: vendors) (name: vendors) > ./c ./index.js 3:0-47 @@ -1946,7 +1946,7 @@ asset 460.js 323 bytes [emitted] asset 524.js 206 bytes [emitted] asset 996.js 138 bytes [emitted] Entrypoint main 303 KiB = main.js -runtime modules 5.99 KiB 7 modules +runtime modules 6 KiB 7 modules cacheable modules 293 KiB ./index.js 52 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -1963,7 +1963,7 @@ asset 460.js 323 bytes [emitted] asset 524.js 206 bytes [emitted] asset 996.js 138 bytes [emitted] Entrypoint main [big] 303 KiB = main.js -runtime modules 5.99 KiB 7 modules +runtime modules 6 KiB 7 modules cacheable modules 293 KiB ./index.js 52 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -2022,7 +2022,7 @@ asset 460.js 323 bytes [emitted] asset 524.js 206 bytes [emitted] asset 996.js 138 bytes [emitted] Entrypoint main [big] 303 KiB = main.js -runtime modules 5.99 KiB 7 modules +runtime modules 6 KiB 7 modules cacheable modules 293 KiB ./index.js 52 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -2130,7 +2130,7 @@ asset 460.js 323 bytes {460} [emitted] asset 524.js 206 bytes {524} [emitted] asset 996.js 138 bytes {996} [emitted] Entrypoint main 10.2 KiB = main.js -chunk {179} (runtime: main) main.js (main) 73 bytes (javascript) 5.99 KiB (runtime) >{460}< >{996}< [entry] [rendered] +chunk {179} (runtime: main) main.js (main) 73 bytes (javascript) 6 KiB (runtime) >{460}< >{996}< [entry] [rendered] > ./index main chunk {460} (runtime: main) 460.js 54 bytes <{179}> >{524}< [rendered] > ./c [10] ./index.js 3:0-16 @@ -2138,7 +2138,7 @@ chunk {524} (runtime: main) 524.js 44 bytes <{460}> [rendered] > [460] ./c.js 1:0-52 chunk {996} (runtime: main) 996.js 22 bytes <{179}> [rendered] > ./b [10] ./index.js 2:0-16 -runtime modules 5.99 KiB +runtime modules 6 KiB webpack/runtime/ensure chunk 326 bytes {179} [code generated] [no exports] [used exports unknown] @@ -2228,7 +2228,7 @@ LOG from webpack.FileSystemInfo Directory info in cache: 0 timestamps 0 hashes 0 timestamp hash combinations Managed items info in cache: 0 items -1970-04-20 12:42:42: webpack x.x.x compiled successfully in X ms (470e5df7d5fc05a2cfff)" +1970-04-20 12:42:42: webpack x.x.x compiled successfully in X ms (44c013196446a1259957)" `; exports[`StatsTestCases should print correct stats for preset-errors-only 1`] = `""`; @@ -2307,7 +2307,7 @@ asset main.js 10.2 KiB [emitted] (name: main) asset 460.js 323 bytes [emitted] asset 524.js 206 bytes [emitted] asset 996.js 138 bytes [emitted] -runtime modules 5.99 KiB 7 modules +runtime modules 6 KiB 7 modules cacheable modules 193 bytes ./index.js 51 bytes [built] [code generated] ./a.js 22 bytes [built] [code generated] @@ -2330,7 +2330,7 @@ exports[`StatsTestCases should print correct stats for preset-normal-performance asset 460.js 323 bytes [emitted] asset 524.js 206 bytes [emitted] asset 996.js 138 bytes [emitted] -runtime modules 5.99 KiB 7 modules +runtime modules 6 KiB 7 modules cacheable modules 293 KiB ./index.js 52 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -2358,7 +2358,7 @@ exports[`StatsTestCases should print correct stats for preset-normal-performance asset 460.js 355 bytes [emitted] 1 related asset asset 524.js 238 bytes [emitted] 1 related asset asset 996.js 170 bytes [emitted] 1 related asset -runtime modules 5.99 KiB 7 modules +runtime modules 6 KiB 7 modules cacheable modules 293 KiB ./index.js 52 bytes [built] [code generated] ./a.js 293 KiB [built] [code generated] @@ -2406,9 +2406,9 @@ asset 460.js 323 bytes {460} [emitted] asset 524.js 206 bytes {524} [emitted] asset 996.js 138 bytes {996} [emitted] Entrypoint main 10.2 KiB = main.js -chunk {179} (runtime: main) main.js (main) 73 bytes (javascript) 5.99 KiB (runtime) >{460}< >{996}< [entry] [rendered] +chunk {179} (runtime: main) main.js (main) 73 bytes (javascript) 6 KiB (runtime) >{460}< >{996}< [entry] [rendered] > ./index main - runtime modules 5.99 KiB + runtime modules 6 KiB webpack/runtime/ensure chunk 326 bytes {179} [code generated] [no exports] [used exports unknown] @@ -2604,7 +2604,7 @@ LOG from webpack.FileSystemInfo Directory info in cache: 0 timestamps 0 hashes 0 timestamp hash combinations Managed items info in cache: 0 items -1970-04-20 12:42:42: webpack x.x.x compiled successfully in X ms (5966d7136f537890a286)" +1970-04-20 12:42:42: webpack x.x.x compiled successfully in X ms (44c013196446a1259957)" `; exports[`StatsTestCases should print correct stats for real-content-hash 1`] = ` @@ -2956,8 +2956,8 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp asset production-dy_js.js 1.14 KiB [emitted] asset production-dz_js.js 1.14 KiB [emitted] asset production-c.js 93 bytes [emitted] (name: c) - chunk (runtime: a) production-a.js (a) 605 bytes (javascript) 6.58 KiB (runtime) [entry] [rendered] - runtime modules 6.58 KiB 9 modules + chunk (runtime: a) production-a.js (a) 605 bytes (javascript) 6.57 KiB (runtime) [entry] [rendered] + runtime modules 6.57 KiB 9 modules cacheable modules 605 bytes ./a.js 261 bytes [built] [code generated] [no exports used] @@ -2969,8 +2969,8 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp [only some exports used: x] ./reexport.js 37 bytes [dependent] [built] [code generated] [only some exports used: x] - chunk (runtime: b) production-b.js (b) 605 bytes (javascript) 6.58 KiB (runtime) [entry] [rendered] - runtime modules 6.58 KiB 9 modules + chunk (runtime: b) production-b.js (b) 605 bytes (javascript) 6.57 KiB (runtime) [entry] [rendered] + runtime modules 6.57 KiB 9 modules cacheable modules 605 bytes ./b.js 261 bytes [built] [code generated] [no exports used] @@ -3005,7 +3005,7 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp ./dz.js 46 bytes [built] [code generated] ./module.js?chunk 122 bytes [dependent] [built] [code generated] [only some exports used: identity, w, x, z] - runtime modules 13.2 KiB 18 modules + runtime modules 13.1 KiB 18 modules cacheable modules 1.15 KiB ./a.js 261 bytes [built] [code generated] [no exports used] @@ -3030,15 +3030,15 @@ exports[`StatsTestCases should print correct stats for runtime-specific-used-exp production (webpack x.x.x) compiled successfully in X ms development: - asset development-a.js 15.8 KiB [emitted] (name: a) - asset development-b.js 15.8 KiB [emitted] (name: b) + asset development-a.js 15.9 KiB [emitted] (name: a) + asset development-b.js 15.9 KiB [emitted] (name: b) asset development-dw_js.js 2.11 KiB [emitted] asset development-dx_js.js 2.11 KiB [emitted] asset development-dy_js.js 2.11 KiB [emitted] asset development-dz_js.js 2.11 KiB [emitted] asset development-c.js 1.13 KiB [emitted] (name: c) - chunk (runtime: a) development-a.js (a) 605 bytes (javascript) 6.57 KiB (runtime) [entry] [rendered] - runtime modules 6.57 KiB 9 modules + chunk (runtime: a) development-a.js (a) 605 bytes (javascript) 6.58 KiB (runtime) [entry] [rendered] + runtime modules 6.58 KiB 9 modules cacheable modules 605 bytes ./a.js 261 bytes [built] [code generated] [used exports unknown] @@ -3050,8 +3050,8 @@ development: [used exports unknown] ./reexport.js 37 bytes [dependent] [built] [code generated] [used exports unknown] - chunk (runtime: b) development-b.js (b) 605 bytes (javascript) 6.57 KiB (runtime) [entry] [rendered] - runtime modules 6.57 KiB 9 modules + chunk (runtime: b) development-b.js (b) 605 bytes (javascript) 6.58 KiB (runtime) [entry] [rendered] + runtime modules 6.58 KiB 9 modules cacheable modules 605 bytes ./b.js 261 bytes [built] [code generated] [used exports unknown] @@ -3086,7 +3086,7 @@ development: [used exports unknown] ./module.js?chunk 122 bytes [dependent] [built] [code generated] [used exports unknown] - runtime modules 13.1 KiB 18 modules + runtime modules 13.2 KiB 18 modules cacheable modules 1.15 KiB ./a.js 261 bytes [built] [code generated] [used exports unknown] @@ -3193,7 +3193,7 @@ global: `; exports[`StatsTestCases should print correct stats for scope-hoisting-bailouts 1`] = ` -"runtime modules 6.83 KiB 10 modules +"runtime modules 6.82 KiB 10 modules built modules 615 bytes [built] code generated modules 530 bytes [code generated] ./index.js 150 bytes [built] [code generated] @@ -3495,9 +3495,9 @@ exports[`StatsTestCases should print correct stats for split-chunks 1`] = ` chunk (runtime: main) default/769.js (id hint: vendors) 20 bytes <{179}> ={282}= ={383}= ={568}= ={767}= [rendered] split chunk (cache group: defaultVendors) > ./c ./index.js 3:0-47 ./node_modules/z.js 20 bytes [built] [code generated] - chunk (runtime: a) default/a.js (a) 245 bytes (javascript) 6.64 KiB (runtime) >{137}< >{568}< [entry] [rendered] + chunk (runtime: a) default/a.js (a) 245 bytes (javascript) 6.65 KiB (runtime) >{137}< >{568}< [entry] [rendered] > ./a a - runtime modules 6.64 KiB 9 modules + runtime modules 6.65 KiB 9 modules dependent modules 60 bytes [dependent] 3 modules ./a.js + 1 modules 185 bytes [built] [code generated] chunk (runtime: main) default/async-a.js (async-a) 185 bytes <{179}> ={282}= ={767}= ={954}= >{137}< >{568}< [rendered] @@ -3724,7 +3724,7 @@ name-too-long: name-too-long (webpack x.x.x) compiled successfully custom-chunks-filter: - Entrypoint main 11.5 KiB = custom-chunks-filter/main.js + Entrypoint main 11.4 KiB = custom-chunks-filter/main.js Entrypoint a 12.5 KiB = custom-chunks-filter/a.js Entrypoint b 8.14 KiB = custom-chunks-filter/282.js 414 bytes custom-chunks-filter/954.js 414 bytes custom-chunks-filter/568.js 414 bytes custom-chunks-filter/767.js 414 bytes custom-chunks-filter/b.js 6.52 KiB Entrypoint c 8.14 KiB = custom-chunks-filter/282.js 414 bytes custom-chunks-filter/769.js 414 bytes custom-chunks-filter/568.js 414 bytes custom-chunks-filter/767.js 414 bytes custom-chunks-filter/c.js 6.52 KiB @@ -3790,7 +3790,7 @@ custom-chunks-filter: custom-chunks-filter (webpack x.x.x) compiled successfully custom-chunks-filter-in-cache-groups: - Entrypoint main 11.3 KiB = custom-chunks-filter-in-cache-groups/main.js + Entrypoint main 11.2 KiB = custom-chunks-filter-in-cache-groups/main.js Entrypoint a 14.5 KiB = custom-chunks-filter-in-cache-groups/176.js 864 bytes custom-chunks-filter-in-cache-groups/a.js 13.7 KiB Entrypoint b 8.45 KiB = custom-chunks-filter-in-cache-groups/vendors.js 1.05 KiB custom-chunks-filter-in-cache-groups/b.js 7.4 KiB Entrypoint c 8.45 KiB = custom-chunks-filter-in-cache-groups/vendors.js 1.05 KiB custom-chunks-filter-in-cache-groups/c.js 7.4 KiB From 3943ccefca455839e6a5388082c5f333a0d390e5 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 15 Mar 2023 06:50:10 +0530 Subject: [PATCH 34/38] fix: initialize `this._cacheStage` in ModuleGraph constructor --- lib/ModuleGraph.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ModuleGraph.js b/lib/ModuleGraph.js index e67e7dbddbd..4e96315a56e 100644 --- a/lib/ModuleGraph.js +++ b/lib/ModuleGraph.js @@ -128,6 +128,9 @@ class ModuleGraph { /** @type {Map>} */ this._moduleMemCaches = undefined; + + /** @type {string} */ + this._cacheStage = undefined; } /** From 196b49f4a7ddc1ae1cda6b00c08381e1a8fd47a2 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 14 Mar 2023 18:42:11 +0530 Subject: [PATCH 35/38] test(configCases): add a test case for #16040 --- .../output-module/issue-16040/bar.css | 3 + .../output-module/issue-16040/bar.js | 7 ++ .../output-module/issue-16040/entry.js | 1 + .../output-module/issue-16040/foo.css | 3 + .../output-module/issue-16040/foo.js | 7 ++ .../output-module/issue-16040/index.js | 15 ++++ .../output-module/issue-16040/test.config.js | 5 ++ .../issue-16040/webpack.config.js | 77 +++++++++++++++++++ 8 files changed, 118 insertions(+) create mode 100644 test/configCases/output-module/issue-16040/bar.css create mode 100644 test/configCases/output-module/issue-16040/bar.js create mode 100644 test/configCases/output-module/issue-16040/entry.js create mode 100644 test/configCases/output-module/issue-16040/foo.css create mode 100644 test/configCases/output-module/issue-16040/foo.js create mode 100644 test/configCases/output-module/issue-16040/index.js create mode 100644 test/configCases/output-module/issue-16040/test.config.js create mode 100644 test/configCases/output-module/issue-16040/webpack.config.js diff --git a/test/configCases/output-module/issue-16040/bar.css b/test/configCases/output-module/issue-16040/bar.css new file mode 100644 index 00000000000..5330aae07f8 --- /dev/null +++ b/test/configCases/output-module/issue-16040/bar.css @@ -0,0 +1,3 @@ +.bar { + color: #fff; +} \ No newline at end of file diff --git a/test/configCases/output-module/issue-16040/bar.js b/test/configCases/output-module/issue-16040/bar.js new file mode 100644 index 00000000000..f4ca3ebdc21 --- /dev/null +++ b/test/configCases/output-module/issue-16040/bar.js @@ -0,0 +1,7 @@ +import { countBy } from 'lodash-es' + +import './bar.css' + +const result = countBy([6.1, 4.2, 6.3], Math.floor) + +export default result['6'] \ No newline at end of file diff --git a/test/configCases/output-module/issue-16040/entry.js b/test/configCases/output-module/issue-16040/entry.js new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/test/configCases/output-module/issue-16040/entry.js @@ -0,0 +1 @@ + diff --git a/test/configCases/output-module/issue-16040/foo.css b/test/configCases/output-module/issue-16040/foo.css new file mode 100644 index 00000000000..6bbab56ba21 --- /dev/null +++ b/test/configCases/output-module/issue-16040/foo.css @@ -0,0 +1,3 @@ +.foo { + color: #fff; +} \ No newline at end of file diff --git a/test/configCases/output-module/issue-16040/foo.js b/test/configCases/output-module/issue-16040/foo.js new file mode 100644 index 00000000000..d9805d58ba5 --- /dev/null +++ b/test/configCases/output-module/issue-16040/foo.js @@ -0,0 +1,7 @@ +import { dropRight } from 'lodash-es' + +import './foo.css' + +const result = dropRight([10, 20, 30], 2) + +export default result[0] \ No newline at end of file diff --git a/test/configCases/output-module/issue-16040/index.js b/test/configCases/output-module/issue-16040/index.js new file mode 100644 index 00000000000..cecb68042a2 --- /dev/null +++ b/test/configCases/output-module/issue-16040/index.js @@ -0,0 +1,15 @@ +import foo from "./foo.js"; +import bar from "./bar.js"; + +console.log(foo + bar); + +it("should not contain non javascript chunk in the main bundle", () => { + const fs = require("fs"); + const source = fs.readFileSync(__STATS__.outputPath + "/main.mjs", "utf-8"); + + expect(__STATS__.chunks.some(c => c.names.includes("style"))).toBe(true); + // Should not import "./style.mjs";` + expect(source).not.toMatch( + /import\s\*\sas+\s__webpack_chunk_[0-9]+__\sfrom\s"\.\/style\.mjs"/g + ); +}); diff --git a/test/configCases/output-module/issue-16040/test.config.js b/test/configCases/output-module/issue-16040/test.config.js new file mode 100644 index 00000000000..be83c69bf17 --- /dev/null +++ b/test/configCases/output-module/issue-16040/test.config.js @@ -0,0 +1,5 @@ +module.exports = { + findBundle: function(i, options) { + return ["main.mjs", "vendor.mjs", "runtime.mjs"]; + } +}; diff --git a/test/configCases/output-module/issue-16040/webpack.config.js b/test/configCases/output-module/issue-16040/webpack.config.js new file mode 100644 index 00000000000..275e36a5232 --- /dev/null +++ b/test/configCases/output-module/issue-16040/webpack.config.js @@ -0,0 +1,77 @@ +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); + +module.exports = { + mode: "production", + devtool: false, + experiments: { + outputModule: true + }, + output: { + publicPath: "/", + filename: "[name].mjs", + chunkFilename: "[name].chunk.js", + assetModuleFilename: "[hash][ext][query]", + module: true, + libraryTarget: "module", + chunkFormat: "module", + chunkLoading: "import", + environment: { + dynamicImport: true, + module: true + } + }, + + module: { + rules: [ + { + test: /\.css$/i, + use: [MiniCssExtractPlugin.loader, "css-loader"] + } + ] + }, + + plugins: [ + new MiniCssExtractPlugin({ + filename: "style.css", + chunkFilename: "[id].css" + }) + ], + + optimization: { + splitChunks: { + chunks: "all", + + cacheGroups: { + style: { + name: "style", + type: "css/mini-extract", + chunks: "all", + enforce: true + }, + + defaultVendors: { + name: "vendor", + test: /[\\/]node_modules[\\/]/, + priority: -10, + chunks: "initial", + reuseExistingChunk: true + }, + + default: { + minChunks: 2, + priority: -20, + reuseExistingChunk: true + } + } + }, + + runtimeChunk: { + name: "runtime" + }, + + // currently Webpack has bugs when setting concatenateModules to true while produce ES Module output. + // concatenateModules: false, + + minimize: false + } +}; From 0df270ac9fc5a188e0e0da57636d571a5e087c86 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 15 Mar 2023 13:30:11 +0530 Subject: [PATCH 36/38] test: fix test case for node v10 --- test/configCases/output-module/issue-16040/bar.css | 2 +- test/configCases/output-module/issue-16040/bar.js | 8 ++++---- test/configCases/output-module/issue-16040/entry.js | 1 - test/configCases/output-module/issue-16040/foo.css | 2 +- test/configCases/output-module/issue-16040/foo.js | 8 ++++---- test/configCases/output-module/issue-16040/test.config.js | 2 +- test/configCases/output-module/issue-16040/test.filter.js | 5 +++++ 7 files changed, 16 insertions(+), 12 deletions(-) delete mode 100644 test/configCases/output-module/issue-16040/entry.js create mode 100644 test/configCases/output-module/issue-16040/test.filter.js diff --git a/test/configCases/output-module/issue-16040/bar.css b/test/configCases/output-module/issue-16040/bar.css index 5330aae07f8..66d9575715c 100644 --- a/test/configCases/output-module/issue-16040/bar.css +++ b/test/configCases/output-module/issue-16040/bar.css @@ -1,3 +1,3 @@ .bar { color: #fff; -} \ No newline at end of file +} diff --git a/test/configCases/output-module/issue-16040/bar.js b/test/configCases/output-module/issue-16040/bar.js index f4ca3ebdc21..cce1f49a437 100644 --- a/test/configCases/output-module/issue-16040/bar.js +++ b/test/configCases/output-module/issue-16040/bar.js @@ -1,7 +1,7 @@ -import { countBy } from 'lodash-es' +import { countBy } from "lodash-es"; -import './bar.css' +import "./bar.css"; -const result = countBy([6.1, 4.2, 6.3], Math.floor) +const result = countBy([6.1, 4.2, 6.3], Math.floor); -export default result['6'] \ No newline at end of file +export default result["6"]; diff --git a/test/configCases/output-module/issue-16040/entry.js b/test/configCases/output-module/issue-16040/entry.js deleted file mode 100644 index 8b137891791..00000000000 --- a/test/configCases/output-module/issue-16040/entry.js +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/configCases/output-module/issue-16040/foo.css b/test/configCases/output-module/issue-16040/foo.css index 6bbab56ba21..33a418a59a8 100644 --- a/test/configCases/output-module/issue-16040/foo.css +++ b/test/configCases/output-module/issue-16040/foo.css @@ -1,3 +1,3 @@ .foo { color: #fff; -} \ No newline at end of file +} diff --git a/test/configCases/output-module/issue-16040/foo.js b/test/configCases/output-module/issue-16040/foo.js index d9805d58ba5..dd96b964c76 100644 --- a/test/configCases/output-module/issue-16040/foo.js +++ b/test/configCases/output-module/issue-16040/foo.js @@ -1,7 +1,7 @@ -import { dropRight } from 'lodash-es' +import { dropRight } from "lodash-es"; -import './foo.css' +import "./foo.css"; -const result = dropRight([10, 20, 30], 2) +const result = dropRight([10, 20, 30], 2); -export default result[0] \ No newline at end of file +export default result[0]; diff --git a/test/configCases/output-module/issue-16040/test.config.js b/test/configCases/output-module/issue-16040/test.config.js index be83c69bf17..d8558101ac8 100644 --- a/test/configCases/output-module/issue-16040/test.config.js +++ b/test/configCases/output-module/issue-16040/test.config.js @@ -1,5 +1,5 @@ module.exports = { - findBundle: function(i, options) { + findBundle: function (i, options) { return ["main.mjs", "vendor.mjs", "runtime.mjs"]; } }; diff --git a/test/configCases/output-module/issue-16040/test.filter.js b/test/configCases/output-module/issue-16040/test.filter.js new file mode 100644 index 00000000000..ad4dc826959 --- /dev/null +++ b/test/configCases/output-module/issue-16040/test.filter.js @@ -0,0 +1,5 @@ +const supportsRequireInModule = require("../../../helpers/supportsRequireInModule"); + +module.exports = () => { + return supportsRequireInModule(); +}; From dbf7bf39ab96e1462603435c150d601bb69ebe4e Mon Sep 17 00:00:00 2001 From: Sean Larkin Date: Wed, 15 Mar 2023 08:00:47 -0700 Subject: [PATCH 37/38] 5.76.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5e3ff54f9ac..2407bead5b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webpack", - "version": "5.76.1", + "version": "5.76.2", "author": "Tobias Koppers @sokra", "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.", "license": "MIT", From 66fe018a61e545343dbbe5f7e96349c0ffa72b22 Mon Sep 17 00:00:00 2001 From: ShenHongFei Date: Sat, 18 Mar 2023 13:22:28 +0800 Subject: [PATCH 38/38] fix: complete the missing nodejs builtin modules --- lib/node/NodeTargetPlugin.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/node/NodeTargetPlugin.js b/lib/node/NodeTargetPlugin.js index adea6ab7801..1cc01810daa 100644 --- a/lib/node/NodeTargetPlugin.js +++ b/lib/node/NodeTargetPlugin.js @@ -31,6 +31,7 @@ const builtins = [ "http2", "https", "inspector", + "inspector/promises", "module", "net", "os", @@ -42,8 +43,10 @@ const builtins = [ "punycode", "querystring", "readline", + "readline/promises", "repl", "stream", + "stream/consumers", "stream/promises", "stream/web", "string_decoder",