From 1c6e7a9344c960a51a54c71616ce20f7a579ce44 Mon Sep 17 00:00:00 2001 From: Lex Alexander Date: Wed, 29 May 2019 14:11:49 -0700 Subject: [PATCH 01/19] feat(NormalModule/ModuleParseError): Show loaders used from config when module parsing fails -Closes #9025 --- lib/ModuleParseError.js | 11 +- lib/NormalModule.js | 27 ++++- test/Errors.test.js | 109 ++++++++++++++++++ .../__snapshots__/StatsTestCases.test.js.snap | 7 +- test/fixtures/abc.html | 6 + 5 files changed, 152 insertions(+), 8 deletions(-) create mode 100644 test/fixtures/abc.html diff --git a/lib/ModuleParseError.js b/lib/ModuleParseError.js index 32c7a69c1..fd90970f4 100644 --- a/lib/ModuleParseError.js +++ b/lib/ModuleParseError.js @@ -13,11 +13,20 @@ class ModuleParseError extends WebpackError { * @param {Module} module the errored module * @param {string} source source code * @param {Error&any} err the parse error + * @param {string[]} loaders the loaders used */ - constructor(module, source, err) { + constructor(module, source, err, loaders) { let message = "Module parse failed: " + err.message; let loc = undefined; message += "\nYou may need an appropriate loader to handle this file type."; + if (loaders.length >= 1) { + message += `\nTried processing with these loaders:${loaders + .map(l => `\n * ${l}`) + .join("")}.`; + } else { + message += + "\nNo Loaders configured to process this file. See https://webpack.js.org/concepts#loaders"; + } if ( err.loc && typeof err.loc === "object" && diff --git a/lib/NormalModule.js b/lib/NormalModule.js index 3e9dc5555..c68913acf 100644 --- a/lib/NormalModule.js +++ b/lib/NormalModule.js @@ -83,7 +83,6 @@ class NormalModule extends Module { this.matchResource = matchResource; this.loaders = loaders; if (resolveOptions !== undefined) this.resolveOptions = resolveOptions; - // Info from Build this.error = null; this._source = null; @@ -347,7 +346,6 @@ class NormalModule extends Module { markModuleAsErrored(error) { // Restore build meta from successful build to keep importing state this.buildMeta = Object.assign({}, this._lastSuccessfulBuildMeta); - this.error = error; this.errors.push(this.error); this._source = new RawSource( @@ -423,7 +421,6 @@ class NormalModule extends Module { fileDependencies: new Set(), contextDependencies: new Set() }; - return this.doBuild(options, compilation, resolver, fs, err => { this._cachedSources.clear(); @@ -442,9 +439,31 @@ class NormalModule extends Module { return callback(); } + const getLoaders = options => { + const module = + options && options.constructor === Object ? options.module || {} : {}; + const rules = module.rules || []; + if (!rules.length) { + return []; + } + let arr = []; + const getLoader = rule => rule.loader || rule.use || ""; + rules.forEach(rule => { + if (Array.isArray(rule.use)) { + rule.use.forEach(r => { + arr.push(getLoader(r)); + }); + } else { + arr.push(getLoader(rule)); + } + }); + return arr; + }; + const handleParseError = e => { const source = this._source.source(); - const error = new ModuleParseError(this, source, e); + const loaders = getLoaders(options); + const error = new ModuleParseError(this, source, e, loaders); this.markModuleAsErrored(error); this._initBuildHash(compilation); return callback(); diff --git a/test/Errors.test.js b/test/Errors.test.js index 8d5a8fbd1..69ef25055 100644 --- a/test/Errors.test.js +++ b/test/Errors.test.js @@ -393,4 +393,113 @@ describe("Errors", () => { } ); }); + + it("should show loader used if it is present when module parsing fails", done => { + const folder = path.join(__dirname, "/fixtures"); + getErrors( + { + mode: "development", + entry: path.resolve(folder, "./abc.html"), + module: { + rules: [ + { + test: /\.json$/, + use: [{ loader: "json-loader" }] + } + ] + } + }, + (errors, warnings) => { + const messages = errors[0].split("\n"); + const loaderUsedMessage = messages.filter(message => + message.includes("* json-loader.") + )[0]; + expect(loaderUsedMessage).toMatch("* json-loader."); + done(); + } + ); + }); + + it("should show all loaders used if they are in config when module parsing fails", done => { + const folder = path.join(__dirname, "/fixtures"); + getErrors( + { + mode: "development", + entry: path.resolve(folder, "./abc.html"), + module: { + rules: [ + { + test: /\.json$/, + use: [{ loader: "json-loader" }, { loader: "coffee-loader" }] + } + ] + } + }, + (errors, warnings) => { + const messages = errors[0].split("\n"); + const loaderUsedMessage = messages.filter(message => { + return ( + message.includes(" * json-loader") || + message.includes(" * coffee-loader.") + ); + }); + expect(loaderUsedMessage).toEqual([ + " * json-loader", + " * coffee-loader." + ]); + done(); + } + ); + }); + + it("should show all loaders used if use is a string", done => { + const folder = path.join(__dirname, "/fixtures"); + getErrors( + { + mode: "development", + entry: path.resolve(folder, "./abc.html"), + module: { + rules: [ + { test: /\.json$/, use: "json-loader" }, + { test: /\.coffee$/, use: "coffee-loader" } + ] + } + }, + (errors, warnings) => { + const messages = errors[0].split("\n"); + const loaderUsedMessage = messages.filter(message => { + return ( + message.includes(" * json-loader") || + message.includes(" * coffee-loader.") + ); + }); + expect(loaderUsedMessage).toEqual([ + " * json-loader", + " * coffee-loader." + ]); + done(); + } + ); + }); + + it("should show 'No Loaders present to process this file.' if loaders are not included in config when module parsing fails", done => { + const folder = path.join(__dirname, "/fixtures"); + getErrors( + { + mode: "development", + entry: path.resolve(folder, "./abc.html"), + module: {} + }, + (errors, warnings) => { + const messages = errors[0].split("\n"); + const loaderUsedMessage = messages.filter(message => + message.includes("No Loaders configured") + )[0]; + expect(loaderUsedMessage).toMatch( + "No Loaders configured to process this file. See https://webpack.js.org/concepts#loaders" + ); + done(); + } + ); + }); }); diff --git a/test/__snapshots__/StatsTestCases.test.js.snap b/test/__snapshots__/StatsTestCases.test.js.snap index 3b0138b5d..651e55607 100644 --- a/test/__snapshots__/StatsTestCases.test.js.snap +++ b/test/__snapshots__/StatsTestCases.test.js.snap @@ -1573,10 +1573,10 @@ chunk {7} main.js (main) 523 bytes >{0}< >{1}< >{2}< >{5}< [entry] [rendered] `; exports[`StatsTestCases should print correct stats for parse-error 1`] = ` -" Asset Size Chunks Chunk Names -main.js 4.01 KiB 0 main +" Asset Size Chunks Chunk Names +main.js 4.1 KiB 0 main Entrypoint main = main.js -[0] ./b.js 169 bytes {0} [built] [failed] [1 error] +[0] ./b.js 258 bytes {0} [built] [failed] [1 error] [1] ./index.js + 1 modules 35 bytes {0} [built] | ./index.js 15 bytes [built] | ./a.js 15 bytes [built] @@ -1584,6 +1584,7 @@ Entrypoint main = main.js ERROR in ./b.js 6:7 Module parse failed: Unexpected token (6:7) You may need an appropriate loader to handle this file type. +No Loaders configured to process this file. See https://webpack.js.org/concepts#loaders | includes | a > parser ) diff --git a/test/fixtures/abc.html b/test/fixtures/abc.html new file mode 100644 index 000000000..a86002af2 --- /dev/null +++ b/test/fixtures/abc.html @@ -0,0 +1,6 @@ + + + +

I love webpack :)

