webpack 5.21.0 → 5.23.0
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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/lib/ChunkGraph.js +3 -2
- package/lib/CodeGenerationResults.js +2 -1
- package/lib/Compilation.js +91 -40
- package/lib/EvalDevToolModulePlugin.js +4 -0
- package/lib/EvalSourceMapDevToolPlugin.js +4 -0
- package/lib/ExportsInfo.js +1 -0
- package/lib/ExternalModule.js +8 -7
- package/lib/FlagDependencyUsagePlugin.js +7 -6
- package/lib/JavascriptMetaInfoPlugin.js +62 -0
- package/lib/LibManifestPlugin.js +1 -13
- package/lib/Module.js +2 -3
- package/lib/MultiCompiler.js +170 -77
- package/lib/MultiStats.js +9 -6
- package/lib/NormalModuleFactory.js +135 -22
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimePlugin.js +10 -1
- package/lib/Watching.js +70 -27
- package/lib/WebpackOptionsApply.js +7 -7
- package/lib/config/defaults.js +26 -10
- package/lib/config/target.js +1 -1
- package/lib/container/ContainerEntryModule.js +2 -1
- package/lib/dependencies/AMDDefineDependency.js +1 -1
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -1
- package/lib/dependencies/HarmonyExportInitFragment.js +2 -3
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +9 -2
- package/lib/dependencies/LoaderPlugin.js +9 -2
- package/lib/dependencies/URLDependency.js +35 -13
- package/lib/dependencies/URLPlugin.js +3 -1
- package/lib/dependencies/WorkerPlugin.js +7 -1
- package/lib/hmr/LazyCompilationPlugin.js +2 -2
- package/lib/index.js +1 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +15 -4
- package/lib/javascript/JavascriptModulesPlugin.js +143 -78
- package/lib/javascript/JavascriptParser.js +1 -0
- package/lib/json/JsonGenerator.js +29 -8
- package/lib/library/AbstractLibraryPlugin.js +108 -32
- package/lib/library/AmdLibraryPlugin.js +12 -6
- package/lib/library/AssignLibraryPlugin.js +137 -26
- package/lib/library/EnableLibraryPlugin.js +18 -7
- package/lib/library/ExportPropertyLibraryPlugin.js +16 -5
- package/lib/library/JsonpLibraryPlugin.js +3 -1
- package/lib/library/ModuleLibraryPlugin.js +100 -0
- package/lib/library/SystemLibraryPlugin.js +1 -1
- package/lib/node/NodeTargetPlugin.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +54 -35
- package/lib/optimize/InnerGraph.js +5 -4
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +2 -3
- package/lib/runtime/RelativeUrlRuntimeModule.js +41 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +1 -0
- package/lib/serialization/ObjectMiddleware.js +34 -19
- package/lib/stats/DefaultStatsFactoryPlugin.js +1 -12
- package/lib/stats/DefaultStatsPrinterPlugin.js +19 -6
- package/lib/util/IterableHelpers.js +46 -0
- package/lib/util/LazyBucketSortedSet.js +3 -2
- package/lib/util/SetHelpers.js +11 -0
- package/lib/webpack.js +56 -50
- package/package.json +3 -3
- package/schemas/WebpackOptions.json +8 -1
- package/types.d.ts +38 -7
- package/lib/FlagUsingEvalPlugin.js +0 -44
@@ -0,0 +1,41 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
*/
|
4
|
+
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const RuntimeGlobals = require("../RuntimeGlobals");
|
8
|
+
const Template = require("../Template");
|
9
|
+
const HelperRuntimeModule = require("./HelperRuntimeModule");
|
10
|
+
|
11
|
+
class RelativeUrlRuntimeModule extends HelperRuntimeModule {
|
12
|
+
constructor() {
|
13
|
+
super("relative url");
|
14
|
+
}
|
15
|
+
|
16
|
+
/**
|
17
|
+
* @returns {string} runtime code
|
18
|
+
*/
|
19
|
+
generate() {
|
20
|
+
const { runtimeTemplate } = this.compilation;
|
21
|
+
return Template.asString([
|
22
|
+
`${RuntimeGlobals.relativeUrl} = function RelativeURL(url) {`,
|
23
|
+
Template.indent([
|
24
|
+
'var realUrl = new URL(url, "x:/");',
|
25
|
+
"var values = {};",
|
26
|
+
"for (var key in realUrl) values[key] = realUrl[key];",
|
27
|
+
"values.href = url;",
|
28
|
+
'values.pathname = url.replace(/[?#].*/, "");',
|
29
|
+
'values.origin = values.protocol = "";',
|
30
|
+
`values.toString = values.toJSON = ${runtimeTemplate.returningFunction(
|
31
|
+
"url"
|
32
|
+
)};`,
|
33
|
+
"for (var key in values) Object.defineProperty(this, key, Object.assign({ enumerable: true, configurable: true, value: values[key] }));"
|
34
|
+
]),
|
35
|
+
"};",
|
36
|
+
`${RuntimeGlobals.relativeUrl}.prototype = URL.prototype;`
|
37
|
+
]);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
module.exports = RelativeUrlRuntimeModule;
|
@@ -56,6 +56,7 @@ class StartupChunkDependenciesPlugin {
|
|
56
56
|
.for(RuntimeGlobals.startupEntrypoint)
|
57
57
|
.tap("StartupChunkDependenciesPlugin", (chunk, set) => {
|
58
58
|
if (!isEnabledForChunk(chunk)) return;
|
59
|
+
set.add(RuntimeGlobals.require);
|
59
60
|
set.add(RuntimeGlobals.ensureChunk);
|
60
61
|
set.add(RuntimeGlobals.ensureChunkIncludeEntries);
|
61
62
|
compilation.addRuntimeModule(
|
@@ -208,12 +208,14 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
208
208
|
}
|
209
209
|
|
210
210
|
static getSerializerFor(object) {
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
211
|
+
const proto = Object.getPrototypeOf(object);
|
212
|
+
let c;
|
213
|
+
if (proto === null) {
|
214
|
+
// Object created with Object.create(null)
|
215
|
+
c = null;
|
216
|
+
} else {
|
217
|
+
c = proto.constructor;
|
218
|
+
if (!c) {
|
217
219
|
throw new Error(
|
218
220
|
"Serialization of objects with prototype without valid constructor property not possible"
|
219
221
|
);
|
@@ -238,6 +240,12 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
238
240
|
return serializer;
|
239
241
|
}
|
240
242
|
|
243
|
+
static _getDeserializerForWithoutError(request, name) {
|
244
|
+
const key = request + "/" + name;
|
245
|
+
const serializer = serializerInversed.get(key);
|
246
|
+
return serializer;
|
247
|
+
}
|
248
|
+
|
241
249
|
/**
|
242
250
|
* @param {DeserializedType} data data
|
243
251
|
* @param {Object} context context object
|
@@ -577,25 +585,32 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
577
585
|
}
|
578
586
|
const name = read();
|
579
587
|
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
588
|
+
serializer = ObjectMiddleware._getDeserializerForWithoutError(
|
589
|
+
request,
|
590
|
+
name
|
591
|
+
);
|
592
|
+
|
593
|
+
if (serializer === undefined) {
|
594
|
+
if (request && !loadedRequests.has(request)) {
|
595
|
+
let loaded = false;
|
596
|
+
for (const [regExp, loader] of loaders) {
|
597
|
+
if (regExp.test(request)) {
|
598
|
+
if (loader(request)) {
|
599
|
+
loaded = true;
|
600
|
+
break;
|
601
|
+
}
|
587
602
|
}
|
588
603
|
}
|
589
|
-
|
590
|
-
|
591
|
-
|
604
|
+
if (!loaded) {
|
605
|
+
require(request);
|
606
|
+
}
|
607
|
+
|
608
|
+
loadedRequests.add(request);
|
592
609
|
}
|
593
610
|
|
594
|
-
|
611
|
+
serializer = ObjectMiddleware.getDeserializerFor(request, name);
|
595
612
|
}
|
596
613
|
|
597
|
-
serializer = ObjectMiddleware.getDeserializerFor(request, name);
|
598
|
-
|
599
614
|
objectTypeLookup.push(serializer);
|
600
615
|
currentPosTypeLookup++;
|
601
616
|
}
|
@@ -12,6 +12,7 @@ const { LogType } = require("../logging/Logger");
|
|
12
12
|
const AggressiveSplittingPlugin = require("../optimize/AggressiveSplittingPlugin");
|
13
13
|
const ConcatenatedModule = require("../optimize/ConcatenatedModule");
|
14
14
|
const SizeLimitsPlugin = require("../performance/SizeLimitsPlugin");
|
15
|
+
const { countIterable } = require("../util/IterableHelpers");
|
15
16
|
const {
|
16
17
|
compareLocations,
|
17
18
|
compareChunksById,
|
@@ -360,18 +361,6 @@ const mapObject = (obj, fn) => {
|
|
360
361
|
return newObj;
|
361
362
|
};
|
362
363
|
|
363
|
-
/**
|
364
|
-
* @template T
|
365
|
-
* @param {Iterable<T>} iterable an iterable
|
366
|
-
* @returns {number} count of items
|
367
|
-
*/
|
368
|
-
const countIterable = iterable => {
|
369
|
-
let i = 0;
|
370
|
-
// eslint-disable-next-line no-unused-vars
|
371
|
-
for (const _ of iterable) i++;
|
372
|
-
return i;
|
373
|
-
};
|
374
|
-
|
375
364
|
/**
|
376
365
|
* @param {Compilation} compilation the compilation
|
377
366
|
* @param {function(Compilation, string): any[]} getItems get items
|
@@ -106,6 +106,7 @@ const SIMPLE_PRINTERS = {
|
|
106
106
|
versionMessage ||
|
107
107
|
errorsMessage ||
|
108
108
|
warningsMessage ||
|
109
|
+
(errorsCount === 0 && warningsCount === 0) ||
|
109
110
|
timeMessage ||
|
110
111
|
hashMessage
|
111
112
|
)
|
@@ -192,7 +193,11 @@ const SIMPLE_PRINTERS = {
|
|
192
193
|
childWarnings,
|
193
194
|
"WARNING",
|
194
195
|
"WARNINGS"
|
195
|
-
)} in child compilations
|
196
|
+
)} in child compilations${
|
197
|
+
compilation.children
|
198
|
+
? ""
|
199
|
+
: " (Use 'stats.children: true' resp. '--stats-children' for more details)"
|
200
|
+
}`
|
196
201
|
);
|
197
202
|
}
|
198
203
|
}
|
@@ -210,7 +215,11 @@ const SIMPLE_PRINTERS = {
|
|
210
215
|
childErrors,
|
211
216
|
"ERROR",
|
212
217
|
"ERRORS"
|
213
|
-
)} in child compilations
|
218
|
+
)} in child compilations${
|
219
|
+
compilation.children
|
220
|
+
? ""
|
221
|
+
: " (Use 'stats.children: true' resp. '--stats-children' for more details)"
|
222
|
+
}`
|
214
223
|
);
|
215
224
|
}
|
216
225
|
}
|
@@ -1186,10 +1195,14 @@ class DefaultStatsPrinterPlugin {
|
|
1186
1195
|
}
|
1187
1196
|
if (start) {
|
1188
1197
|
context[color] = str =>
|
1189
|
-
`${start}${
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1198
|
+
`${start}${
|
1199
|
+
typeof str === "string"
|
1200
|
+
? str.replace(
|
1201
|
+
/((\u001b\[39m|\u001b\[22m|\u001b\[0m)+)/g,
|
1202
|
+
`$1${start}`
|
1203
|
+
)
|
1204
|
+
: str
|
1205
|
+
}\u001b[39m\u001b[22m`;
|
1193
1206
|
} else {
|
1194
1207
|
context[color] = str => str;
|
1195
1208
|
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @template T
|
10
|
+
* @param {Iterable<T>} set a set
|
11
|
+
* @returns {T | undefined} last item
|
12
|
+
*/
|
13
|
+
const last = set => {
|
14
|
+
let last;
|
15
|
+
for (const item of set) last = item;
|
16
|
+
return last;
|
17
|
+
};
|
18
|
+
|
19
|
+
/**
|
20
|
+
* @template T
|
21
|
+
* @param {Iterable<T>} iterable iterable
|
22
|
+
* @param {function(T): boolean} filter predicate
|
23
|
+
* @returns {boolean} true, if some items match the filter predicate
|
24
|
+
*/
|
25
|
+
const someInIterable = (iterable, filter) => {
|
26
|
+
for (const item of iterable) {
|
27
|
+
if (filter(item)) return true;
|
28
|
+
}
|
29
|
+
return false;
|
30
|
+
};
|
31
|
+
|
32
|
+
/**
|
33
|
+
* @template T
|
34
|
+
* @param {Iterable<T>} iterable an iterable
|
35
|
+
* @returns {number} count of items
|
36
|
+
*/
|
37
|
+
const countIterable = iterable => {
|
38
|
+
let i = 0;
|
39
|
+
// eslint-disable-next-line no-unused-vars
|
40
|
+
for (const _ of iterable) i++;
|
41
|
+
return i;
|
42
|
+
};
|
43
|
+
|
44
|
+
exports.last = last;
|
45
|
+
exports.someInIterable = someInIterable;
|
46
|
+
exports.countIterable = countIterable;
|
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const { first } = require("./SetHelpers");
|
8
9
|
const SortableSet = require("./SortableSet");
|
9
10
|
|
10
11
|
/**
|
@@ -103,12 +104,12 @@ class LazyBucketSortedSet {
|
|
103
104
|
this._unsortedItems.clear();
|
104
105
|
}
|
105
106
|
this._keys.sort();
|
106
|
-
const key = this._keys
|
107
|
+
const key = first(this._keys);
|
107
108
|
const entry = this._map.get(key);
|
108
109
|
if (this._leaf) {
|
109
110
|
const leafEntry = /** @type {SortableSet<T>} */ (entry);
|
110
111
|
leafEntry.sort();
|
111
|
-
const item = leafEntry
|
112
|
+
const item = first(leafEntry);
|
112
113
|
leafEntry.delete(item);
|
113
114
|
if (leafEntry.size === 0) {
|
114
115
|
this._deleteKey(key);
|
package/lib/util/SetHelpers.js
CHANGED
@@ -63,6 +63,17 @@ const find = (set, fn) => {
|
|
63
63
|
}
|
64
64
|
};
|
65
65
|
|
66
|
+
/**
|
67
|
+
* @template T
|
68
|
+
* @param {Set<T>} set a set
|
69
|
+
* @returns {T | undefined} first item
|
70
|
+
*/
|
71
|
+
const first = set => {
|
72
|
+
const entry = set.values().next();
|
73
|
+
return entry.done ? undefined : entry.value;
|
74
|
+
};
|
75
|
+
|
66
76
|
exports.intersect = intersect;
|
67
77
|
exports.isSubset = isSubset;
|
68
78
|
exports.find = find;
|
79
|
+
exports.first = first;
|
package/lib/webpack.js
CHANGED
@@ -20,6 +20,7 @@ const validateSchema = require("./validateSchema");
|
|
20
20
|
|
21
21
|
/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
|
22
22
|
/** @typedef {import("./Compiler").WatchOptions} WatchOptions */
|
23
|
+
/** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */
|
23
24
|
/** @typedef {import("./MultiStats")} MultiStats */
|
24
25
|
/** @typedef {import("./Stats")} Stats */
|
25
26
|
|
@@ -33,11 +34,12 @@ const validateSchema = require("./validateSchema");
|
|
33
34
|
|
34
35
|
/**
|
35
36
|
* @param {WebpackOptions[]} childOptions options array
|
37
|
+
* @param {MultiCompilerOptions} options options
|
36
38
|
* @returns {MultiCompiler} a multi-compiler
|
37
39
|
*/
|
38
|
-
const createMultiCompiler = childOptions => {
|
40
|
+
const createMultiCompiler = (childOptions, options) => {
|
39
41
|
const compilers = childOptions.map(options => createCompiler(options));
|
40
|
-
const compiler = new MultiCompiler(compilers);
|
42
|
+
const compiler = new MultiCompiler(compilers, options);
|
41
43
|
for (const childCompiler of compilers) {
|
42
44
|
if (childCompiler.options.dependencies) {
|
43
45
|
compiler.setDependencies(
|
@@ -87,63 +89,67 @@ const createCompiler = rawOptions => {
|
|
87
89
|
|
88
90
|
/**
|
89
91
|
* @callback WebpackFunctionMulti
|
90
|
-
* @param {WebpackOptions[]} options options objects
|
92
|
+
* @param {WebpackOptions[] & MultiCompilerOptions} options options objects
|
91
93
|
* @param {Callback<MultiStats>=} callback callback
|
92
94
|
* @returns {MultiCompiler} the multi compiler object
|
93
95
|
*/
|
94
96
|
|
95
|
-
const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
/** @type {
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
watch = options.watch;
|
115
|
-
watchOptions = options.watchOptions || {};
|
116
|
-
}
|
117
|
-
return { compiler, watch, watchOptions };
|
118
|
-
};
|
119
|
-
if (callback) {
|
120
|
-
try {
|
121
|
-
const { compiler, watch, watchOptions } = create();
|
122
|
-
if (watch) {
|
123
|
-
compiler.watch(watchOptions, callback);
|
97
|
+
const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
|
98
|
+
/**
|
99
|
+
* @param {WebpackOptions | (WebpackOptions[] & MultiCompilerOptions)} options options
|
100
|
+
* @param {Callback<Stats> & Callback<MultiStats>=} callback callback
|
101
|
+
* @returns {Compiler | MultiCompiler}
|
102
|
+
*/
|
103
|
+
(options, callback) => {
|
104
|
+
const create = () => {
|
105
|
+
validateSchema(webpackOptionsSchema, options);
|
106
|
+
/** @type {MultiCompiler|Compiler} */
|
107
|
+
let compiler;
|
108
|
+
let watch = false;
|
109
|
+
/** @type {WatchOptions|WatchOptions[]} */
|
110
|
+
let watchOptions;
|
111
|
+
if (Array.isArray(options)) {
|
112
|
+
/** @type {MultiCompiler} */
|
113
|
+
compiler = createMultiCompiler(options, options);
|
114
|
+
watch = options.some(options => options.watch);
|
115
|
+
watchOptions = options.map(options => options.watchOptions || {});
|
124
116
|
} else {
|
125
|
-
|
126
|
-
|
127
|
-
|
117
|
+
/** @type {Compiler} */
|
118
|
+
compiler = createCompiler(options);
|
119
|
+
watch = options.watch;
|
120
|
+
watchOptions = options.watchOptions || {};
|
121
|
+
}
|
122
|
+
return { compiler, watch, watchOptions };
|
123
|
+
};
|
124
|
+
if (callback) {
|
125
|
+
try {
|
126
|
+
const { compiler, watch, watchOptions } = create();
|
127
|
+
if (watch) {
|
128
|
+
compiler.watch(watchOptions, callback);
|
129
|
+
} else {
|
130
|
+
compiler.run((err, stats) => {
|
131
|
+
compiler.close(err2 => {
|
132
|
+
callback(err || err2, stats);
|
133
|
+
});
|
128
134
|
});
|
129
|
-
}
|
135
|
+
}
|
136
|
+
return compiler;
|
137
|
+
} catch (err) {
|
138
|
+
process.nextTick(() => callback(err));
|
139
|
+
return null;
|
140
|
+
}
|
141
|
+
} else {
|
142
|
+
const { compiler, watch } = create();
|
143
|
+
if (watch) {
|
144
|
+
util.deprecate(
|
145
|
+
() => {},
|
146
|
+
"A 'callback' argument need to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.",
|
147
|
+
"DEP_WEBPACK_WATCH_WITHOUT_CALLBACK"
|
148
|
+
)();
|
130
149
|
}
|
131
150
|
return compiler;
|
132
|
-
} catch (err) {
|
133
|
-
process.nextTick(() => callback(err));
|
134
|
-
return null;
|
135
|
-
}
|
136
|
-
} else {
|
137
|
-
const { compiler, watch } = create();
|
138
|
-
if (watch) {
|
139
|
-
util.deprecate(
|
140
|
-
() => {},
|
141
|
-
"A 'callback' argument need to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.",
|
142
|
-
"DEP_WEBPACK_WATCH_WITHOUT_CALLBACK"
|
143
|
-
)();
|
144
151
|
}
|
145
|
-
return compiler;
|
146
152
|
}
|
147
|
-
|
153
|
+
);
|
148
154
|
|
149
155
|
module.exports = webpack;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.23.0",
|
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",
|
@@ -55,12 +55,12 @@
|
|
55
55
|
"eslint": "^7.14.0",
|
56
56
|
"eslint-config-prettier": "^7.0.0",
|
57
57
|
"eslint-plugin-jest": "^24.1.3",
|
58
|
-
"eslint-plugin-jsdoc": "^
|
58
|
+
"eslint-plugin-jsdoc": "^32.0.2",
|
59
59
|
"eslint-plugin-node": "^11.0.0",
|
60
60
|
"eslint-plugin-prettier": "^3.1.4",
|
61
61
|
"file-loader": "^6.0.0",
|
62
62
|
"fork-ts-checker-webpack-plugin": "^6.0.5",
|
63
|
-
"husky": "^
|
63
|
+
"husky": "^5.0.9",
|
64
64
|
"is-ci": "^2.0.0",
|
65
65
|
"istanbul": "^0.4.5",
|
66
66
|
"jest": "^26.6.3",
|
@@ -1269,7 +1269,14 @@
|
|
1269
1269
|
},
|
1270
1270
|
"url": {
|
1271
1271
|
"description": "Enable/disable parsing of new URL() syntax.",
|
1272
|
-
"
|
1272
|
+
"anyOf": [
|
1273
|
+
{
|
1274
|
+
"enum": ["relative"]
|
1275
|
+
},
|
1276
|
+
{
|
1277
|
+
"type": "boolean"
|
1278
|
+
}
|
1279
|
+
]
|
1273
1280
|
},
|
1274
1281
|
"worker": {
|
1275
1282
|
"description": "Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register().",
|
package/types.d.ts
CHANGED
@@ -118,6 +118,11 @@ declare class AbstractLibraryPlugin<T> {
|
|
118
118
|
entryName: string,
|
119
119
|
libraryContext: LibraryContext<T>
|
120
120
|
): void;
|
121
|
+
embedInRuntimeBailout(
|
122
|
+
module: Module,
|
123
|
+
renderContext: RenderContextObject,
|
124
|
+
libraryContext: LibraryContext<T>
|
125
|
+
): undefined | string;
|
121
126
|
runtimeRequirements(
|
122
127
|
chunk: Chunk,
|
123
128
|
set: Set<string>,
|
@@ -128,12 +133,19 @@ declare class AbstractLibraryPlugin<T> {
|
|
128
133
|
renderContext: RenderContextObject,
|
129
134
|
libraryContext: LibraryContext<T>
|
130
135
|
): Source;
|
136
|
+
renderStartup(
|
137
|
+
source: Source,
|
138
|
+
module: Module,
|
139
|
+
renderContext: StartupRenderContext,
|
140
|
+
libraryContext: LibraryContext<T>
|
141
|
+
): Source;
|
131
142
|
chunkHash(
|
132
143
|
chunk: Chunk,
|
133
144
|
hash: Hash,
|
134
145
|
chunkHashContext: ChunkHashContext,
|
135
146
|
libraryContext: LibraryContext<T>
|
136
147
|
): void;
|
148
|
+
static COMMON_LIBRARY_NAME_MESSAGE: string;
|
137
149
|
}
|
138
150
|
declare class AggressiveMergingPlugin {
|
139
151
|
constructor(options?: any);
|
@@ -1646,7 +1658,13 @@ declare interface CompilationHooksJavascriptModulesPlugin {
|
|
1646
1658
|
renderChunk: SyncWaterfallHook<[Source, RenderContextObject]>;
|
1647
1659
|
renderMain: SyncWaterfallHook<[Source, RenderContextObject]>;
|
1648
1660
|
render: SyncWaterfallHook<[Source, RenderContextObject]>;
|
1661
|
+
renderStartup: SyncWaterfallHook<[Source, Module, StartupRenderContext]>;
|
1649
1662
|
renderRequire: SyncWaterfallHook<[string, RenderBootstrapContext]>;
|
1663
|
+
inlineInRuntimeBailout: SyncBailHook<
|
1664
|
+
[Module, RenderBootstrapContext],
|
1665
|
+
string
|
1666
|
+
>;
|
1667
|
+
embedInRuntimeBailout: SyncBailHook<[Module, RenderContextObject], string>;
|
1650
1668
|
chunkHash: SyncHook<[Chunk, Hash, ChunkHashContext]>;
|
1651
1669
|
useSourceMap: SyncBailHook<[Chunk, RenderContextObject], boolean>;
|
1652
1670
|
}
|
@@ -4412,7 +4430,7 @@ declare class JavascriptParser extends Parser {
|
|
4412
4430
|
varDeclarationLet: HookMap<SyncBailHook<[Declaration], boolean | void>>;
|
4413
4431
|
varDeclarationConst: HookMap<SyncBailHook<[Declaration], boolean | void>>;
|
4414
4432
|
varDeclarationVar: HookMap<SyncBailHook<[Declaration], boolean | void>>;
|
4415
|
-
pattern: HookMap<SyncBailHook<
|
4433
|
+
pattern: HookMap<SyncBailHook<[Identifier], boolean | void>>;
|
4416
4434
|
canRename: HookMap<SyncBailHook<[Expression], boolean | void>>;
|
4417
4435
|
rename: HookMap<SyncBailHook<[Expression], boolean | void>>;
|
4418
4436
|
assign: HookMap<SyncBailHook<[AssignmentExpression], boolean | void>>;
|
@@ -4881,7 +4899,7 @@ declare interface JavascriptParserOptions {
|
|
4881
4899
|
/**
|
4882
4900
|
* Enable/disable parsing of new URL() syntax.
|
4883
4901
|
*/
|
4884
|
-
url?: boolean;
|
4902
|
+
url?: boolean | "relative";
|
4885
4903
|
|
4886
4904
|
/**
|
4887
4905
|
* Disable or configure parsing of WebWorker syntax like new Worker() or navigator.serviceWorker.register().
|
@@ -6234,7 +6252,10 @@ declare abstract class ModuleTemplate {
|
|
6234
6252
|
readonly runtimeTemplate: any;
|
6235
6253
|
}
|
6236
6254
|
declare class MultiCompiler {
|
6237
|
-
constructor(
|
6255
|
+
constructor(
|
6256
|
+
compilers: Compiler[] | Record<string, Compiler>,
|
6257
|
+
options: MultiCompilerOptions
|
6258
|
+
);
|
6238
6259
|
hooks: Readonly<{
|
6239
6260
|
done: SyncHook<[MultiStats]>;
|
6240
6261
|
invalid: MultiHook<SyncHook<[null | string, number]>>;
|
@@ -6246,7 +6267,7 @@ declare class MultiCompiler {
|
|
6246
6267
|
compilers: Compiler[];
|
6247
6268
|
dependencies: WeakMap<Compiler, string[]>;
|
6248
6269
|
running: boolean;
|
6249
|
-
readonly options: WebpackOptionsNormalized[];
|
6270
|
+
readonly options: WebpackOptionsNormalized[] & MultiCompilerOptions;
|
6250
6271
|
readonly outputPath: string;
|
6251
6272
|
inputFileSystem: InputFileSystem;
|
6252
6273
|
outputFileSystem: OutputFileSystem;
|
@@ -6268,6 +6289,12 @@ declare class MultiCompiler {
|
|
6268
6289
|
purgeInputFileSystem(): void;
|
6269
6290
|
close(callback: CallbackFunction<void>): void;
|
6270
6291
|
}
|
6292
|
+
declare interface MultiCompilerOptions {
|
6293
|
+
/**
|
6294
|
+
* how many Compilers are allows to run at the same time in parallel
|
6295
|
+
*/
|
6296
|
+
parallelism?: number;
|
6297
|
+
}
|
6271
6298
|
declare abstract class MultiStats {
|
6272
6299
|
stats: Stats[];
|
6273
6300
|
readonly hash: string;
|
@@ -9860,6 +9887,7 @@ declare abstract class StackedMap<K, V> {
|
|
9860
9887
|
readonly size: number;
|
9861
9888
|
createChild(): StackedMap<K, V>;
|
9862
9889
|
}
|
9890
|
+
type StartupRenderContext = RenderContextObject & { inlined: boolean };
|
9863
9891
|
type Statement =
|
9864
9892
|
| FunctionDeclaration
|
9865
9893
|
| VariableDeclaration
|
@@ -10448,7 +10476,7 @@ declare interface UpdateHashContextGenerator {
|
|
10448
10476
|
chunkGraph: ChunkGraph;
|
10449
10477
|
runtime: RuntimeSpec;
|
10450
10478
|
}
|
10451
|
-
type UsageStateType = 0 |
|
10479
|
+
type UsageStateType = 0 | 1 | 2 | 3 | 4;
|
10452
10480
|
declare interface UserResolveOptions {
|
10453
10481
|
/**
|
10454
10482
|
* A list of module alias configurations or an object which maps key to value
|
@@ -10689,6 +10717,7 @@ declare abstract class Watching {
|
|
10689
10717
|
callbacks: CallbackFunction<void>[];
|
10690
10718
|
closed: boolean;
|
10691
10719
|
suspended: boolean;
|
10720
|
+
blocked: boolean;
|
10692
10721
|
watchOptions: {
|
10693
10722
|
/**
|
10694
10723
|
* Delay the rebuilt after the first change. Value is a time in ms.
|
@@ -11044,14 +11073,14 @@ declare function exports(
|
|
11044
11073
|
callback?: CallbackWebpack<Stats>
|
11045
11074
|
): Compiler;
|
11046
11075
|
declare function exports(
|
11047
|
-
options: Configuration[],
|
11076
|
+
options: Configuration[] & MultiCompilerOptions,
|
11048
11077
|
callback?: CallbackWebpack<MultiStats>
|
11049
11078
|
): MultiCompiler;
|
11050
11079
|
declare namespace exports {
|
11051
11080
|
export const webpack: {
|
11052
11081
|
(options: Configuration, callback?: CallbackWebpack<Stats>): Compiler;
|
11053
11082
|
(
|
11054
|
-
options: Configuration[],
|
11083
|
+
options: Configuration[] & MultiCompilerOptions,
|
11055
11084
|
callback?: CallbackWebpack<MultiStats>
|
11056
11085
|
): MultiCompiler;
|
11057
11086
|
};
|
@@ -11172,6 +11201,7 @@ declare namespace exports {
|
|
11172
11201
|
export let hasOwnProperty: string;
|
11173
11202
|
export let systemContext: string;
|
11174
11203
|
export let baseURI: string;
|
11204
|
+
export let relativeUrl: string;
|
11175
11205
|
export let asyncModule: string;
|
11176
11206
|
}
|
11177
11207
|
export const UsageState: Readonly<{
|
@@ -11453,6 +11483,7 @@ declare namespace exports {
|
|
11453
11483
|
WebpackPluginInstance,
|
11454
11484
|
Asset,
|
11455
11485
|
AssetInfo,
|
11486
|
+
MultiStats,
|
11456
11487
|
ParserState,
|
11457
11488
|
StatsCompilation
|
11458
11489
|
};
|
@@ -1,44 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Sergey Melyukov @smelukov
|
4
|
-
*/
|
5
|
-
|
6
|
-
"use strict";
|
7
|
-
|
8
|
-
const InnerGraph = require("./optimize/InnerGraph");
|
9
|
-
|
10
|
-
/** @typedef {import("./Compiler")} Compiler */
|
11
|
-
|
12
|
-
class FlagUsingEvalPlugin {
|
13
|
-
/**
|
14
|
-
* Apply the plugin
|
15
|
-
* @param {Compiler} compiler the compiler instance
|
16
|
-
* @returns {void}
|
17
|
-
*/
|
18
|
-
apply(compiler) {
|
19
|
-
compiler.hooks.compilation.tap(
|
20
|
-
"FlagUsingEvalPlugin",
|
21
|
-
(compilation, { normalModuleFactory }) => {
|
22
|
-
const handler = parser => {
|
23
|
-
parser.hooks.call.for("eval").tap("FlagUsingEvalPlugin", () => {
|
24
|
-
parser.state.module.buildInfo.moduleConcatenationBailout = "eval()";
|
25
|
-
parser.state.module.buildInfo.usingEval = true;
|
26
|
-
InnerGraph.bailout(parser.state);
|
27
|
-
});
|
28
|
-
};
|
29
|
-
|
30
|
-
normalModuleFactory.hooks.parser
|
31
|
-
.for("javascript/auto")
|
32
|
-
.tap("FlagUsingEvalPlugin", handler);
|
33
|
-
normalModuleFactory.hooks.parser
|
34
|
-
.for("javascript/dynamic")
|
35
|
-
.tap("FlagUsingEvalPlugin", handler);
|
36
|
-
normalModuleFactory.hooks.parser
|
37
|
-
.for("javascript/esm")
|
38
|
-
.tap("FlagUsingEvalPlugin", handler);
|
39
|
-
}
|
40
|
-
);
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
module.exports = FlagUsingEvalPlugin;
|