webpack 4.10.1 → 4.10.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/lib/AmdMainTemplatePlugin.js +3 -1
- package/lib/BannerPlugin.js +3 -1
- package/lib/BasicEvaluatedExpression.js +14 -11
- package/lib/CachePlugin.js +12 -5
- package/lib/Chunk.js +44 -16
- package/lib/ChunkGroup.js +13 -5
- package/lib/Compilation.js +70 -28
- package/lib/Compiler.js +22 -10
- package/lib/ConstPlugin.js +25 -9
- package/lib/ContextModule.js +88 -36
- package/lib/ContextModuleFactory.js +18 -7
- package/lib/ContextReplacementPlugin.js +14 -7
- package/lib/DefinePlugin.js +15 -6
- package/lib/DependenciesBlock.js +3 -1
- package/lib/DependenciesBlockVariable.js +2 -1
- package/lib/DllPlugin.js +4 -2
- package/lib/DynamicEntryPlugin.js +4 -2
- package/lib/ErrorHelpers.js +5 -2
- package/lib/EvalSourceMapDevToolPlugin.js +2 -1
- package/lib/FlagDependencyUsagePlugin.js +11 -5
- package/lib/FunctionModuleTemplatePlugin.js +8 -6
- package/lib/HotModuleReplacement.runtime.js +7 -3
- package/lib/HotModuleReplacementPlugin.js +13 -6
- package/lib/JavascriptGenerator.js +2 -1
- package/lib/JavascriptModulesPlugin.js +4 -9
- package/lib/JsonParser.js +2 -1
- package/lib/LibraryTemplatePlugin.js +2 -1
- package/lib/LoaderOptionsPlugin.js +2 -1
- package/lib/MainTemplate.js +2 -1
- package/lib/Module.js +9 -5
- package/lib/ModuleFilenameHelpers.js +20 -8
- package/lib/MultiCompiler.js +19 -7
- package/lib/MultiModule.js +5 -2
- package/lib/NodeStuffPlugin.js +2 -1
- package/lib/NormalModule.js +11 -4
- package/lib/NormalModuleFactory.js +30 -12
- package/lib/OptionsDefaulter.js +7 -3
- package/lib/Parser.js +137 -59
- package/lib/ParserHelpers.js +5 -2
- package/lib/ProgressPlugin.js +2 -2
- package/lib/RawModule.js +4 -2
- package/lib/RecordIdsPlugin.js +11 -7
- package/lib/RequestShortener.js +13 -6
- package/lib/RuleSet.js +39 -18
- package/lib/RuntimeTemplate.js +21 -10
- package/lib/SourceMapDevToolPlugin.js +4 -3
- package/lib/Stats.js +64 -28
- package/lib/Template.js +4 -2
- package/lib/TemplatedPathPlugin.js +6 -3
- package/lib/UmdMainTemplatePlugin.js +8 -3
- package/lib/WarnCaseSensitiveModulesPlugin.js +2 -1
- package/lib/Watching.js +3 -2
- package/lib/WebpackOptionsApply.js +32 -16
- package/lib/WebpackOptionsDefaulter.js +7 -4
- package/lib/WebpackOptionsValidationError.js +48 -19
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +17 -8
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +6 -3
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +4 -2
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +7 -3
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +6 -3
- package/lib/dependencies/ImportParserPlugin.js +2 -1
- package/lib/dependencies/LoaderPlugin.js +12 -7
- package/lib/dependencies/LocalModulesHelpers.js +13 -6
- package/lib/dependencies/RequireContextPlugin.js +4 -2
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +8 -4
- package/lib/formatLocation.js +15 -7
- package/lib/node/NodeMainTemplateAsync.runtime.js +1 -1
- package/lib/node/NodeMainTemplatePlugin.js +6 -3
- package/lib/node/NodeSourcePlugin.js +9 -5
- package/lib/node/NodeWatchFileSystem.js +29 -12
- package/lib/optimize/AggressiveSplittingPlugin.js +12 -6
- package/lib/optimize/ConcatenatedModule.js +19 -8
- package/lib/optimize/MergeDuplicateChunksPlugin.js +6 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +23 -10
- package/lib/optimize/OccurrenceOrderPlugin.js +11 -4
- package/lib/optimize/RemoveParentModulesPlugin.js +17 -7
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
- package/lib/optimize/SplitChunksPlugin.js +33 -20
- package/lib/util/SortableSet.js +5 -2
- package/lib/util/StackedSetMap.js +12 -5
- package/lib/wasm/WasmMainTemplatePlugin.js +4 -2
- package/lib/wasm/WebAssemblyGenerator.js +7 -0
- package/lib/web/JsonpMainTemplate.runtime.js +2 -1
- package/lib/web/JsonpMainTemplatePlugin.js +2 -1
- package/lib/webpack.js +2 -1
- package/lib/webworker/WebWorkerMainTemplate.runtime.js +2 -1
- package/package.json +9 -9
package/lib/Parser.js
CHANGED
@@ -117,17 +117,18 @@ class Parser extends Tapable {
|
|
117
117
|
const regexp = HOOK_MAP_COMPAT_CONFIG[name];
|
118
118
|
const match = regexp.exec(options.name);
|
119
119
|
if (match) {
|
120
|
-
if (match[1])
|
120
|
+
if (match[1]) {
|
121
121
|
this.hooks[name].tap(
|
122
122
|
match[1],
|
123
123
|
options.fn.name || "unnamed compat plugin",
|
124
124
|
options.fn.bind(this)
|
125
125
|
);
|
126
|
-
else
|
126
|
+
} else {
|
127
127
|
this.hooks[name].tap(
|
128
128
|
options.fn.name || "unnamed compat plugin",
|
129
129
|
options.fn.bind(this)
|
130
130
|
);
|
131
|
+
}
|
131
132
|
return true;
|
132
133
|
}
|
133
134
|
}
|
@@ -156,12 +157,14 @@ class Parser extends Tapable {
|
|
156
157
|
.setBoolean(expr.value)
|
157
158
|
.setRange(expr.range);
|
158
159
|
}
|
159
|
-
if (expr.value === null)
|
160
|
+
if (expr.value === null) {
|
160
161
|
return new BasicEvaluatedExpression().setNull().setRange(expr.range);
|
161
|
-
|
162
|
+
}
|
163
|
+
if (expr.value instanceof RegExp) {
|
162
164
|
return new BasicEvaluatedExpression()
|
163
165
|
.setRegExp(expr.value)
|
164
166
|
.setRange(expr.range);
|
167
|
+
}
|
165
168
|
});
|
166
169
|
this.hooks.evaluate.for("LogicalExpression").tap("Parser", expr => {
|
167
170
|
let left;
|
@@ -411,22 +414,26 @@ class Parser extends Tapable {
|
|
411
414
|
.setRange(expr.range);
|
412
415
|
}
|
413
416
|
const arg = this.evaluateExpression(expr.argument);
|
414
|
-
if (arg.isString() || arg.isWrapped())
|
417
|
+
if (arg.isString() || arg.isWrapped()) {
|
415
418
|
return new BasicEvaluatedExpression()
|
416
419
|
.setString("string")
|
417
420
|
.setRange(expr.range);
|
418
|
-
|
421
|
+
}
|
422
|
+
if (arg.isNumber()) {
|
419
423
|
return new BasicEvaluatedExpression()
|
420
424
|
.setString("number")
|
421
425
|
.setRange(expr.range);
|
422
|
-
|
426
|
+
}
|
427
|
+
if (arg.isBoolean()) {
|
423
428
|
return new BasicEvaluatedExpression()
|
424
429
|
.setString("boolean")
|
425
430
|
.setRange(expr.range);
|
426
|
-
|
431
|
+
}
|
432
|
+
if (arg.isArray() || arg.isConstArray() || arg.isRegExp()) {
|
427
433
|
return new BasicEvaluatedExpression()
|
428
434
|
.setString("object")
|
429
435
|
.setRange(expr.range);
|
436
|
+
}
|
430
437
|
} else if (expr.operator === "!") {
|
431
438
|
const argument = this.evaluateExpression(expr.argument);
|
432
439
|
if (!argument) return;
|
@@ -434,19 +441,23 @@ class Parser extends Tapable {
|
|
434
441
|
return new BasicEvaluatedExpression()
|
435
442
|
.setBoolean(!argument.bool)
|
436
443
|
.setRange(expr.range);
|
437
|
-
}
|
444
|
+
}
|
445
|
+
if (argument.isTruthy()) {
|
438
446
|
return new BasicEvaluatedExpression()
|
439
447
|
.setBoolean(false)
|
440
448
|
.setRange(expr.range);
|
441
|
-
}
|
449
|
+
}
|
450
|
+
if (argument.isFalsy()) {
|
442
451
|
return new BasicEvaluatedExpression()
|
443
452
|
.setBoolean(true)
|
444
453
|
.setRange(expr.range);
|
445
|
-
}
|
454
|
+
}
|
455
|
+
if (argument.isString()) {
|
446
456
|
return new BasicEvaluatedExpression()
|
447
457
|
.setBoolean(!argument.string)
|
448
458
|
.setRange(expr.range);
|
449
|
-
}
|
459
|
+
}
|
460
|
+
if (argument.isNumber()) {
|
450
461
|
return new BasicEvaluatedExpression()
|
451
462
|
.setBoolean(!argument.number)
|
452
463
|
.setRange(expr.range);
|
@@ -696,7 +707,9 @@ class Parser extends Tapable {
|
|
696
707
|
result = param.string.split(arg.string);
|
697
708
|
} else if (arg.isRegExp()) {
|
698
709
|
result = param.string.split(arg.regExp);
|
699
|
-
} else
|
710
|
+
} else {
|
711
|
+
return;
|
712
|
+
}
|
700
713
|
return new BasicEvaluatedExpression()
|
701
714
|
.setArray(result)
|
702
715
|
.setRange(expr.range);
|
@@ -710,10 +723,16 @@ class Parser extends Tapable {
|
|
710
723
|
const alternate = this.evaluateExpression(expr.alternate);
|
711
724
|
if (!consequent || !alternate) return;
|
712
725
|
res = new BasicEvaluatedExpression();
|
713
|
-
if (consequent.isConditional())
|
714
|
-
|
715
|
-
|
716
|
-
|
726
|
+
if (consequent.isConditional()) {
|
727
|
+
res.setOptions(consequent.options);
|
728
|
+
} else {
|
729
|
+
res.setOptions([consequent]);
|
730
|
+
}
|
731
|
+
if (alternate.isConditional()) {
|
732
|
+
res.addOptions(alternate.options);
|
733
|
+
} else {
|
734
|
+
res.addOptions([alternate]);
|
735
|
+
}
|
717
736
|
} else {
|
718
737
|
res = this.evaluateExpression(
|
719
738
|
conditionValue ? expr.consequent : expr.alternate
|
@@ -735,9 +754,9 @@ class Parser extends Tapable {
|
|
735
754
|
|
736
755
|
getRenameIdentifier(expr) {
|
737
756
|
const result = this.evaluateExpression(expr);
|
738
|
-
if (
|
739
|
-
|
740
|
-
|
757
|
+
if (result && result.isIdentifier()) {
|
758
|
+
return result.identifier;
|
759
|
+
}
|
741
760
|
}
|
742
761
|
|
743
762
|
walkClass(classy) {
|
@@ -746,17 +765,21 @@ class Parser extends Tapable {
|
|
746
765
|
const wasTopLevel = this.scope.topLevelScope;
|
747
766
|
this.scope.topLevelScope = false;
|
748
767
|
for (const methodDefinition of classy.body.body) {
|
749
|
-
if (methodDefinition.type === "MethodDefinition")
|
768
|
+
if (methodDefinition.type === "MethodDefinition") {
|
750
769
|
this.walkMethodDefinition(methodDefinition);
|
770
|
+
}
|
751
771
|
}
|
752
772
|
this.scope.topLevelScope = wasTopLevel;
|
753
773
|
}
|
754
774
|
}
|
755
775
|
|
756
776
|
walkMethodDefinition(methodDefinition) {
|
757
|
-
if (methodDefinition.computed && methodDefinition.key)
|
777
|
+
if (methodDefinition.computed && methodDefinition.key) {
|
758
778
|
this.walkExpression(methodDefinition.key);
|
759
|
-
|
779
|
+
}
|
780
|
+
if (methodDefinition.value) {
|
781
|
+
this.walkExpression(methodDefinition.value);
|
782
|
+
}
|
760
783
|
}
|
761
784
|
|
762
785
|
// Prewalking iterates the scope for variable declarations
|
@@ -912,7 +935,9 @@ class Parser extends Tapable {
|
|
912
935
|
|
913
936
|
prewalkIfStatement(statement) {
|
914
937
|
this.prewalkStatement(statement.consequent);
|
915
|
-
if (statement.alternate)
|
938
|
+
if (statement.alternate) {
|
939
|
+
this.prewalkStatement(statement.alternate);
|
940
|
+
}
|
916
941
|
}
|
917
942
|
|
918
943
|
walkIfStatement(statement) {
|
@@ -920,10 +945,15 @@ class Parser extends Tapable {
|
|
920
945
|
if (result === undefined) {
|
921
946
|
this.walkExpression(statement.test);
|
922
947
|
this.walkStatement(statement.consequent);
|
923
|
-
if (statement.alternate)
|
948
|
+
if (statement.alternate) {
|
949
|
+
this.walkStatement(statement.alternate);
|
950
|
+
}
|
924
951
|
} else {
|
925
|
-
if (result)
|
926
|
-
|
952
|
+
if (result) {
|
953
|
+
this.walkStatement(statement.consequent);
|
954
|
+
} else if (statement.alternate) {
|
955
|
+
this.walkStatement(statement.alternate);
|
956
|
+
}
|
927
957
|
}
|
928
958
|
}
|
929
959
|
|
@@ -1006,26 +1036,34 @@ class Parser extends Tapable {
|
|
1006
1036
|
|
1007
1037
|
prewalkForStatement(statement) {
|
1008
1038
|
if (statement.init) {
|
1009
|
-
if (statement.init.type === "VariableDeclaration")
|
1039
|
+
if (statement.init.type === "VariableDeclaration") {
|
1010
1040
|
this.prewalkStatement(statement.init);
|
1041
|
+
}
|
1011
1042
|
}
|
1012
1043
|
this.prewalkStatement(statement.body);
|
1013
1044
|
}
|
1014
1045
|
|
1015
1046
|
walkForStatement(statement) {
|
1016
1047
|
if (statement.init) {
|
1017
|
-
if (statement.init.type === "VariableDeclaration")
|
1048
|
+
if (statement.init.type === "VariableDeclaration") {
|
1018
1049
|
this.walkStatement(statement.init);
|
1019
|
-
else
|
1050
|
+
} else {
|
1051
|
+
this.walkExpression(statement.init);
|
1052
|
+
}
|
1053
|
+
}
|
1054
|
+
if (statement.test) {
|
1055
|
+
this.walkExpression(statement.test);
|
1056
|
+
}
|
1057
|
+
if (statement.update) {
|
1058
|
+
this.walkExpression(statement.update);
|
1020
1059
|
}
|
1021
|
-
if (statement.test) this.walkExpression(statement.test);
|
1022
|
-
if (statement.update) this.walkExpression(statement.update);
|
1023
1060
|
this.walkStatement(statement.body);
|
1024
1061
|
}
|
1025
1062
|
|
1026
1063
|
prewalkForInStatement(statement) {
|
1027
|
-
if (statement.left.type === "VariableDeclaration")
|
1064
|
+
if (statement.left.type === "VariableDeclaration") {
|
1028
1065
|
this.prewalkVariableDeclaration(statement.left);
|
1066
|
+
}
|
1029
1067
|
this.prewalkStatement(statement.body);
|
1030
1068
|
}
|
1031
1069
|
|
@@ -1142,7 +1180,7 @@ class Parser extends Tapable {
|
|
1142
1180
|
switch (specifier.type) {
|
1143
1181
|
case "ExportSpecifier": {
|
1144
1182
|
const name = specifier.exported.name;
|
1145
|
-
if (source)
|
1183
|
+
if (source) {
|
1146
1184
|
this.hooks.exportImportSpecifier.call(
|
1147
1185
|
statement,
|
1148
1186
|
source,
|
@@ -1150,13 +1188,14 @@ class Parser extends Tapable {
|
|
1150
1188
|
name,
|
1151
1189
|
specifierIndex
|
1152
1190
|
);
|
1153
|
-
else
|
1191
|
+
} else {
|
1154
1192
|
this.hooks.exportSpecifier.call(
|
1155
1193
|
statement,
|
1156
1194
|
specifier.local.name,
|
1157
1195
|
name,
|
1158
1196
|
specifierIndex
|
1159
1197
|
);
|
1198
|
+
}
|
1160
1199
|
break;
|
1161
1200
|
}
|
1162
1201
|
}
|
@@ -1445,11 +1484,15 @@ class Parser extends Tapable {
|
|
1445
1484
|
}
|
1446
1485
|
|
1447
1486
|
walkArrayExpression(expression) {
|
1448
|
-
if (expression.elements)
|
1487
|
+
if (expression.elements) {
|
1488
|
+
this.walkExpressions(expression.elements);
|
1489
|
+
}
|
1449
1490
|
}
|
1450
1491
|
|
1451
1492
|
walkSpreadElement(expression) {
|
1452
|
-
if (expression.argument)
|
1493
|
+
if (expression.argument) {
|
1494
|
+
this.walkExpression(expression.argument);
|
1495
|
+
}
|
1453
1496
|
}
|
1454
1497
|
|
1455
1498
|
walkObjectExpression(expression) {
|
@@ -1463,10 +1506,16 @@ class Parser extends Tapable {
|
|
1463
1506
|
this.walkExpression(prop.argument);
|
1464
1507
|
continue;
|
1465
1508
|
}
|
1466
|
-
if (prop.computed)
|
1467
|
-
|
1509
|
+
if (prop.computed) {
|
1510
|
+
this.walkExpression(prop.key);
|
1511
|
+
}
|
1512
|
+
if (prop.shorthand) {
|
1513
|
+
this.scope.inShorthand = true;
|
1514
|
+
}
|
1468
1515
|
this.walkExpression(prop.value);
|
1469
|
-
if (prop.shorthand)
|
1516
|
+
if (prop.shorthand) {
|
1517
|
+
this.scope.inShorthand = false;
|
1518
|
+
}
|
1470
1519
|
}
|
1471
1520
|
}
|
1472
1521
|
|
@@ -1576,10 +1625,15 @@ class Parser extends Tapable {
|
|
1576
1625
|
if (result === undefined) {
|
1577
1626
|
this.walkExpression(expression.test);
|
1578
1627
|
this.walkExpression(expression.consequent);
|
1579
|
-
if (expression.alternate)
|
1628
|
+
if (expression.alternate) {
|
1629
|
+
this.walkExpression(expression.alternate);
|
1630
|
+
}
|
1580
1631
|
} else {
|
1581
|
-
if (result)
|
1582
|
-
|
1632
|
+
if (result) {
|
1633
|
+
this.walkExpression(expression.consequent);
|
1634
|
+
} else if (expression.alternate) {
|
1635
|
+
this.walkExpression(expression.alternate);
|
1636
|
+
}
|
1583
1637
|
}
|
1584
1638
|
}
|
1585
1639
|
|
@@ -1596,21 +1650,30 @@ class Parser extends Tapable {
|
|
1596
1650
|
}
|
1597
1651
|
|
1598
1652
|
this.walkExpression(expression.callee);
|
1599
|
-
if (expression.arguments)
|
1653
|
+
if (expression.arguments) {
|
1654
|
+
this.walkExpressions(expression.arguments);
|
1655
|
+
}
|
1600
1656
|
}
|
1601
1657
|
|
1602
1658
|
walkYieldExpression(expression) {
|
1603
|
-
if (expression.argument)
|
1659
|
+
if (expression.argument) {
|
1660
|
+
this.walkExpression(expression.argument);
|
1661
|
+
}
|
1604
1662
|
}
|
1605
1663
|
|
1606
1664
|
walkTemplateLiteral(expression) {
|
1607
|
-
if (expression.expressions)
|
1665
|
+
if (expression.expressions) {
|
1666
|
+
this.walkExpressions(expression.expressions);
|
1667
|
+
}
|
1608
1668
|
}
|
1609
1669
|
|
1610
1670
|
walkTaggedTemplateExpression(expression) {
|
1611
|
-
if (expression.tag)
|
1612
|
-
|
1671
|
+
if (expression.tag) {
|
1672
|
+
this.walkExpression(expression.tag);
|
1673
|
+
}
|
1674
|
+
if (expression.quasi && expression.quasi.expressions) {
|
1613
1675
|
this.walkExpressions(expression.quasi.expressions);
|
1676
|
+
}
|
1614
1677
|
}
|
1615
1678
|
|
1616
1679
|
walkClassExpression(expression) {
|
@@ -1624,8 +1687,9 @@ class Parser extends Tapable {
|
|
1624
1687
|
const hook = this.hooks.canRename.get(renameIdentifier);
|
1625
1688
|
if (hook !== undefined && hook.call(argOrThis)) {
|
1626
1689
|
const hook = this.hooks.rename.get(renameIdentifier);
|
1627
|
-
if (hook === undefined || !hook.call(argOrThis))
|
1690
|
+
if (hook === undefined || !hook.call(argOrThis)) {
|
1628
1691
|
return renameIdentifier;
|
1692
|
+
}
|
1629
1693
|
}
|
1630
1694
|
}
|
1631
1695
|
this.walkExpression(argOrThis);
|
@@ -1852,11 +1916,12 @@ class Parser extends Tapable {
|
|
1852
1916
|
parseString(expression) {
|
1853
1917
|
switch (expression.type) {
|
1854
1918
|
case "BinaryExpression":
|
1855
|
-
if (expression.operator === "+")
|
1919
|
+
if (expression.operator === "+") {
|
1856
1920
|
return (
|
1857
1921
|
this.parseString(expression.left) +
|
1858
1922
|
this.parseString(expression.right)
|
1859
1923
|
);
|
1924
|
+
}
|
1860
1925
|
break;
|
1861
1926
|
case "Literal":
|
1862
1927
|
return expression.value + "";
|
@@ -1903,12 +1968,20 @@ class Parser extends Tapable {
|
|
1903
1968
|
const consequent = this.parseCalculatedString(expression.consequent);
|
1904
1969
|
const alternate = this.parseCalculatedString(expression.alternate);
|
1905
1970
|
const items = [];
|
1906
|
-
if (consequent.conditional)
|
1907
|
-
|
1908
|
-
else
|
1909
|
-
|
1910
|
-
else
|
1911
|
-
|
1971
|
+
if (consequent.conditional) {
|
1972
|
+
items.push(...consequent.conditional);
|
1973
|
+
} else if (!consequent.code) {
|
1974
|
+
items.push(consequent);
|
1975
|
+
} else {
|
1976
|
+
break;
|
1977
|
+
}
|
1978
|
+
if (alternate.conditional) {
|
1979
|
+
items.push(...alternate.conditional);
|
1980
|
+
} else if (!alternate.code) {
|
1981
|
+
items.push(alternate);
|
1982
|
+
} else {
|
1983
|
+
break;
|
1984
|
+
}
|
1912
1985
|
return {
|
1913
1986
|
range: undefined,
|
1914
1987
|
value: "",
|
@@ -1975,8 +2048,9 @@ class Parser extends Tapable {
|
|
1975
2048
|
sourceType: this.sourceType,
|
1976
2049
|
locations: false
|
1977
2050
|
});
|
1978
|
-
if (ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement")
|
2051
|
+
if (ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement") {
|
1979
2052
|
throw new Error("evaluate: Source is not a expression");
|
2053
|
+
}
|
1980
2054
|
return this.evaluateExpression(ast.body[0].expression);
|
1981
2055
|
}
|
1982
2056
|
|
@@ -2029,8 +2103,12 @@ class Parser extends Tapable {
|
|
2029
2103
|
return null;
|
2030
2104
|
}
|
2031
2105
|
let prefix = "";
|
2032
|
-
for (let i = exprName.length - 1; i >= 2; i--)
|
2033
|
-
|
2106
|
+
for (let i = exprName.length - 1; i >= 2; i--) {
|
2107
|
+
prefix += exprName[i] + ".";
|
2108
|
+
}
|
2109
|
+
if (exprName.length > 1) {
|
2110
|
+
prefix += exprName[1];
|
2111
|
+
}
|
2034
2112
|
const name = prefix ? prefix + "." + exprName[0] : exprName[0];
|
2035
2113
|
const nameGeneral = prefix;
|
2036
2114
|
return {
|
package/lib/ParserHelpers.js
CHANGED
@@ -72,8 +72,11 @@ ParserHelpers.evaluateToIdentifier = (identifier, truthy) => {
|
|
72
72
|
let evex = new BasicEvaluatedExpression()
|
73
73
|
.setIdentifier(identifier)
|
74
74
|
.setRange(expr.range);
|
75
|
-
if (truthy === true)
|
76
|
-
|
75
|
+
if (truthy === true) {
|
76
|
+
evex = evex.setTruthy();
|
77
|
+
} else if (truthy === false) {
|
78
|
+
evex = evex.setFalsy();
|
79
|
+
}
|
77
80
|
return evex;
|
78
81
|
};
|
79
82
|
};
|
package/lib/ProgressPlugin.js
CHANGED
@@ -101,7 +101,7 @@ class ProgressPlugin {
|
|
101
101
|
|
102
102
|
const update = module => {
|
103
103
|
handler(
|
104
|
-
0.1 + doneModules / Math.max(lastModulesCount, moduleCount) * 0.6,
|
104
|
+
0.1 + (doneModules / Math.max(lastModulesCount, moduleCount)) * 0.6,
|
105
105
|
"building modules",
|
106
106
|
`${doneModules}/${moduleCount} modules`,
|
107
107
|
`${activeModules.length} active`,
|
@@ -187,7 +187,7 @@ class ProgressPlugin {
|
|
187
187
|
const numberOfHooks = Object.keys(hooks).length;
|
188
188
|
Object.keys(hooks).forEach((name, idx) => {
|
189
189
|
const title = hooks[name];
|
190
|
-
const percentage = idx / numberOfHooks * 0.25 + 0.7;
|
190
|
+
const percentage = (idx / numberOfHooks) * 0.25 + 0.7;
|
191
191
|
compilation.hooks[name].intercept({
|
192
192
|
name: "ProgressPlugin",
|
193
193
|
context: true,
|
package/lib/RawModule.js
CHANGED
@@ -42,9 +42,11 @@ module.exports = class RawModule extends Module {
|
|
42
42
|
}
|
43
43
|
|
44
44
|
source() {
|
45
|
-
if (this.useSourceMap)
|
45
|
+
if (this.useSourceMap) {
|
46
46
|
return new OriginalSource(this.sourceStr, this.identifier());
|
47
|
-
else
|
47
|
+
} else {
|
48
|
+
return new RawSource(this.sourceStr);
|
49
|
+
}
|
48
50
|
}
|
49
51
|
|
50
52
|
updateHash(hash) {
|
package/lib/RecordIdsPlugin.js
CHANGED
@@ -56,18 +56,20 @@ class RecordIdsPlugin {
|
|
56
56
|
module.id = id;
|
57
57
|
}
|
58
58
|
}
|
59
|
-
if (Array.isArray(records.modules.usedIds))
|
59
|
+
if (Array.isArray(records.modules.usedIds)) {
|
60
60
|
compilation.usedModuleIds = new Set(records.modules.usedIds);
|
61
|
+
}
|
61
62
|
}
|
62
63
|
);
|
63
64
|
|
64
65
|
const getModuleIdentifier = module => {
|
65
|
-
if (portableIds)
|
66
|
+
if (portableIds) {
|
66
67
|
return identifierUtils.makePathsRelative(
|
67
68
|
compiler.context,
|
68
69
|
module.identifier(),
|
69
70
|
compilation.cache
|
70
71
|
);
|
72
|
+
}
|
71
73
|
return module.identifier();
|
72
74
|
};
|
73
75
|
|
@@ -77,26 +79,27 @@ class RecordIdsPlugin {
|
|
77
79
|
const index = chunkGroup.chunks.indexOf(chunk);
|
78
80
|
for (const origin of chunkGroup.origins) {
|
79
81
|
if (origin.module) {
|
80
|
-
if (origin.request)
|
82
|
+
if (origin.request) {
|
81
83
|
sources.push(
|
82
84
|
`${index} ${getModuleIdentifier(origin.module)} ${
|
83
85
|
origin.request
|
84
86
|
}`
|
85
87
|
);
|
86
|
-
else if (typeof origin.loc === "string")
|
88
|
+
} else if (typeof origin.loc === "string") {
|
87
89
|
sources.push(
|
88
90
|
`${index} ${getModuleIdentifier(origin.module)} ${origin.loc}`
|
89
91
|
);
|
90
|
-
else if (
|
92
|
+
} else if (
|
91
93
|
origin.loc &&
|
92
94
|
typeof origin.loc === "object" &&
|
93
95
|
origin.loc.start
|
94
|
-
)
|
96
|
+
) {
|
95
97
|
sources.push(
|
96
98
|
`${index} ${getModuleIdentifier(
|
97
99
|
origin.module
|
98
100
|
)} ${JSON.stringify(origin.loc.start)}`
|
99
101
|
);
|
102
|
+
}
|
100
103
|
}
|
101
104
|
}
|
102
105
|
}
|
@@ -152,8 +155,9 @@ class RecordIdsPlugin {
|
|
152
155
|
}
|
153
156
|
}
|
154
157
|
}
|
155
|
-
if (Array.isArray(records.chunks.usedIds))
|
158
|
+
if (Array.isArray(records.chunks.usedIds)) {
|
156
159
|
compilation.usedChunkIds = new Set(records.chunks.usedIds);
|
160
|
+
}
|
157
161
|
}
|
158
162
|
);
|
159
163
|
});
|
package/lib/RequestShortener.js
CHANGED
@@ -23,8 +23,9 @@ const createRegExpForPath = path => {
|
|
23
23
|
class RequestShortener {
|
24
24
|
constructor(directory) {
|
25
25
|
directory = normalizeBackSlashDirection(directory);
|
26
|
-
if (SEPARATOR_REGEXP.test(directory))
|
26
|
+
if (SEPARATOR_REGEXP.test(directory)) {
|
27
27
|
directory = directory.substr(0, directory.length - 1);
|
28
|
+
}
|
28
29
|
|
29
30
|
if (directory) {
|
30
31
|
this.currentDirectoryRegExp = createRegExpForPath(directory);
|
@@ -54,16 +55,22 @@ class RequestShortener {
|
|
54
55
|
shorten(request) {
|
55
56
|
if (!request) return request;
|
56
57
|
const cacheEntry = this.cache.get(request);
|
57
|
-
if (cacheEntry !== undefined)
|
58
|
+
if (cacheEntry !== undefined) {
|
59
|
+
return cacheEntry;
|
60
|
+
}
|
58
61
|
let result = normalizeBackSlashDirection(request);
|
59
|
-
if (this.buildinsAsModule && this.buildinsRegExp)
|
62
|
+
if (this.buildinsAsModule && this.buildinsRegExp) {
|
60
63
|
result = result.replace(this.buildinsRegExp, "!(webpack)");
|
61
|
-
|
64
|
+
}
|
65
|
+
if (this.currentDirectoryRegExp) {
|
62
66
|
result = result.replace(this.currentDirectoryRegExp, "!.");
|
63
|
-
|
67
|
+
}
|
68
|
+
if (this.parentDirectoryRegExp) {
|
64
69
|
result = result.replace(this.parentDirectoryRegExp, "!..");
|
65
|
-
|
70
|
+
}
|
71
|
+
if (!this.buildinsAsModule && this.buildinsRegExp) {
|
66
72
|
result = result.replace(this.buildinsRegExp, "!(webpack)");
|
73
|
+
}
|
67
74
|
result = result.replace(INDEX_JS_REGEXP, "$1");
|
68
75
|
result = result.replace(FRONT_OR_BACK_BANG_REGEXP, "");
|
69
76
|
this.cache.set(request, result);
|