webpack 5.33.0 → 5.35.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/bin/webpack.js +0 -0
- package/lib/BannerPlugin.js +11 -7
- package/lib/ChunkGraph.js +12 -6
- package/lib/CleanPlugin.js +17 -15
- package/lib/Compilation.js +1 -1
- package/lib/DllPlugin.js +11 -7
- package/lib/DllReferencePlugin.js +11 -7
- package/lib/FileSystemInfo.js +112 -74
- package/lib/IgnorePlugin.js +11 -6
- package/lib/LoaderOptionsPlugin.js +10 -7
- package/lib/NormalModule.js +2 -2
- package/lib/ProgressPlugin.js +10 -6
- package/lib/RuntimePlugin.js +3 -1
- package/lib/SourceMapDevToolPlugin.js +10 -7
- package/lib/WatchIgnorePlugin.js +11 -6
- package/lib/WebpackOptionsApply.js +2 -1
- package/lib/asset/AssetModulesPlugin.js +33 -14
- package/lib/cache/PackFileCacheStrategy.js +16 -2
- package/lib/config/defaults.js +2 -1
- package/lib/container/ContainerPlugin.js +11 -3
- package/lib/container/ContainerReferencePlugin.js +12 -3
- package/lib/container/ModuleFederationPlugin.js +12 -5
- package/lib/debug/ProfilingPlugin.js +10 -6
- package/lib/dependencies/LoaderPlugin.js +6 -1
- package/lib/ids/HashedModuleIdsPlugin.js +11 -6
- package/lib/ids/OccurrenceChunkIdsPlugin.js +11 -6
- package/lib/ids/OccurrenceModuleIdsPlugin.js +11 -6
- package/lib/index.js +9 -3
- package/lib/json/JsonModulesPlugin.js +9 -8
- package/lib/node/CommonJsChunkLoadingPlugin.js +3 -1
- package/lib/node/NodeTargetPlugin.js +5 -1
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +3 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +3 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +12 -6
- package/lib/optimize/LimitChunkCountPlugin.js +18 -10
- package/lib/optimize/MinChunkSizePlugin.js +11 -7
- package/lib/runtime/StartupChunkDependenciesPlugin.js +3 -1
- package/lib/serialization/BinaryMiddleware.js +47 -25
- package/lib/sharing/ConsumeSharedPlugin.js +11 -3
- package/lib/sharing/ProvideSharedPlugin.js +11 -3
- package/lib/util/comparators.js +1 -3
- package/lib/util/create-schema-validation.js +21 -0
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/web/FetchCompileAsyncWasmPlugin.js +3 -1
- package/lib/web/FetchCompileWasmPlugin.js +3 -1
- package/lib/web/JsonpChunkLoadingPlugin.js +3 -1
- package/lib/webpack.js +7 -2
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
- package/package.json +6 -6
- package/schemas/WebpackOptions.check.d.ts +7 -0
- package/schemas/WebpackOptions.check.js +6 -0
- package/schemas/WebpackOptions.json +13 -9
- package/schemas/plugins/BannerPlugin.check.d.ts +7 -0
- package/schemas/plugins/BannerPlugin.check.js +6 -0
- package/schemas/plugins/DllPlugin.check.d.ts +7 -0
- package/schemas/plugins/DllPlugin.check.js +6 -0
- package/schemas/plugins/DllReferencePlugin.check.d.ts +7 -0
- package/schemas/plugins/DllReferencePlugin.check.js +6 -0
- package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +7 -0
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +6 -0
- package/schemas/plugins/IgnorePlugin.check.d.ts +7 -0
- package/schemas/plugins/IgnorePlugin.check.js +6 -0
- package/schemas/plugins/JsonModulesPluginParser.check.d.ts +7 -0
- package/schemas/plugins/JsonModulesPluginParser.check.js +6 -0
- package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +7 -0
- package/schemas/plugins/LoaderOptionsPlugin.check.js +6 -0
- package/schemas/plugins/ProgressPlugin.check.d.ts +7 -0
- package/schemas/plugins/ProgressPlugin.check.js +6 -0
- package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +7 -0
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +6 -0
- package/schemas/plugins/WatchIgnorePlugin.check.d.ts +7 -0
- package/schemas/plugins/WatchIgnorePlugin.check.js +6 -0
- package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +6 -0
- package/schemas/plugins/asset/AssetGeneratorOptions.json +3 -0
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +6 -0
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.json +3 -0
- package/schemas/plugins/asset/AssetParserOptions.check.d.ts +7 -0
- package/schemas/plugins/asset/AssetParserOptions.check.js +6 -0
- package/schemas/plugins/asset/AssetParserOptions.json +3 -0
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +6 -0
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.json +3 -0
- package/schemas/plugins/container/ContainerPlugin.check.d.ts +7 -0
- package/schemas/plugins/container/ContainerPlugin.check.js +6 -0
- package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +7 -0
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +6 -0
- package/schemas/plugins/container/ExternalsType.check.d.ts +7 -0
- package/schemas/plugins/container/ExternalsType.check.js +6 -0
- package/schemas/plugins/container/ExternalsType.json +3 -0
- package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +7 -0
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +6 -0
- package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +7 -0
- package/schemas/plugins/debug/ProfilingPlugin.check.js +6 -0
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +7 -0
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +6 -0
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +7 -0
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +6 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +7 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +6 -0
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +7 -0
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +6 -0
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +7 -0
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +6 -0
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +7 -0
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +6 -0
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +7 -0
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +6 -0
- package/schemas/plugins/sharing/SharePlugin.check.d.ts +7 -0
- package/schemas/plugins/sharing/SharePlugin.check.js +6 -0
- package/types.d.ts +21 -3
package/bin/webpack.js
CHANGED
File without changes
|
package/lib/BannerPlugin.js
CHANGED
@@ -5,18 +5,25 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
const { validate } = require("schema-utils");
|
9
8
|
const { ConcatSource } = require("webpack-sources");
|
10
9
|
const Compilation = require("./Compilation");
|
11
10
|
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
12
11
|
const Template = require("./Template");
|
13
|
-
|
14
|
-
const schema = require("../schemas/plugins/BannerPlugin.json");
|
12
|
+
const createSchemaValidation = require("./util/create-schema-validation");
|
15
13
|
|
16
14
|
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginArgument} BannerPluginArgument */
|
17
15
|
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginOptions} BannerPluginOptions */
|
18
16
|
/** @typedef {import("./Compiler")} Compiler */
|
19
17
|
|
18
|
+
const validate = createSchemaValidation(
|
19
|
+
require("../schemas/plugins/BannerPlugin.check.js"),
|
20
|
+
() => require("../schemas/plugins/BannerPlugin.json"),
|
21
|
+
{
|
22
|
+
name: "Banner Plugin",
|
23
|
+
baseDataPath: "options"
|
24
|
+
}
|
25
|
+
);
|
26
|
+
|
20
27
|
const wrapComment = str => {
|
21
28
|
if (!str.includes("\n")) {
|
22
29
|
return Template.toComment(str);
|
@@ -40,10 +47,7 @@ class BannerPlugin {
|
|
40
47
|
};
|
41
48
|
}
|
42
49
|
|
43
|
-
validate(
|
44
|
-
name: "Banner Plugin",
|
45
|
-
baseDataPath: "options"
|
46
|
-
});
|
50
|
+
validate(options);
|
47
51
|
|
48
52
|
this.options = options;
|
49
53
|
|
package/lib/ChunkGraph.js
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const util = require("util");
|
9
|
+
const Entrypoint = require("./Entrypoint");
|
9
10
|
const ModuleGraphConnection = require("./ModuleGraphConnection");
|
10
11
|
const { first } = require("./util/SetHelpers");
|
11
12
|
const SortableSet = require("./util/SortableSet");
|
@@ -31,7 +32,6 @@ const {
|
|
31
32
|
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
32
33
|
/** @typedef {import("./Chunk")} Chunk */
|
33
34
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
34
|
-
/** @typedef {import("./Entrypoint")} Entrypoint */
|
35
35
|
/** @typedef {import("./Module")} Module */
|
36
36
|
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
37
37
|
/** @typedef {import("./RuntimeModule")} RuntimeModule */
|
@@ -1042,16 +1042,22 @@ class ChunkGraph {
|
|
1042
1042
|
* @returns {Iterable<Chunk>} iterable of chunks
|
1043
1043
|
*/
|
1044
1044
|
getChunkEntryDependentChunksIterable(chunk) {
|
1045
|
-
const cgc = this._getChunkGraphChunk(chunk);
|
1046
1045
|
/** @type {Set<Chunk>} */
|
1047
1046
|
const set = new Set();
|
1048
|
-
for (const chunkGroup of
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1047
|
+
for (const chunkGroup of chunk.groupsIterable) {
|
1048
|
+
if (chunkGroup instanceof Entrypoint) {
|
1049
|
+
const entrypointChunk = chunkGroup.getEntrypointChunk();
|
1050
|
+
const cgc = this._getChunkGraphChunk(entrypointChunk);
|
1051
|
+
for (const chunkGroup of cgc.entryModules.values()) {
|
1052
|
+
for (const c of chunkGroup.chunks) {
|
1053
|
+
if (c !== chunk && c !== entrypointChunk && !c.hasRuntime()) {
|
1054
|
+
set.add(c);
|
1055
|
+
}
|
1056
|
+
}
|
1052
1057
|
}
|
1053
1058
|
}
|
1054
1059
|
}
|
1060
|
+
|
1055
1061
|
return set;
|
1056
1062
|
}
|
1057
1063
|
|
package/lib/CleanPlugin.js
CHANGED
@@ -6,11 +6,10 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const asyncLib = require("neo-async");
|
9
|
-
const { validate } = require("schema-utils");
|
10
9
|
const { SyncBailHook } = require("tapable");
|
11
10
|
const Compilation = require("../lib/Compilation");
|
11
|
+
const createSchemaValidation = require("./util/create-schema-validation");
|
12
12
|
const { join } = require("./util/fs");
|
13
|
-
const memoize = require("./util/memoize");
|
14
13
|
const processAsyncTree = require("./util/processAsyncTree");
|
15
14
|
|
16
15
|
/** @typedef {import("../declarations/WebpackOptions").CleanOptions} CleanOptions */
|
@@ -26,13 +25,20 @@ const processAsyncTree = require("./util/processAsyncTree");
|
|
26
25
|
* @property {SyncBailHook<[string], boolean>} keep when returning true the file/directory will be kept during cleaning, returning false will clean it and ignore the following plugins and config
|
27
26
|
*/
|
28
27
|
|
29
|
-
const
|
30
|
-
|
31
|
-
|
32
|
-
definitions
|
33
|
-
|
34
|
-
|
35
|
-
}
|
28
|
+
const validate = createSchemaValidation(
|
29
|
+
undefined,
|
30
|
+
() => {
|
31
|
+
const { definitions } = require("../schemas/WebpackOptions.json");
|
32
|
+
return {
|
33
|
+
definitions,
|
34
|
+
oneOf: [{ $ref: "#/definitions/CleanOptions" }]
|
35
|
+
};
|
36
|
+
},
|
37
|
+
{
|
38
|
+
name: "Clean Plugin",
|
39
|
+
baseDataPath: "options"
|
40
|
+
}
|
41
|
+
);
|
36
42
|
|
37
43
|
/**
|
38
44
|
* @param {OutputFileSystem} fs filesystem
|
@@ -255,13 +261,9 @@ class CleanPlugin {
|
|
255
261
|
return hooks;
|
256
262
|
}
|
257
263
|
|
258
|
-
/** @param {CleanOptions}
|
264
|
+
/** @param {CleanOptions} options options */
|
259
265
|
constructor(options = {}) {
|
260
|
-
validate(
|
261
|
-
name: "Clean Plugin",
|
262
|
-
baseDataPath: "options"
|
263
|
-
});
|
264
|
-
|
266
|
+
validate(options);
|
265
267
|
this.options = { dry: false, ...options };
|
266
268
|
}
|
267
269
|
|
package/lib/Compilation.js
CHANGED
@@ -4035,7 +4035,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4035
4035
|
|
4036
4036
|
const entrypoint = new Entrypoint({
|
4037
4037
|
runtime,
|
4038
|
-
chunkLoading:
|
4038
|
+
chunkLoading: false,
|
4039
4039
|
...options.entryOptions
|
4040
4040
|
});
|
4041
4041
|
chunkGraph.connectChunkAndEntryModule(chunk, module, entrypoint);
|
package/lib/DllPlugin.js
CHANGED
@@ -8,22 +8,26 @@
|
|
8
8
|
const DllEntryPlugin = require("./DllEntryPlugin");
|
9
9
|
const FlagAllModulesAsUsedPlugin = require("./FlagAllModulesAsUsedPlugin");
|
10
10
|
const LibManifestPlugin = require("./LibManifestPlugin");
|
11
|
-
|
12
|
-
const { validate } = require("schema-utils");
|
13
|
-
const schema = require("../schemas/plugins/DllPlugin.json");
|
11
|
+
const createSchemaValidation = require("./util/create-schema-validation");
|
14
12
|
|
15
13
|
/** @typedef {import("../declarations/plugins/DllPlugin").DllPluginOptions} DllPluginOptions */
|
16
14
|
/** @typedef {import("./Compiler")} Compiler */
|
17
15
|
|
16
|
+
const validate = createSchemaValidation(
|
17
|
+
require("../schemas/plugins/DllPlugin.check.js"),
|
18
|
+
() => require("../schemas/plugins/DllPlugin.json"),
|
19
|
+
{
|
20
|
+
name: "Dll Plugin",
|
21
|
+
baseDataPath: "options"
|
22
|
+
}
|
23
|
+
);
|
24
|
+
|
18
25
|
class DllPlugin {
|
19
26
|
/**
|
20
27
|
* @param {DllPluginOptions} options options object
|
21
28
|
*/
|
22
29
|
constructor(options) {
|
23
|
-
validate(
|
24
|
-
name: "Dll Plugin",
|
25
|
-
baseDataPath: "options"
|
26
|
-
});
|
30
|
+
validate(options);
|
27
31
|
this.options = {
|
28
32
|
...options,
|
29
33
|
entryOnly: options.entryOnly !== false
|
@@ -10,24 +10,28 @@ const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
|
|
10
10
|
const ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin");
|
11
11
|
const WebpackError = require("./WebpackError");
|
12
12
|
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
|
13
|
+
const createSchemaValidation = require("./util/create-schema-validation");
|
13
14
|
const makePathsRelative = require("./util/identifier").makePathsRelative;
|
14
15
|
|
15
|
-
const { validate } = require("schema-utils");
|
16
|
-
const schema = require("../schemas/plugins/DllReferencePlugin.json");
|
17
|
-
|
18
16
|
/** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
|
19
17
|
/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */
|
20
18
|
/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptionsManifest} DllReferencePluginOptionsManifest */
|
21
19
|
|
20
|
+
const validate = createSchemaValidation(
|
21
|
+
require("../schemas/plugins/DllReferencePlugin.check.js"),
|
22
|
+
() => require("../schemas/plugins/DllReferencePlugin.json"),
|
23
|
+
{
|
24
|
+
name: "Dll Reference Plugin",
|
25
|
+
baseDataPath: "options"
|
26
|
+
}
|
27
|
+
);
|
28
|
+
|
22
29
|
class DllReferencePlugin {
|
23
30
|
/**
|
24
31
|
* @param {DllReferencePluginOptions} options options object
|
25
32
|
*/
|
26
33
|
constructor(options) {
|
27
|
-
validate(
|
28
|
-
name: "Dll Reference Plugin",
|
29
|
-
baseDataPath: "options"
|
30
|
-
});
|
34
|
+
validate(options);
|
31
35
|
this.options = options;
|
32
36
|
/** @type {WeakMap<Object, {path: string, data: DllReferencePluginOptionsManifest?, error: Error?}>} */
|
33
37
|
this._compilationData = new WeakMap();
|
package/lib/FileSystemInfo.js
CHANGED
@@ -77,6 +77,92 @@ const DONE_ITERATOR_RESULT = new Set().keys().next();
|
|
77
77
|
// Tsh = Timestamp + Hash
|
78
78
|
// Tshs = Timestamp + Hash combinations
|
79
79
|
|
80
|
+
class SnapshotIterator {
|
81
|
+
constructor(next) {
|
82
|
+
this.next = next;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
class SnapshotIterable {
|
87
|
+
constructor(snapshot, getMaps) {
|
88
|
+
this.snapshot = snapshot;
|
89
|
+
this.getMaps = getMaps;
|
90
|
+
}
|
91
|
+
|
92
|
+
[Symbol.iterator]() {
|
93
|
+
let state = 0;
|
94
|
+
/** @type {IterableIterator<string>} */
|
95
|
+
let it;
|
96
|
+
/** @type {(Snapshot) => (Map<string, any> | Set<string>)[]} */
|
97
|
+
let getMaps;
|
98
|
+
/** @type {(Map<string, any> | Set<string>)[]} */
|
99
|
+
let maps;
|
100
|
+
/** @type {Snapshot} */
|
101
|
+
let snapshot;
|
102
|
+
let queue;
|
103
|
+
return new SnapshotIterator(() => {
|
104
|
+
for (;;) {
|
105
|
+
switch (state) {
|
106
|
+
case 0:
|
107
|
+
snapshot = this.snapshot;
|
108
|
+
getMaps = this.getMaps;
|
109
|
+
maps = getMaps(snapshot);
|
110
|
+
state = 1;
|
111
|
+
/* falls through */
|
112
|
+
case 1:
|
113
|
+
if (maps.length > 0) {
|
114
|
+
const map = maps.pop();
|
115
|
+
if (map !== undefined) {
|
116
|
+
it = map.keys();
|
117
|
+
state = 2;
|
118
|
+
} else {
|
119
|
+
break;
|
120
|
+
}
|
121
|
+
} else {
|
122
|
+
state = 3;
|
123
|
+
break;
|
124
|
+
}
|
125
|
+
/* falls through */
|
126
|
+
case 2: {
|
127
|
+
const result = it.next();
|
128
|
+
if (!result.done) return result;
|
129
|
+
state = 1;
|
130
|
+
break;
|
131
|
+
}
|
132
|
+
case 3: {
|
133
|
+
const children = snapshot.children;
|
134
|
+
if (children !== undefined) {
|
135
|
+
if (children.size === 1) {
|
136
|
+
// shortcut for a single child
|
137
|
+
// avoids allocation of queue
|
138
|
+
for (const child of children) snapshot = child;
|
139
|
+
maps = getMaps(snapshot);
|
140
|
+
state = 1;
|
141
|
+
break;
|
142
|
+
}
|
143
|
+
if (queue === undefined) queue = [];
|
144
|
+
for (const child of children) {
|
145
|
+
queue.push(child);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
if (queue !== undefined && queue.length > 0) {
|
149
|
+
snapshot = queue.pop();
|
150
|
+
maps = getMaps(snapshot);
|
151
|
+
state = 1;
|
152
|
+
break;
|
153
|
+
} else {
|
154
|
+
state = 4;
|
155
|
+
}
|
156
|
+
}
|
157
|
+
/* falls through */
|
158
|
+
case 4:
|
159
|
+
return DONE_ITERATOR_RESULT;
|
160
|
+
}
|
161
|
+
}
|
162
|
+
});
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
80
166
|
class Snapshot {
|
81
167
|
constructor() {
|
82
168
|
this._flags = 0;
|
@@ -283,63 +369,7 @@ class Snapshot {
|
|
283
369
|
* @returns {Iterable<string>} iterable
|
284
370
|
*/
|
285
371
|
_createIterable(getMaps) {
|
286
|
-
|
287
|
-
return {
|
288
|
-
[Symbol.iterator]() {
|
289
|
-
let state = 0;
|
290
|
-
/** @type {IterableIterator<string>} */
|
291
|
-
let it;
|
292
|
-
let maps = getMaps(snapshot);
|
293
|
-
const queue = [];
|
294
|
-
return {
|
295
|
-
next() {
|
296
|
-
for (;;) {
|
297
|
-
switch (state) {
|
298
|
-
case 0:
|
299
|
-
if (maps.length > 0) {
|
300
|
-
const map = maps.pop();
|
301
|
-
if (map !== undefined) {
|
302
|
-
it = map.keys();
|
303
|
-
state = 1;
|
304
|
-
} else {
|
305
|
-
break;
|
306
|
-
}
|
307
|
-
} else {
|
308
|
-
state = 2;
|
309
|
-
break;
|
310
|
-
}
|
311
|
-
/* falls through */
|
312
|
-
case 1: {
|
313
|
-
const result = it.next();
|
314
|
-
if (!result.done) return result;
|
315
|
-
state = 0;
|
316
|
-
break;
|
317
|
-
}
|
318
|
-
case 2: {
|
319
|
-
const children = snapshot.children;
|
320
|
-
if (children !== undefined) {
|
321
|
-
for (const child of children) {
|
322
|
-
queue.push(child);
|
323
|
-
}
|
324
|
-
}
|
325
|
-
if (queue.length > 0) {
|
326
|
-
snapshot = queue.pop();
|
327
|
-
maps = getMaps(snapshot);
|
328
|
-
state = 0;
|
329
|
-
break;
|
330
|
-
} else {
|
331
|
-
state = 3;
|
332
|
-
}
|
333
|
-
}
|
334
|
-
/* falls through */
|
335
|
-
case 3:
|
336
|
-
return DONE_ITERATOR_RESULT;
|
337
|
-
}
|
338
|
-
}
|
339
|
-
}
|
340
|
-
};
|
341
|
-
}
|
342
|
-
};
|
372
|
+
return new SnapshotIterable(this, getMaps);
|
343
373
|
}
|
344
374
|
|
345
375
|
/**
|
@@ -1219,7 +1249,7 @@ class FileSystemInfo {
|
|
1219
1249
|
return callback();
|
1220
1250
|
}
|
1221
1251
|
resolveResults.set(key, undefined);
|
1222
|
-
resolveContext(context, path, resolverContext, (err, result) => {
|
1252
|
+
resolveContext(context, path, resolverContext, (err, _, result) => {
|
1223
1253
|
if (err) {
|
1224
1254
|
if (expected === false) {
|
1225
1255
|
resolveResults.set(key, false);
|
@@ -1229,11 +1259,12 @@ class FileSystemInfo {
|
|
1229
1259
|
err.message += `\nwhile resolving '${path}' in ${context} to a directory`;
|
1230
1260
|
return callback(err);
|
1231
1261
|
}
|
1232
|
-
|
1262
|
+
const resultPath = result.path;
|
1263
|
+
resolveResults.set(key, resultPath);
|
1233
1264
|
push({
|
1234
1265
|
type: RBDT_DIRECTORY,
|
1235
1266
|
context: undefined,
|
1236
|
-
path:
|
1267
|
+
path: resultPath,
|
1237
1268
|
expected: undefined,
|
1238
1269
|
issuer: job
|
1239
1270
|
});
|
@@ -1246,14 +1277,16 @@ class FileSystemInfo {
|
|
1246
1277
|
return callback();
|
1247
1278
|
}
|
1248
1279
|
resolveResults.set(key, undefined);
|
1249
|
-
resolve(context, path, resolverContext, (err, result) => {
|
1280
|
+
resolve(context, path, resolverContext, (err, _, result) => {
|
1250
1281
|
if (typeof expected === "string") {
|
1251
|
-
if (result === expected) {
|
1252
|
-
resolveResults.set(key, result);
|
1282
|
+
if (!err && result && result.path === expected) {
|
1283
|
+
resolveResults.set(key, result.path);
|
1253
1284
|
} else {
|
1254
1285
|
invalidResolveResults.add(key);
|
1255
1286
|
this.logger.warn(
|
1256
|
-
`Resolving '${path}' in ${context} for build dependencies doesn't lead to expected result '${expected}', but to '${
|
1287
|
+
`Resolving '${path}' in ${context} for build dependencies doesn't lead to expected result '${expected}', but to '${
|
1288
|
+
err || (result && result.path)
|
1289
|
+
}' instead. Resolving dependencies are ignored for this path.\n${pathToString(
|
1257
1290
|
job
|
1258
1291
|
)}`
|
1259
1292
|
);
|
@@ -1270,11 +1303,12 @@ class FileSystemInfo {
|
|
1270
1303
|
)}`;
|
1271
1304
|
return callback(err);
|
1272
1305
|
}
|
1273
|
-
|
1306
|
+
const resultPath = result.path;
|
1307
|
+
resolveResults.set(key, resultPath);
|
1274
1308
|
push({
|
1275
1309
|
type: RBDT_FILE,
|
1276
1310
|
context: undefined,
|
1277
|
-
path:
|
1311
|
+
path: resultPath,
|
1278
1312
|
expected: undefined,
|
1279
1313
|
issuer: job
|
1280
1314
|
});
|
@@ -1616,38 +1650,42 @@ class FileSystemInfo {
|
|
1616
1650
|
const [type, context, path] = key.split("\n");
|
1617
1651
|
switch (type) {
|
1618
1652
|
case "d":
|
1619
|
-
resolveContext(context, path, {}, (err, result) => {
|
1653
|
+
resolveContext(context, path, {}, (err, _, result) => {
|
1620
1654
|
if (expectedResult === false)
|
1621
1655
|
return callback(err ? undefined : INVALID);
|
1622
1656
|
if (err) return callback(err);
|
1623
|
-
|
1657
|
+
const resultPath = result.path;
|
1658
|
+
if (resultPath !== expectedResult) return callback(INVALID);
|
1624
1659
|
callback();
|
1625
1660
|
});
|
1626
1661
|
break;
|
1627
1662
|
case "f":
|
1628
|
-
resolveCjs(context, path, {}, (err, result) => {
|
1663
|
+
resolveCjs(context, path, {}, (err, _, result) => {
|
1629
1664
|
if (expectedResult === false)
|
1630
1665
|
return callback(err ? undefined : INVALID);
|
1631
1666
|
if (err) return callback(err);
|
1632
|
-
|
1667
|
+
const resultPath = result.path;
|
1668
|
+
if (resultPath !== expectedResult) return callback(INVALID);
|
1633
1669
|
callback();
|
1634
1670
|
});
|
1635
1671
|
break;
|
1636
1672
|
case "c":
|
1637
|
-
resolveCjsAsChild(context, path, {}, (err, result) => {
|
1673
|
+
resolveCjsAsChild(context, path, {}, (err, _, result) => {
|
1638
1674
|
if (expectedResult === false)
|
1639
1675
|
return callback(err ? undefined : INVALID);
|
1640
1676
|
if (err) return callback(err);
|
1641
|
-
|
1677
|
+
const resultPath = result.path;
|
1678
|
+
if (resultPath !== expectedResult) return callback(INVALID);
|
1642
1679
|
callback();
|
1643
1680
|
});
|
1644
1681
|
break;
|
1645
1682
|
case "e":
|
1646
|
-
resolveEsm(context, path, {}, (err, result) => {
|
1683
|
+
resolveEsm(context, path, {}, (err, _, result) => {
|
1647
1684
|
if (expectedResult === false)
|
1648
1685
|
return callback(err ? undefined : INVALID);
|
1649
1686
|
if (err) return callback(err);
|
1650
|
-
|
1687
|
+
const resultPath = result.path;
|
1688
|
+
if (resultPath !== expectedResult) return callback(INVALID);
|
1651
1689
|
callback();
|
1652
1690
|
});
|
1653
1691
|
break;
|
package/lib/IgnorePlugin.js
CHANGED
@@ -5,22 +5,27 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
const
|
9
|
-
const schema = require("../schemas/plugins/IgnorePlugin.json");
|
8
|
+
const createSchemaValidation = require("./util/create-schema-validation");
|
10
9
|
|
11
10
|
/** @typedef {import("../declarations/plugins/IgnorePlugin").IgnorePluginOptions} IgnorePluginOptions */
|
12
11
|
/** @typedef {import("./Compiler")} Compiler */
|
13
12
|
/** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */
|
14
13
|
|
14
|
+
const validate = createSchemaValidation(
|
15
|
+
require("../schemas/plugins/IgnorePlugin.check.js"),
|
16
|
+
() => require("../schemas/plugins/IgnorePlugin.json"),
|
17
|
+
{
|
18
|
+
name: "Ignore Plugin",
|
19
|
+
baseDataPath: "options"
|
20
|
+
}
|
21
|
+
);
|
22
|
+
|
15
23
|
class IgnorePlugin {
|
16
24
|
/**
|
17
25
|
* @param {IgnorePluginOptions} options IgnorePlugin options
|
18
26
|
*/
|
19
27
|
constructor(options) {
|
20
|
-
validate(
|
21
|
-
name: "Ignore Plugin",
|
22
|
-
baseDataPath: "options"
|
23
|
-
});
|
28
|
+
validate(options);
|
24
29
|
this.options = options;
|
25
30
|
|
26
31
|
/** @private @type {Function} */
|
@@ -7,22 +7,25 @@
|
|
7
7
|
|
8
8
|
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
9
9
|
const NormalModule = require("./NormalModule");
|
10
|
-
|
11
|
-
const { validate } = require("schema-utils");
|
12
|
-
const schema = require("../schemas/plugins/LoaderOptionsPlugin.json");
|
10
|
+
const createSchemaValidation = require("./util/create-schema-validation");
|
13
11
|
|
14
12
|
/** @typedef {import("../declarations/plugins/LoaderOptionsPlugin").LoaderOptionsPluginOptions} LoaderOptionsPluginOptions */
|
15
13
|
/** @typedef {import("./Compiler")} Compiler */
|
16
14
|
|
15
|
+
const validate = createSchemaValidation(
|
16
|
+
require("../schemas/plugins/LoaderOptionsPlugin.check.js"),
|
17
|
+
() => require("../schemas/plugins/LoaderOptionsPlugin.json"),
|
18
|
+
{
|
19
|
+
name: "Loader Options Plugin",
|
20
|
+
baseDataPath: "options"
|
21
|
+
}
|
22
|
+
);
|
17
23
|
class LoaderOptionsPlugin {
|
18
24
|
/**
|
19
25
|
* @param {LoaderOptionsPluginOptions} options options object
|
20
26
|
*/
|
21
27
|
constructor(options = {}) {
|
22
|
-
validate(
|
23
|
-
name: "Loader Options Plugin",
|
24
|
-
baseDataPath: "options"
|
25
|
-
});
|
28
|
+
validate(options);
|
26
29
|
if (typeof options !== "object") options = {};
|
27
30
|
if (!options.test) {
|
28
31
|
options.test = {
|
package/lib/NormalModule.js
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
const parseJson = require("json-parse-better-errors");
|
9
9
|
const { getContext, runLoaders } = require("loader-runner");
|
10
10
|
const querystring = require("querystring");
|
11
|
-
const { validate } = require("schema-utils");
|
12
11
|
const { HookMap, SyncHook, AsyncSeriesBailHook } = require("tapable");
|
13
12
|
const {
|
14
13
|
CachedSource,
|
@@ -68,6 +67,7 @@ const memoize = require("./util/memoize");
|
|
68
67
|
const getInvalidDependenciesModuleWarning = memoize(() =>
|
69
68
|
require("./InvalidDependenciesModuleWarning")
|
70
69
|
);
|
70
|
+
const getValidate = memoize(() => require("schema-utils").validate);
|
71
71
|
|
72
72
|
const ABSOLUTE_PATH_REGEX = /^([a-zA-Z]:\\|\\\\|\/)/;
|
73
73
|
|
@@ -499,7 +499,7 @@ class NormalModule extends Module {
|
|
499
499
|
if (schema.title && (match = /^(.+) (.+)$/.exec(schema.title))) {
|
500
500
|
[, name, baseDataPath] = match;
|
501
501
|
}
|
502
|
-
|
502
|
+
getValidate()(schema, options, {
|
503
503
|
name,
|
504
504
|
baseDataPath
|
505
505
|
});
|
package/lib/ProgressPlugin.js
CHANGED
@@ -5,17 +5,24 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
const { validate } = require("schema-utils");
|
9
|
-
const schema = require("../schemas/plugins/ProgressPlugin.json");
|
10
8
|
const Compiler = require("./Compiler");
|
11
9
|
const MultiCompiler = require("./MultiCompiler");
|
12
10
|
const NormalModule = require("./NormalModule");
|
11
|
+
const createSchemaValidation = require("./util/create-schema-validation");
|
13
12
|
const { contextify } = require("./util/identifier");
|
14
13
|
|
15
14
|
/** @typedef {import("../declarations/plugins/ProgressPlugin").HandlerFunction} HandlerFunction */
|
16
15
|
/** @typedef {import("../declarations/plugins/ProgressPlugin").ProgressPluginArgument} ProgressPluginArgument */
|
17
16
|
/** @typedef {import("../declarations/plugins/ProgressPlugin").ProgressPluginOptions} ProgressPluginOptions */
|
18
17
|
|
18
|
+
const validate = createSchemaValidation(
|
19
|
+
require("../schemas/plugins/ProgressPlugin.check.js"),
|
20
|
+
() => require("../schemas/plugins/ProgressPlugin.json"),
|
21
|
+
{
|
22
|
+
name: "Progress Plugin",
|
23
|
+
baseDataPath: "options"
|
24
|
+
}
|
25
|
+
);
|
19
26
|
const median3 = (a, b, c) => {
|
20
27
|
return a + b + c - Math.max(a, b, c) - Math.min(a, b, c);
|
21
28
|
};
|
@@ -115,10 +122,7 @@ class ProgressPlugin {
|
|
115
122
|
};
|
116
123
|
}
|
117
124
|
|
118
|
-
validate(
|
119
|
-
name: "Progress Plugin",
|
120
|
-
baseDataPath: "options"
|
121
|
-
});
|
125
|
+
validate(options);
|
122
126
|
options = { ...ProgressPlugin.defaultOptions, ...options };
|
123
127
|
|
124
128
|
this.profile = options.profile;
|
package/lib/RuntimePlugin.js
CHANGED
@@ -179,7 +179,9 @@ class RuntimePlugin {
|
|
179
179
|
const { publicPath: globalPublicPath, scriptType } = outputOptions;
|
180
180
|
const entryOptions = chunk.getEntryOptions();
|
181
181
|
const publicPath =
|
182
|
-
|
182
|
+
entryOptions && entryOptions.publicPath !== undefined
|
183
|
+
? entryOptions.publicPath
|
184
|
+
: globalPublicPath;
|
183
185
|
|
184
186
|
if (publicPath === "auto") {
|
185
187
|
const module = new AutoPublicPathRuntimeModule();
|
@@ -6,18 +6,16 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const asyncLib = require("neo-async");
|
9
|
-
const { validate } = require("schema-utils");
|
10
9
|
const { ConcatSource, RawSource } = require("webpack-sources");
|
11
10
|
const Compilation = require("./Compilation");
|
12
11
|
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
13
12
|
const ProgressPlugin = require("./ProgressPlugin");
|
14
13
|
const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
|
14
|
+
const createSchemaValidation = require("./util/create-schema-validation");
|
15
15
|
const createHash = require("./util/createHash");
|
16
16
|
const { relative, dirname } = require("./util/fs");
|
17
17
|
const { absolutify } = require("./util/identifier");
|
18
18
|
|
19
|
-
const schema = require("../schemas/plugins/SourceMapDevToolPlugin.json");
|
20
|
-
|
21
19
|
/** @typedef {import("source-map").RawSourceMap} SourceMap */
|
22
20
|
/** @typedef {import("webpack-sources").MapOptions} MapOptions */
|
23
21
|
/** @typedef {import("webpack-sources").Source} Source */
|
@@ -30,6 +28,14 @@ const schema = require("../schemas/plugins/SourceMapDevToolPlugin.json");
|
|
30
28
|
/** @typedef {import("./Module")} Module */
|
31
29
|
/** @typedef {import("./util/Hash")} Hash */
|
32
30
|
|
31
|
+
const validate = createSchemaValidation(
|
32
|
+
require("../schemas/plugins/SourceMapDevToolPlugin.check.js"),
|
33
|
+
() => require("../schemas/plugins/SourceMapDevToolPlugin.json"),
|
34
|
+
{
|
35
|
+
name: "SourceMap DevTool Plugin",
|
36
|
+
baseDataPath: "options"
|
37
|
+
}
|
38
|
+
);
|
33
39
|
/**
|
34
40
|
* @typedef {object} SourceMapTask
|
35
41
|
* @property {Source} asset
|
@@ -110,10 +116,7 @@ class SourceMapDevToolPlugin {
|
|
110
116
|
* @throws {Error} throws error, if got more than 1 arguments
|
111
117
|
*/
|
112
118
|
constructor(options = {}) {
|
113
|
-
validate(
|
114
|
-
name: "SourceMap DevTool Plugin",
|
115
|
-
baseDataPath: "options"
|
116
|
-
});
|
119
|
+
validate(options);
|
117
120
|
|
118
121
|
/** @type {string | false} */
|
119
122
|
this.sourceMapFilename = options.filename;
|