webpack 4.19.0 → 4.20.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/README.md +4 -0
- package/lib/AmdMainTemplatePlugin.js +5 -3
- package/lib/BannerPlugin.js +13 -5
- package/lib/Chunk.js +3 -0
- package/lib/Compilation.js +23 -18
- package/lib/Compiler.js +6 -12
- package/lib/DllPlugin.js +5 -0
- package/lib/DllReferencePlugin.js +70 -46
- package/lib/DynamicEntryPlugin.js +4 -3
- package/lib/EntryOptionPlugin.js +2 -1
- package/lib/ExternalModule.js +16 -4
- package/lib/HashedModuleIdsPlugin.js +9 -1
- package/lib/HotUpdateChunk.js +1 -0
- package/lib/IgnorePlugin.js +10 -14
- package/lib/LibraryTemplatePlugin.js +33 -10
- package/lib/LoaderOptionsPlugin.js +5 -0
- package/lib/Module.js +4 -0
- package/lib/SourceMapDevToolPlugin.js +16 -3
- package/lib/Template.js +1 -0
- package/lib/UmdMainTemplatePlugin.js +2 -1
- package/lib/WatchIgnorePlugin.js +5 -0
- package/lib/WebpackOptionsApply.js +18 -2
- package/lib/WebpackOptionsDefaulter.js +5 -1
- package/lib/debug/ProfilingPlugin.js +6 -0
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +16 -1
- package/lib/dependencies/HarmonyExportExpressionDependency.js +7 -2
- package/lib/dependencies/ImportParserPlugin.js +1 -1
- package/lib/dependencies/WebAssemblyImportDependency.js +9 -1
- package/lib/node/NodeMainTemplatePlugin.js +2 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +9 -2
- package/lib/optimize/ConcatenatedModule.js +10 -2
- package/lib/optimize/LimitChunkCountPlugin.js +9 -2
- package/lib/optimize/MinChunkSizePlugin.js +5 -0
- package/lib/optimize/OccurrenceChunkOrderPlugin.js +5 -0
- package/lib/optimize/OccurrenceModuleOrderPlugin.js +5 -0
- package/lib/web/JsonpExportMainTemplatePlugin.js +3 -0
- package/lib/webpack.js +12 -1
- package/package.json +11 -8
- package/schemas/WebpackOptions.json +1293 -1113
- package/schemas/plugins/BannerPlugin.json +34 -27
- package/schemas/plugins/DllPlugin.json +18 -16
- package/schemas/plugins/DllReferencePlugin.json +180 -68
- package/schemas/plugins/HashedModuleIdsPlugin.json +9 -3
- package/schemas/plugins/IgnorePlugin.json +17 -11
- package/schemas/plugins/LoaderOptionsPlugin.json +27 -26
- package/schemas/plugins/SourceMapDevToolPlugin.json +87 -83
- package/schemas/plugins/WatchIgnorePlugin.json +18 -16
- package/schemas/plugins/debug/ProfilingPlugin.json +13 -12
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.json +23 -22
- package/schemas/plugins/optimize/LimitChunkCountPlugin.json +16 -15
- package/schemas/plugins/optimize/MinChunkSizePlugin.json +4 -3
- package/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json +2 -1
- package/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json +2 -1
package/lib/Module.js
CHANGED
@@ -262,6 +262,10 @@ class Module extends DependenciesBlock {
|
|
262
262
|
}
|
263
263
|
}
|
264
264
|
|
265
|
+
/**
|
266
|
+
* @param {string=} exportName the name of the export
|
267
|
+
* @returns {boolean|string} false if the export isn't used, true if no exportName is provided and the module is used, or the name to access it if the export is used
|
268
|
+
*/
|
265
269
|
isUsed(exportName) {
|
266
270
|
if (!exportName) return this.used !== false;
|
267
271
|
if (this.used === null || this.usedExports === null) return exportName;
|
@@ -13,6 +13,8 @@ const createHash = require("./util/createHash");
|
|
13
13
|
const validateOptions = require("schema-utils");
|
14
14
|
const schema = require("../schemas/plugins/SourceMapDevToolPlugin.json");
|
15
15
|
|
16
|
+
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
|
17
|
+
|
16
18
|
const basename = name => {
|
17
19
|
if (!name.includes("/")) return name;
|
18
20
|
return name.substr(name.lastIndexOf("/") + 1);
|
@@ -52,6 +54,9 @@ const getTaskForFile = (file, chunk, options, compilation) => {
|
|
52
54
|
};
|
53
55
|
|
54
56
|
class SourceMapDevToolPlugin {
|
57
|
+
/**
|
58
|
+
* @param {SourceMapDevToolPluginOptions=} options options object
|
59
|
+
*/
|
55
60
|
constructor(options) {
|
56
61
|
if (arguments.length > 1) {
|
57
62
|
throw new Error(
|
@@ -59,10 +64,12 @@ class SourceMapDevToolPlugin {
|
|
59
64
|
);
|
60
65
|
}
|
61
66
|
|
62
|
-
validateOptions(schema, options || {}, "SourceMap DevTool Plugin");
|
63
|
-
|
64
67
|
if (!options) options = {};
|
68
|
+
|
69
|
+
validateOptions(schema, options, "SourceMap DevTool Plugin");
|
70
|
+
|
65
71
|
this.sourceMapFilename = options.filename;
|
72
|
+
/** @type {string | false} */
|
66
73
|
this.sourceMappingURLComment =
|
67
74
|
options.append === false
|
68
75
|
? false
|
@@ -84,7 +91,7 @@ class SourceMapDevToolPlugin {
|
|
84
91
|
const fallbackModuleFilenameTemplate = this.fallbackModuleFilenameTemplate;
|
85
92
|
const requestShortener = compiler.requestShortener;
|
86
93
|
const options = this.options;
|
87
|
-
options.test = options.test || /\.(js|css)($|\?)/i;
|
94
|
+
options.test = options.test || /\.(m?js|css)($|\?)/i;
|
88
95
|
|
89
96
|
const matchObject = ModuleFilenameHelpers.matchObject.bind(
|
90
97
|
undefined,
|
@@ -227,6 +234,7 @@ class SourceMapDevToolPlugin {
|
|
227
234
|
sourceMap.sourceRoot = options.sourceRoot || "";
|
228
235
|
sourceMap.file = file;
|
229
236
|
assetsCache.set(asset, { file, assets });
|
237
|
+
/** @type {string | false} */
|
230
238
|
let currentSourceMappingURLComment = sourceMappingURLComment;
|
231
239
|
if (
|
232
240
|
currentSourceMappingURLComment !== false &&
|
@@ -276,6 +284,11 @@ class SourceMapDevToolPlugin {
|
|
276
284
|
] = new RawSource(sourceMapString);
|
277
285
|
chunk.files.push(sourceMapFile);
|
278
286
|
} else {
|
287
|
+
if (currentSourceMappingURLComment === false) {
|
288
|
+
throw new Error(
|
289
|
+
"SourceMapDevToolPlugin: append can't be false when no filename is provided"
|
290
|
+
);
|
291
|
+
}
|
279
292
|
assets[file] = compilation.assets[file] = new ConcatSource(
|
280
293
|
new RawSource(source),
|
281
294
|
currentSourceMappingURLComment
|
package/lib/Template.js
CHANGED
@@ -252,6 +252,7 @@ class Template {
|
|
252
252
|
source.add(`Array(${minId}).concat(`);
|
253
253
|
}
|
254
254
|
source.add("[\n");
|
255
|
+
/** @type {Map<string|number, {id: string|number, source: Source|string}>} */
|
255
256
|
const modules = new Map();
|
256
257
|
for (const module of allModules) {
|
257
258
|
modules.set(module.id, module);
|
@@ -7,6 +7,7 @@
|
|
7
7
|
const { ConcatSource, OriginalSource } = require("webpack-sources");
|
8
8
|
const Template = require("./Template");
|
9
9
|
|
10
|
+
/** @typedef {import("../declarations/WebpackOptions").LibraryCustomUmdObject} LibraryCustomUmdObject */
|
10
11
|
/** @typedef {import("./Compilation")} Compilation */
|
11
12
|
|
12
13
|
/**
|
@@ -38,7 +39,7 @@ const accessorAccess = (base, accessor, joinWith = ", ") => {
|
|
38
39
|
.join(joinWith);
|
39
40
|
};
|
40
41
|
|
41
|
-
/** @typedef {string | string[] |
|
42
|
+
/** @typedef {string | string[] | LibraryCustomUmdObject} UmdMainTemplatePluginName */
|
42
43
|
|
43
44
|
/**
|
44
45
|
* @typedef {Object} AuxiliaryCommentObject
|
package/lib/WatchIgnorePlugin.js
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
const validateOptions = require("schema-utils");
|
8
8
|
const schema = require("../schemas/plugins/WatchIgnorePlugin.json");
|
9
9
|
|
10
|
+
/** @typedef {import("../declarations/plugins/WatchIgnorePlugin").WatchIgnorePluginOptions} WatchIgnorePluginOptions */
|
11
|
+
|
10
12
|
class IgnoringWatchFileSystem {
|
11
13
|
constructor(wfs, paths) {
|
12
14
|
this.wfs = wfs;
|
@@ -82,6 +84,9 @@ class IgnoringWatchFileSystem {
|
|
82
84
|
}
|
83
85
|
|
84
86
|
class WatchIgnorePlugin {
|
87
|
+
/**
|
88
|
+
* @param {WatchIgnorePluginOptions} paths list of paths
|
89
|
+
*/
|
85
90
|
constructor(paths) {
|
86
91
|
validateOptions(schema, paths, "Watch Ignore Plugin");
|
87
92
|
this.paths = paths;
|
@@ -63,11 +63,19 @@ const DefinePlugin = require("./DefinePlugin");
|
|
63
63
|
const SizeLimitsPlugin = require("./performance/SizeLimitsPlugin");
|
64
64
|
const WasmFinalizeExportsPlugin = require("./wasm/WasmFinalizeExportsPlugin");
|
65
65
|
|
66
|
+
/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
|
67
|
+
/** @typedef {import("./Compiler")} Compiler */
|
68
|
+
|
66
69
|
class WebpackOptionsApply extends OptionsApply {
|
67
70
|
constructor() {
|
68
71
|
super();
|
69
72
|
}
|
70
73
|
|
74
|
+
/**
|
75
|
+
* @param {WebpackOptions} options options object
|
76
|
+
* @param {Compiler} compiler compiler object
|
77
|
+
* @returns {WebpackOptions} options object
|
78
|
+
*/
|
71
79
|
process(options, compiler) {
|
72
80
|
let ExternalsPlugin;
|
73
81
|
compiler.outputPath = options.output.path;
|
@@ -75,6 +83,8 @@ class WebpackOptionsApply extends OptionsApply {
|
|
75
83
|
compiler.recordsOutputPath =
|
76
84
|
options.recordsOutputPath || options.recordsPath;
|
77
85
|
compiler.name = options.name;
|
86
|
+
// TODO webpack 5 refactor this to MultiCompiler.setDependencies() with a WeakMap
|
87
|
+
// @ts-ignore TODO
|
78
88
|
compiler.dependencies = options.dependencies;
|
79
89
|
if (typeof options.target === "string") {
|
80
90
|
let JsonpTemplatePlugin;
|
@@ -201,7 +211,9 @@ class WebpackOptionsApply extends OptionsApply {
|
|
201
211
|
default:
|
202
212
|
throw new Error("Unsupported target '" + options.target + "'.");
|
203
213
|
}
|
204
|
-
}
|
214
|
+
}
|
215
|
+
// @ts-ignore This is always true, which is good this way
|
216
|
+
else if (options.target !== false) {
|
205
217
|
options.target(compiler);
|
206
218
|
} else {
|
207
219
|
throw new Error("Unsupported target '" + options.target + "'.");
|
@@ -450,7 +462,11 @@ class WebpackOptionsApply extends OptionsApply {
|
|
450
462
|
}
|
451
463
|
if (options.optimization.minimize) {
|
452
464
|
for (const minimizer of options.optimization.minimizer) {
|
453
|
-
minimizer
|
465
|
+
if (typeof minimizer === "function") {
|
466
|
+
minimizer.apply(compiler);
|
467
|
+
} else {
|
468
|
+
minimizer.apply(compiler);
|
469
|
+
}
|
454
470
|
}
|
455
471
|
}
|
456
472
|
|
@@ -327,7 +327,11 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
|
|
327
327
|
this.set("resolve.extensions", [".wasm", ".mjs", ".js", ".json"]);
|
328
328
|
this.set("resolve.mainFiles", ["index"]);
|
329
329
|
this.set("resolve.aliasFields", "make", options => {
|
330
|
-
if (
|
330
|
+
if (
|
331
|
+
options.target === "web" ||
|
332
|
+
options.target === "webworker" ||
|
333
|
+
options.target === "electron-renderer"
|
334
|
+
) {
|
331
335
|
return ["browser"];
|
332
336
|
} else {
|
333
337
|
return [];
|
@@ -2,6 +2,9 @@ const fs = require("fs");
|
|
2
2
|
const { Tracer } = require("chrome-trace-event");
|
3
3
|
const validateOptions = require("schema-utils");
|
4
4
|
const schema = require("../../schemas/plugins/debug/ProfilingPlugin.json");
|
5
|
+
|
6
|
+
/** @typedef {import("../../declarations/plugins/debug/ProfilingPlugin").ProfilingPluginOptions} ProfilingPluginOptions */
|
7
|
+
|
5
8
|
let inspector = undefined;
|
6
9
|
|
7
10
|
try {
|
@@ -145,6 +148,9 @@ const createTrace = outputPath => {
|
|
145
148
|
const pluginName = "ProfilingPlugin";
|
146
149
|
|
147
150
|
class ProfilingPlugin {
|
151
|
+
/**
|
152
|
+
* @param {ProfilingPluginOptions=} opts options object
|
153
|
+
*/
|
148
154
|
constructor(opts) {
|
149
155
|
validateOptions(schema, opts || {}, "Profiling plugin");
|
150
156
|
opts = opts || {};
|
@@ -54,10 +54,25 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
54
54
|
parser.hooks.exportExpression.tap(
|
55
55
|
"HarmonyExportDependencyParserPlugin",
|
56
56
|
(statement, expr) => {
|
57
|
+
const comments = parser.getComments([
|
58
|
+
statement.range[0],
|
59
|
+
expr.range[0]
|
60
|
+
]);
|
57
61
|
const dep = new HarmonyExportExpressionDependency(
|
58
62
|
parser.state.module,
|
59
63
|
expr.range,
|
60
|
-
statement.range
|
64
|
+
statement.range,
|
65
|
+
comments
|
66
|
+
.map(c => {
|
67
|
+
switch (c.type) {
|
68
|
+
case "Block":
|
69
|
+
return `/*${c.value}*/`;
|
70
|
+
case "Line":
|
71
|
+
return `//${c.value}\n`;
|
72
|
+
}
|
73
|
+
return "";
|
74
|
+
})
|
75
|
+
.join("")
|
61
76
|
);
|
62
77
|
dep.loc = Object.create(statement.loc);
|
63
78
|
dep.loc.index = -1;
|
@@ -6,11 +6,12 @@
|
|
6
6
|
const NullDependency = require("./NullDependency");
|
7
7
|
|
8
8
|
class HarmonyExportExpressionDependency extends NullDependency {
|
9
|
-
constructor(originModule, range, rangeStatement) {
|
9
|
+
constructor(originModule, range, rangeStatement, prefix) {
|
10
10
|
super();
|
11
11
|
this.originModule = originModule;
|
12
12
|
this.range = range;
|
13
13
|
this.rangeStatement = rangeStatement;
|
14
|
+
this.prefix = prefix;
|
14
15
|
}
|
15
16
|
|
16
17
|
get type() {
|
@@ -31,7 +32,11 @@ HarmonyExportExpressionDependency.Template = class HarmonyExportDependencyTempla
|
|
31
32
|
const content = this.getContent(dep.originModule, used);
|
32
33
|
|
33
34
|
if (dep.range) {
|
34
|
-
source.replace(
|
35
|
+
source.replace(
|
36
|
+
dep.rangeStatement[0],
|
37
|
+
dep.range[0] - 1,
|
38
|
+
content + "(" + dep.prefix
|
39
|
+
);
|
35
40
|
source.replace(dep.range[1], dep.rangeStatement[1] - 1, ");");
|
36
41
|
return;
|
37
42
|
}
|
@@ -8,12 +8,20 @@ const DependencyReference = require("./DependencyReference");
|
|
8
8
|
const ModuleDependency = require("./ModuleDependency");
|
9
9
|
const UnsupportedWebAssemblyFeatureError = require("../wasm/UnsupportedWebAssemblyFeatureError");
|
10
10
|
|
11
|
+
/** @typedef {import("@webassemblyjs/ast").ModuleImportDescription} ModuleImportDescription */
|
12
|
+
|
11
13
|
class WebAssemblyImportDependency extends ModuleDependency {
|
14
|
+
/**
|
15
|
+
* @param {string} request the request
|
16
|
+
* @param {string} name the imported name
|
17
|
+
* @param {ModuleImportDescription} description the WASM ast node
|
18
|
+
* @param {false | string} onlyDirectImport if only direct imports are allowed
|
19
|
+
*/
|
12
20
|
constructor(request, name, description, onlyDirectImport) {
|
13
21
|
super(request);
|
14
22
|
/** @type {string} */
|
15
23
|
this.name = name;
|
16
|
-
/** @type {
|
24
|
+
/** @type {ModuleImportDescription} */
|
17
25
|
this.description = description;
|
18
26
|
/** @type {false | string} */
|
19
27
|
this.onlyDirectImport = onlyDirectImport;
|
@@ -96,7 +96,7 @@ module.exports = class NodeMainTemplatePlugin {
|
|
96
96
|
"var promise = new Promise(function(resolve, reject) {",
|
97
97
|
Template.indent([
|
98
98
|
"installedChunkData = installedChunks[chunkId] = [resolve, reject];",
|
99
|
-
"var filename = __dirname
|
99
|
+
"var filename = require('path').join(__dirname, " +
|
100
100
|
mainTemplate.getAssetPath(
|
101
101
|
JSON.stringify(`/${chunkFilename}`),
|
102
102
|
{
|
@@ -155,7 +155,7 @@ module.exports = class NodeMainTemplatePlugin {
|
|
155
155
|
contentHashType: "javascript"
|
156
156
|
}
|
157
157
|
) +
|
158
|
-
";",
|
158
|
+
");",
|
159
159
|
"require('fs').readFile(filename, 'utf-8', function(err, content) {",
|
160
160
|
Template.indent(
|
161
161
|
[
|
@@ -9,6 +9,8 @@ const { intersect } = require("../util/SetHelpers");
|
|
9
9
|
const validateOptions = require("schema-utils");
|
10
10
|
const schema = require("../../schemas/plugins/optimize/AggressiveSplittingPlugin.json");
|
11
11
|
|
12
|
+
/** @typedef {import("../../declarations/plugins/optimize/AggressiveSplittingPlugin").AggressiveSplittingPluginOptions} AggressiveSplittingPluginOptions */
|
13
|
+
|
12
14
|
const moveModuleBetween = (oldChunk, newChunk) => {
|
13
15
|
return module => {
|
14
16
|
oldChunk.moveModule(module, newChunk);
|
@@ -22,10 +24,15 @@ const isNotAEntryModule = entryModule => {
|
|
22
24
|
};
|
23
25
|
|
24
26
|
class AggressiveSplittingPlugin {
|
27
|
+
/**
|
28
|
+
* @param {AggressiveSplittingPluginOptions=} options options object
|
29
|
+
*/
|
25
30
|
constructor(options) {
|
26
|
-
|
31
|
+
if (!options) options = {};
|
32
|
+
|
33
|
+
validateOptions(schema, options, "Aggressive Splitting Plugin");
|
27
34
|
|
28
|
-
this.options = options
|
35
|
+
this.options = options;
|
29
36
|
if (typeof this.options.minSize !== "number") {
|
30
37
|
this.options.minSize = 30 * 1024;
|
31
38
|
}
|
@@ -1364,12 +1364,20 @@ class HarmonyExportExpressionDependencyConcatenatedTemplate {
|
|
1364
1364
|
}
|
1365
1365
|
|
1366
1366
|
if (dep.range) {
|
1367
|
-
source.replace(
|
1367
|
+
source.replace(
|
1368
|
+
dep.rangeStatement[0],
|
1369
|
+
dep.range[0] - 1,
|
1370
|
+
content + "(" + dep.prefix
|
1371
|
+
);
|
1368
1372
|
source.replace(dep.range[1], dep.rangeStatement[1] - 1, ");");
|
1369
1373
|
return;
|
1370
1374
|
}
|
1371
1375
|
|
1372
|
-
source.replace(
|
1376
|
+
source.replace(
|
1377
|
+
dep.rangeStatement[0],
|
1378
|
+
dep.rangeStatement[1] - 1,
|
1379
|
+
content + dep.prefix
|
1380
|
+
);
|
1373
1381
|
}
|
1374
1382
|
}
|
1375
1383
|
|
@@ -7,10 +7,17 @@
|
|
7
7
|
const validateOptions = require("schema-utils");
|
8
8
|
const schema = require("../../schemas/plugins/optimize/LimitChunkCountPlugin.json");
|
9
9
|
|
10
|
+
/** @typedef {import("../../declarations/plugins/optimize/LimitChunkCountPlugin").LimitChunkCountPluginOptions} LimitChunkCountPluginOptions */
|
11
|
+
|
10
12
|
class LimitChunkCountPlugin {
|
13
|
+
/**
|
14
|
+
* @param {LimitChunkCountPluginOptions=} options options object
|
15
|
+
*/
|
11
16
|
constructor(options) {
|
12
|
-
|
13
|
-
|
17
|
+
if (!options) options = {};
|
18
|
+
|
19
|
+
validateOptions(schema, options, "Limit Chunk Count Plugin");
|
20
|
+
this.options = options;
|
14
21
|
}
|
15
22
|
apply(compiler) {
|
16
23
|
const options = this.options;
|
@@ -7,7 +7,12 @@
|
|
7
7
|
const validateOptions = require("schema-utils");
|
8
8
|
const schema = require("../../schemas/plugins/optimize/MinChunkSizePlugin.json");
|
9
9
|
|
10
|
+
/** @typedef {import("../../declarations/plugins/optimize/MinChunkSizePlugin").MinChunkSizePluginOptions} MinChunkSizePluginOptions */
|
11
|
+
|
10
12
|
class MinChunkSizePlugin {
|
13
|
+
/**
|
14
|
+
* @param {MinChunkSizePluginOptions} options options object
|
15
|
+
*/
|
11
16
|
constructor(options) {
|
12
17
|
validateOptions(schema, options, "Min Chunk Size Plugin");
|
13
18
|
this.options = options;
|
@@ -7,7 +7,12 @@
|
|
7
7
|
const validateOptions = require("schema-utils");
|
8
8
|
const schema = require("../../schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json");
|
9
9
|
|
10
|
+
/** @typedef {import("../../declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin").OccurrenceOrderChunkIdsPluginOptions} OccurrenceOrderChunkIdsPluginOptions */
|
11
|
+
|
10
12
|
class OccurrenceOrderChunkIdsPlugin {
|
13
|
+
/**
|
14
|
+
* @param {OccurrenceOrderChunkIdsPluginOptions=} options options object
|
15
|
+
*/
|
11
16
|
constructor(options = {}) {
|
12
17
|
validateOptions(schema, options, "Occurrence Order Chunk Ids Plugin");
|
13
18
|
this.options = options;
|
@@ -7,7 +7,12 @@
|
|
7
7
|
const validateOptions = require("schema-utils");
|
8
8
|
const schema = require("../../schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json");
|
9
9
|
|
10
|
+
/** @typedef {import("../../declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin").OccurrenceOrderModuleIdsPluginOptions} OccurrenceOrderModuleIdsPluginOptions */
|
11
|
+
|
10
12
|
class OccurrenceOrderModuleIdsPlugin {
|
13
|
+
/**
|
14
|
+
* @param {OccurrenceOrderModuleIdsPluginOptions=} options options object
|
15
|
+
*/
|
11
16
|
constructor(options = {}) {
|
12
17
|
validateOptions(schema, options, "Occurrence Order Module Ids Plugin");
|
13
18
|
this.options = options;
|
package/lib/webpack.js
CHANGED
@@ -15,6 +15,13 @@ const webpackOptionsSchema = require("../schemas/WebpackOptions.json");
|
|
15
15
|
const RemovedPluginError = require("./RemovedPluginError");
|
16
16
|
const version = require("../package.json").version;
|
17
17
|
|
18
|
+
/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
|
19
|
+
|
20
|
+
/**
|
21
|
+
* @param {WebpackOptions} options options object
|
22
|
+
* @param {function(Error=, Stats=): void=} callback callback
|
23
|
+
* @returns {Compiler | MultiCompiler} the compiler object
|
24
|
+
*/
|
18
25
|
const webpack = (options, callback) => {
|
19
26
|
const webpackOptionsValidationErrors = validateSchema(
|
20
27
|
webpackOptionsSchema,
|
@@ -34,7 +41,11 @@ const webpack = (options, callback) => {
|
|
34
41
|
new NodeEnvironmentPlugin().apply(compiler);
|
35
42
|
if (options.plugins && Array.isArray(options.plugins)) {
|
36
43
|
for (const plugin of options.plugins) {
|
37
|
-
plugin
|
44
|
+
if (typeof plugin === "function") {
|
45
|
+
plugin.apply(compiler);
|
46
|
+
} else {
|
47
|
+
plugin.apply(compiler);
|
48
|
+
}
|
38
49
|
}
|
39
50
|
}
|
40
51
|
compiler.hooks.environment.call();
|
package/package.json
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.20.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",
|
7
7
|
"dependencies": {
|
8
|
-
"@webassemblyjs/ast": "1.7.
|
9
|
-
"@webassemblyjs/helper-module-context": "1.7.
|
10
|
-
"@webassemblyjs/wasm-edit": "1.7.
|
11
|
-
"@webassemblyjs/wasm-parser": "1.7.
|
8
|
+
"@webassemblyjs/ast": "1.7.8",
|
9
|
+
"@webassemblyjs/helper-module-context": "1.7.8",
|
10
|
+
"@webassemblyjs/wasm-edit": "1.7.8",
|
11
|
+
"@webassemblyjs/wasm-parser": "1.7.8",
|
12
12
|
"acorn": "^5.6.2",
|
13
13
|
"acorn-dynamic-import": "^3.0.0",
|
14
14
|
"ajv": "^6.1.0",
|
@@ -28,7 +28,7 @@
|
|
28
28
|
"tapable": "^1.1.0",
|
29
29
|
"uglifyjs-webpack-plugin": "^1.2.4",
|
30
30
|
"watchpack": "^1.5.0",
|
31
|
-
"webpack-sources": "^1.
|
31
|
+
"webpack-sources": "^1.3.0"
|
32
32
|
},
|
33
33
|
"devDependencies": {
|
34
34
|
"@types/node": "^9.6.4",
|
@@ -58,6 +58,7 @@
|
|
58
58
|
"jest": "^23.4.1",
|
59
59
|
"jest-silent-reporter": "^0.0.5",
|
60
60
|
"json-loader": "^0.5.7",
|
61
|
+
"json-schema-to-typescript": "^6.0.1",
|
61
62
|
"less": "^2.5.1",
|
62
63
|
"less-loader": "^4.0.3",
|
63
64
|
"lint-staged": "^7.2.0",
|
@@ -118,10 +119,12 @@
|
|
118
119
|
"build:examples": "cd examples && node buildAll.js",
|
119
120
|
"pretest": "yarn lint",
|
120
121
|
"prelint": "yarn setup",
|
121
|
-
"lint": "yarn code-lint && yarn schema-lint && yarn type-lint",
|
122
|
+
"lint": "yarn code-lint && yarn schema-lint && yarn type-lint && yarn special-lint",
|
122
123
|
"code-lint": "eslint --cache \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.js\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
|
123
124
|
"type-lint": "tsc --pretty",
|
124
|
-
"
|
125
|
+
"special-lint": "node tooling/inherit-types && node tooling/format-schemas && node tooling/compile-to-definitions",
|
126
|
+
"special-lint-fix": "node tooling/inherit-types --write --override && node tooling/format-schemas --write && node tooling/compile-to-definitions --write",
|
127
|
+
"fix": "yarn code-lint --fix && yarn special-lint-fix",
|
125
128
|
"pretty": "prettier --loglevel warn --write \"*.{ts,js,json}\" \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
|
126
129
|
"schema-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\" --no-verbose",
|
127
130
|
"benchmark": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.js\" --runInBand",
|