+ + \ No newline at end of file From 45582c51e7faf2d7c1ee0f39a4f763accb367b8a Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 3 Jun 2019 15:23:13 +0200 Subject: [PATCH 02/19] avoid loading from rule set, simplify --- lib/ModuleParseError.js | 11 +- lib/NormalModule.js | 27 +---- test/Errors.test.js | 109 +++++++++++------- .../__snapshots__/StatsTestCases.test.js.snap | 9 +- test/fixtures/errors/add-comment-loader.js | 3 + test/fixtures/errors/identity-loader.js | 3 + 6 files changed, 90 insertions(+), 72 deletions(-) create mode 100644 test/fixtures/errors/add-comment-loader.js create mode 100644 test/fixtures/errors/identity-loader.js diff --git a/lib/ModuleParseError.js b/lib/ModuleParseError.js index fd90970f4..6f197e064 100644 --- a/lib/ModuleParseError.js +++ b/lib/ModuleParseError.js @@ -18,14 +18,15 @@ class ModuleParseError extends WebpackError { constructor(module, source, err, loaders) { let message = "Module parse failed: " + err.message; let loc = undefined; - message += "\nYou may need an appropriate loader to handle this file type."; if (loaders.length >= 1) { - message += `\nTried processing with these loaders:${loaders - .map(l => `\n * ${l}`) - .join("")}.`; + message += `\nFile was processed with these loaders:${loaders + .map(loader => `\n * ${loader}`) + .join("")}`; + message += + "\nYou may need an additional loader to handle the result of these loaders."; } else { message += - "\nNo Loaders configured to process this file. See https://webpack.js.org/concepts#loaders"; + "\nYou may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders"; } if ( err.loc && diff --git a/lib/NormalModule.js b/lib/NormalModule.js index c68913acf..cbefa9555 100644 --- a/lib/NormalModule.js +++ b/lib/NormalModule.js @@ -83,6 +83,7 @@ class NormalModule extends Module { this.matchResource = matchResource; this.loaders = loaders; if (resolveOptions !== undefined) this.resolveOptions = resolveOptions; + // Info from Build this.error = null; this._source = null; @@ -421,6 +422,7 @@ class NormalModule extends Module { fileDependencies: new Set(), contextDependencies: new Set() }; + return this.doBuild(options, compilation, resolver, fs, err => { this._cachedSources.clear(); @@ -439,30 +441,11 @@ class NormalModule extends Module { return callback(); } - const getLoaders = options => { - const module = - options && options.constructor === Object ? options.module || {} : {}; - const rules = module.rules || []; - if (!rules.length) { - return []; - } - let arr = []; - const getLoader = rule => rule.loader || rule.use || ""; - rules.forEach(rule => { - if (Array.isArray(rule.use)) { - rule.use.forEach(r => { - arr.push(getLoader(r)); - }); - } else { - arr.push(getLoader(rule)); - } - }); - return arr; - }; - const handleParseError = e => { const source = this._source.source(); - const loaders = getLoaders(options); + const loaders = this.loaders.map(item => + contextify(options.context, item.loader) + ); const error = new ModuleParseError(this, source, e, loaders); this.markModuleAsErrored(error); this._initBuildHash(compilation); diff --git a/test/Errors.test.js b/test/Errors.test.js index 69ef25055..dc73c2c93 100644 --- a/test/Errors.test.js +++ b/test/Errors.test.js @@ -394,6 +394,15 @@ describe("Errors", () => { ); }); + const identityLoader = path.resolve( + __dirname, + "fixtures/errors/identity-loader.js" + ); + const addCommentLoader = path.resolve( + __dirname, + "fixtures/errors/add-comment-loader.js" + ); + it("should show loader used if it is present when module parsing fails", done => { const folder = path.join(__dirname, "/fixtures"); getErrors( @@ -403,18 +412,26 @@ describe("Errors", () => { module: { rules: [ { - test: /\.json$/, - use: [{ loader: "json-loader" }] + test: /\.html$/, + use: [{ loader: identityLoader }] } ] } }, (errors, warnings) => { - const messages = errors[0].split("\n"); - const loaderUsedMessage = messages.filter(message => - message.includes("* json-loader.") - )[0]; - expect(loaderUsedMessage).toMatch("* json-loader."); + expect(errors).toMatchInlineSnapshot(` +Array [ + "../abc.html 1:0 +Module parse failed: Unexpected token (1:0) +File was processed with these loaders: + * ./identity-loader.js +You may need an additional loader to handle the result of these loaders. +> +| +| ", +] +`); + expect(errors[0]).toMatch("File was processed with these loaders"); done(); } ); @@ -429,24 +446,27 @@ describe("Errors", () => { module: { rules: [ { - test: /\.json$/, - use: [{ loader: "json-loader" }, { loader: "coffee-loader" }] + test: /\.html$/, + use: [{ loader: identityLoader }, { loader: addCommentLoader }] } ] } }, (errors, warnings) => { - const messages = errors[0].split("\n"); - const loaderUsedMessage = messages.filter(message => { - return ( - message.includes(" * json-loader") || - message.includes(" * coffee-loader.") - ); - }); - expect(loaderUsedMessage).toEqual([ - " * json-loader", - " * coffee-loader." - ]); + expect(errors).toMatchInlineSnapshot(` +Array [ + "../abc.html 1:0 +Module parse failed: Unexpected token (1:0) +File was processed with these loaders: + * ./identity-loader.js + * ./add-comment-loader.js +You may need an additional loader to handle the result of these loaders. +> +| +| ", +] +`); + expect(errors[0]).toMatch("File was processed with these loaders"); done(); } ); @@ -460,29 +480,32 @@ describe("Errors", () => { entry: path.resolve(folder, "./abc.html"), module: { rules: [ - { test: /\.json$/, use: "json-loader" }, - { test: /\.coffee$/, use: "coffee-loader" } + { test: /\.html$/, use: identityLoader }, + { test: /\.html$/, use: addCommentLoader } ] } }, (errors, warnings) => { - const messages = errors[0].split("\n"); - const loaderUsedMessage = messages.filter(message => { - return ( - message.includes(" * json-loader") || - message.includes(" * coffee-loader.") - ); - }); - expect(loaderUsedMessage).toEqual([ - " * json-loader", - " * coffee-loader." - ]); + expect(errors).toMatchInlineSnapshot(` +Array [ + "../abc.html 1:0 +Module parse failed: Unexpected token (1:0) +File was processed with these loaders: + * ./identity-loader.js + * ./add-comment-loader.js +You may need an additional loader to handle the result of these loaders. +> +| +| ", +] +`); + expect(errors[0]).toMatch("File was processed with these loaders"); done(); } ); }); - it("should show 'No Loaders present to process this file.' if loaders are not included in config when module parsing fails", done => { + it("should show 'no loaders are configured to process this file' if loaders are not included in config when module parsing fails", done => { const folder = path.join(__dirname, "/fixtures"); getErrors( { @@ -491,12 +514,18 @@ describe("Errors", () => { module: {} }, (errors, warnings) => { - const messages = errors[0].split("\n"); - const loaderUsedMessage = messages.filter(message => - message.includes("No Loaders configured") - )[0]; - expect(loaderUsedMessage).toMatch( - "No Loaders configured to process this file. See https://webpack.js.org/concepts#loaders" + expect(errors).toMatchInlineSnapshot(` +Array [ + "../abc.html 1:0 +Module parse failed: Unexpected token (1:0) +You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders +> +| +| ", +] +`); + expect(errors[0]).toMatch( + "no loaders are configured to process this file" ); done(); } diff --git a/test/__snapshots__/StatsTestCases.test.js.snap b/test/__snapshots__/StatsTestCases.test.js.snap index 651e55607..4792864bb 100644 --- a/test/__snapshots__/StatsTestCases.test.js.snap +++ b/test/__snapshots__/StatsTestCases.test.js.snap @@ -1573,18 +1573,17 @@ chunk {7} main.js (main) 523 bytes >{0}< >{1}< >{2}< >{5}< [entry] [rendered] `; exports[`StatsTestCases should print correct stats for parse-error 1`] = ` -" Asset Size Chunks Chunk Names -main.js 4.1 KiB 0 main +" Asset Size Chunks Chunk Names +main.js 4.11 KiB 0 main Entrypoint main = main.js -[0] ./b.js 258 bytes {0} [built] [failed] [1 error] +[0] ./b.js 271 bytes {0} [built] [failed] [1 error] [1] ./index.js + 1 modules 35 bytes {0} [built] | ./index.js 15 bytes [built] | ./a.js 15 bytes [built] ERROR in ./b.js 6:7 Module parse failed: Unexpected token (6:7) -You may need an appropriate loader to handle this file type. -No Loaders configured to process this file. See https://webpack.js.org/concepts#loaders +You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders | includes | a > parser ) diff --git a/test/fixtures/errors/add-comment-loader.js b/test/fixtures/errors/add-comment-loader.js new file mode 100644 index 000000000..1cfa533d6 --- /dev/null +++ b/test/fixtures/errors/add-comment-loader.js @@ -0,0 +1,3 @@ +module.exports = function(source) { + return source + "// some comment"; +}; diff --git a/test/fixtures/errors/identity-loader.js b/test/fixtures/errors/identity-loader.js new file mode 100644 index 000000000..6e64f4af6 --- /dev/null +++ b/test/fixtures/errors/identity-loader.js @@ -0,0 +1,3 @@ +module.exports = function(source) { + return source; +}; From aa78e27a44f25176a98b0bd0a880cd79ec1281bc Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 4 Jun 2019 14:48:46 +0200 Subject: [PATCH 03/19] fix splitting of windows newlines move fixture update snapshots --- lib/ModuleParseError.js | 2 +- test/Errors.test.js | 36 ++++++++++++++++------------------- test/fixtures/abc.html | 6 ------ test/fixtures/errors/abc.html | 6 ++++++ 4 files changed, 23 insertions(+), 27 deletions(-) delete mode 100644 test/fixtures/abc.html create mode 100644 test/fixtures/errors/abc.html diff --git a/lib/ModuleParseError.js b/lib/ModuleParseError.js index 6f197e064..2ff22b7ed 100644 --- a/lib/ModuleParseError.js +++ b/lib/ModuleParseError.js @@ -38,7 +38,7 @@ class ModuleParseError extends WebpackError { // binary file message += "\n(Source code omitted for this binary file)"; } else { - const sourceLines = source.split("\n"); + const sourceLines = source.split(/\r?\n/); const start = Math.max(0, lineNumber - 3); const linesBefore = sourceLines.slice(start, lineNumber - 1); const theLine = sourceLines[lineNumber - 1]; diff --git a/test/Errors.test.js b/test/Errors.test.js index dc73c2c93..448ea3fb5 100644 --- a/test/Errors.test.js +++ b/test/Errors.test.js @@ -404,11 +404,10 @@ describe("Errors", () => { ); it("should show loader used if it is present when module parsing fails", done => { - const folder = path.join(__dirname, "/fixtures"); getErrors( { mode: "development", - entry: path.resolve(folder, "./abc.html"), + entry: "./abc.html", module: { rules: [ { @@ -421,14 +420,14 @@ describe("Errors", () => { (errors, warnings) => { expect(errors).toMatchInlineSnapshot(` Array [ - "../abc.html 1:0 + "./abc.html 1:0 Module parse failed: Unexpected token (1:0) File was processed with these loaders: * ./identity-loader.js You may need an additional loader to handle the result of these loaders. > -| -| ", +| +| ", ] `); expect(errors[0]).toMatch("File was processed with these loaders"); @@ -438,11 +437,10 @@ You may need an additional loader to handle the result of these loaders. }); it("should show all loaders used if they are in config when module parsing fails", done => { - const folder = path.join(__dirname, "/fixtures"); getErrors( { mode: "development", - entry: path.resolve(folder, "./abc.html"), + entry: "./abc.html", module: { rules: [ { @@ -455,15 +453,15 @@ You may need an additional loader to handle the result of these loaders. (errors, warnings) => { expect(errors).toMatchInlineSnapshot(` Array [ - "../abc.html 1:0 + "./abc.html 1:0 Module parse failed: Unexpected token (1:0) File was processed with these loaders: * ./identity-loader.js * ./add-comment-loader.js You may need an additional loader to handle the result of these loaders. > -| -| ", +| +| ", ] `); expect(errors[0]).toMatch("File was processed with these loaders"); @@ -473,11 +471,10 @@ You may need an additional loader to handle the result of these loaders. }); it("should show all loaders used if use is a string", done => { - const folder = path.join(__dirname, "/fixtures"); getErrors( { mode: "development", - entry: path.resolve(folder, "./abc.html"), + entry: "./abc.html", module: { rules: [ { test: /\.html$/, use: identityLoader }, @@ -488,15 +485,15 @@ You may need an additional loader to handle the result of these loaders. (errors, warnings) => { expect(errors).toMatchInlineSnapshot(` Array [ - "../abc.html 1:0 + "./abc.html 1:0 Module parse failed: Unexpected token (1:0) File was processed with these loaders: * ./identity-loader.js * ./add-comment-loader.js You may need an additional loader to handle the result of these loaders. > -| -| ", +| +| ", ] `); expect(errors[0]).toMatch("File was processed with these loaders"); @@ -506,22 +503,21 @@ You may need an additional loader to handle the result of these loaders. }); it("should show 'no loaders are configured to process this file' if loaders are not included in config when module parsing fails", done => { - const folder = path.join(__dirname, "/fixtures"); getErrors( { mode: "development", - entry: path.resolve(folder, "./abc.html"), + entry: "./abc.html", module: {} }, (errors, warnings) => { expect(errors).toMatchInlineSnapshot(` Array [ - "../abc.html 1:0 + "./abc.html 1:0 Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders > -| -| ", +| +| ", ] `); expect(errors[0]).toMatch( diff --git a/test/fixtures/abc.html b/test/fixtures/abc.html deleted file mode 100644 index a86002af2..000000000 --- a/test/fixtures/abc.html +++ /dev/null @@ -1,6 +0,0 @@ - - - -

I love webpack :)

- - \ No newline at end of file diff --git a/test/fixtures/errors/abc.html b/test/fixtures/errors/abc.html new file mode 100644 index 000000000..32a090d95 --- /dev/null +++ b/test/fixtures/errors/abc.html @@ -0,0 +1,6 @@ + + + +

I love webpack :)

+ + From 2cd6489579d99c4ef8d36c3a8bc1ca7934e7b582 Mon Sep 17 00:00:00 2001 From: Lex Alexander Date: Tue, 4 Jun 2019 11:45:48 -0700 Subject: [PATCH 04/19] Added test to account for module parsing failure for binary files --- test/Errors.test.js | 22 ++++++++++++++++++++++ test/fixtures/font.ttf | Bin 0 -> 2830 bytes 2 files changed, 22 insertions(+) create mode 100644 test/fixtures/font.ttf diff --git a/test/Errors.test.js b/test/Errors.test.js index 448ea3fb5..c1cf32999 100644 --- a/test/Errors.test.js +++ b/test/Errors.test.js @@ -527,4 +527,26 @@ You may need an appropriate loader to handle this file type, currently no loader } ); }); + + it("should show 'source code omitted for this binary file' when module parsing fails for binary files", done => { + const folder = path.join(__dirname, "/fixtures"); + getErrors( + { + mode: "development", + entry: path.resolve(folder, "./font.ttf"), + module: {} + }, + (errors, warnings) => { + expect(errors).toMatchInlineSnapshot(` +Array [ + "../font.ttf 1:0 +Module parse failed: Unexpected character '' (1:0) +You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders +(Source code omitted for this binary file)", +] +`); + done(); + } + ); + }); }); diff --git a/test/fixtures/font.ttf b/test/fixtures/font.ttf new file mode 100644 index 0000000000000000000000000000000000000000..37af10e09df8f0465dcef081997dbdd0b0d3f323 GIT binary patch literal 2830 zcmb_e`%;@l6#wn+M-oCtkV1(jLl+DT&>)dvYPb{`D3Z|;GNnbdV+%rCrsbwkN^NQ1 z!*_9f2A{-N@ORFBUx-}%OZd*&v*&)!-U0(4i@*Q;0}l12`pPQFEI~NfSO=!omsTIn z_kA_0oJ7(>Vr6w~{AI#0RK>>D-sa)(BzaXJRRRpj=bJ}|$fJ+q8g)9J@4k6Pwk2@h z$^oeN?mXSx?)?jCGylH4XJC#~34 z_cl)t-Iq>hhS|XHZ|*(y^%>>-NPptt@Zjk9vnM2ufJZ8c-a=Yp>@uhPRtQhp)#_I8 zrU|a?k5Nlf{p!nN3!cl((IP(5-Vkpq-L=s9mVgeW$v~zW^7H@C9HTj8@bRe@fn?AKqC}w9aZ-(?ors&VUNaG_P)l5;=1eh z70=Z+tJscDQ&)(tT1h0?uhJ{YT6eGN)M6hZA%ssQDalGfWUE@YP*wF3W7V9~IFpLQ zE)AzA?9U}$2H|uEtT%w%0(u+#z&$6hL%(YXc5*9B2v_^z-6(uC#oI%o50MJh54i{e zNJfD@15IElarZ{w>;tR#m0PLRwYsbzRQ2=dwstj^i%$x zKlYUMclLL4;72>L^s(jr#7ahg!{>cbEhn$A3=SH&=`cPfGk)e8ViFRH!%;Jj^amLKo$24KG=~>$%3PS??G8s{A9x z$5-lzzQLgU!&{u`T-O;NE?Fem*lQ(;#>KG(>Ho9=x^ed^ z4O8I%Z8L2a%&K{0w#;iegI9sQ*Sxn}r<-u=Zcon1RS*qC&*V%sL(7`{X!A9bY literal 0 HcmV?d00001 From cf9e926c79e1d534559bd96fc2387c5448e79a5d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 5 Jun 2019 15:38:08 +0000 Subject: [PATCH 05/19] chore(deps): bump handlebars from 4.1.0 to 4.1.2 Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.0 to 4.1.2. - [Release notes](https://github.com/wycats/handlebars.js/releases) - [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md) - [Commits](https://github.com/wycats/handlebars.js/compare/v4.1.0...v4.1.2) Signed-off-by: dependabot[bot] --- yarn.lock | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4a48b646d..c090dc490 100644 --- a/yarn.lock +++ b/yarn.lock @@ -893,7 +893,7 @@ async@1.x: resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" integrity sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo= -async@^2.5.0, async@^2.6.1: +async@^2.6.1: version "2.6.2" resolved "https://registry.yarnpkg.com/async/-/async-2.6.2.tgz#18330ea7e6e313887f5d2f2a904bac6fe4dd5381" integrity sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg== @@ -1519,12 +1519,12 @@ commander@2.8.x: dependencies: graceful-readlink ">= 1.0.0" -commander@^2.14.1, commander@^2.9.0, commander@~2.19.0: +commander@^2.14.1, commander@^2.9.0: version "2.19.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a" integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg== -commander@^2.19.0: +commander@^2.19.0, commander@~2.20.0: version "2.20.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422" integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ== @@ -2854,21 +2854,10 @@ growly@^1.3.0: resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE= -handlebars@^4.0.1: - version "4.1.0" - resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.1.0.tgz#0d6a6f34ff1f63cecec8423aa4169827bf787c3a" - integrity sha512-l2jRuU1NAWK6AW5qqcTATWQJvNPEwkM7NEKSiv/gqOsoSQbVoWyqVEY5GS+XPQ88zLNmqASRpzfdm8d79hJS+w== - dependencies: - async "^2.5.0" - optimist "^0.6.1" - source-map "^0.6.1" - optionalDependencies: - uglify-js "^3.1.4" - -handlebars@^4.1.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.1.1.tgz#6e4e41c18ebe7719ae4d38e5aca3d32fa3dd23d3" - integrity sha512-3Zhi6C0euYZL5sM0Zcy7lInLXKQ+YLcF/olbN010mzGQ4XVm50JeyBnMqofHh696GrciGruC7kCcApPDJvVgwA== +handlebars@^4.0.1, handlebars@^4.1.0: + version "4.1.2" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.1.2.tgz#b6b37c1ced0306b221e094fc7aca3ec23b131b67" + integrity sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw== dependencies: neo-async "^2.6.0" optimist "^0.6.1" @@ -6821,11 +6810,11 @@ uglify-js@^2.4.19, uglify-js@^2.6.1: uglify-to-browserify "~1.0.0" uglify-js@^3.1.4: - version "3.5.2" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.5.2.tgz#dc0c7ac2da0a4b7d15e84266818ff30e82529474" - integrity sha512-imog1WIsi9Yb56yRt5TfYVxGmnWs3WSGU73ieSOlMVFwhJCA9W8fqFFMMj4kgDqiS/80LGdsYnWL7O9UcjEBlg== + version "3.6.0" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.6.0.tgz#704681345c53a8b2079fb6cec294b05ead242ff5" + integrity sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg== dependencies: - commander "~2.19.0" + commander "~2.20.0" source-map "~0.6.1" uglify-js@~2.2.5: From 94a15b7a9659a65858fbc542404f3ef73d5ccdb9 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" Date: Thu, 6 Jun 2019 02:14:34 +0000 Subject: [PATCH 06/19] chore(deps-dev): bump coveralls from 3.0.3 to 3.0.4 Bumps [coveralls](https://github.com/nickmerwin/node-coveralls) from 3.0.3 to 3.0.4. - [Release notes](https://github.com/nickmerwin/node-coveralls/releases) - [Commits](https://github.com/nickmerwin/node-coveralls/compare/3.0.3...3.0.4) Signed-off-by: dependabot-preview[bot] --- yarn.lock | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4a48b646d..67d2dc976 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1663,9 +1663,9 @@ cosmiconfig@^5.0.7, cosmiconfig@^5.2.0: parse-json "^4.0.0" coveralls@^3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-3.0.3.tgz#83b1c64aea1c6afa69beaf50b55ac1bc4d13e2b8" - integrity sha512-viNfeGlda2zJr8Gj1zqXpDMRjw9uM54p7wzZdvLRyOgnAfCe974Dq4veZkjJdxQXbmdppu6flEajFYseHYaUhg== + version "3.0.4" + resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-3.0.4.tgz#f50233c9c62fd0973f710fce85fd19dba24cff4b" + integrity sha512-eyqUWA/7RT0JagiL0tThVhjbIjoiEUyWCjtUJoOPcWoeofP5WK/jb2OJYoBFrR6DvplR+AxOyuBqk4JHkk5ykA== dependencies: growl "~> 1.10.0" js-yaml "^3.11.0" @@ -3943,15 +3943,7 @@ js-stringify@^1.0.1: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== -js-yaml@3.x, js-yaml@^3.11.0, js-yaml@^3.12.0, js-yaml@^3.12.1, js-yaml@^3.13.0: - version "3.13.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.0.tgz#38ee7178ac0eea2c97ff6d96fff4b18c7d8cf98e" - integrity sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ== - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - -js-yaml@^3.13.1: +js-yaml@3.x, js-yaml@^3.11.0, js-yaml@^3.12.0, js-yaml@^3.12.1, js-yaml@^3.13.0, js-yaml@^3.13.1: version "3.13.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== From 7ababcff893e94281de4ffee084553e145d8dc7a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" Date: Thu, 6 Jun 2019 12:51:49 +0000 Subject: [PATCH 07/19] chore(deps-dev): bump lint-staged from 8.1.7 to 8.2.0 Bumps [lint-staged](https://github.com/okonet/lint-staged) from 8.1.7 to 8.2.0. - [Release notes](https://github.com/okonet/lint-staged/releases) - [Commits](https://github.com/okonet/lint-staged/compare/v8.1.7...v8.2.0) Signed-off-by: dependabot-preview[bot] --- yarn.lock | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/yarn.lock b/yarn.lock index ca780e83b..10b19be9e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1519,12 +1519,7 @@ commander@2.8.x: dependencies: graceful-readlink ">= 1.0.0" -commander@^2.14.1, commander@^2.9.0: - version "2.19.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a" - integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg== - -commander@^2.19.0, commander@~2.20.0: +commander@^2.14.1, commander@^2.19.0, commander@^2.9.0, commander@~2.20.0: version "2.20.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422" integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ== @@ -2602,11 +2597,6 @@ find-cache-dir@^2.0.0: make-dir "^1.0.0" pkg-dir "^3.0.0" -find-parent-dir@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/find-parent-dir/-/find-parent-dir-0.3.0.tgz#33c44b429ab2b2f0646299c5f9f718f376ff8d54" - integrity sha1-M8RLQpqysvBkYpnF+fcY83b/jVQ= - find-up@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" @@ -4177,9 +4167,9 @@ levn@^0.3.0, levn@~0.3.0: type-check "~0.3.2" lint-staged@^8.0.4: - version "8.1.7" - resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-8.1.7.tgz#a8988bc83bdffa97d04adb09dbc0b1f3a58fa6fc" - integrity sha512-egT0goFhIFoOGk6rasPngTFh2qDqxZddM0PwI58oi66RxCDcn5uDwxmiasWIF0qGnchHSYVJ8HPRD5LrFo7TKA== + version "8.2.0" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-8.2.0.tgz#3d4149a229580815c955047a7acd8f09054be5a9" + integrity sha512-DxguyxGOIfb67wZ6EOrqzjAbw6ZH9XK3YS74HO+erJf6+SAQeJJPN//GBOG5xhdt2THeuXjVPaHcCYOWGZwRbA== dependencies: chalk "^2.3.1" commander "^2.14.1" @@ -4188,7 +4178,6 @@ lint-staged@^8.0.4: dedent "^0.7.0" del "^3.0.0" execa "^1.0.0" - find-parent-dir "^0.3.0" g-status "^2.0.2" is-glob "^4.0.0" is-windows "^1.0.2" From 096c0f0027ba2764496bdaa725ca69293ce1be26 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" Date: Fri, 7 Jun 2019 02:17:43 +0000 Subject: [PATCH 08/19] chore(deps-dev): bump prettier from 1.17.1 to 1.18.0 Bumps [prettier](https://github.com/prettier/prettier) from 1.17.1 to 1.18.0. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/1.17.1...1.18.0) Signed-off-by: dependabot-preview[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index ca780e83b..38f3824db 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5328,9 +5328,9 @@ prettier-linter-helpers@^1.0.0: fast-diff "^1.1.2" prettier@^1.14.3, prettier@^1.16.4: - version "1.17.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.17.1.tgz#ed64b4e93e370cb8a25b9ef7fef3e4fd1c0995db" - integrity sha512-TzGRNvuUSmPgwivDqkZ9tM/qTGW9hqDKWOE9YHiyQdixlKbv7kvEqsmDPrcHJTKwthU774TQwZXVtaQ/mMsvjg== + version "1.18.0" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.0.tgz#d1701ca9b2941864b52f3262b35946d2c9cd88f0" + integrity sha512-YsdAD29M0+WY2xXZk3i0PA16olY9qZss+AuODxglXcJ+2ZBwFv+6k5tE8GS8/HKAthaajlS/WqhdgcjumOrPlg== pretty-format@^24.5.0: version "24.5.0" From fd4b3c503a832b5d86bc347bdd41c5d460dbf929 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Sun, 9 Jun 2019 11:23:42 +0200 Subject: [PATCH 09/19] pretty files --- declarations.d.ts | 2 +- lib/ChunkGroup.js | 8 ++--- lib/Compilation.js | 8 ++--- lib/MainTemplate.js | 4 +-- lib/NormalModuleFactory.js | 4 +-- ...armonyExportImportedSpecifierDependency.js | 4 +-- .../HarmonyImportSpecifierDependency.js | 4 +-- lib/dependencies/ImportParserPlugin.js | 32 +++++-------------- lib/dependencies/LoaderPlugin.js | 4 +-- .../WebAssemblyImportDependency.js | 4 +-- lib/optimize/ChunkModuleIdRangePlugin.js | 4 +-- lib/optimize/ConcatenatedModule.js | 24 ++++---------- lib/wasm/WasmFinalizeExportsPlugin.js | 4 +-- lib/wasm/WasmMainTemplatePlugin.js | 4 +-- lib/web/JsonpMainTemplatePlugin.js | 4 +-- open-bot.yaml | 2 +- test/BenchmarkTestCases.benchmark.js | 12 ++----- 17 files changed, 33 insertions(+), 95 deletions(-) diff --git a/declarations.d.ts b/declarations.d.ts index 1a5344e75..83b612e4c 100644 --- a/declarations.d.ts +++ b/declarations.d.ts @@ -59,7 +59,7 @@ declare module "neo-async" { } export type AsyncAutoTasks, E> = { - [K in keyof R]: AsyncAutoTask + [K in keyof R]: AsyncAutoTask; }; export type AsyncAutoTask, E> = | AsyncAutoTaskFunctionWithoutDependencies diff --git a/lib/ChunkGroup.js b/lib/ChunkGroup.js index 031fc14e4..58e766039 100644 --- a/lib/ChunkGroup.js +++ b/lib/ChunkGroup.js @@ -496,18 +496,14 @@ class ChunkGroup { for (const child of chunk._children) { if (!child._parents.has(chunk)) { throw new Error( - `checkConstraints: child missing parent ${chunk.debugId} -> ${ - child.debugId - }` + `checkConstraints: child missing parent ${chunk.debugId} -> ${child.debugId}` ); } } for (const parentChunk of chunk._parents) { if (!parentChunk._children.has(chunk)) { throw new Error( - `checkConstraints: parent missing child ${parentChunk.debugId} <- ${ - chunk.debugId - }` + `checkConstraints: parent missing child ${parentChunk.debugId} <- ${chunk.debugId}` ); } } diff --git a/lib/Compilation.js b/lib/Compilation.js index 514a4db11..80ef083e3 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -694,9 +694,7 @@ class Compilation extends Tapable { const factory = this.dependencyFactories.get(dep.constructor); if (factory === undefined) { throw new Error( - `No module factory available for dependency type: ${ - dep.constructor.name - }` + `No module factory available for dependency type: ${dep.constructor.name}` ); } let innerMap = dependencies.get(factory); @@ -958,9 +956,7 @@ class Compilation extends Tapable { const moduleFactory = this.dependencyFactories.get(Dep); if (!moduleFactory) { throw new Error( - `No dependency factory available for this dependency type: ${ - dependency.constructor.name - }` + `No dependency factory available for this dependency type: ${dependency.constructor.name}` ); } diff --git a/lib/MainTemplate.js b/lib/MainTemplate.js index 1023dc63a..9028823ed 100644 --- a/lib/MainTemplate.js +++ b/lib/MainTemplate.js @@ -345,9 +345,7 @@ module.exports = class MainTemplate extends Tapable { buf.push(""); buf.push("// Object.prototype.hasOwnProperty.call"); buf.push( - `${ - this.requireFn - }.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };` + `${this.requireFn}.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };` ); const publicPath = this.getPublicPath({ diff --git a/lib/NormalModuleFactory.js b/lib/NormalModuleFactory.js index 23ef0ae1d..49c1dbd80 100644 --- a/lib/NormalModuleFactory.js +++ b/lib/NormalModuleFactory.js @@ -435,9 +435,7 @@ class NormalModuleFactory extends Tapable { err.message + "\n" + "BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.\n" + - ` You need to specify '${ - item.loader - }-loader' instead of '${item.loader}',\n` + + ` You need to specify '${item.loader}-loader' instead of '${item.loader}',\n` + " see https://webpack.js.org/migrate/3/#automatic-loader-module-name-extension-removed"; } callback(err); diff --git a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js index af782589d..19642ddff 100644 --- a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +++ b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js @@ -382,9 +382,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency { // We are sure that it's not provided const idIsNotNameMessage = this._id !== this.name ? ` (reexported as '${this.name}')` : ""; - const errorMessage = `"export '${ - this._id - }'${idIsNotNameMessage} was not found in '${this.userRequest}'`; + const errorMessage = `"export '${this._id}'${idIsNotNameMessage} was not found in '${this.userRequest}'`; return [new HarmonyLinkingError(errorMessage)]; } diff --git a/lib/dependencies/HarmonyImportSpecifierDependency.js b/lib/dependencies/HarmonyImportSpecifierDependency.js index 769711932..9f681a6f3 100644 --- a/lib/dependencies/HarmonyImportSpecifierDependency.js +++ b/lib/dependencies/HarmonyImportSpecifierDependency.js @@ -107,9 +107,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency { // We are sure that it's not provided const idIsNotNameMessage = this._id !== this.name ? ` (imported as '${this.name}')` : ""; - const errorMessage = `"export '${ - this._id - }'${idIsNotNameMessage} was not found in '${this.userRequest}'`; + const errorMessage = `"export '${this._id}'${idIsNotNameMessage} was not found in '${this.userRequest}'`; return [new HarmonyLinkingError(errorMessage)]; } diff --git a/lib/dependencies/ImportParserPlugin.js b/lib/dependencies/ImportParserPlugin.js index db22574f6..cb751a814 100644 --- a/lib/dependencies/ImportParserPlugin.js +++ b/lib/dependencies/ImportParserPlugin.js @@ -43,9 +43,7 @@ class ImportParserPlugin { const { comment } = e; parser.state.module.warnings.push( new CommentCompilationWarning( - `Compilation error while processing magic comment(-s): /*${ - comment.value - }*/: ${e.message}`, + `Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`, parser.state.module, comment.loc ) @@ -59,9 +57,7 @@ class ImportParserPlugin { parser.state.module.warnings.push( new UnsupportedFeatureWarning( parser.state.module, - `\`webpackIgnore\` expected a boolean, but received: ${ - importOptions.webpackIgnore - }.`, + `\`webpackIgnore\` expected a boolean, but received: ${importOptions.webpackIgnore}.`, expr.loc ) ); @@ -77,9 +73,7 @@ class ImportParserPlugin { parser.state.module.warnings.push( new UnsupportedFeatureWarning( parser.state.module, - `\`webpackChunkName\` expected a string, but received: ${ - importOptions.webpackChunkName - }.`, + `\`webpackChunkName\` expected a string, but received: ${importOptions.webpackChunkName}.`, expr.loc ) ); @@ -92,9 +86,7 @@ class ImportParserPlugin { parser.state.module.warnings.push( new UnsupportedFeatureWarning( parser.state.module, - `\`webpackMode\` expected a string, but received: ${ - importOptions.webpackMode - }.`, + `\`webpackMode\` expected a string, but received: ${importOptions.webpackMode}.`, expr.loc ) ); @@ -111,9 +103,7 @@ class ImportParserPlugin { parser.state.module.warnings.push( new UnsupportedFeatureWarning( parser.state.module, - `\`webpackPrefetch\` expected true or a number, but received: ${ - importOptions.webpackPrefetch - }.`, + `\`webpackPrefetch\` expected true or a number, but received: ${importOptions.webpackPrefetch}.`, expr.loc ) ); @@ -128,9 +118,7 @@ class ImportParserPlugin { parser.state.module.warnings.push( new UnsupportedFeatureWarning( parser.state.module, - `\`webpackPreload\` expected true or a number, but received: ${ - importOptions.webpackPreload - }.`, + `\`webpackPreload\` expected true or a number, but received: ${importOptions.webpackPreload}.`, expr.loc ) ); @@ -144,9 +132,7 @@ class ImportParserPlugin { parser.state.module.warnings.push( new UnsupportedFeatureWarning( parser.state.module, - `\`webpackInclude\` expected a regular expression, but received: ${ - importOptions.webpackInclude - }.`, + `\`webpackInclude\` expected a regular expression, but received: ${importOptions.webpackInclude}.`, expr.loc ) ); @@ -162,9 +148,7 @@ class ImportParserPlugin { parser.state.module.warnings.push( new UnsupportedFeatureWarning( parser.state.module, - `\`webpackExclude\` expected a regular expression, but received: ${ - importOptions.webpackExclude - }.`, + `\`webpackExclude\` expected a regular expression, but received: ${importOptions.webpackExclude}.`, expr.loc ) ); diff --git a/lib/dependencies/LoaderPlugin.js b/lib/dependencies/LoaderPlugin.js index c781d0636..e46f593b7 100644 --- a/lib/dependencies/LoaderPlugin.js +++ b/lib/dependencies/LoaderPlugin.js @@ -49,9 +49,7 @@ class LoaderPlugin { if (factory === undefined) { return callback( new Error( - `No module factory available for dependency type: ${ - dep.constructor.name - }` + `No module factory available for dependency type: ${dep.constructor.name}` ) ); } diff --git a/lib/dependencies/WebAssemblyImportDependency.js b/lib/dependencies/WebAssemblyImportDependency.js index d765b0db0..4b36faa9b 100644 --- a/lib/dependencies/WebAssemblyImportDependency.js +++ b/lib/dependencies/WebAssemblyImportDependency.js @@ -40,9 +40,7 @@ class WebAssemblyImportDependency extends ModuleDependency { ) { return [ new UnsupportedWebAssemblyFeatureError( - `Import "${this.name}" from "${this.request}" with ${ - this.onlyDirectImport - } can only be used for direct wasm to wasm dependencies` + `Import "${this.name}" from "${this.request}" with ${this.onlyDirectImport} can only be used for direct wasm to wasm dependencies` ) ]; } diff --git a/lib/optimize/ChunkModuleIdRangePlugin.js b/lib/optimize/ChunkModuleIdRangePlugin.js index f507e426c..9e3abd3ba 100644 --- a/lib/optimize/ChunkModuleIdRangePlugin.js +++ b/lib/optimize/ChunkModuleIdRangePlugin.js @@ -26,9 +26,7 @@ class ChunkModuleIdRangePlugin { ); if (!chunk) { throw new Error( - `ChunkModuleIdRangePlugin: Chunk with name '${ - options.name - }"' was not found` + `ChunkModuleIdRangePlugin: Chunk with name '${options.name}"' was not found` ); } diff --git a/lib/optimize/ConcatenatedModule.js b/lib/optimize/ConcatenatedModule.js index 4a2973b91..dd5813254 100644 --- a/lib/optimize/ConcatenatedModule.js +++ b/lib/optimize/ConcatenatedModule.js @@ -1136,23 +1136,17 @@ class ConcatenatedModule extends Module { if (info.interopNamespaceObjectUsed) { if (info.module.buildMeta.exportsType === "named") { result.add( - `var ${ - info.interopNamespaceObjectName - } = /*#__PURE__*/__webpack_require__.t(${info.name}, 2);\n` + `var ${info.interopNamespaceObjectName} = /*#__PURE__*/__webpack_require__.t(${info.name}, 2);\n` ); } else if (!info.module.buildMeta.exportsType) { result.add( - `var ${ - info.interopNamespaceObjectName - } = /*#__PURE__*/__webpack_require__.t(${info.name});\n` + `var ${info.interopNamespaceObjectName} = /*#__PURE__*/__webpack_require__.t(${info.name});\n` ); } } if (info.interopDefaultAccessUsed) { result.add( - `var ${ - info.interopDefaultAccessName - } = /*#__PURE__*/__webpack_require__.n(${info.name});\n` + `var ${info.interopDefaultAccessName} = /*#__PURE__*/__webpack_require__.n(${info.name});\n` ); } break; @@ -1266,9 +1260,7 @@ class HarmonyImportSpecifierDependencyConcatenatedTemplate { }_ns${strictFlag}__[${JSON.stringify(dep._id)}]`; } else { const exportData = Buffer.from(dep._id, "utf-8").toString("hex"); - content = `__WEBPACK_MODULE_REFERENCE__${ - info.index - }_${exportData}${callFlag}${strictFlag}__`; + content = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${callFlag}${strictFlag}__`; } if (dep.shorthand) { content = dep.name + ": " + content; @@ -1464,14 +1456,10 @@ class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate { ? "_strict" : ""; if (def.id === true) { - finalName = `__WEBPACK_MODULE_REFERENCE__${ - info.index - }_ns${strictFlag}__`; + finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`; } else { const exportData = Buffer.from(def.id, "utf-8").toString("hex"); - finalName = `__WEBPACK_MODULE_REFERENCE__${ - info.index - }_${exportData}${strictFlag}__`; + finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${strictFlag}__`; } const exportsName = this.rootModule.exportsArgument; const content = diff --git a/lib/wasm/WasmFinalizeExportsPlugin.js b/lib/wasm/WasmFinalizeExportsPlugin.js index 40491a9a6..52df869cb 100644 --- a/lib/wasm/WasmFinalizeExportsPlugin.js +++ b/lib/wasm/WasmFinalizeExportsPlugin.js @@ -46,9 +46,7 @@ class WasmFinalizeExportsPlugin { // 4. error /** @type {any} */ const error = new UnsupportedWebAssemblyFeatureError( - `Export "${name}" with ${ - jsIncompatibleExports[name] - } can only be used for direct wasm to wasm dependencies` + `Export "${name}" with ${jsIncompatibleExports[name]} can only be used for direct wasm to wasm dependencies` ); error.module = module; error.origin = reason.module; diff --git a/lib/wasm/WasmMainTemplatePlugin.js b/lib/wasm/WasmMainTemplatePlugin.js index fccfa819d..494c8ec93 100644 --- a/lib/wasm/WasmMainTemplatePlugin.js +++ b/lib/wasm/WasmMainTemplatePlugin.js @@ -307,9 +307,7 @@ class WasmMainTemplatePlugin { "}", "promises.push(installedWasmModules[wasmModuleId] = promise.then(function(res) {", Template.indent([ - `return ${ - mainTemplate.requireFn - }.w[wasmModuleId] = (res.instance || res).exports;` + `return ${mainTemplate.requireFn}.w[wasmModuleId] = (res.instance || res).exports;` ]), "}));" ]), diff --git a/lib/web/JsonpMainTemplatePlugin.js b/lib/web/JsonpMainTemplatePlugin.js index 75a9da22a..b00d5b668 100644 --- a/lib/web/JsonpMainTemplatePlugin.js +++ b/lib/web/JsonpMainTemplatePlugin.js @@ -340,9 +340,7 @@ class JsonpMainTemplatePlugin { source, "", "// on error function for async loading", - `${ - mainTemplate.requireFn - }.oe = function(err) { console.error(err); throw err; };` + `${mainTemplate.requireFn}.oe = function(err) { console.error(err); throw err; };` ]); } ); diff --git a/open-bot.yaml b/open-bot.yaml index 8dce36481..d2e1bfffa 100644 --- a/open-bot.yaml +++ b/open-bot.yaml @@ -505,7 +505,7 @@ rules: context: "licence/cla" description: "Contributor License Agreement is not needed for this user." state: "success" - + # merge dependabot PRs automatically - filters: open: true diff --git a/test/BenchmarkTestCases.benchmark.js b/test/BenchmarkTestCases.benchmark.js index 9a78a2260..e5dc9064e 100644 --- a/test/BenchmarkTestCases.benchmark.js +++ b/test/BenchmarkTestCases.benchmark.js @@ -279,9 +279,7 @@ describe("BenchmarkTestCases", function() { describe(`${testName} create benchmarks`, function() { baselines.forEach(baseline => { let baselineStats = null; - it(`should benchmark ${baseline.name} (${ - baseline.rev - })`, function(done) { + it(`should benchmark ${baseline.name} (${baseline.rev})`, function(done) { const outputDirectory = path.join( __dirname, "js", @@ -332,14 +330,10 @@ describe("BenchmarkTestCases", function() { }, 180000); if (baseline.name !== "HEAD") { - it(`HEAD should not be slower than ${baseline.name} (${ - baseline.rev - })`, function() { + it(`HEAD should not be slower than ${baseline.name} (${baseline.rev})`, function() { if (baselineStats.maxConfidence < headStats.minConfidence) { throw new Error( - `HEAD (${headStats.text}) is slower than ${baseline.name} (${ - baselineStats.text - }) (90% confidence)` + `HEAD (${headStats.text}) is slower than ${baseline.name} (${baselineStats.text}) (90% confidence)` ); } else if ( baselineStats.minConfidence > headStats.maxConfidence From 9f1112749a57a7bb397f22b7ca95c77ed72fa2f9 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" Date: Mon, 10 Jun 2019 02:16:27 +0000 Subject: [PATCH 10/19] chore(deps-dev): bump prettier from 1.18.0 to 1.18.2 Bumps [prettier](https://github.com/prettier/prettier) from 1.18.0 to 1.18.2. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/1.18.0...1.18.2) Signed-off-by: dependabot-preview[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index f66a47030..88453c139 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5317,9 +5317,9 @@ prettier-linter-helpers@^1.0.0: fast-diff "^1.1.2" prettier@^1.14.3, prettier@^1.16.4: - version "1.18.0" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.0.tgz#d1701ca9b2941864b52f3262b35946d2c9cd88f0" - integrity sha512-YsdAD29M0+WY2xXZk3i0PA16olY9qZss+AuODxglXcJ+2ZBwFv+6k5tE8GS8/HKAthaajlS/WqhdgcjumOrPlg== + version "1.18.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea" + integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw== pretty-format@^24.5.0: version "24.5.0" From 30882ca548625e6d1e54323ff5c61795c6ab4bda Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 11 Jun 2019 10:03:53 +0200 Subject: [PATCH 11/19] Link to JS Foundation Code Of Conduct --- CODE_OF_CONDUCT.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..22ab32170 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1 @@ +[Code of Conduct](https://js.foundation/community/code-of-conduct) From 85b09176b30948a3e4a99f26fbba51fdebc97b38 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" Date: Wed, 12 Jun 2019 02:15:10 +0000 Subject: [PATCH 12/19] chore(deps-dev): bump @types/node from 10.14.8 to 10.14.9 Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 10.14.8 to 10.14.9. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 88453c139..c98a7c9ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -373,9 +373,9 @@ integrity sha512-MeatbbUsZ80BEsKPXby6pUZjUM9ZuHIpWElN0siopih3fvnlpX2O9L6D5+dzDIb36lf9tM/8U4PVdLQ+L4qr4A== "@types/node@^10.12.21": - version "10.14.8" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.8.tgz#fe444203ecef1162348cd6deb76c62477b2cc6e9" - integrity sha512-I4+DbJEhLEg4/vIy/2gkWDvXBOOtPKV9EnLhYjMoqxcRW+TTZtUftkHktz/a8suoD5mUL7m6ReLrkPvSsCQQmw== + version "10.14.9" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.9.tgz#2e8d678039d27943ce53a1913386133227fd9066" + integrity sha512-NelG/dSahlXYtSoVPErrp06tYFrvzj8XLWmKA+X8x0W//4MqbUyZu++giUG/v0bjAT6/Qxa8IjodrfdACyb0Fg== "@types/prettier@^1.16.1": version "1.16.1" From 7fb14ec2c24e29cc7cada48de937dca29ed26071 Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Fri, 11 Jan 2019 12:06:35 +0100 Subject: [PATCH 13/19] Add name property to error thrown on chunk load failure This allows to catch failed chunk loads --- lib/web/JsonpMainTemplatePlugin.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/web/JsonpMainTemplatePlugin.js b/lib/web/JsonpMainTemplatePlugin.js index b00d5b668..d817c52b9 100644 --- a/lib/web/JsonpMainTemplatePlugin.js +++ b/lib/web/JsonpMainTemplatePlugin.js @@ -188,6 +188,7 @@ class JsonpMainTemplatePlugin { "var errorType = event && (event.type === 'load' ? 'missing' : event.type);", "var realSrc = event && event.target && event.target.src;", "error.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';", + "error.name = 'ChunkLoadError';", "error.type = errorType;", "error.request = realSrc;", "chunk[1](error);" From 74178d4d4bdcacb9d85e521485c8d8b8005d5bfb Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Thu, 16 May 2019 10:00:12 -0700 Subject: [PATCH 14/19] Update snapshot --- .../__snapshots__/StatsTestCases.test.js.snap | 118 +++++++++--------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/test/__snapshots__/StatsTestCases.test.js.snap b/test/__snapshots__/StatsTestCases.test.js.snap index 6e89877d4..0f4ab9745 100644 --- a/test/__snapshots__/StatsTestCases.test.js.snap +++ b/test/__snapshots__/StatsTestCases.test.js.snap @@ -1,21 +1,21 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`StatsTestCases should print correct stats for aggressive-splitting-entry 1`] = ` -"Hash: d524793ebb8ce4369ef3d524793ebb8ce4369ef3 +"Hash: 6cbb823182bf98157dae6cbb823182bf98157dae Child fitting: - Hash: d524793ebb8ce4369ef3 + Hash: 6cbb823182bf98157dae Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names + 1b9909fbb925939aa3dc.js 11.2 KiB 1 [emitted] 33966214360bbbb31383.js 1.94 KiB 2 [emitted] 445d4c6a1d7381d6cb2c.js 1.94 KiB 3 [emitted] - 921eee6e6f9c90854444.js 11.1 KiB 1 [emitted] d4b551c6319035df2898.js 1.05 KiB 0 [emitted] - Entrypoint main = 33966214360bbbb31383.js 445d4c6a1d7381d6cb2c.js 921eee6e6f9c90854444.js + Entrypoint main = 33966214360bbbb31383.js 445d4c6a1d7381d6cb2c.js 1b9909fbb925939aa3dc.js chunk {0} d4b551c6319035df2898.js 916 bytes <{1}> <{2}> <{3}> > ./g [4] ./index.js 7:0-13 [7] ./g.js 916 bytes {0} [built] - chunk {1} 921eee6e6f9c90854444.js 1.87 KiB ={2}= ={3}= >{0}< [entry] [rendered] + chunk {1} 1b9909fbb925939aa3dc.js 1.87 KiB ={2}= ={3}= >{0}< [entry] [rendered] > ./index main [3] ./e.js 899 bytes {1} [built] [4] ./index.js 111 bytes {1} [built] @@ -29,19 +29,19 @@ Child fitting: [1] ./c.js 899 bytes {3} [built] [2] ./d.js 899 bytes {3} [built] Child content-change: - Hash: d524793ebb8ce4369ef3 + Hash: 6cbb823182bf98157dae Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names + 1b9909fbb925939aa3dc.js 11.2 KiB 1 [emitted] 33966214360bbbb31383.js 1.94 KiB 2 [emitted] 445d4c6a1d7381d6cb2c.js 1.94 KiB 3 [emitted] - 921eee6e6f9c90854444.js 11.1 KiB 1 [emitted] d4b551c6319035df2898.js 1.05 KiB 0 [emitted] - Entrypoint main = 33966214360bbbb31383.js 445d4c6a1d7381d6cb2c.js 921eee6e6f9c90854444.js + Entrypoint main = 33966214360bbbb31383.js 445d4c6a1d7381d6cb2c.js 1b9909fbb925939aa3dc.js chunk {0} d4b551c6319035df2898.js 916 bytes <{1}> <{2}> <{3}> > ./g [4] ./index.js 7:0-13 [7] ./g.js 916 bytes {0} [built] - chunk {1} 921eee6e6f9c90854444.js 1.87 KiB ={2}= ={3}= >{0}< [entry] [rendered] + chunk {1} 1b9909fbb925939aa3dc.js 1.87 KiB ={2}= ={3}= >{0}< [entry] [rendered] > ./index main [3] ./e.js 899 bytes {1} [built] [4] ./index.js 111 bytes {1} [built] @@ -57,13 +57,12 @@ Child content-change: `; exports[`StatsTestCases should print correct stats for aggressive-splitting-on-demand 1`] = ` -"Hash: 96eb8998861d28c252c9 +"Hash: 6201a8de459c0eb391bf Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names 01a8254701931adbf278.js 1.01 KiB 9 [emitted] 07830cd8072d83cdc6ad.js 1.01 KiB 10 [emitted] -12cc6b35fbee8a83d4c7.js 9.75 KiB 4 [emitted] main 2736cf9d79233cd0a9b6.js 1.93 KiB 0 [emitted] 29de52df747b400f6177.js 1 KiB 1 [emitted] 41be79832883258c21e6.js 1.94 KiB 6 [emitted] @@ -71,9 +70,10 @@ Built at: Thu Jan 01 1970 00:00:00 GMT 5bc7f208cd99a83b4e33.js 1.94 KiB 8 [emitted] 7f83e5c2f4e52435dd2c.js 1.96 KiB 2 [emitted] ba9fedb7aa0c69201639.js 1.94 KiB 11 [emitted] +c8f26699902585c4b2f5.js 9.8 KiB 4 [emitted] main d40ae25f5e7ef09d2e24.js 1.94 KiB 7, 10 [emitted] e5fb899955fa03a8053b.js 1.94 KiB 5 [emitted] -Entrypoint main = 12cc6b35fbee8a83d4c7.js +Entrypoint main = c8f26699902585c4b2f5.js chunk {0} 2736cf9d79233cd0a9b6.js 1.76 KiB <{4}> ={1}= ={2}= ={3}= ={6}= ={10}= [recorded] aggressive splitted > ./b ./d ./e ./f ./g [11] ./index.js 5:0-44 > ./b ./d ./e ./f ./g ./h ./i ./j ./k [11] ./index.js 6:0-72 @@ -93,7 +93,7 @@ chunk {3} 43c1ac24102c075ecb2d.js 1.76 KiB <{4}> ={0}= ={2}= ={6}= ={10}= [re > ./b ./d ./e ./f ./g ./h ./i ./j ./k [11] ./index.js 6:0-72 [2] ./e.js 899 bytes {1} {3} [built] [6] ./h.js 899 bytes {3} {11} [built] -chunk {4} 12cc6b35fbee8a83d4c7.js (main) 248 bytes >{0}< >{1}< >{2}< >{3}< >{5}< >{6}< >{7}< >{8}< >{9}< >{10}< >{11}< [entry] [rendered] +chunk {4} c8f26699902585c4b2f5.js (main) 248 bytes >{0}< >{1}< >{2}< >{3}< >{5}< >{6}< >{7}< >{8}< >{9}< >{10}< >{11}< [entry] [rendered] > ./index main [11] ./index.js 248 bytes {4} [built] chunk {5} e5fb899955fa03a8053b.js 1.76 KiB <{4}> @@ -492,14 +492,14 @@ chunk {1} main1.js (main1) 136 bytes [entry] [rendered] `; exports[`StatsTestCases should print correct stats for chunks 1`] = ` -"Hash: d705fa47b1ad3d93dd58 +"Hash: 6d9c801dfe464fffa280 Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names 1.bundle.js 232 bytes 1 [emitted] 2.bundle.js 152 bytes 2 [emitted] 3.bundle.js 289 bytes 3 [emitted] - bundle.js 8.34 KiB 0 [emitted] main + bundle.js 8.38 KiB 0 [emitted] main Entrypoint main = bundle.js chunk {0} bundle.js (main) 73 bytes >{2}< >{3}< [entry] [rendered] > ./index main @@ -530,14 +530,14 @@ chunk {3} 3.bundle.js 54 bytes <{0}> >{1}< [rendered] `; exports[`StatsTestCases should print correct stats for chunks-development 1`] = ` -"Hash: c12322ddb1ced28f356c +"Hash: 22e4d9d4c5efbcf0fe75 Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names 0.bundle.js 588 bytes 0 [emitted] 1.bundle.js 297 bytes 1 [emitted] 2.bundle.js 433 bytes 2 [emitted] - bundle.js 8.72 KiB main [emitted] main + bundle.js 8.76 KiB main [emitted] main Entrypoint main = bundle.js chunk {0} 0.bundle.js 60 bytes <{2}> [rendered] > [./c.js] ./c.js 1:0-52 @@ -1072,14 +1072,14 @@ chunk {5} y.js (y) 0 bytes <{3}> <{4}> [rendered] `; exports[`StatsTestCases should print correct stats for import-context-filter 1`] = ` -"Hash: 029b08a3a0c343d3a477 +"Hash: 239c0f8f5ce6a754f40e Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names 0.js 305 bytes 0 [emitted] 1.js 314 bytes 1 [emitted] 2.js 308 bytes 2 [emitted] -entry.js 9.16 KiB 3 [emitted] entry +entry.js 9.2 KiB 3 [emitted] entry Entrypoint entry = entry.js [0] ./templates/bar.js 38 bytes {0} [optional] [built] [1] ./templates/baz.js 38 bytes {1} [optional] [built] @@ -1089,12 +1089,12 @@ Entrypoint entry = entry.js `; exports[`StatsTestCases should print correct stats for import-weak 1`] = ` -"Hash: 3c7715820cb46e731729 +"Hash: 8b1d4de9c2aa6d6e0ce9 Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names 1.js 149 bytes 1 [emitted] -entry.js 8.58 KiB 0 [emitted] entry +entry.js 8.63 KiB 0 [emitted] entry Entrypoint entry = entry.js [0] ./modules/b.js 22 bytes {1} [built] [1] ./entry.js 120 bytes {0} [built] @@ -1124,7 +1124,7 @@ Compilation error while processing magic comment(-s): /* webpackPrefetch: true, `; exports[`StatsTestCases should print correct stats for issue-7577 1`] = ` -"Hash: 9c248e1f7cf8b331fba532fffa02370ddddc7d7dfcb8e81ff94ce622913a +"Hash: 9c248e1f7cf8b331fba532fffa02370ddddc7d7d78deefb67762da57e753 Child Hash: 9c248e1f7cf8b331fba5 Time: Xms @@ -1148,7 +1148,7 @@ Child [0] ./node_modules/vendor.js 23 bytes {vendors~main} [built] [1] ./b.js 17 bytes {all~main} [built] Child - Hash: fcb8e81ff94ce622913a + Hash: 78deefb67762da57e753 Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names @@ -1156,15 +1156,15 @@ Child c-1-5eacbd7fee2224716029.js 153 bytes 1 [emitted] c-all~main-3de9f206741c28715d19.js 305 bytes all~main [emitted] all~main c-main-75156155081cda3092db.js 114 bytes main [emitted] main - c-runtime~main-d9218b78b260b895303b.js 9.7 KiB runtime~main [emitted] runtime~main - Entrypoint main = c-runtime~main-d9218b78b260b895303b.js c-all~main-3de9f206741c28715d19.js c-main-75156155081cda3092db.js (prefetch: c-1-5eacbd7fee2224716029.js c-0-5b8bdddff2dcbbac44bf.js) + c-runtime~main-3fa83e7a8272f64029da.js 9.75 KiB runtime~main [emitted] runtime~main + Entrypoint main = c-runtime~main-3fa83e7a8272f64029da.js c-all~main-3de9f206741c28715d19.js c-main-75156155081cda3092db.js (prefetch: c-1-5eacbd7fee2224716029.js c-0-5b8bdddff2dcbbac44bf.js) [0] ./b.js 17 bytes {0} [built] [1] ./c.js 61 bytes {all~main} [built] [2] ./node_modules/vendor.js 23 bytes {1} [built]" `; exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin 1`] = ` -"Hash: 4c228d725cbf3eab49b01d459b5ae91657520cf1ea5d046a3a3199b128cb4e594c01cb2ee66a4e9e +"Hash: 4c228d725cbf3eab49b078fd140246b08c69fb40853ad9ffeae5168f8a48972e61b6398bb46205b3 Child 1 chunks: Hash: 4c228d725cbf3eab49b0 Time: Xms @@ -1180,12 +1180,12 @@ Child 1 chunks: [4] ./d.js 22 bytes {0} [built] [5] ./e.js 22 bytes {0} [built] Child 2 chunks: - Hash: 1d459b5ae91657520cf1 + Hash: 78fd140246b08c69fb40 Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names 0.bundle.js 401 bytes 0 [emitted] - bundle.js 8.57 KiB 1 [emitted] main + bundle.js 8.62 KiB 1 [emitted] main Entrypoint main = bundle.js chunk {0} 0.bundle.js 88 bytes <{1}> [rendered] [2] ./a.js 22 bytes {0} [built] @@ -1196,13 +1196,13 @@ Child 2 chunks: [0] ./index.js 101 bytes {1} [built] [1] ./c.js 30 bytes {1} [built] Child 3 chunks: - Hash: ea5d046a3a3199b128cb + Hash: 853ad9ffeae5168f8a48 Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names 1.bundle.js 245 bytes 1 [emitted] 2.bundle.js 232 bytes 2 [emitted] - bundle.js 8.57 KiB 0 [emitted] main + bundle.js 8.62 KiB 0 [emitted] main Entrypoint main = bundle.js chunk {0} bundle.js (main) 131 bytes <{0}> >{0}< >{1}< >{2}< [entry] [rendered] [0] ./index.js 101 bytes {0} [built] @@ -1214,14 +1214,14 @@ Child 3 chunks: [4] ./d.js 22 bytes {2} [built] [5] ./e.js 22 bytes {2} [built] Child 4 chunks: - Hash: 4e594c01cb2ee66a4e9e + Hash: 972e61b6398bb46205b3 Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names 1.bundle.js 245 bytes 1 [emitted] 2.bundle.js 152 bytes 2 [emitted] 3.bundle.js 152 bytes 3 [emitted] - bundle.js 8.57 KiB 0 [emitted] main + bundle.js 8.62 KiB 0 [emitted] main Entrypoint main = bundle.js chunk {0} bundle.js (main) 131 bytes <{0}> >{0}< >{1}< >{2}< >{3}< [entry] [rendered] [0] ./index.js 101 bytes {0} [built] @@ -1291,7 +1291,7 @@ Entrypoint main = main.js `; exports[`StatsTestCases should print correct stats for module-assets 1`] = ` -"Hash: 2c05268b726f002f1d70 +"Hash: 54bf3faf38ba75ca46ce Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Entrypoint main = main.js @@ -1313,9 +1313,9 @@ exports[`StatsTestCases should print correct stats for module-deduplication 1`] 6.js 661 bytes 6 [emitted] 7.js 661 bytes 7 [emitted] 8.js 661 bytes 8 [emitted] -e1.js 9.48 KiB 3 [emitted] e1 -e2.js 9.5 KiB 4 [emitted] e2 -e3.js 9.52 KiB 5 [emitted] e3 +e1.js 9.52 KiB 3 [emitted] e1 +e2.js 9.54 KiB 4 [emitted] e2 +e3.js 9.56 KiB 5 [emitted] e3 Entrypoint e1 = e1.js Entrypoint e2 = e2.js Entrypoint e3 = e3.js @@ -1359,9 +1359,9 @@ exports[`StatsTestCases should print correct stats for module-deduplication-name async1.js 820 bytes 0 [emitted] async1 async2.js 820 bytes 1 [emitted] async2 async3.js 820 bytes 2 [emitted] async3 - e1.js 9.34 KiB 3 [emitted] e1 - e2.js 9.36 KiB 4 [emitted] e2 - e3.js 9.38 KiB 5 [emitted] e3 + e1.js 9.38 KiB 3 [emitted] e1 + e2.js 9.4 KiB 4 [emitted] e2 + e3.js 9.42 KiB 5 [emitted] e3 Entrypoint e1 = e1.js Entrypoint e2 = e2.js Entrypoint e3 = e3.js @@ -1487,13 +1487,13 @@ Entrypoint entry = vendor.js entry.js `; exports[`StatsTestCases should print correct stats for named-chunks-plugin-async 1`] = ` -"Hash: 60385d369365bc0fd54c +"Hash: 103757d96f9997c329e8 Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names chunk-containing-__a_js.js 307 bytes chunk-containing-__a_js [emitted] chunk-containing-__b_js.js 182 bytes chunk-containing-__b_js [emitted] - entry.js 8.23 KiB entry [emitted] entry + entry.js 8.28 KiB entry [emitted] entry Entrypoint entry = entry.js [0] ./entry.js 47 bytes {entry} [built] [1] ./modules/b.js 22 bytes {chunk-containing-__b_js} [built] @@ -1523,7 +1523,7 @@ Child child: `; exports[`StatsTestCases should print correct stats for optimize-chunks 1`] = ` -"Hash: 9fb1f75980b8d2b56559 +"Hash: ebe795145b72dc9668df Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names @@ -1534,7 +1534,7 @@ Built at: Thu Jan 01 1970 00:00:00 GMT cir1.js 299 bytes 0 [emitted] cir1 cir2 from cir1.js 359 bytes 6, 5 [emitted] cir2 from cir1 cir2.js 299 bytes 5 [emitted] cir2 - main.js 9.14 KiB 7 [emitted] main + main.js 9.19 KiB 7 [emitted] main Entrypoint main = main.js chunk {0} cir1.js (cir1) 81 bytes <{5}> <{7}> >{6}< [rendered] > [5] ./index.js 13:0-54 @@ -1826,7 +1826,7 @@ exports[`StatsTestCases should print correct stats for prefetch 1`] = ` " Asset Size Chunks Chunk Names inner.js 130 bytes 0 [emitted] inner inner2.js 188 bytes 1 [emitted] inner2 - main.js 9.76 KiB 2 [emitted] main + main.js 9.81 KiB 2 [emitted] main normal.js 130 bytes 3 [emitted] normal prefetched.js 475 bytes 4 [emitted] prefetched prefetched2.js 127 bytes 5 [emitted] prefetched2 @@ -1859,7 +1859,7 @@ exports[`StatsTestCases should print correct stats for preload 1`] = ` " Asset Size Chunks Chunk Names inner.js 130 bytes 0 [emitted] inner inner2.js 188 bytes 1 [emitted] inner2 - main.js 9.86 KiB 2 [emitted] main + main.js 9.91 KiB 2 [emitted] main normal.js 130 bytes 3 [emitted] normal preloaded.js 467 bytes 4 [emitted] preloaded preloaded2.js 127 bytes 5 [emitted] preloaded2 @@ -1875,14 +1875,14 @@ chunk {6} preloaded3.js (preloaded3) 0 bytes <{2}> [rendered]" `; exports[`StatsTestCases should print correct stats for preset-detailed 1`] = ` -"Hash: 6ec7fe98c2ecd225affe +"Hash: 3d7ab97d01611dac4854 Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names 1.js 232 bytes 1 [emitted] 2.js 152 bytes 2 [emitted] 3.js 289 bytes 3 [emitted] -main.js 8.34 KiB 0 [emitted] main +main.js 8.39 KiB 0 [emitted] main Entrypoint main = main.js chunk {0} main.js (main) 73 bytes >{2}< >{3}< [entry] [rendered] > ./index main @@ -1936,14 +1936,14 @@ exports[`StatsTestCases should print correct stats for preset-none-array 1`] = ` exports[`StatsTestCases should print correct stats for preset-none-error 1`] = `""`; exports[`StatsTestCases should print correct stats for preset-normal 1`] = ` -"Hash: 6ec7fe98c2ecd225affe +"Hash: 3d7ab97d01611dac4854 Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names 1.js 232 bytes 1 [emitted] 2.js 152 bytes 2 [emitted] 3.js 289 bytes 3 [emitted] -main.js 8.34 KiB 0 [emitted] main +main.js 8.39 KiB 0 [emitted] main Entrypoint main = main.js [0] ./index.js 51 bytes {0} [built] [1] ./a.js 22 bytes {0} [built] @@ -2014,14 +2014,14 @@ Entrypoints: `; exports[`StatsTestCases should print correct stats for preset-verbose 1`] = ` -"Hash: 6ec7fe98c2ecd225affe +"Hash: 3d7ab97d01611dac4854 Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names 1.js 232 bytes 1 [emitted] 2.js 152 bytes 2 [emitted] 3.js 289 bytes 3 [emitted] -main.js 8.34 KiB 0 [emitted] main +main.js 8.39 KiB 0 [emitted] main Entrypoint main = main.js chunk {0} main.js (main) 73 bytes >{2}< >{3}< [entry] [rendered] > ./index main @@ -2111,7 +2111,7 @@ exports[`StatsTestCases should print correct stats for runtime-chunk-integration Asset Size Chunks Chunk Names 0.js 728 bytes 0 [emitted] main1.js 539 bytes 1 [emitted] main1 - runtime.js 8.81 KiB 2 [emitted] runtime + runtime.js 8.86 KiB 2 [emitted] runtime Entrypoint main1 = runtime.js main1.js [0] ./main1.js 66 bytes {1} [built] [1] ./b.js 20 bytes {0} [built] @@ -2121,7 +2121,7 @@ Child manifest is named entry: Asset Size Chunks Chunk Names 0.js 737 bytes 0 [emitted] main1.js 539 bytes 2 [emitted] main1 - manifest.js 9.12 KiB 1 [emitted] manifest + manifest.js 9.17 KiB 1 [emitted] manifest Entrypoint main1 = manifest.js main1.js Entrypoint manifest = manifest.js [0] ./main1.js 66 bytes {2} [built] @@ -2142,7 +2142,7 @@ Entrypoint e2 = runtime.js e2.js" `; exports[`StatsTestCases should print correct stats for scope-hoisting-bailouts 1`] = ` -"Hash: 2a7b18734507859f49cf +"Hash: 068d217ebeaaa0ea68bf Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Entrypoint index = index.js @@ -2174,9 +2174,9 @@ Entrypoint entry = entry.js `; exports[`StatsTestCases should print correct stats for scope-hoisting-multi 1`] = ` -"Hash: a5a12aaa20eb499386135bf1947abb0f025e8f21 +"Hash: 69b9ad8f1b3ea52c02f9ec5c553a8e60ff987af7 Child - Hash: a5a12aaa20eb49938613 + Hash: 69b9ad8f1b3ea52c02f9 Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Entrypoint first = vendor.js first.js @@ -2193,7 +2193,7 @@ Child [9] ./common_lazy_shared.js 25 bytes {2} {3} {4} [built] [10] ./common_lazy.js 25 bytes {2} {3} [built] Child - Hash: 5bf1947abb0f025e8f21 + Hash: ec5c553a8e60ff987af7 Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Entrypoint first = vendor.js first.js @@ -2221,12 +2221,12 @@ Child `; exports[`StatsTestCases should print correct stats for side-effects-issue-7428 1`] = ` -"Hash: 0521fcbcd079754c226d +"Hash: 1e21ad8ce2760ebcc568 Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT Asset Size Chunks Chunk Names 1.js 481 bytes 1 [emitted] -main.js 9.4 KiB 0 [emitted] main +main.js 9.45 KiB 0 [emitted] main Entrypoint main = main.js [0] ./components/src/CompAB/index.js 87 bytes [built] [no exports used] From df5e118da4a58f1472826654e8b6baf777d7c08f Mon Sep 17 00:00:00 2001 From: alreadyExisted Date: Thu, 25 Apr 2019 18:58:20 +0300 Subject: [PATCH 15/19] fix(mjs): remove unused namespace build errors --- .../HarmonyExportImportedSpecifierDependency.js | 5 ++--- lib/dependencies/HarmonyImportSpecifierDependency.js | 5 ++--- test/cases/mjs/cjs-import-default/errors.js | 9 --------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js index 19642ddff..1183dc542 100644 --- a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +++ b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js @@ -355,12 +355,11 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency { // It's not an harmony module if ( this.originModule.buildMeta.strictHarmonyModule && + this._id && this._id !== "default" ) { // In strict harmony modules we only support the default export - const exportName = this._id - ? `the named export '${this._id}'` - : "the namespace object"; + const exportName = `the named export '${this._id}'`; return [ new HarmonyLinkingError( `Can't reexport ${exportName} from non EcmaScript module (only default export is available)` diff --git a/lib/dependencies/HarmonyImportSpecifierDependency.js b/lib/dependencies/HarmonyImportSpecifierDependency.js index 9f681a6f3..76b9e2410 100644 --- a/lib/dependencies/HarmonyImportSpecifierDependency.js +++ b/lib/dependencies/HarmonyImportSpecifierDependency.js @@ -80,12 +80,11 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency { // It's not an harmony module if ( this.originModule.buildMeta.strictHarmonyModule && + this._id && this._id !== "default" ) { // In strict harmony modules we only support the default export - const exportName = this._id - ? `the named export '${this._id}'` - : "the namespace object"; + const exportName = `the named export '${this._id}'`; return [ new HarmonyLinkingError( `Can't import ${exportName} from non EcmaScript module (only default export is available)` diff --git a/test/cases/mjs/cjs-import-default/errors.js b/test/cases/mjs/cjs-import-default/errors.js index 5e0f6e012..49b98a34e 100644 --- a/test/cases/mjs/cjs-import-default/errors.js +++ b/test/cases/mjs/cjs-import-default/errors.js @@ -1,19 +1,10 @@ module.exports = [ - [ - /Can't import the namespace object from non EcmaScript module \(only default export is available\)/ - ], - [ - /Can't import the namespace object from non EcmaScript module \(only default export is available\)/ - ], [ /Can't import the named export 'data' from non EcmaScript module \(only default export is available\)/ ], [ /Can't import the named export 'data' from non EcmaScript module \(only default export is available\)/ ], - [ - /Can't reexport the namespace object from non EcmaScript module \(only default export is available\)/ - ], [ /Can't reexport the named export 'data' from non EcmaScript module \(only default export is available\)/ ] From 8d5ad83b3274029e37386dbd5d0c64d8102bcd6f Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 20 May 2019 09:45:56 +0200 Subject: [PATCH 16/19] simplify code --- lib/dependencies/HarmonyExportImportedSpecifierDependency.js | 3 +-- lib/dependencies/HarmonyImportSpecifierDependency.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js index 1183dc542..15429b6ed 100644 --- a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +++ b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js @@ -359,10 +359,9 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency { this._id !== "default" ) { // In strict harmony modules we only support the default export - const exportName = `the named export '${this._id}'`; return [ new HarmonyLinkingError( - `Can't reexport ${exportName} from non EcmaScript module (only default export is available)` + `Can't reexport the named export '${this._id}' from non EcmaScript module (only default export is available)` ) ]; } diff --git a/lib/dependencies/HarmonyImportSpecifierDependency.js b/lib/dependencies/HarmonyImportSpecifierDependency.js index 76b9e2410..d07fbf1ca 100644 --- a/lib/dependencies/HarmonyImportSpecifierDependency.js +++ b/lib/dependencies/HarmonyImportSpecifierDependency.js @@ -84,10 +84,9 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency { this._id !== "default" ) { // In strict harmony modules we only support the default export - const exportName = `the named export '${this._id}'`; return [ new HarmonyLinkingError( - `Can't import ${exportName} from non EcmaScript module (only default export is available)` + `Can't import the named export '${this._id}' from non EcmaScript module (only default export is available)` ) ]; } From a1d45671c1f0cf6d41347718e5797c8ec50bc280 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 12 Jun 2019 15:28:45 +0200 Subject: [PATCH 17/19] fix error message and stack in Firefox in Firefox stack doesn't include the message --- hot/dev-server.js | 4 ++-- hot/log.js | 12 ++++++++++++ hot/only-dev-server.js | 7 ++----- hot/poll.js | 7 ++----- hot/signal.js | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/hot/dev-server.js b/hot/dev-server.js index 682a47f84..f396a34af 100644 --- a/hot/dev-server.js +++ b/hot/dev-server.js @@ -40,10 +40,10 @@ if (module.hot) { "warning", "[HMR] Cannot apply update. Need to do a full reload!" ); - log("warning", "[HMR] " + (err.stack || err.message)); + log("warning", "[HMR] " + log.formatError(err)); window.location.reload(); } else { - log("warning", "[HMR] Update failed: " + (err.stack || err.message)); + log("warning", "[HMR] Update failed: " + log.formatError(err)); } }); }; diff --git a/hot/log.js b/hot/log.js index 0d05673f8..32a1c69b1 100644 --- a/hot/log.js +++ b/hot/log.js @@ -45,3 +45,15 @@ module.exports.groupEnd = logGroup(groupEnd); module.exports.setLogLevel = function(level) { logLevel = level; }; + +module.exports.formatError = function(err) { + var message = err.message; + var stack = err.stack; + if (!stack) { + return message; + } else if (stack.indexOf(message) < 0) { + return message + "\n" + stack; + } else { + return stack; + } +}; diff --git a/hot/only-dev-server.js b/hot/only-dev-server.js index 043f2430b..12df4687e 100644 --- a/hot/only-dev-server.js +++ b/hot/only-dev-server.js @@ -72,12 +72,9 @@ if (module.hot) { "warning", "[HMR] Cannot check for update. Need to do a full reload!" ); - log("warning", "[HMR] " + (err.stack || err.message)); + log("warning", "[HMR] " + log.formatError(err)); } else { - log( - "warning", - "[HMR] Update check failed: " + (err.stack || err.message) - ); + log("warning", "[HMR] Update check failed: " + log.formatError(err)); } }); }; diff --git a/hot/poll.js b/hot/poll.js index 8193db01f..81d33e7c7 100644 --- a/hot/poll.js +++ b/hot/poll.js @@ -23,13 +23,10 @@ if (module.hot) { var status = module.hot.status(); if (["abort", "fail"].indexOf(status) >= 0) { log("warning", "[HMR] Cannot apply update."); - log("warning", "[HMR] " + (err.stack || err.message)); + log("warning", "[HMR] " + log.formatError(err)); log("warning", "[HMR] You need to restart the application!"); } else { - log( - "warning", - "[HMR] Update failed: " + (err.stack || err.message) - ); + log("warning", "[HMR] Update failed: " + log.formatError(err)); } }); } diff --git a/hot/signal.js b/hot/signal.js index 24c4f5cb3..63bfdd650 100644 --- a/hot/signal.js +++ b/hot/signal.js @@ -37,7 +37,7 @@ if (module.hot) { var status = module.hot.status(); if (["abort", "fail"].indexOf(status) >= 0) { log("warning", "[HMR] Cannot apply update."); - log("warning", "[HMR] " + (err.stack || err.message)); + log("warning", "[HMR] " + log.formatError(err)); log("warning", "[HMR] You need to restart the application!"); } else { log("warning", "[HMR] Update failed: " + (err.stack || err.message)); From e04b1a52a0c743cd002f2ca78337b3747f2e3137 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 13 Jun 2019 00:41:42 +0200 Subject: [PATCH 18/19] handle block scopes correctly fixes #9253 fixes #9183 --- lib/Parser.js | 301 ++++++++++++++++------ test/cases/parsing/block-scopes/index.js | 76 ++++++ test/cases/parsing/block-scopes/module.js | 1 + 3 files changed, 300 insertions(+), 78 deletions(-) create mode 100644 test/cases/parsing/block-scopes/index.js create mode 100644 test/cases/parsing/block-scopes/module.js diff --git a/lib/Parser.js b/lib/Parser.js index 554fa667a..cc53cce57 100644 --- a/lib/Parser.js +++ b/lib/Parser.js @@ -13,7 +13,6 @@ const util = require("util"); const vm = require("vm"); const BasicEvaluatedExpression = require("./BasicEvaluatedExpression"); const StackedSetMap = require("./util/StackedSetMap"); -const TrackingSet = require("./util/TrackingSet"); const acornParser = acorn.Parser.extend(acornDynamicImport); @@ -34,8 +33,6 @@ const defaultParserOptions = { // regexp to match at lease one "magic comment" const webpackCommentRegExp = new RegExp(/(^|\W)webpack[A-Z]{1,}[A-Za-z]{1,}:/); -const EMPTY_ARRAY = []; - const EMPTY_COMMENT_OPTIONS = { options: null, errors: null @@ -857,6 +854,14 @@ class Parser extends Tapable { } } + // Block-Prewalking iterates the scope for block variable declarations + blockPrewalkStatements(statements) { + for (let index = 0, len = statements.length; index < len; index++) { + const statement = statements[index]; + this.blockPrewalkStatement(statement); + } + } + // Walking iterates the statements and expressions and processes them walkStatements(statements) { for (let index = 0, len = statements.length; index < len; index++) { @@ -870,9 +875,6 @@ class Parser extends Tapable { case "BlockStatement": this.prewalkBlockStatement(statement); break; - case "ClassDeclaration": - this.prewalkClassDeclaration(statement); - break; case "DoWhileStatement": this.prewalkDoWhileStatement(statement); break; @@ -924,6 +926,23 @@ class Parser extends Tapable { } } + blockPrewalkStatement(statement) { + switch (statement.type) { + case "VariableDeclaration": + this.blockPrewalkVariableDeclaration(statement); + break; + case "ExportDefaultDeclaration": + this.blockPrewalkExportDefaultDeclaration(statement); + break; + case "ExportNamedDeclaration": + this.blockPrewalkExportNamedDeclaration(statement); + break; + case "ClassDeclaration": + this.blockPrewalkClassDeclaration(statement); + break; + } + } + walkStatement(statement) { if (this.hooks.statement.call(statement) !== undefined) return; switch (statement.type) { @@ -993,7 +1012,11 @@ class Parser extends Tapable { } walkBlockStatement(statement) { - this.walkStatements(statement.body); + this.inBlockScope(() => { + const body = statement.body; + this.blockPrewalkStatements(body); + this.walkStatements(body); + }); } walkExpressionStatement(statement) { @@ -1111,20 +1134,30 @@ class Parser extends Tapable { } walkForStatement(statement) { - if (statement.init) { - if (statement.init.type === "VariableDeclaration") { - this.walkStatement(statement.init); - } else { - this.walkExpression(statement.init); + this.inBlockScope(() => { + if (statement.init) { + if (statement.init.type === "VariableDeclaration") { + this.blockPrewalkVariableDeclaration(statement.init); + this.walkStatement(statement.init); + } else { + this.walkExpression(statement.init); + } } - } - if (statement.test) { - this.walkExpression(statement.test); - } - if (statement.update) { - this.walkExpression(statement.update); - } - this.walkStatement(statement.body); + if (statement.test) { + this.walkExpression(statement.test); + } + if (statement.update) { + this.walkExpression(statement.update); + } + const body = statement.body; + if (body.type === "BlockStatement") { + // no need to add additional scope + this.blockPrewalkStatements(body.body); + this.walkStatements(body.body); + } else { + this.walkStatement(body); + } + }); } prewalkForInStatement(statement) { @@ -1135,13 +1168,23 @@ class Parser extends Tapable { } walkForInStatement(statement) { - if (statement.left.type === "VariableDeclaration") { - this.walkVariableDeclaration(statement.left); - } else { - this.walkPattern(statement.left); - } - this.walkExpression(statement.right); - this.walkStatement(statement.body); + this.inBlockScope(() => { + if (statement.left.type === "VariableDeclaration") { + this.blockPrewalkVariableDeclaration(statement.left); + this.walkVariableDeclaration(statement.left); + } else { + this.walkPattern(statement.left); + } + this.walkExpression(statement.right); + const body = statement.body; + if (body.type === "BlockStatement") { + // no need to add additional scope + this.blockPrewalkStatements(body.body); + this.walkStatements(body.body); + } else { + this.walkStatement(body); + } + }); } prewalkForOfStatement(statement) { @@ -1152,13 +1195,23 @@ class Parser extends Tapable { } walkForOfStatement(statement) { - if (statement.left.type === "VariableDeclaration") { - this.walkVariableDeclaration(statement.left); - } else { - this.walkPattern(statement.left); - } - this.walkExpression(statement.right); - this.walkStatement(statement.body); + this.inBlockScope(() => { + if (statement.left.type === "VariableDeclaration") { + this.blockPrewalkVariableDeclaration(statement.left); + this.walkVariableDeclaration(statement.left); + } else { + this.walkPattern(statement.left); + } + this.walkExpression(statement.right); + const body = statement.body; + if (body.type === "BlockStatement") { + // no need to add additional scope + this.blockPrewalkStatements(body.body); + this.walkStatements(body.body); + } else { + this.walkStatement(body); + } + }); } // Declarations @@ -1172,7 +1225,7 @@ class Parser extends Tapable { walkFunctionDeclaration(statement) { const wasTopLevel = this.scope.topLevelScope; this.scope.topLevelScope = false; - this.inScope(statement.params, () => { + this.inFunctionScope(true, statement.params, () => { for (const param of statement.params) { this.walkPattern(param); } @@ -1213,6 +1266,33 @@ class Parser extends Tapable { } } + enterDeclaration(declaration, onIdent) { + switch (declaration.type) { + case "VariableDeclaration": + for (const declarator of declaration.declarations) { + switch (declarator.type) { + case "VariableDeclarator": { + this.enterPattern(declarator.id, onIdent); + break; + } + } + } + break; + case "FunctionDeclaration": + this.enterPattern(declaration.id, onIdent); + break; + case "ClassDeclaration": + this.enterPattern(declaration.id, onIdent); + break; + } + } + + blockPrewalkExportNamedDeclaration(statement) { + if (statement.declaration) { + this.blockPrewalkStatement(statement.declaration); + } + } + prewalkExportNamedDeclaration(statement) { let source; if (statement.source) { @@ -1225,16 +1305,11 @@ class Parser extends Tapable { if ( !this.hooks.exportDeclaration.call(statement, statement.declaration) ) { - const originalDefinitions = this.scope.definitions; - const tracker = new TrackingSet(this.scope.definitions); - this.scope.definitions = tracker; this.prewalkStatement(statement.declaration); - const newDefs = Array.from(tracker.getAddedItems()); - this.scope.definitions = originalDefinitions; - for (let index = newDefs.length - 1; index >= 0; index--) { - const def = newDefs[index]; - this.hooks.exportSpecifier.call(statement, def, def, index); - } + let index = 0; + this.enterDeclaration(statement.declaration, def => { + this.hooks.exportSpecifier.call(statement, def, def, index++); + }); } } if (statement.specifiers) { @@ -1276,18 +1351,24 @@ class Parser extends Tapable { } } + blockPrewalkExportDefaultDeclaration(statement) { + if (statement.declaration.type === "ClassDeclaration") { + this.blockPrewalkClassDeclaration(statement.declaration); + } + } + prewalkExportDefaultDeclaration(statement) { - if (statement.declaration.id) { - const originalDefinitions = this.scope.definitions; - const tracker = new TrackingSet(this.scope.definitions); - this.scope.definitions = tracker; - this.prewalkStatement(statement.declaration); - const newDefs = Array.from(tracker.getAddedItems()); - this.scope.definitions = originalDefinitions; - for (let index = 0, len = newDefs.length; index < len; index++) { - const def = newDefs[index]; - this.hooks.exportSpecifier.call(statement, def, "default"); - } + this.prewalkStatement(statement.declaration); + if ( + statement.declaration.id && + statement.declaration.type !== "FunctionExpression" && + statement.declaration.type !== "ClassExpression" + ) { + this.hooks.exportSpecifier.call( + statement, + statement.declaration.id.name, + "default" + ); } } @@ -1331,12 +1412,20 @@ class Parser extends Tapable { } prewalkVariableDeclaration(statement) { + if (statement.kind !== "var") return; + this._prewalkVariableDeclaration(statement, this.hooks.varDeclarationVar); + } + + blockPrewalkVariableDeclaration(statement) { + if (statement.kind === "var") return; const hookMap = statement.kind === "const" ? this.hooks.varDeclarationConst - : statement.kind === "let" - ? this.hooks.varDeclarationLet - : this.hooks.varDeclarationVar; + : this.hooks.varDeclarationLet; + this._prewalkVariableDeclaration(statement, hookMap); + } + + _prewalkVariableDeclaration(statement, hookMap) { for (const declarator of statement.declarations) { switch (declarator.type) { case "VariableDeclarator": { @@ -1385,7 +1474,7 @@ class Parser extends Tapable { } } - prewalkClassDeclaration(statement) { + blockPrewalkClassDeclaration(statement) { if (statement.id) { this.scope.renames.set(statement.id.name, null); this.scope.definitions.add(statement.id.name); @@ -1415,11 +1504,15 @@ class Parser extends Tapable { } walkCatchClause(catchClause) { - // Error binding is optional in catch clause since ECMAScript 2019 - const errorBinding = - catchClause.param === null ? EMPTY_ARRAY : [catchClause.param]; - - this.inScope(errorBinding, () => { + this.inBlockScope(() => { + // Error binding is optional in catch clause since ECMAScript 2019 + if (catchClause.param !== null) { + this.enterPattern(catchClause.param, ident => { + this.scope.renames.set(ident, null); + this.scope.definitions.add(ident); + }); + this.walkPattern(catchClause.param); + } this.prewalkStatement(catchClause.body); this.walkStatement(catchClause.body); }); @@ -1600,7 +1693,7 @@ class Parser extends Tapable { scopeParams.push(expression.id.name); } - this.inScope(scopeParams, () => { + this.inFunctionScope(true, scopeParams, () => { for (const param of expression.params) { this.walkPattern(param); } @@ -1616,7 +1709,7 @@ class Parser extends Tapable { } walkArrowFunctionExpression(expression) { - this.inScope(expression.params, () => { + this.inFunctionScope(false, expression.params, () => { for (const param of expression.params) { this.walkPattern(param); } @@ -1791,7 +1884,7 @@ class Parser extends Tapable { scopeParams.push(functionExpression.id.name); } - this.inScope(scopeParams, () => { + this.inFunctionScope(true, scopeParams, () => { if (renameThis) { this.scope.renames.set("this", renameThis); } @@ -1896,6 +1989,12 @@ class Parser extends Tapable { } } + /** + * @deprecated + * @param {any} params scope params + * @param {function(): void} fn inner function + * @returns {void} + */ inScope(params, fn) { const oldScope = this.scope; this.scope = { @@ -1909,19 +2008,54 @@ class Parser extends Tapable { this.scope.renames.set("this", null); - for (const param of params) { - if (typeof param !== "string") { - this.enterPattern(param, param => { - this.scope.renames.set(param, null); - this.scope.definitions.add(param); - }); - } else if (param) { - this.scope.renames.set(param, null); - this.scope.definitions.add(param); - } - } + this.enterPatterns(params, ident => { + this.scope.renames.set(ident, null); + this.scope.definitions.add(ident); + }); fn(); + + this.scope = oldScope; + } + + inFunctionScope(hasThis, params, fn) { + const oldScope = this.scope; + this.scope = { + topLevelScope: oldScope.topLevelScope, + inTry: false, + inShorthand: false, + isStrict: oldScope.isStrict, + definitions: oldScope.definitions.createChild(), + renames: oldScope.renames.createChild() + }; + + if (hasThis) { + this.scope.renames.set("this", null); + } + + this.enterPatterns(params, ident => { + this.scope.renames.set(ident, null); + this.scope.definitions.add(ident); + }); + + fn(); + + this.scope = oldScope; + } + + inBlockScope(fn) { + const oldScope = this.scope; + this.scope = { + topLevelScope: oldScope.topLevelScope, + inTry: oldScope.inTry, + inShorthand: false, + isStrict: oldScope.isStrict, + definitions: oldScope.definitions.createChild(), + renames: oldScope.renames.createChild() + }; + + fn(); + this.scope = oldScope; } @@ -1936,6 +2070,16 @@ class Parser extends Tapable { } } + enterPatterns(patterns, onIdent) { + for (const pattern of patterns) { + if (typeof pattern !== "string") { + this.enterPattern(pattern, onIdent); + } else if (pattern) { + onIdent(pattern); + } + } + } + enterPattern(pattern, onIdent) { if (!pattern) return; switch (pattern.type) { @@ -2137,6 +2281,7 @@ class Parser extends Tapable { if (this.hooks.program.call(ast, comments) === undefined) { this.detectStrictMode(ast.body); this.prewalkStatements(ast.body); + this.blockPrewalkStatements(ast.body); this.walkStatements(ast.body); } this.scope = oldScope; diff --git a/test/cases/parsing/block-scopes/index.js b/test/cases/parsing/block-scopes/index.js new file mode 100644 index 000000000..2019fb4cc --- /dev/null +++ b/test/cases/parsing/block-scopes/index.js @@ -0,0 +1,76 @@ +import ok from "./module"; + +// This should not leak an "ok" declaration into this scope +export default (function ok() {}); + +it("should allow block scopes", () => { + expect(ok).toBe("ok"); + if (true) { + const ok = "no"; + expect(ok).toBe("no"); + } + expect(ok).toBe("ok"); + { + let ok = "no"; + expect(ok).toBe("no"); + } + expect(ok).toBe("ok"); + { + class ok {} + expect(new ok()).toBeInstanceOf(ok); + } + expect(ok).toBe("ok"); + for (let ok = "no", once = true; once; once = !once) { + expect(ok).toBe("no"); + } + expect(ok).toBe("ok"); + for (const ok of ["no"]) { + expect(ok).toBe("no"); + } + expect(ok).toBe("ok"); + for (const ok in { no: 1 }) { + expect(ok).toBe("no"); + } + expect(ok).toBe("ok"); + try { + throw "no"; + } catch (ok) { + expect(ok).toBe("no"); + } + expect(ok).toBe("ok"); +}); + +it("should allow function scopes in block scopes", () => { + let f; + { + f = () => { + expect(ok).toBe("no"); + }; + const ok = "no"; + } + f(); +}); + +it("should not block scope vars (for)", () => { + expect(ok).toBe(undefined); + for (var ok = "no", once = true; once; once = !once) { + expect(ok).toBe("no"); + } + expect(ok).toBe("no"); +}); + +it("should not block scope vars (for-of)", () => { + expect(ok).toBe(undefined); + for (var ok of ["no"]) { + expect(ok).toBe("no"); + } + expect(ok).toBe("no"); +}); + +it("should not block scope vars (for-in)", () => { + expect(ok).toBe(undefined); + for (var ok in { no: 1 }) { + expect(ok).toBe("no"); + } + expect(ok).toBe("no"); +}); diff --git a/test/cases/parsing/block-scopes/module.js b/test/cases/parsing/block-scopes/module.js new file mode 100644 index 000000000..5c6b89abf --- /dev/null +++ b/test/cases/parsing/block-scopes/module.js @@ -0,0 +1 @@ +export default "ok"; From 34c86675728430c0f41fe415dbbacf87b5a2875d Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 13 Jun 2019 01:09:52 +0200 Subject: [PATCH 19/19] 4.34.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5c3b4a4d0..8d1bcf485 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webpack", - "version": "4.33.0", + "version": "4.34.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",