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
@@ -43,9 +43,7 @@ class ImportParserPlugin {
|
|
43
43
|
const { comment } = e;
|
44
44
|
parser.state.module.warnings.push(
|
45
45
|
new CommentCompilationWarning(
|
46
|
-
`Compilation error while processing magic comment(-s): /*${
|
47
|
-
comment.value
|
48
|
-
}*/: ${e.message}`,
|
46
|
+
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
|
49
47
|
parser.state.module,
|
50
48
|
comment.loc
|
51
49
|
)
|
@@ -59,9 +57,7 @@ class ImportParserPlugin {
|
|
59
57
|
parser.state.module.warnings.push(
|
60
58
|
new UnsupportedFeatureWarning(
|
61
59
|
parser.state.module,
|
62
|
-
`\`webpackIgnore\` expected a boolean, but received: ${
|
63
|
-
importOptions.webpackIgnore
|
64
|
-
}.`,
|
60
|
+
`\`webpackIgnore\` expected a boolean, but received: ${importOptions.webpackIgnore}.`,
|
65
61
|
expr.loc
|
66
62
|
)
|
67
63
|
);
|
@@ -77,9 +73,7 @@ class ImportParserPlugin {
|
|
77
73
|
parser.state.module.warnings.push(
|
78
74
|
new UnsupportedFeatureWarning(
|
79
75
|
parser.state.module,
|
80
|
-
`\`webpackChunkName\` expected a string, but received: ${
|
81
|
-
importOptions.webpackChunkName
|
82
|
-
}.`,
|
76
|
+
`\`webpackChunkName\` expected a string, but received: ${importOptions.webpackChunkName}.`,
|
83
77
|
expr.loc
|
84
78
|
)
|
85
79
|
);
|
@@ -92,9 +86,7 @@ class ImportParserPlugin {
|
|
92
86
|
parser.state.module.warnings.push(
|
93
87
|
new UnsupportedFeatureWarning(
|
94
88
|
parser.state.module,
|
95
|
-
`\`webpackMode\` expected a string, but received: ${
|
96
|
-
importOptions.webpackMode
|
97
|
-
}.`,
|
89
|
+
`\`webpackMode\` expected a string, but received: ${importOptions.webpackMode}.`,
|
98
90
|
expr.loc
|
99
91
|
)
|
100
92
|
);
|
@@ -111,9 +103,7 @@ class ImportParserPlugin {
|
|
111
103
|
parser.state.module.warnings.push(
|
112
104
|
new UnsupportedFeatureWarning(
|
113
105
|
parser.state.module,
|
114
|
-
`\`webpackPrefetch\` expected true or a number, but received: ${
|
115
|
-
importOptions.webpackPrefetch
|
116
|
-
}.`,
|
106
|
+
`\`webpackPrefetch\` expected true or a number, but received: ${importOptions.webpackPrefetch}.`,
|
117
107
|
expr.loc
|
118
108
|
)
|
119
109
|
);
|
@@ -128,9 +118,7 @@ class ImportParserPlugin {
|
|
128
118
|
parser.state.module.warnings.push(
|
129
119
|
new UnsupportedFeatureWarning(
|
130
120
|
parser.state.module,
|
131
|
-
`\`webpackPreload\` expected true or a number, but received: ${
|
132
|
-
importOptions.webpackPreload
|
133
|
-
}.`,
|
121
|
+
`\`webpackPreload\` expected true or a number, but received: ${importOptions.webpackPreload}.`,
|
134
122
|
expr.loc
|
135
123
|
)
|
136
124
|
);
|
@@ -144,9 +132,7 @@ class ImportParserPlugin {
|
|
144
132
|
parser.state.module.warnings.push(
|
145
133
|
new UnsupportedFeatureWarning(
|
146
134
|
parser.state.module,
|
147
|
-
`\`webpackInclude\` expected a regular expression, but received: ${
|
148
|
-
importOptions.webpackInclude
|
149
|
-
}.`,
|
135
|
+
`\`webpackInclude\` expected a regular expression, but received: ${importOptions.webpackInclude}.`,
|
150
136
|
expr.loc
|
151
137
|
)
|
152
138
|
);
|
@@ -162,9 +148,7 @@ class ImportParserPlugin {
|
|
162
148
|
parser.state.module.warnings.push(
|
163
149
|
new UnsupportedFeatureWarning(
|
164
150
|
parser.state.module,
|
165
|
-
`\`webpackExclude\` expected a regular expression, but received: ${
|
166
|
-
importOptions.webpackExclude
|
167
|
-
}.`,
|
151
|
+
`\`webpackExclude\` expected a regular expression, but received: ${importOptions.webpackExclude}.`,
|
168
152
|
expr.loc
|
169
153
|
)
|
170
154
|
);
|
@@ -49,9 +49,7 @@ class LoaderPlugin {
|
|
49
49
|
if (factory === undefined) {
|
50
50
|
return callback(
|
51
51
|
new Error(
|
52
|
-
`No module factory available for dependency type: ${
|
53
|
-
dep.constructor.name
|
54
|
-
}`
|
52
|
+
`No module factory available for dependency type: ${dep.constructor.name}`
|
55
53
|
)
|
56
54
|
);
|
57
55
|
}
|
@@ -40,9 +40,7 @@ class WebAssemblyImportDependency extends ModuleDependency {
|
|
40
40
|
) {
|
41
41
|
return [
|
42
42
|
new UnsupportedWebAssemblyFeatureError(
|
43
|
-
`Import "${this.name}" from "${this.request}" with ${
|
44
|
-
this.onlyDirectImport
|
45
|
-
} can only be used for direct wasm to wasm dependencies`
|
43
|
+
`Import "${this.name}" from "${this.request}" with ${this.onlyDirectImport} can only be used for direct wasm to wasm dependencies`
|
46
44
|
)
|
47
45
|
];
|
48
46
|
}
|
@@ -26,9 +26,7 @@ class ChunkModuleIdRangePlugin {
|
|
26
26
|
);
|
27
27
|
if (!chunk) {
|
28
28
|
throw new Error(
|
29
|
-
`ChunkModuleIdRangePlugin: Chunk with name '${
|
30
|
-
options.name
|
31
|
-
}"' was not found`
|
29
|
+
`ChunkModuleIdRangePlugin: Chunk with name '${options.name}"' was not found`
|
32
30
|
);
|
33
31
|
}
|
34
32
|
|
@@ -1136,23 +1136,17 @@ class ConcatenatedModule extends Module {
|
|
1136
1136
|
if (info.interopNamespaceObjectUsed) {
|
1137
1137
|
if (info.module.buildMeta.exportsType === "named") {
|
1138
1138
|
result.add(
|
1139
|
-
`var ${
|
1140
|
-
info.interopNamespaceObjectName
|
1141
|
-
} = /*#__PURE__*/__webpack_require__.t(${info.name}, 2);\n`
|
1139
|
+
`var ${info.interopNamespaceObjectName} = /*#__PURE__*/__webpack_require__.t(${info.name}, 2);\n`
|
1142
1140
|
);
|
1143
1141
|
} else if (!info.module.buildMeta.exportsType) {
|
1144
1142
|
result.add(
|
1145
|
-
`var ${
|
1146
|
-
info.interopNamespaceObjectName
|
1147
|
-
} = /*#__PURE__*/__webpack_require__.t(${info.name});\n`
|
1143
|
+
`var ${info.interopNamespaceObjectName} = /*#__PURE__*/__webpack_require__.t(${info.name});\n`
|
1148
1144
|
);
|
1149
1145
|
}
|
1150
1146
|
}
|
1151
1147
|
if (info.interopDefaultAccessUsed) {
|
1152
1148
|
result.add(
|
1153
|
-
`var ${
|
1154
|
-
info.interopDefaultAccessName
|
1155
|
-
} = /*#__PURE__*/__webpack_require__.n(${info.name});\n`
|
1149
|
+
`var ${info.interopDefaultAccessName} = /*#__PURE__*/__webpack_require__.n(${info.name});\n`
|
1156
1150
|
);
|
1157
1151
|
}
|
1158
1152
|
break;
|
@@ -1266,9 +1260,7 @@ class HarmonyImportSpecifierDependencyConcatenatedTemplate {
|
|
1266
1260
|
}_ns${strictFlag}__[${JSON.stringify(dep._id)}]`;
|
1267
1261
|
} else {
|
1268
1262
|
const exportData = Buffer.from(dep._id, "utf-8").toString("hex");
|
1269
|
-
content = `__WEBPACK_MODULE_REFERENCE__${
|
1270
|
-
info.index
|
1271
|
-
}_${exportData}${callFlag}${strictFlag}__`;
|
1263
|
+
content = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${callFlag}${strictFlag}__`;
|
1272
1264
|
}
|
1273
1265
|
if (dep.shorthand) {
|
1274
1266
|
content = dep.name + ": " + content;
|
@@ -1464,14 +1456,10 @@ class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate {
|
|
1464
1456
|
? "_strict"
|
1465
1457
|
: "";
|
1466
1458
|
if (def.id === true) {
|
1467
|
-
finalName = `__WEBPACK_MODULE_REFERENCE__${
|
1468
|
-
info.index
|
1469
|
-
}_ns${strictFlag}__`;
|
1459
|
+
finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`;
|
1470
1460
|
} else {
|
1471
1461
|
const exportData = Buffer.from(def.id, "utf-8").toString("hex");
|
1472
|
-
finalName = `__WEBPACK_MODULE_REFERENCE__${
|
1473
|
-
info.index
|
1474
|
-
}_${exportData}${strictFlag}__`;
|
1462
|
+
finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${strictFlag}__`;
|
1475
1463
|
}
|
1476
1464
|
const exportsName = this.rootModule.exportsArgument;
|
1477
1465
|
const content =
|
@@ -123,9 +123,11 @@ module.exports = class SplitChunksPlugin {
|
|
123
123
|
getCacheGroups: SplitChunksPlugin.normalizeCacheGroups({
|
124
124
|
cacheGroups: options.cacheGroups,
|
125
125
|
name: options.name,
|
126
|
-
automaticNameDelimiter: options.automaticNameDelimiter
|
126
|
+
automaticNameDelimiter: options.automaticNameDelimiter,
|
127
|
+
automaticNameMaxLength: options.automaticNameMaxLength
|
127
128
|
}),
|
128
129
|
automaticNameDelimiter: options.automaticNameDelimiter,
|
130
|
+
automaticNameMaxLength: options.automaticNameMaxLength || 109,
|
129
131
|
fallbackCacheGroup: SplitChunksPlugin.normalizeFallbackCacheGroup(
|
130
132
|
options.fallbackCacheGroup || {},
|
131
133
|
options
|
@@ -133,7 +135,12 @@ module.exports = class SplitChunksPlugin {
|
|
133
135
|
};
|
134
136
|
}
|
135
137
|
|
136
|
-
static normalizeName({
|
138
|
+
static normalizeName({
|
139
|
+
name,
|
140
|
+
automaticNameDelimiter,
|
141
|
+
automaticNamePrefix,
|
142
|
+
automaticNameMaxLength
|
143
|
+
}) {
|
137
144
|
if (name === true) {
|
138
145
|
/** @type {WeakMap<Chunk[], Record<string, string>>} */
|
139
146
|
const cache = new WeakMap();
|
@@ -160,11 +167,17 @@ module.exports = class SplitChunksPlugin {
|
|
160
167
|
// Filenames and paths can't be too long otherwise an
|
161
168
|
// ENAMETOOLONG error is raised. If the generated name if too
|
162
169
|
// long, it is truncated and a hash is appended. The limit has
|
163
|
-
// been set to
|
170
|
+
// been set to 109 to prevent `[name].[chunkhash].[ext]` from
|
164
171
|
// generating a 256+ character string.
|
165
|
-
if (name.length >
|
172
|
+
if (name.length > automaticNameMaxLength) {
|
173
|
+
const hashedFilename = hashFilename(name);
|
174
|
+
const sliceLength =
|
175
|
+
automaticNameMaxLength -
|
176
|
+
(automaticNameDelimiter.length + hashedFilename.length);
|
166
177
|
name =
|
167
|
-
name.slice(0,
|
178
|
+
name.slice(0, sliceLength) +
|
179
|
+
automaticNameDelimiter +
|
180
|
+
hashFilename(name);
|
168
181
|
}
|
169
182
|
cacheEntry[cacheGroup] = name;
|
170
183
|
return name;
|
@@ -213,7 +226,12 @@ module.exports = class SplitChunksPlugin {
|
|
213
226
|
};
|
214
227
|
}
|
215
228
|
|
216
|
-
static normalizeCacheGroups({
|
229
|
+
static normalizeCacheGroups({
|
230
|
+
cacheGroups,
|
231
|
+
name,
|
232
|
+
automaticNameDelimiter,
|
233
|
+
automaticNameMaxLength
|
234
|
+
}) {
|
217
235
|
if (typeof cacheGroups === "function") {
|
218
236
|
// TODO webpack 5 remove this
|
219
237
|
if (cacheGroups.length !== 1) {
|
@@ -259,7 +277,9 @@ module.exports = class SplitChunksPlugin {
|
|
259
277
|
typeof option.automaticNameDelimiter === "string"
|
260
278
|
? option.automaticNameDelimiter
|
261
279
|
: automaticNameDelimiter,
|
262
|
-
automaticNamePrefix: option.automaticNamePrefix
|
280
|
+
automaticNamePrefix: option.automaticNamePrefix,
|
281
|
+
automaticNameMaxLength:
|
282
|
+
option.automaticNameMaxLength || automaticNameMaxLength
|
263
283
|
}) || (() => {}),
|
264
284
|
chunksFilter: SplitChunksPlugin.normalizeChunksFilter(
|
265
285
|
option.chunks
|
@@ -46,9 +46,7 @@ class WasmFinalizeExportsPlugin {
|
|
46
46
|
// 4. error
|
47
47
|
/** @type {any} */
|
48
48
|
const error = new UnsupportedWebAssemblyFeatureError(
|
49
|
-
`Export "${name}" with ${
|
50
|
-
jsIncompatibleExports[name]
|
51
|
-
} can only be used for direct wasm to wasm dependencies`
|
49
|
+
`Export "${name}" with ${jsIncompatibleExports[name]} can only be used for direct wasm to wasm dependencies`
|
52
50
|
);
|
53
51
|
error.module = module;
|
54
52
|
error.origin = reason.module;
|
@@ -307,9 +307,7 @@ class WasmMainTemplatePlugin {
|
|
307
307
|
"}",
|
308
308
|
"promises.push(installedWasmModules[wasmModuleId] = promise.then(function(res) {",
|
309
309
|
Template.indent([
|
310
|
-
`return ${
|
311
|
-
mainTemplate.requireFn
|
312
|
-
}.w[wasmModuleId] = (res.instance || res).exports;`
|
310
|
+
`return ${mainTemplate.requireFn}.w[wasmModuleId] = (res.instance || res).exports;`
|
313
311
|
]),
|
314
312
|
"}));"
|
315
313
|
]),
|
@@ -188,6 +188,7 @@ class JsonpMainTemplatePlugin {
|
|
188
188
|
"var errorType = event && (event.type === 'load' ? 'missing' : event.type);",
|
189
189
|
"var realSrc = event && event.target && event.target.src;",
|
190
190
|
"error.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';",
|
191
|
+
"error.name = 'ChunkLoadError';",
|
191
192
|
"error.type = errorType;",
|
192
193
|
"error.request = realSrc;",
|
193
194
|
"chunk[1](error);"
|
@@ -340,9 +341,7 @@ class JsonpMainTemplatePlugin {
|
|
340
341
|
source,
|
341
342
|
"",
|
342
343
|
"// on error function for async loading",
|
343
|
-
`${
|
344
|
-
mainTemplate.requireFn
|
345
|
-
}.oe = function(err) { console.error(err); throw err; };`
|
344
|
+
`${mainTemplate.requireFn}.oe = function(err) { console.error(err); throw err; };`
|
346
345
|
]);
|
347
346
|
}
|
348
347
|
);
|
package/lib/webpack.js
CHANGED
@@ -32,7 +32,9 @@ const webpack = (options, callback) => {
|
|
32
32
|
}
|
33
33
|
let compiler;
|
34
34
|
if (Array.isArray(options)) {
|
35
|
-
compiler = new MultiCompiler(
|
35
|
+
compiler = new MultiCompiler(
|
36
|
+
Array.from(options).map(options => webpack(options))
|
37
|
+
);
|
36
38
|
} else if (typeof options === "object") {
|
37
39
|
options = new WebpackOptionsDefaulter().process(options);
|
38
40
|
|
@@ -45,6 +45,7 @@ class WebWorkerMainTemplatePlugin {
|
|
45
45
|
"if(!installedChunks[chunkId]) {",
|
46
46
|
Template.indent([
|
47
47
|
"importScripts(" +
|
48
|
+
"__webpack_require__.p + " +
|
48
49
|
mainTemplate.getAssetPath(JSON.stringify(chunkFilename), {
|
49
50
|
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
50
51
|
hashWithLength: length =>
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.35.2",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"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.",
|
6
6
|
"license": "MIT",
|
@@ -72,6 +72,7 @@
|
|
72
72
|
"rimraf": "^2.6.2",
|
73
73
|
"script-loader": "~0.7.0",
|
74
74
|
"simple-git": "^1.65.0",
|
75
|
+
"strip-ansi": "^5.2.0",
|
75
76
|
"style-loader": "^0.23.1",
|
76
77
|
"typescript": "^3.0.0-rc",
|
77
78
|
"url-loader": "^1.1.2",
|
@@ -553,6 +553,11 @@
|
|
553
553
|
"type": "string",
|
554
554
|
"minLength": 1
|
555
555
|
},
|
556
|
+
"automaticNameMaxLength": {
|
557
|
+
"description": "Sets the max length for the name of a created chunk",
|
558
|
+
"type": "number",
|
559
|
+
"minimum": 1
|
560
|
+
},
|
556
561
|
"cacheGroups": {
|
557
562
|
"description": "Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks)",
|
558
563
|
"type": "object",
|
@@ -582,6 +587,11 @@
|
|
582
587
|
"type": "string",
|
583
588
|
"minLength": 1
|
584
589
|
},
|
590
|
+
"automaticNameMaxLength": {
|
591
|
+
"description": "Sets the max length for the name of a created chunk",
|
592
|
+
"type": "number",
|
593
|
+
"minimum": 1
|
594
|
+
},
|
585
595
|
"automaticNamePrefix": {
|
586
596
|
"description": "Sets the name prefix for created chunks",
|
587
597
|
"type": "string"
|
@@ -1511,6 +1521,14 @@
|
|
1511
1521
|
}
|
1512
1522
|
]
|
1513
1523
|
},
|
1524
|
+
"realResource": {
|
1525
|
+
"description": "Match rules with custom resource name",
|
1526
|
+
"anyOf": [
|
1527
|
+
{
|
1528
|
+
"$ref": "#/definitions/RuleSetConditionOrConditionsAbsolute"
|
1529
|
+
}
|
1530
|
+
]
|
1531
|
+
},
|
1514
1532
|
"resolve": {
|
1515
1533
|
"description": "Options for the resolver",
|
1516
1534
|
"type": "object",
|