webpack 4.33.0 → 4.35.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/WebpackOptions.d.ts +12 -0
- package/hot/dev-server.js +2 -2
- package/hot/log.js +12 -0
- package/hot/only-dev-server.js +2 -5
- package/hot/poll.js +2 -5
- package/hot/signal.js +1 -1
- package/lib/ChunkGroup.js +2 -6
- package/lib/Compilation.js +2 -6
- package/lib/MainTemplate.js +1 -3
- package/lib/ModuleParseError.js +13 -3
- package/lib/MultiWatching.js +12 -0
- package/lib/NormalModule.js +4 -2
- package/lib/NormalModuleFactory.js +6 -4
- package/lib/OptionsDefaulter.js +62 -4
- package/lib/Parser.js +221 -76
- package/lib/ProgressPlugin.js +24 -6
- package/lib/Watching.js +17 -1
- package/lib/WebpackOptionsDefaulter.js +1 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +3 -7
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +3 -7
- package/lib/dependencies/ImportParserPlugin.js +8 -24
- package/lib/dependencies/LoaderPlugin.js +1 -3
- package/lib/dependencies/WebAssemblyImportDependency.js +1 -3
- package/lib/optimize/ChunkModuleIdRangePlugin.js +1 -3
- package/lib/optimize/ConcatenatedModule.js +6 -18
- package/lib/optimize/SplitChunksPlugin.js +27 -7
- package/lib/wasm/WasmFinalizeExportsPlugin.js +1 -3
- package/lib/wasm/WasmMainTemplatePlugin.js +1 -3
- package/lib/web/JsonpMainTemplatePlugin.js +2 -3
- package/lib/webpack.js +3 -1
- package/lib/webworker/WebWorkerMainTemplatePlugin.js +1 -0
- package/package.json +2 -1
- package/schemas/WebpackOptions.json +18 -0
package/lib/Parser.js
CHANGED
@@ -13,7 +13,6 @@ const util = require("util");
|
|
13
13
|
const vm = require("vm");
|
14
14
|
const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
15
15
|
const StackedSetMap = require("./util/StackedSetMap");
|
16
|
-
const TrackingSet = require("./util/TrackingSet");
|
17
16
|
|
18
17
|
const acornParser = acorn.Parser.extend(acornDynamicImport);
|
19
18
|
|
@@ -34,8 +33,6 @@ const defaultParserOptions = {
|
|
34
33
|
// regexp to match at lease one "magic comment"
|
35
34
|
const webpackCommentRegExp = new RegExp(/(^|\W)webpack[A-Z]{1,}[A-Za-z]{1,}:/);
|
36
35
|
|
37
|
-
const EMPTY_ARRAY = [];
|
38
|
-
|
39
36
|
const EMPTY_COMMENT_OPTIONS = {
|
40
37
|
options: null,
|
41
38
|
errors: null
|
@@ -857,6 +854,14 @@ class Parser extends Tapable {
|
|
857
854
|
}
|
858
855
|
}
|
859
856
|
|
857
|
+
// Block-Prewalking iterates the scope for block variable declarations
|
858
|
+
blockPrewalkStatements(statements) {
|
859
|
+
for (let index = 0, len = statements.length; index < len; index++) {
|
860
|
+
const statement = statements[index];
|
861
|
+
this.blockPrewalkStatement(statement);
|
862
|
+
}
|
863
|
+
}
|
864
|
+
|
860
865
|
// Walking iterates the statements and expressions and processes them
|
861
866
|
walkStatements(statements) {
|
862
867
|
for (let index = 0, len = statements.length; index < len; index++) {
|
@@ -870,9 +875,6 @@ class Parser extends Tapable {
|
|
870
875
|
case "BlockStatement":
|
871
876
|
this.prewalkBlockStatement(statement);
|
872
877
|
break;
|
873
|
-
case "ClassDeclaration":
|
874
|
-
this.prewalkClassDeclaration(statement);
|
875
|
-
break;
|
876
878
|
case "DoWhileStatement":
|
877
879
|
this.prewalkDoWhileStatement(statement);
|
878
880
|
break;
|
@@ -924,6 +926,23 @@ class Parser extends Tapable {
|
|
924
926
|
}
|
925
927
|
}
|
926
928
|
|
929
|
+
blockPrewalkStatement(statement) {
|
930
|
+
switch (statement.type) {
|
931
|
+
case "VariableDeclaration":
|
932
|
+
this.blockPrewalkVariableDeclaration(statement);
|
933
|
+
break;
|
934
|
+
case "ExportDefaultDeclaration":
|
935
|
+
this.blockPrewalkExportDefaultDeclaration(statement);
|
936
|
+
break;
|
937
|
+
case "ExportNamedDeclaration":
|
938
|
+
this.blockPrewalkExportNamedDeclaration(statement);
|
939
|
+
break;
|
940
|
+
case "ClassDeclaration":
|
941
|
+
this.blockPrewalkClassDeclaration(statement);
|
942
|
+
break;
|
943
|
+
}
|
944
|
+
}
|
945
|
+
|
927
946
|
walkStatement(statement) {
|
928
947
|
if (this.hooks.statement.call(statement) !== undefined) return;
|
929
948
|
switch (statement.type) {
|
@@ -993,7 +1012,11 @@ class Parser extends Tapable {
|
|
993
1012
|
}
|
994
1013
|
|
995
1014
|
walkBlockStatement(statement) {
|
996
|
-
this.
|
1015
|
+
this.inBlockScope(() => {
|
1016
|
+
const body = statement.body;
|
1017
|
+
this.blockPrewalkStatements(body);
|
1018
|
+
this.walkStatements(body);
|
1019
|
+
});
|
997
1020
|
}
|
998
1021
|
|
999
1022
|
walkExpressionStatement(statement) {
|
@@ -1111,20 +1134,30 @@ class Parser extends Tapable {
|
|
1111
1134
|
}
|
1112
1135
|
|
1113
1136
|
walkForStatement(statement) {
|
1114
|
-
|
1115
|
-
if (statement.init
|
1116
|
-
|
1137
|
+
this.inBlockScope(() => {
|
1138
|
+
if (statement.init) {
|
1139
|
+
if (statement.init.type === "VariableDeclaration") {
|
1140
|
+
this.blockPrewalkVariableDeclaration(statement.init);
|
1141
|
+
this.walkStatement(statement.init);
|
1142
|
+
} else {
|
1143
|
+
this.walkExpression(statement.init);
|
1144
|
+
}
|
1145
|
+
}
|
1146
|
+
if (statement.test) {
|
1147
|
+
this.walkExpression(statement.test);
|
1148
|
+
}
|
1149
|
+
if (statement.update) {
|
1150
|
+
this.walkExpression(statement.update);
|
1151
|
+
}
|
1152
|
+
const body = statement.body;
|
1153
|
+
if (body.type === "BlockStatement") {
|
1154
|
+
// no need to add additional scope
|
1155
|
+
this.blockPrewalkStatements(body.body);
|
1156
|
+
this.walkStatements(body.body);
|
1117
1157
|
} else {
|
1118
|
-
this.
|
1158
|
+
this.walkStatement(body);
|
1119
1159
|
}
|
1120
|
-
}
|
1121
|
-
if (statement.test) {
|
1122
|
-
this.walkExpression(statement.test);
|
1123
|
-
}
|
1124
|
-
if (statement.update) {
|
1125
|
-
this.walkExpression(statement.update);
|
1126
|
-
}
|
1127
|
-
this.walkStatement(statement.body);
|
1160
|
+
});
|
1128
1161
|
}
|
1129
1162
|
|
1130
1163
|
prewalkForInStatement(statement) {
|
@@ -1135,13 +1168,23 @@ class Parser extends Tapable {
|
|
1135
1168
|
}
|
1136
1169
|
|
1137
1170
|
walkForInStatement(statement) {
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1171
|
+
this.inBlockScope(() => {
|
1172
|
+
if (statement.left.type === "VariableDeclaration") {
|
1173
|
+
this.blockPrewalkVariableDeclaration(statement.left);
|
1174
|
+
this.walkVariableDeclaration(statement.left);
|
1175
|
+
} else {
|
1176
|
+
this.walkPattern(statement.left);
|
1177
|
+
}
|
1178
|
+
this.walkExpression(statement.right);
|
1179
|
+
const body = statement.body;
|
1180
|
+
if (body.type === "BlockStatement") {
|
1181
|
+
// no need to add additional scope
|
1182
|
+
this.blockPrewalkStatements(body.body);
|
1183
|
+
this.walkStatements(body.body);
|
1184
|
+
} else {
|
1185
|
+
this.walkStatement(body);
|
1186
|
+
}
|
1187
|
+
});
|
1145
1188
|
}
|
1146
1189
|
|
1147
1190
|
prewalkForOfStatement(statement) {
|
@@ -1152,13 +1195,23 @@ class Parser extends Tapable {
|
|
1152
1195
|
}
|
1153
1196
|
|
1154
1197
|
walkForOfStatement(statement) {
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1198
|
+
this.inBlockScope(() => {
|
1199
|
+
if (statement.left.type === "VariableDeclaration") {
|
1200
|
+
this.blockPrewalkVariableDeclaration(statement.left);
|
1201
|
+
this.walkVariableDeclaration(statement.left);
|
1202
|
+
} else {
|
1203
|
+
this.walkPattern(statement.left);
|
1204
|
+
}
|
1205
|
+
this.walkExpression(statement.right);
|
1206
|
+
const body = statement.body;
|
1207
|
+
if (body.type === "BlockStatement") {
|
1208
|
+
// no need to add additional scope
|
1209
|
+
this.blockPrewalkStatements(body.body);
|
1210
|
+
this.walkStatements(body.body);
|
1211
|
+
} else {
|
1212
|
+
this.walkStatement(body);
|
1213
|
+
}
|
1214
|
+
});
|
1162
1215
|
}
|
1163
1216
|
|
1164
1217
|
// Declarations
|
@@ -1172,7 +1225,7 @@ class Parser extends Tapable {
|
|
1172
1225
|
walkFunctionDeclaration(statement) {
|
1173
1226
|
const wasTopLevel = this.scope.topLevelScope;
|
1174
1227
|
this.scope.topLevelScope = false;
|
1175
|
-
this.
|
1228
|
+
this.inFunctionScope(true, statement.params, () => {
|
1176
1229
|
for (const param of statement.params) {
|
1177
1230
|
this.walkPattern(param);
|
1178
1231
|
}
|
@@ -1213,6 +1266,33 @@ class Parser extends Tapable {
|
|
1213
1266
|
}
|
1214
1267
|
}
|
1215
1268
|
|
1269
|
+
enterDeclaration(declaration, onIdent) {
|
1270
|
+
switch (declaration.type) {
|
1271
|
+
case "VariableDeclaration":
|
1272
|
+
for (const declarator of declaration.declarations) {
|
1273
|
+
switch (declarator.type) {
|
1274
|
+
case "VariableDeclarator": {
|
1275
|
+
this.enterPattern(declarator.id, onIdent);
|
1276
|
+
break;
|
1277
|
+
}
|
1278
|
+
}
|
1279
|
+
}
|
1280
|
+
break;
|
1281
|
+
case "FunctionDeclaration":
|
1282
|
+
this.enterPattern(declaration.id, onIdent);
|
1283
|
+
break;
|
1284
|
+
case "ClassDeclaration":
|
1285
|
+
this.enterPattern(declaration.id, onIdent);
|
1286
|
+
break;
|
1287
|
+
}
|
1288
|
+
}
|
1289
|
+
|
1290
|
+
blockPrewalkExportNamedDeclaration(statement) {
|
1291
|
+
if (statement.declaration) {
|
1292
|
+
this.blockPrewalkStatement(statement.declaration);
|
1293
|
+
}
|
1294
|
+
}
|
1295
|
+
|
1216
1296
|
prewalkExportNamedDeclaration(statement) {
|
1217
1297
|
let source;
|
1218
1298
|
if (statement.source) {
|
@@ -1225,16 +1305,11 @@ class Parser extends Tapable {
|
|
1225
1305
|
if (
|
1226
1306
|
!this.hooks.exportDeclaration.call(statement, statement.declaration)
|
1227
1307
|
) {
|
1228
|
-
const originalDefinitions = this.scope.definitions;
|
1229
|
-
const tracker = new TrackingSet(this.scope.definitions);
|
1230
|
-
this.scope.definitions = tracker;
|
1231
1308
|
this.prewalkStatement(statement.declaration);
|
1232
|
-
|
1233
|
-
this.
|
1234
|
-
|
1235
|
-
|
1236
|
-
this.hooks.exportSpecifier.call(statement, def, def, index);
|
1237
|
-
}
|
1309
|
+
let index = 0;
|
1310
|
+
this.enterDeclaration(statement.declaration, def => {
|
1311
|
+
this.hooks.exportSpecifier.call(statement, def, def, index++);
|
1312
|
+
});
|
1238
1313
|
}
|
1239
1314
|
}
|
1240
1315
|
if (statement.specifiers) {
|
@@ -1276,18 +1351,24 @@ class Parser extends Tapable {
|
|
1276
1351
|
}
|
1277
1352
|
}
|
1278
1353
|
|
1354
|
+
blockPrewalkExportDefaultDeclaration(statement) {
|
1355
|
+
if (statement.declaration.type === "ClassDeclaration") {
|
1356
|
+
this.blockPrewalkClassDeclaration(statement.declaration);
|
1357
|
+
}
|
1358
|
+
}
|
1359
|
+
|
1279
1360
|
prewalkExportDefaultDeclaration(statement) {
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
this.
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1361
|
+
this.prewalkStatement(statement.declaration);
|
1362
|
+
if (
|
1363
|
+
statement.declaration.id &&
|
1364
|
+
statement.declaration.type !== "FunctionExpression" &&
|
1365
|
+
statement.declaration.type !== "ClassExpression"
|
1366
|
+
) {
|
1367
|
+
this.hooks.exportSpecifier.call(
|
1368
|
+
statement,
|
1369
|
+
statement.declaration.id.name,
|
1370
|
+
"default"
|
1371
|
+
);
|
1291
1372
|
}
|
1292
1373
|
}
|
1293
1374
|
|
@@ -1331,12 +1412,20 @@ class Parser extends Tapable {
|
|
1331
1412
|
}
|
1332
1413
|
|
1333
1414
|
prewalkVariableDeclaration(statement) {
|
1415
|
+
if (statement.kind !== "var") return;
|
1416
|
+
this._prewalkVariableDeclaration(statement, this.hooks.varDeclarationVar);
|
1417
|
+
}
|
1418
|
+
|
1419
|
+
blockPrewalkVariableDeclaration(statement) {
|
1420
|
+
if (statement.kind === "var") return;
|
1334
1421
|
const hookMap =
|
1335
1422
|
statement.kind === "const"
|
1336
1423
|
? this.hooks.varDeclarationConst
|
1337
|
-
:
|
1338
|
-
|
1339
|
-
|
1424
|
+
: this.hooks.varDeclarationLet;
|
1425
|
+
this._prewalkVariableDeclaration(statement, hookMap);
|
1426
|
+
}
|
1427
|
+
|
1428
|
+
_prewalkVariableDeclaration(statement, hookMap) {
|
1340
1429
|
for (const declarator of statement.declarations) {
|
1341
1430
|
switch (declarator.type) {
|
1342
1431
|
case "VariableDeclarator": {
|
@@ -1385,7 +1474,7 @@ class Parser extends Tapable {
|
|
1385
1474
|
}
|
1386
1475
|
}
|
1387
1476
|
|
1388
|
-
|
1477
|
+
blockPrewalkClassDeclaration(statement) {
|
1389
1478
|
if (statement.id) {
|
1390
1479
|
this.scope.renames.set(statement.id.name, null);
|
1391
1480
|
this.scope.definitions.add(statement.id.name);
|
@@ -1415,11 +1504,15 @@ class Parser extends Tapable {
|
|
1415
1504
|
}
|
1416
1505
|
|
1417
1506
|
walkCatchClause(catchClause) {
|
1418
|
-
|
1419
|
-
|
1420
|
-
catchClause.param
|
1421
|
-
|
1422
|
-
|
1507
|
+
this.inBlockScope(() => {
|
1508
|
+
// Error binding is optional in catch clause since ECMAScript 2019
|
1509
|
+
if (catchClause.param !== null) {
|
1510
|
+
this.enterPattern(catchClause.param, ident => {
|
1511
|
+
this.scope.renames.set(ident, null);
|
1512
|
+
this.scope.definitions.add(ident);
|
1513
|
+
});
|
1514
|
+
this.walkPattern(catchClause.param);
|
1515
|
+
}
|
1423
1516
|
this.prewalkStatement(catchClause.body);
|
1424
1517
|
this.walkStatement(catchClause.body);
|
1425
1518
|
});
|
@@ -1600,7 +1693,7 @@ class Parser extends Tapable {
|
|
1600
1693
|
scopeParams.push(expression.id.name);
|
1601
1694
|
}
|
1602
1695
|
|
1603
|
-
this.
|
1696
|
+
this.inFunctionScope(true, scopeParams, () => {
|
1604
1697
|
for (const param of expression.params) {
|
1605
1698
|
this.walkPattern(param);
|
1606
1699
|
}
|
@@ -1616,7 +1709,7 @@ class Parser extends Tapable {
|
|
1616
1709
|
}
|
1617
1710
|
|
1618
1711
|
walkArrowFunctionExpression(expression) {
|
1619
|
-
this.
|
1712
|
+
this.inFunctionScope(false, expression.params, () => {
|
1620
1713
|
for (const param of expression.params) {
|
1621
1714
|
this.walkPattern(param);
|
1622
1715
|
}
|
@@ -1791,7 +1884,7 @@ class Parser extends Tapable {
|
|
1791
1884
|
scopeParams.push(functionExpression.id.name);
|
1792
1885
|
}
|
1793
1886
|
|
1794
|
-
this.
|
1887
|
+
this.inFunctionScope(true, scopeParams, () => {
|
1795
1888
|
if (renameThis) {
|
1796
1889
|
this.scope.renames.set("this", renameThis);
|
1797
1890
|
}
|
@@ -1896,6 +1989,12 @@ class Parser extends Tapable {
|
|
1896
1989
|
}
|
1897
1990
|
}
|
1898
1991
|
|
1992
|
+
/**
|
1993
|
+
* @deprecated
|
1994
|
+
* @param {any} params scope params
|
1995
|
+
* @param {function(): void} fn inner function
|
1996
|
+
* @returns {void}
|
1997
|
+
*/
|
1899
1998
|
inScope(params, fn) {
|
1900
1999
|
const oldScope = this.scope;
|
1901
2000
|
this.scope = {
|
@@ -1909,19 +2008,54 @@ class Parser extends Tapable {
|
|
1909
2008
|
|
1910
2009
|
this.scope.renames.set("this", null);
|
1911
2010
|
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
2011
|
+
this.enterPatterns(params, ident => {
|
2012
|
+
this.scope.renames.set(ident, null);
|
2013
|
+
this.scope.definitions.add(ident);
|
2014
|
+
});
|
2015
|
+
|
2016
|
+
fn();
|
2017
|
+
|
2018
|
+
this.scope = oldScope;
|
2019
|
+
}
|
2020
|
+
|
2021
|
+
inFunctionScope(hasThis, params, fn) {
|
2022
|
+
const oldScope = this.scope;
|
2023
|
+
this.scope = {
|
2024
|
+
topLevelScope: oldScope.topLevelScope,
|
2025
|
+
inTry: false,
|
2026
|
+
inShorthand: false,
|
2027
|
+
isStrict: oldScope.isStrict,
|
2028
|
+
definitions: oldScope.definitions.createChild(),
|
2029
|
+
renames: oldScope.renames.createChild()
|
2030
|
+
};
|
2031
|
+
|
2032
|
+
if (hasThis) {
|
2033
|
+
this.scope.renames.set("this", null);
|
1922
2034
|
}
|
1923
2035
|
|
2036
|
+
this.enterPatterns(params, ident => {
|
2037
|
+
this.scope.renames.set(ident, null);
|
2038
|
+
this.scope.definitions.add(ident);
|
2039
|
+
});
|
2040
|
+
|
1924
2041
|
fn();
|
2042
|
+
|
2043
|
+
this.scope = oldScope;
|
2044
|
+
}
|
2045
|
+
|
2046
|
+
inBlockScope(fn) {
|
2047
|
+
const oldScope = this.scope;
|
2048
|
+
this.scope = {
|
2049
|
+
topLevelScope: oldScope.topLevelScope,
|
2050
|
+
inTry: oldScope.inTry,
|
2051
|
+
inShorthand: false,
|
2052
|
+
isStrict: oldScope.isStrict,
|
2053
|
+
definitions: oldScope.definitions.createChild(),
|
2054
|
+
renames: oldScope.renames.createChild()
|
2055
|
+
};
|
2056
|
+
|
2057
|
+
fn();
|
2058
|
+
|
1925
2059
|
this.scope = oldScope;
|
1926
2060
|
}
|
1927
2061
|
|
@@ -1936,6 +2070,16 @@ class Parser extends Tapable {
|
|
1936
2070
|
}
|
1937
2071
|
}
|
1938
2072
|
|
2073
|
+
enterPatterns(patterns, onIdent) {
|
2074
|
+
for (const pattern of patterns) {
|
2075
|
+
if (typeof pattern !== "string") {
|
2076
|
+
this.enterPattern(pattern, onIdent);
|
2077
|
+
} else if (pattern) {
|
2078
|
+
onIdent(pattern);
|
2079
|
+
}
|
2080
|
+
}
|
2081
|
+
}
|
2082
|
+
|
1939
2083
|
enterPattern(pattern, onIdent) {
|
1940
2084
|
if (!pattern) return;
|
1941
2085
|
switch (pattern.type) {
|
@@ -2137,6 +2281,7 @@ class Parser extends Tapable {
|
|
2137
2281
|
if (this.hooks.program.call(ast, comments) === undefined) {
|
2138
2282
|
this.detectStrictMode(ast.body);
|
2139
2283
|
this.prewalkStatements(ast.body);
|
2284
|
+
this.blockPrewalkStatements(ast.body);
|
2140
2285
|
this.walkStatements(ast.body);
|
2141
2286
|
}
|
2142
2287
|
this.scope = oldScope;
|
package/lib/ProgressPlugin.js
CHANGED
@@ -18,7 +18,8 @@ const createDefaultHandler = profile => {
|
|
18
18
|
|
19
19
|
const defaultHandler = (percentage, msg, ...args) => {
|
20
20
|
let state = msg;
|
21
|
-
const details = args;
|
21
|
+
const details = args.filter(v => v.length);
|
22
|
+
const maxLineLength = process.stderr.columns || Infinity;
|
22
23
|
if (percentage < 1) {
|
23
24
|
percentage = Math.floor(percentage * 100);
|
24
25
|
msg = `${percentage}% ${msg}`;
|
@@ -28,12 +29,28 @@ const createDefaultHandler = profile => {
|
|
28
29
|
if (percentage < 10) {
|
29
30
|
msg = ` ${msg}`;
|
30
31
|
}
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
|
33
|
+
if (details.length) {
|
34
|
+
const maxTotalDetailsLength = maxLineLength - msg.length;
|
35
|
+
const totalDetailsLength = details.reduce(
|
36
|
+
(a, b) => a + b.length,
|
37
|
+
details.length // account for added space before each detail text
|
38
|
+
);
|
39
|
+
const maxDetailLength =
|
40
|
+
totalDetailsLength < maxTotalDetailsLength
|
41
|
+
? Infinity
|
42
|
+
: Math.floor(maxTotalDetailsLength / details.length);
|
43
|
+
|
44
|
+
for (let detail of details) {
|
45
|
+
if (!detail) continue;
|
46
|
+
if (detail.length + 1 > maxDetailLength) {
|
47
|
+
const truncatePrefix = "...";
|
48
|
+
detail = `${truncatePrefix}${detail.substr(
|
49
|
+
-(maxDetailLength - truncatePrefix.length - 1)
|
50
|
+
)}`;
|
51
|
+
}
|
52
|
+
msg += ` ${detail}`;
|
35
53
|
}
|
36
|
-
msg += ` ${detail}`;
|
37
54
|
}
|
38
55
|
}
|
39
56
|
if (profile) {
|
@@ -55,6 +72,7 @@ const createDefaultHandler = profile => {
|
|
55
72
|
}
|
56
73
|
if (lastMessage !== msg) {
|
57
74
|
goToLineStart(msg);
|
75
|
+
msg = msg.substring(0, maxLineLength);
|
58
76
|
process.stderr.write(msg);
|
59
77
|
lastMessage = msg;
|
60
78
|
}
|
package/lib/Watching.js
CHANGED
@@ -13,6 +13,7 @@ class Watching {
|
|
13
13
|
this.handler = handler;
|
14
14
|
this.callbacks = [];
|
15
15
|
this.closed = false;
|
16
|
+
this.suspended = false;
|
16
17
|
if (typeof watchOptions === "number") {
|
17
18
|
this.watchOptions = {
|
18
19
|
aggregateTimeout: watchOptions
|
@@ -133,7 +134,9 @@ class Watching {
|
|
133
134
|
this.compiler.fileTimestamps = fileTimestamps;
|
134
135
|
this.compiler.contextTimestamps = contextTimestamps;
|
135
136
|
this.compiler.removedFiles = removedFiles;
|
136
|
-
this.
|
137
|
+
if (!this.suspended) {
|
138
|
+
this._invalidate();
|
139
|
+
}
|
137
140
|
},
|
138
141
|
(fileName, changeTime) => {
|
139
142
|
this.compiler.hooks.invalid.call(fileName, changeTime);
|
@@ -158,6 +161,7 @@ class Watching {
|
|
158
161
|
this.watcher.pause();
|
159
162
|
this.watcher = null;
|
160
163
|
}
|
164
|
+
|
161
165
|
if (this.running) {
|
162
166
|
this.invalid = true;
|
163
167
|
return false;
|
@@ -166,6 +170,18 @@ class Watching {
|
|
166
170
|
}
|
167
171
|
}
|
168
172
|
|
173
|
+
suspend() {
|
174
|
+
this.suspended = true;
|
175
|
+
this.invalid = false;
|
176
|
+
}
|
177
|
+
|
178
|
+
resume() {
|
179
|
+
if (this.suspended) {
|
180
|
+
this.suspended = false;
|
181
|
+
this._invalidate();
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
169
185
|
close(callback) {
|
170
186
|
const finalCallback = () => {
|
171
187
|
this.compiler.hooks.watchClose.call();
|
@@ -231,6 +231,7 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
|
|
231
231
|
return isProductionLikeMode(options) ? 5 : Infinity;
|
232
232
|
});
|
233
233
|
this.set("optimization.splitChunks.automaticNameDelimiter", "~");
|
234
|
+
this.set("optimization.splitChunks.automaticNameMaxLength", 109);
|
234
235
|
this.set("optimization.splitChunks.maxInitialRequests", "make", options => {
|
235
236
|
return isProductionLikeMode(options) ? 3 : Infinity;
|
236
237
|
});
|
@@ -355,15 +355,13 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
355
355
|
// It's not an harmony module
|
356
356
|
if (
|
357
357
|
this.originModule.buildMeta.strictHarmonyModule &&
|
358
|
+
this._id &&
|
358
359
|
this._id !== "default"
|
359
360
|
) {
|
360
361
|
// In strict harmony modules we only support the default export
|
361
|
-
const exportName = this._id
|
362
|
-
? `the named export '${this._id}'`
|
363
|
-
: "the namespace object";
|
364
362
|
return [
|
365
363
|
new HarmonyLinkingError(
|
366
|
-
`Can't reexport ${
|
364
|
+
`Can't reexport the named export '${this._id}' from non EcmaScript module (only default export is available)`
|
367
365
|
)
|
368
366
|
];
|
369
367
|
}
|
@@ -382,9 +380,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
382
380
|
// We are sure that it's not provided
|
383
381
|
const idIsNotNameMessage =
|
384
382
|
this._id !== this.name ? ` (reexported as '${this.name}')` : "";
|
385
|
-
const errorMessage = `"export '${
|
386
|
-
this._id
|
387
|
-
}'${idIsNotNameMessage} was not found in '${this.userRequest}'`;
|
383
|
+
const errorMessage = `"export '${this._id}'${idIsNotNameMessage} was not found in '${this.userRequest}'`;
|
388
384
|
return [new HarmonyLinkingError(errorMessage)];
|
389
385
|
}
|
390
386
|
|
@@ -80,15 +80,13 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
80
80
|
// It's not an harmony module
|
81
81
|
if (
|
82
82
|
this.originModule.buildMeta.strictHarmonyModule &&
|
83
|
+
this._id &&
|
83
84
|
this._id !== "default"
|
84
85
|
) {
|
85
86
|
// In strict harmony modules we only support the default export
|
86
|
-
const exportName = this._id
|
87
|
-
? `the named export '${this._id}'`
|
88
|
-
: "the namespace object";
|
89
87
|
return [
|
90
88
|
new HarmonyLinkingError(
|
91
|
-
`Can't import ${
|
89
|
+
`Can't import the named export '${this._id}' from non EcmaScript module (only default export is available)`
|
92
90
|
)
|
93
91
|
];
|
94
92
|
}
|
@@ -107,9 +105,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
107
105
|
// We are sure that it's not provided
|
108
106
|
const idIsNotNameMessage =
|
109
107
|
this._id !== this.name ? ` (imported as '${this.name}')` : "";
|
110
|
-
const errorMessage = `"export '${
|
111
|
-
this._id
|
112
|
-
}'${idIsNotNameMessage} was not found in '${this.userRequest}'`;
|
108
|
+
const errorMessage = `"export '${this._id}'${idIsNotNameMessage} was not found in '${this.userRequest}'`;
|
113
109
|
return [new HarmonyLinkingError(errorMessage)];
|
114
110
|
}
|
115
111
|
|