Merge pull request #11904 from webpack/bugfix/11897

improve handling of ASI in concatenated modules and with imports
This commit is contained in:
Tobias Koppers 2020-11-03 16:22:45 +01:00 committed by GitHub
commit a76c9be259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 151 additions and 83 deletions

View File

@ -59,9 +59,13 @@ module.exports = class HarmonyImportDependencyParserPlugin {
(statement, source) => {
parser.state.lastHarmonyImportOrder =
(parser.state.lastHarmonyImportOrder || 0) + 1;
const clearDep = new ConstDependency("", statement.range);
const clearDep = new ConstDependency(
parser.isAsiPosition(statement.range[0]) ? ";" : "",
statement.range
);
clearDep.loc = statement.loc;
parser.state.module.addPresentationalDependency(clearDep);
parser.unsetAsiPosition(statement.range[1]);
const sideEffectDep = new HarmonyImportSideEffectDependency(
source,
parser.state.lastHarmonyImportOrder

View File

@ -1405,7 +1405,11 @@ class JavascriptParser extends Parser {
}
preWalkStatement(statement) {
if (this.hooks.preStatement.call(statement)) return;
this.statementPath.push(statement);
if (this.hooks.preStatement.call(statement)) {
this.prevStatement = this.statementPath.pop();
return;
}
switch (statement.type) {
case "BlockStatement":
this.preWalkBlockStatement(statement);
@ -1447,10 +1451,15 @@ class JavascriptParser extends Parser {
this.preWalkWithStatement(statement);
break;
}
this.prevStatement = this.statementPath.pop();
}
blockPreWalkStatement(statement) {
if (this.hooks.blockPreStatement.call(statement)) return;
this.statementPath.push(statement);
if (this.hooks.blockPreStatement.call(statement)) {
this.prevStatement = this.statementPath.pop();
return;
}
switch (statement.type) {
case "ImportDeclaration":
this.blockPreWalkImportDeclaration(statement);
@ -1471,6 +1480,7 @@ class JavascriptParser extends Parser {
this.blockPreWalkClassDeclaration(statement);
break;
}
this.prevStatement = this.statementPath.pop();
}
walkStatement(statement) {
@ -1549,7 +1559,9 @@ class JavascriptParser extends Parser {
walkBlockStatement(statement) {
this.inBlockScope(() => {
const body = statement.body;
const prev = this.prevStatement;
this.blockPreWalkStatements(body);
this.prevStatement = prev;
this.walkStatements(body);
});
}
@ -1689,7 +1701,9 @@ class JavascriptParser extends Parser {
const body = statement.body;
if (body.type === "BlockStatement") {
// no need to add additional scope
const prev = this.prevStatement;
this.blockPreWalkStatements(body.body);
this.prevStatement = prev;
this.walkStatements(body.body);
} else {
this.walkStatement(body);
@ -1716,7 +1730,9 @@ class JavascriptParser extends Parser {
const body = statement.body;
if (body.type === "BlockStatement") {
// no need to add additional scope
const prev = this.prevStatement;
this.blockPreWalkStatements(body.body);
this.prevStatement = prev;
this.walkStatements(body.body);
} else {
this.walkStatement(body);
@ -1746,7 +1762,9 @@ class JavascriptParser extends Parser {
const body = statement.body;
if (body.type === "BlockStatement") {
// no need to add additional scope
const prev = this.prevStatement;
this.blockPreWalkStatements(body.body);
this.prevStatement = prev;
this.walkStatements(body.body);
} else {
this.walkStatement(body);
@ -1770,7 +1788,9 @@ class JavascriptParser extends Parser {
}
if (statement.body.type === "BlockStatement") {
this.detectMode(statement.body.body);
const prev = this.prevStatement;
this.preWalkStatement(statement.body);
this.prevStatement = prev;
this.walkStatement(statement.body);
} else {
this.walkExpression(statement.body);
@ -1848,7 +1868,9 @@ class JavascriptParser extends Parser {
if (
!this.hooks.exportDeclaration.call(statement, statement.declaration)
) {
const prev = this.prevStatement;
this.preWalkStatement(statement.declaration);
this.prevStatement = prev;
this.blockPreWalkStatement(statement.declaration);
let index = 0;
this.enterDeclaration(statement.declaration, def => {
@ -1896,7 +1918,9 @@ class JavascriptParser extends Parser {
}
blockPreWalkExportDefaultDeclaration(statement) {
const prev = this.prevStatement;
this.preWalkStatement(statement.declaration);
this.prevStatement = prev;
this.blockPreWalkStatement(statement.declaration);
if (
statement.declaration.id &&
@ -2049,7 +2073,9 @@ class JavascriptParser extends Parser {
const switchCase = switchCases[index];
if (switchCase.consequent.length > 0) {
const prev = this.prevStatement;
this.blockPreWalkStatements(switchCase.consequent);
this.prevStatement = prev;
}
}
@ -2079,7 +2105,9 @@ class JavascriptParser extends Parser {
});
this.walkPattern(catchClause.param);
}
const prev = this.prevStatement;
this.blockPreWalkStatement(catchClause.body);
this.prevStatement = prev;
this.walkStatement(catchClause.body);
});
}
@ -2276,7 +2304,9 @@ class JavascriptParser extends Parser {
}
if (expression.body.type === "BlockStatement") {
this.detectMode(expression.body.body);
const prev = this.prevStatement;
this.preWalkStatement(expression.body);
this.prevStatement = prev;
this.walkStatement(expression.body);
} else {
this.walkExpression(expression.body);
@ -2294,7 +2324,9 @@ class JavascriptParser extends Parser {
}
if (expression.body.type === "BlockStatement") {
this.detectMode(expression.body.body);
const prev = this.prevStatement;
this.preWalkStatement(expression.body);
this.prevStatement = prev;
this.walkStatement(expression.body);
} else {
this.walkExpression(expression.body);
@ -2561,7 +2593,9 @@ class JavascriptParser extends Parser {
}
if (functionExpression.body.type === "BlockStatement") {
this.detectMode(functionExpression.body.body);
const prev = this.prevStatement;
this.preWalkStatement(functionExpression.body);
this.prevStatement = prev;
this.walkStatement(functionExpression.body);
} else {
this.walkExpression(functionExpression.body);
@ -3224,7 +3258,9 @@ class JavascriptParser extends Parser {
if (this.hooks.program.call(ast, comments) === undefined) {
this.detectMode(ast.body);
this.preWalkStatements(ast.body);
this.prevStatement = undefined;
this.blockPreWalkStatements(ast.body);
this.prevStatement = undefined;
this.walkStatements(ast.body);
}
this.hooks.finish.call(ast, comments);
@ -3337,14 +3373,24 @@ class JavascriptParser extends Parser {
* @returns {boolean} true when a semicolon has been inserted before this position, false if not
*/
isAsiPosition(pos) {
if (this.prevStatement === undefined) return false;
const currentStatement = this.statementPath[this.statementPath.length - 1];
if (currentStatement === undefined) return true;
return (
currentStatement.range[0] === pos &&
this.semicolons.has(this.prevStatement.range[1])
(currentStatement.range[1] === pos && this.semicolons.has(pos)) ||
(currentStatement.range[0] === pos &&
(this.prevStatement === undefined ||
this.semicolons.has(this.prevStatement.range[1])))
);
}
/**
* @param {number} pos source code position
* @returns {void}
*/
unsetAsiPosition(pos) {
this.semicolons.delete(pos);
}
isStatementLevelExpression(expr) {
const currentStatement = this.statementPath[this.statementPath.length - 1];
return (

View File

@ -253,7 +253,7 @@ default:
vendors:
Entrypoint main 10.9 KiB = vendors/main.js
Entrypoint a 14.3 KiB = vendors/vendors.js 1.07 KiB vendors/a.js 13.3 KiB
Entrypoint a 14.4 KiB = vendors/vendors.js 1.07 KiB vendors/a.js 13.3 KiB
Entrypoint b 8.04 KiB = vendors/vendors.js 1.07 KiB vendors/b.js 6.97 KiB
Entrypoint c 8.04 KiB = vendors/vendors.js 1.07 KiB vendors/c.js 6.97 KiB
chunk (runtime: b) vendors/b.js (b) 156 bytes (javascript) 2.88 KiB (runtime) [entry] [rendered]
@ -656,9 +656,9 @@ webpack x.x.x compiled successfully in X ms"
`;
exports[`StatsTestCases should print correct stats for commons-plugin-issue-4980 1`] = `
"asset app.7ba0d8a51deca2bd4789-1.js 6.08 KiB [emitted] [immutable] (name: app)
"asset app.f59cd23726a8f8e77b9d-1.js 6.08 KiB [emitted] [immutable] (name: app)
asset vendor.c715f5ed2754861797e1-1.js 611 bytes [emitted] [immutable] (name: vendor) (id hint: vendor)
Entrypoint app 6.68 KiB = vendor.c715f5ed2754861797e1-1.js 611 bytes app.7ba0d8a51deca2bd4789-1.js 6.08 KiB
Entrypoint app 6.68 KiB = vendor.c715f5ed2754861797e1-1.js 611 bytes app.f59cd23726a8f8e77b9d-1.js 6.08 KiB
runtime modules 2.88 KiB 3 modules
orphan modules 118 bytes [orphan] 2 modules
cacheable modules 272 bytes
@ -666,9 +666,9 @@ cacheable modules 272 bytes
./constants.js 87 bytes [built] [code generated]
webpack x.x.x compiled successfully in X ms
asset app.c7d38e079a69fb21e8fe-2.js 6.1 KiB [emitted] [immutable] (name: app)
asset app.1aa2b903f5720731623c-2.js 6.1 KiB [emitted] [immutable] (name: app)
asset vendor.c715f5ed2754861797e1-2.js 611 bytes [emitted] [immutable] (name: vendor) (id hint: vendor)
Entrypoint app 6.7 KiB = vendor.c715f5ed2754861797e1-2.js 611 bytes app.c7d38e079a69fb21e8fe-2.js 6.1 KiB
Entrypoint app 6.7 KiB = vendor.c715f5ed2754861797e1-2.js 611 bytes app.1aa2b903f5720731623c-2.js 6.1 KiB
runtime modules 2.88 KiB 3 modules
orphan modules 125 bytes [orphan] 2 modules
cacheable modules 279 bytes
@ -697,10 +697,10 @@ exports[`StatsTestCases should print correct stats for concat-and-sideeffects 1`
`;
exports[`StatsTestCases should print correct stats for context-independence 1`] = `
"asset main-3e770b0a90723d1d9842.js 10.3 KiB [emitted] [immutable] (name: main)
sourceMap main-3e770b0a90723d1d9842.js.map 9.16 KiB [emitted] [dev] (auxiliary name: main)
asset 664-cb106d2f6263642c0727.js 453 bytes [emitted] [immutable]
sourceMap 664-cb106d2f6263642c0727.js.map 344 bytes [emitted] [dev]
"asset main-4212fe5283928e0d7aa0.js 10.3 KiB [emitted] [immutable] (name: main)
sourceMap main-4212fe5283928e0d7aa0.js.map 9.16 KiB [emitted] [dev] (auxiliary name: main)
asset 664-7d3d9dccfd2afec10cdf.js 454 bytes [emitted] [immutable]
sourceMap 664-7d3d9dccfd2afec10cdf.js.map 344 bytes [emitted] [dev]
runtime modules 6.17 KiB 8 modules
orphan modules 19 bytes [orphan] 1 module
cacheable modules 106 bytes
@ -708,10 +708,10 @@ cacheable modules 106 bytes
./a/chunk.js + 1 modules 66 bytes [built] [code generated]
webpack x.x.x compiled successfully in X ms
asset main-3e770b0a90723d1d9842.js 10.3 KiB [emitted] [immutable] (name: main)
sourceMap main-3e770b0a90723d1d9842.js.map 9.16 KiB [emitted] [dev] (auxiliary name: main)
asset 664-cb106d2f6263642c0727.js 453 bytes [emitted] [immutable]
sourceMap 664-cb106d2f6263642c0727.js.map 344 bytes [emitted] [dev]
asset main-4212fe5283928e0d7aa0.js 10.3 KiB [emitted] [immutable] (name: main)
sourceMap main-4212fe5283928e0d7aa0.js.map 9.16 KiB [emitted] [dev] (auxiliary name: main)
asset 664-7d3d9dccfd2afec10cdf.js 454 bytes [emitted] [immutable]
sourceMap 664-7d3d9dccfd2afec10cdf.js.map 344 bytes [emitted] [dev]
runtime modules 6.17 KiB 8 modules
orphan modules 19 bytes [orphan] 1 module
cacheable modules 106 bytes
@ -719,8 +719,8 @@ cacheable modules 106 bytes
./b/chunk.js + 1 modules 66 bytes [built] [code generated]
webpack x.x.x compiled successfully in X ms
asset main-ebaa8fc07a5809ec63a9.js 11.1 KiB [emitted] [immutable] (name: main)
asset 664-12bf7254f5c08e0ac9e9.js 1.51 KiB [emitted] [immutable]
asset main-b4504dd851aaa1ed71f3.js 11.1 KiB [emitted] [immutable] (name: main)
asset 664-16cd38bcf02f2869ae1b.js 1.51 KiB [emitted] [immutable]
runtime modules 6.17 KiB 8 modules
orphan modules 19 bytes [orphan] 1 module
cacheable modules 106 bytes
@ -728,8 +728,8 @@ cacheable modules 106 bytes
./a/chunk.js + 1 modules 66 bytes [built] [code generated]
webpack x.x.x compiled successfully in X ms
asset main-ebaa8fc07a5809ec63a9.js 11.1 KiB [emitted] [immutable] (name: main)
asset 664-12bf7254f5c08e0ac9e9.js 1.51 KiB [emitted] [immutable]
asset main-b4504dd851aaa1ed71f3.js 11.1 KiB [emitted] [immutable] (name: main)
asset 664-16cd38bcf02f2869ae1b.js 1.51 KiB [emitted] [immutable]
runtime modules 6.17 KiB 8 modules
orphan modules 19 bytes [orphan] 1 module
cacheable modules 106 bytes
@ -908,7 +908,7 @@ chunk (runtime: main) trees.js (trees) 215 bytes [rendered]
`;
exports[`StatsTestCases should print correct stats for ignore-warnings 1`] = `
"asset main.js 957 bytes [emitted] (name: main)
"asset main.js 966 bytes [emitted] (name: main)
orphan modules 617 bytes [orphan] 9 modules
./index.js + 9 modules 790 bytes [built] [code generated]
@ -990,23 +990,23 @@ runtime modules 2.58 KiB 2 modules
webpack x.x.x compiled successfully in X ms
asset b-runtime~main-599255de31b112c7d98b.js 6.04 KiB [emitted] [immutable] (name: runtime~main)
asset b-all-b_js-5f2f43e942828cce49a7.js 475 bytes [emitted] [immutable] (id hint: all)
asset b-all-b_js-182a3988391d2f83b14b.js 476 bytes [emitted] [immutable] (id hint: all)
asset b-vendors-node_modules_vendor_js-bf78b376ab124e2d5ed3.js 185 bytes [emitted] [immutable] (id hint: vendors)
asset b-main-0780253982d2b99627d2.js 147 bytes [emitted] [immutable] (name: main)
Entrypoint main 6.83 KiB = b-runtime~main-599255de31b112c7d98b.js 6.04 KiB b-vendors-node_modules_vendor_js-bf78b376ab124e2d5ed3.js 185 bytes b-all-b_js-5f2f43e942828cce49a7.js 475 bytes b-main-0780253982d2b99627d2.js 147 bytes
Entrypoint main 6.83 KiB = b-runtime~main-599255de31b112c7d98b.js 6.04 KiB b-vendors-node_modules_vendor_js-bf78b376ab124e2d5ed3.js 185 bytes b-all-b_js-182a3988391d2f83b14b.js 476 bytes b-main-0780253982d2b99627d2.js 147 bytes
runtime modules 3.14 KiB 4 modules
cacheable modules 40 bytes
./b.js 17 bytes [built] [code generated]
./node_modules/vendor.js 23 bytes [built] [code generated]
webpack x.x.x compiled successfully in X ms
assets by chunk 895 bytes (id hint: all)
asset c-all-b_js-128dddb8321697614d16.js 502 bytes [emitted] [immutable] (id hint: all)
assets by chunk 896 bytes (id hint: all)
asset c-all-b_js-35236c27e21260c248cc.js 503 bytes [emitted] [immutable] (id hint: all)
asset c-all-c_js-5fc6d532ca1ac022819e.js 393 bytes [emitted] [immutable] (id hint: all)
asset c-runtime~main-36cd4e671a91edfac6ab.js 13.7 KiB [emitted] [immutable] (name: runtime~main)
asset c-runtime~main-21f8e7b00ee4c05d167c.js 13.7 KiB [emitted] [immutable] (name: runtime~main)
asset c-main-3737497cd09f5bd99fe3.js 603 bytes [emitted] [immutable] (name: main)
asset c-vendors-node_modules_vendor_js-bf78b376ab124e2d5ed3.js 185 bytes [emitted] [immutable] (id hint: vendors)
Entrypoint main 14.7 KiB = c-runtime~main-36cd4e671a91edfac6ab.js 13.7 KiB c-all-c_js-5fc6d532ca1ac022819e.js 393 bytes c-main-3737497cd09f5bd99fe3.js 603 bytes
Entrypoint main 14.7 KiB = c-runtime~main-21f8e7b00ee4c05d167c.js 13.7 KiB c-all-c_js-5fc6d532ca1ac022819e.js 393 bytes c-main-3737497cd09f5bd99fe3.js 603 bytes
runtime modules 8.81 KiB 12 modules
cacheable modules 101 bytes
./c.js 61 bytes [built] [code generated]
@ -1158,14 +1158,14 @@ webpack x.x.x compiled successfully in X ms"
exports[`StatsTestCases should print correct stats for module-assets 1`] = `
"assets by path *.js 11.6 KiB
asset main.js 10.3 KiB [emitted] (name: main)
asset a.js 744 bytes [emitted] (name: a)
asset b.js 563 bytes [emitted] (name: b)
asset a.js 745 bytes [emitted] (name: a)
asset b.js 564 bytes [emitted] (name: b)
assets by path *.png 42 KiB
asset 1.png 21 KiB [emitted] [from: node_modules/a/1.png] (auxiliary name: a)
asset 2.png 21 KiB [emitted] [from: node_modules/a/2.png] (auxiliary name: a, b)
Entrypoint main 10.3 KiB = main.js
Chunk Group a 744 bytes (42 KiB) = a.js 744 bytes (1.png 21 KiB 2.png 21 KiB)
Chunk Group b 563 bytes (21 KiB) = b.js 563 bytes (2.png 21 KiB)
Chunk Group a 745 bytes (42 KiB) = a.js 745 bytes (1.png 21 KiB 2.png 21 KiB)
Chunk Group b 564 bytes (21 KiB) = b.js 564 bytes (2.png 21 KiB)
chunk (runtime: main) b.js (b) 67 bytes [rendered]
./node_modules/a/2.png 49 bytes [dependent] [built] [code generated] [1 asset]
./node_modules/b/index.js 18 bytes [built] [code generated]
@ -1190,12 +1190,12 @@ exports[`StatsTestCases should print correct stats for module-deduplication 1`]
"asset e1.js 11.9 KiB [emitted] (name: e1)
asset e2.js 11.9 KiB [emitted] (name: e2)
asset e3.js 11.9 KiB [emitted] (name: e3)
asset 172.js 864 bytes [emitted]
asset 326.js 864 bytes [emitted]
asset 923.js 864 bytes [emitted]
asset 114.js 518 bytes [emitted]
asset 593.js 518 bytes [emitted]
asset 716.js 518 bytes [emitted]
asset 172.js 865 bytes [emitted]
asset 326.js 865 bytes [emitted]
asset 923.js 865 bytes [emitted]
asset 114.js 519 bytes [emitted]
asset 593.js 519 bytes [emitted]
asset 716.js 519 bytes [emitted]
chunk (runtime: e1) 114.js 61 bytes [rendered]
./async1.js 61 bytes [built] [code generated]
chunk (runtime: e3) e3.js (e3) 249 bytes (javascript) 6.44 KiB (runtime) [entry] [rendered]
@ -1233,12 +1233,12 @@ webpack x.x.x compiled successfully"
`;
exports[`StatsTestCases should print correct stats for module-deduplication-named 1`] = `
"asset e1.js 11.7 KiB [emitted] (name: e1)
asset e2.js 11.7 KiB [emitted] (name: e2)
asset e3.js 11.7 KiB [emitted] (name: e3)
asset async1.js 970 bytes [emitted] (name: async1)
asset async2.js 970 bytes [emitted] (name: async2)
asset async3.js 970 bytes [emitted] (name: async3)
"asset e1.js 11.8 KiB [emitted] (name: e1)
asset e2.js 11.8 KiB [emitted] (name: e2)
asset e3.js 11.8 KiB [emitted] (name: e3)
asset async1.js 971 bytes [emitted] (name: async1)
asset async2.js 971 bytes [emitted] (name: async2)
asset async3.js 971 bytes [emitted] (name: async3)
chunk (runtime: e3) e3.js (e3) 242 bytes (javascript) 6.49 KiB (runtime) [entry] [rendered]
runtime modules 6.49 KiB 9 modules
cacheable modules 242 bytes
@ -1359,9 +1359,9 @@ webpack x.x.x compiled with 2 errors in X ms"
exports[`StatsTestCases should print correct stats for named-chunk-groups 1`] = `
"Chunk Group main 11.5 KiB = a-main.js
Chunk Group async-a 1.07 KiB = a-52.js 257 bytes a-async-a.js 834 bytes
Chunk Group async-b 1.07 KiB = a-52.js 257 bytes a-async-b.js 834 bytes
Chunk Group async-c 1.45 KiB = a-vendors.js 754 bytes a-async-c.js 733 bytes
Chunk Group async-a 1.07 KiB = a-52.js 257 bytes a-async-a.js 835 bytes
Chunk Group async-b 1.07 KiB = a-52.js 257 bytes a-async-b.js 835 bytes
Chunk Group async-c 1.45 KiB = a-vendors.js 754 bytes a-async-c.js 734 bytes
chunk (runtime: main) a-52.js 149 bytes [rendered] split chunk (cache group: default)
> ./a ./index.js 1:0-47
> ./b ./index.js 2:0-47
@ -1386,9 +1386,9 @@ chunk (runtime: main) a-async-a.js (async-a) 175 bytes [rendered]
webpack x.x.x compiled successfully
Entrypoint main 11.5 KiB = b-main.js
Chunk Group async-a 1.07 KiB = b-52.js 257 bytes b-async-a.js 834 bytes
Chunk Group async-b 1.07 KiB = b-52.js 257 bytes b-async-b.js 834 bytes
Chunk Group async-c 1.45 KiB = b-vendors.js 754 bytes b-async-c.js 733 bytes
Chunk Group async-a 1.07 KiB = b-52.js 257 bytes b-async-a.js 835 bytes
Chunk Group async-b 1.07 KiB = b-52.js 257 bytes b-async-b.js 835 bytes
Chunk Group async-c 1.45 KiB = b-vendors.js 754 bytes b-async-c.js 734 bytes
chunk (runtime: main) b-52.js 149 bytes [rendered] split chunk (cache group: default)
> ./a ./index.js 1:0-47
> ./b ./index.js 2:0-47
@ -2228,12 +2228,12 @@ LOG from webpack.FileSystemInfo
exports[`StatsTestCases should print correct stats for real-content-hash 1`] = `
"a-normal:
assets by path *.js 2.99 KiB
asset e840f17fae83d26b8752-e840f1.js 2.6 KiB [emitted] [immutable] [minimized] (name: runtime~main)
asset 8165cc332165027cbd35-8165cc.js 2.6 KiB [emitted] [immutable] [minimized] (name: runtime~main)
asset 3cc8faad16137711c07e-3cc8fa.js 210 bytes [emitted] [immutable] [minimized] (name: main)
asset b6f77787a670e97d47b5-b6f777.js 193 bytes [emitted] [immutable] [minimized] (name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: main)
Entrypoint main 2.8 KiB (5.89 KiB) = e840f17fae83d26b8752-e840f1.js 2.6 KiB 3cc8faad16137711c07e-3cc8fa.js 210 bytes 1 auxiliary asset
Entrypoint main 2.8 KiB (5.89 KiB) = 8165cc332165027cbd35-8165cc.js 2.6 KiB 3cc8faad16137711c07e-3cc8fa.js 210 bytes 1 auxiliary asset
runtime modules 7.36 KiB 8 modules
orphan modules 23 bytes [orphan] 1 module
cacheable modules 340 bytes (javascript) 20.4 KiB (asset)
@ -2247,12 +2247,12 @@ exports[`StatsTestCases should print correct stats for real-content-hash 1`] = `
b-normal:
assets by path *.js 2.99 KiB
asset de036140a684abb46a68-de0361.js 2.6 KiB [emitted] [immutable] [minimized] (name: runtime~main)
asset 92a0a394f8459d57eed5-92a0a3.js 2.6 KiB [emitted] [immutable] [minimized] (name: runtime~main)
asset 3cc8faad16137711c07e-3cc8fa.js 210 bytes [emitted] [immutable] [minimized] (name: main)
asset b6f77787a670e97d47b5-b6f777.js 193 bytes [emitted] [immutable] [minimized] (name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: main)
Entrypoint main 2.8 KiB (5.89 KiB) = de036140a684abb46a68-de0361.js 2.6 KiB 3cc8faad16137711c07e-3cc8fa.js 210 bytes 1 auxiliary asset
Entrypoint main 2.8 KiB (5.89 KiB) = 92a0a394f8459d57eed5-92a0a3.js 2.6 KiB 3cc8faad16137711c07e-3cc8fa.js 210 bytes 1 auxiliary asset
runtime modules 7.36 KiB 8 modules
orphan modules 19 bytes [orphan] 1 module
cacheable modules 295 bytes (javascript) 20.4 KiB (asset)
@ -2266,15 +2266,15 @@ b-normal:
a-source-map:
assets by path *.js 3.16 KiB
asset 34a1f137ab6013192ef7-34a1f1.js 2.65 KiB [emitted] [immutable] [minimized] (name: runtime~main)
sourceMap 34a1f137ab6013192ef7-34a1f1.js.map 14.3 KiB [emitted] [dev] (auxiliary name: runtime~main)
asset 1faadf70e8b4376ef06a-1faadf.js 2.65 KiB [emitted] [immutable] [minimized] (name: runtime~main)
sourceMap 1faadf70e8b4376ef06a-1faadf.js.map 14.3 KiB [emitted] [dev] (auxiliary name: runtime~main)
asset b8bfcec62cdd15c9a840-b8bfce.js 266 bytes [emitted] [immutable] [minimized] (name: main)
sourceMap b8bfcec62cdd15c9a840-b8bfce.js.map 366 bytes [emitted] [dev] (auxiliary name: main)
asset c7c0f8bb2e61b59a89f5-c7c0f8.js 249 bytes [emitted] [immutable] [minimized] (name: lazy)
sourceMap c7c0f8bb2e61b59a89f5-c7c0f8.js.map 331 bytes [emitted] [dev] (auxiliary name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: main)
Entrypoint main 2.91 KiB (20.5 KiB) = 34a1f137ab6013192ef7-34a1f1.js 2.65 KiB b8bfcec62cdd15c9a840-b8bfce.js 266 bytes 3 auxiliary assets
Entrypoint main 2.91 KiB (20.5 KiB) = 1faadf70e8b4376ef06a-1faadf.js 2.65 KiB b8bfcec62cdd15c9a840-b8bfce.js 266 bytes 3 auxiliary assets
runtime modules 7.36 KiB 8 modules
orphan modules 23 bytes [orphan] 1 module
cacheable modules 340 bytes (javascript) 20.4 KiB (asset)
@ -2288,15 +2288,15 @@ a-source-map:
b-source-map:
assets by path *.js 3.16 KiB
asset 6d482476dfc44d9f4352-6d4824.js 2.65 KiB [emitted] [immutable] [minimized] (name: runtime~main)
sourceMap 6d482476dfc44d9f4352-6d4824.js.map 14.3 KiB [emitted] [dev] (auxiliary name: runtime~main)
asset 37e038cbc55c61c4454c-37e038.js 2.65 KiB [emitted] [immutable] [minimized] (name: runtime~main)
sourceMap 37e038cbc55c61c4454c-37e038.js.map 14.3 KiB [emitted] [dev] (auxiliary name: runtime~main)
asset b8bfcec62cdd15c9a840-b8bfce.js 266 bytes [emitted] [immutable] [minimized] (name: main)
sourceMap b8bfcec62cdd15c9a840-b8bfce.js.map 323 bytes [emitted] [dev] (auxiliary name: main)
asset c7c0f8bb2e61b59a89f5-c7c0f8.js 249 bytes [emitted] [immutable] [minimized] (name: lazy)
sourceMap c7c0f8bb2e61b59a89f5-c7c0f8.js.map 327 bytes [emitted] [dev] (auxiliary name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: main)
Entrypoint main 2.91 KiB (20.5 KiB) = 6d482476dfc44d9f4352-6d4824.js 2.65 KiB b8bfcec62cdd15c9a840-b8bfce.js 266 bytes 3 auxiliary assets
Entrypoint main 2.91 KiB (20.5 KiB) = 37e038cbc55c61c4454c-37e038.js 2.65 KiB b8bfcec62cdd15c9a840-b8bfce.js 266 bytes 3 auxiliary assets
runtime modules 7.36 KiB 8 modules
orphan modules 19 bytes [orphan] 1 module
cacheable modules 295 bytes (javascript) 20.4 KiB (asset)
@ -2329,9 +2329,9 @@ relatedAssets:
asset relatedAssets-chunk_js.js 1.15 KiB [emitted]
compressed relatedAssets-chunk_js.js.br 1.15 KiB [emitted]
compressed relatedAssets-chunk_js.js.gz 1.15 KiB [emitted]
sourceMap relatedAssets-chunk_js.js.map 307 bytes [emitted] [dev]
compressed relatedAssets-chunk_js.js.map.br 307 bytes [emitted]
compressed relatedAssets-chunk_js.js.map.gz 307 bytes [emitted]
sourceMap relatedAssets-chunk_js.js.map 312 bytes [emitted] [dev]
compressed relatedAssets-chunk_js.js.map.br 312 bytes [emitted]
compressed relatedAssets-chunk_js.js.map.gz 312 bytes [emitted]
assets by path *.css 154 bytes
asset relatedAssets-chunk_js.css 79 bytes [emitted]
sourceMap relatedAssets-chunk_js.css.map 197 bytes [emitted] [dev]
@ -2351,13 +2351,13 @@ exclude1:
asset exclude1-main.js 14.5 KiB [emitted] (name: main)
hidden assets 29 KiB 2 assets
sourceMap exclude1-main.js.map 12.3 KiB [emitted] [dev] (auxiliary name: main)
hidden assets 24.5 KiB 2 assets
hidden assets 24.6 KiB 2 assets
1 related asset
1 related asset
asset exclude1-chunk_js.js 1.14 KiB [emitted]
hidden assets 2.29 KiB 2 assets
sourceMap exclude1-chunk_js.js.map 302 bytes [emitted] [dev]
hidden assets 604 bytes 2 assets
sourceMap exclude1-chunk_js.js.map 307 bytes [emitted] [dev]
hidden assets 614 bytes 2 assets
1 related asset
1 related asset
assets by path *.css 144 bytes
@ -2381,7 +2381,7 @@ exclude2:
compressed exclude2-main.js.br 14.5 KiB [emitted]
compressed exclude2-main.js.gz 14.5 KiB [emitted]
asset exclude2-chunk_js.js 1.14 KiB [emitted]
hidden assets 302 bytes 1 asset
hidden assets 307 bytes 1 asset
compressed exclude2-chunk_js.js.br 1.14 KiB [emitted]
compressed exclude2-chunk_js.js.gz 1.14 KiB [emitted]
assets by path *.css 144 bytes
@ -2833,7 +2833,7 @@ webpack x.x.x compiled successfully in X ms"
exports[`StatsTestCases should print correct stats for side-effects-issue-7428 1`] = `
"asset main.js 12 KiB [emitted] (name: main)
asset 1.js 638 bytes [emitted]
asset 1.js 639 bytes [emitted]
runtime modules 6.44 KiB 9 modules
cacheable modules 823 bytes
modules by path ./components/src/ 501 bytes
@ -2939,7 +2939,7 @@ webpack x.x.x compiled successfully in X ms"
`;
exports[`StatsTestCases should print correct stats for side-effects-simple-unused 1`] = `
"asset main.js 322 bytes [emitted] (name: main)
"asset main.js 323 bytes [emitted] (name: main)
./index.js + 2 modules 158 bytes [built] [code generated]
[no exports used]
entry ./index main
@ -3137,8 +3137,8 @@ all-chunks:
manual:
Entrypoint main 11.1 KiB = manual/main.js
Entrypoint a 14.4 KiB = manual/vendors.js 1.07 KiB manual/a.js 13.4 KiB
Entrypoint b 8.12 KiB = manual/vendors.js 1.07 KiB manual/b.js 7.05 KiB
Entrypoint c 8.12 KiB = manual/vendors.js 1.07 KiB manual/c.js 7.05 KiB
Entrypoint b 8.13 KiB = manual/vendors.js 1.07 KiB manual/b.js 7.05 KiB
Entrypoint c 8.13 KiB = manual/vendors.js 1.07 KiB manual/c.js 7.05 KiB
chunk (runtime: b) manual/b.js (b) 156 bytes (javascript) 2.92 KiB (runtime) ={216}= [entry] [rendered]
> ./b b
> x b
@ -3564,9 +3564,9 @@ default (webpack x.x.x) compiled successfully"
`;
exports[`StatsTestCases should print correct stats for split-chunks-issue-7401 1`] = `
"Entrypoint a 6.27 KiB = 282.js 412 bytes a.js 5.86 KiB
"Entrypoint a 6.27 KiB = 282.js 412 bytes a.js 5.87 KiB
Entrypoint b 10.7 KiB = b.js
Chunk Group c 792 bytes = 282.js 412 bytes c.js 380 bytes
Chunk Group c 793 bytes = 282.js 412 bytes c.js 381 bytes
chunk (runtime: b) b.js (b) 43 bytes (javascript) 6.47 KiB (runtime) >{282}< >{459}< [entry] [rendered]
> ./b b
runtime modules 6.47 KiB 9 modules
@ -4030,13 +4030,13 @@ webpack x.x.x compiled successfully"
exports[`StatsTestCases should print correct stats for split-chunks-runtime-specific 1`] = `
"used-exports:
asset used-exports-c.js 5.88 KiB [emitted] (name: c)
asset used-exports-c.js 5.89 KiB [emitted] (name: c)
asset used-exports-b.js 5.88 KiB [emitted] (name: b)
asset used-exports-332.js 422 bytes [emitted]
asset used-exports-a.js 225 bytes [emitted] (name: a)
Entrypoint a 225 bytes = used-exports-a.js
asset used-exports-a.js 226 bytes [emitted] (name: a)
Entrypoint a 226 bytes = used-exports-a.js
Entrypoint b 6.29 KiB = used-exports-332.js 422 bytes used-exports-b.js 5.88 KiB
Entrypoint c 6.3 KiB = used-exports-332.js 422 bytes used-exports-c.js 5.88 KiB
Entrypoint c 6.3 KiB = used-exports-332.js 422 bytes used-exports-c.js 5.89 KiB
chunk (runtime: b) used-exports-b.js (b) 54 bytes (javascript) 2.88 KiB (runtime) [entry] [rendered]
runtime modules 2.88 KiB 3 modules
./b.js 54 bytes [built] [code generated]
@ -4050,13 +4050,13 @@ exports[`StatsTestCases should print correct stats for split-chunks-runtime-spec
used-exports (webpack x.x.x) compiled successfully in X ms
no-used-exports:
asset no-used-exports-c.js 5.88 KiB [emitted] (name: c)
asset no-used-exports-c.js 5.89 KiB [emitted] (name: c)
asset no-used-exports-a.js 5.88 KiB [emitted] (name: a)
asset no-used-exports-b.js 5.88 KiB [emitted] (name: b)
asset no-used-exports-332.js 443 bytes [emitted]
Entrypoint a 6.31 KiB = no-used-exports-332.js 443 bytes no-used-exports-a.js 5.88 KiB
Entrypoint b 6.31 KiB = no-used-exports-332.js 443 bytes no-used-exports-b.js 5.88 KiB
Entrypoint c 6.32 KiB = no-used-exports-332.js 443 bytes no-used-exports-c.js 5.88 KiB
Entrypoint c 6.32 KiB = no-used-exports-332.js 443 bytes no-used-exports-c.js 5.89 KiB
chunk (runtime: b) no-used-exports-b.js (b) 54 bytes (javascript) 2.88 KiB (runtime) [entry] [rendered]
runtime modules 2.88 KiB 3 modules
./b.js 54 bytes [built] [code generated]
@ -4071,13 +4071,13 @@ no-used-exports:
no-used-exports (webpack x.x.x) compiled successfully in X ms
global:
asset global-c.js 5.88 KiB [emitted] (name: c)
asset global-c.js 5.89 KiB [emitted] (name: c)
asset global-a.js 5.88 KiB [emitted] (name: a)
asset global-b.js 5.88 KiB [emitted] (name: b)
asset global-332.js 443 bytes [emitted]
Entrypoint a 6.31 KiB = global-332.js 443 bytes global-a.js 5.88 KiB
Entrypoint b 6.31 KiB = global-332.js 443 bytes global-b.js 5.88 KiB
Entrypoint c 6.32 KiB = global-332.js 443 bytes global-c.js 5.88 KiB
Entrypoint c 6.32 KiB = global-332.js 443 bytes global-c.js 5.89 KiB
chunk (runtime: b) global-b.js (b) 54 bytes (javascript) 2.88 KiB (runtime) [entry] [rendered]
runtime modules 2.88 KiB 3 modules
./b.js 54 bytes [built] [code generated]

View File

@ -0,0 +1 @@
module.exports = { flag: true };

View File

@ -0,0 +1,12 @@
import obj from "./cjs";
// prettier-ignore
obj.flag = true
import { value } from "./module";
import { value as value2 } from "./module?2";
obj.flag = true;
it("should not break on ASI-code", () => {
expect(obj.flag).toBe(true);
expect(value).toBe(true);
expect(value2).toBe(true);
});

View File

@ -0,0 +1,4 @@
obj.flag++;
import obj from "./cjs";
// prettier-ignore
export const value = true

1
types.d.ts vendored
View File

@ -4320,6 +4320,7 @@ declare class JavascriptParser extends Parser {
): boolean;
getComments(range?: any): any;
isAsiPosition(pos: number): boolean;
unsetAsiPosition(pos: number): void;
isStatementLevelExpression(expr?: any): boolean;
getTagData(name?: any, tag?: any): any;
tagVariable(name?: any, tag?: any, data?: any): void;