webpack 5.64.2 → 5.66.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/CacheFacade.js +2 -9
- package/lib/Chunk.js +2 -0
- package/lib/Compilation.js +79 -38
- package/lib/Dependency.js +10 -0
- package/lib/DependencyTemplate.js +9 -0
- package/lib/ExternalModule.js +93 -53
- package/lib/Generator.js +2 -0
- package/lib/Module.js +24 -1
- package/lib/ModuleFilenameHelpers.js +5 -1
- package/lib/NormalModule.js +3 -1
- package/lib/RuntimeGlobals.js +11 -1
- package/lib/RuntimePlugin.js +25 -0
- package/lib/RuntimeTemplate.js +113 -2
- package/lib/Template.js +2 -1
- package/lib/WatchIgnorePlugin.js +14 -1
- package/lib/Watching.js +32 -18
- package/lib/WebpackOptionsApply.js +43 -2
- package/lib/asset/AssetGenerator.js +10 -7
- package/lib/asset/RawDataUrlModule.js +145 -0
- package/lib/config/browserslistTargetHandler.js +38 -1
- package/lib/config/defaults.js +60 -4
- package/lib/config/target.js +10 -0
- package/lib/container/ContainerEntryModule.js +4 -3
- package/lib/css/CssGenerator.js +106 -0
- package/lib/css/CssLoadingRuntimeModule.js +393 -0
- package/lib/css/CssModulesPlugin.js +444 -0
- package/lib/css/CssParser.js +618 -0
- package/lib/css/walkCssTokens.js +659 -0
- package/lib/dependencies/CssExportDependency.js +85 -0
- package/lib/dependencies/CssImportDependency.js +75 -0
- package/lib/dependencies/CssLocalIdentifierDependency.js +119 -0
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +101 -0
- package/lib/dependencies/CssUrlDependency.js +132 -0
- package/lib/dependencies/URLDependency.js +3 -8
- package/lib/esm/ModuleChunkFormatPlugin.js +74 -49
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -1
- package/lib/hmr/lazyCompilationBackend.js +3 -1
- package/lib/index.js +3 -0
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +2 -2
- package/lib/javascript/ChunkHelpers.js +33 -0
- package/lib/javascript/JavascriptGenerator.js +1 -0
- package/lib/javascript/JavascriptParser.js +16 -8
- package/lib/javascript/StartupHelpers.js +4 -28
- package/lib/library/AssignLibraryPlugin.js +31 -13
- package/lib/library/EnableLibraryPlugin.js +11 -0
- package/lib/node/NodeWatchFileSystem.js +85 -31
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +10 -4
- package/lib/sharing/ConsumeSharedModule.js +4 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +25 -4
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/util/create-schema-validation.js +9 -2
- package/lib/util/extractUrlAndGlobal.js +3 -0
- package/lib/util/fs.js +10 -0
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/internalSerializables.js +11 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +3 -3
- package/lib/webpack.js +9 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +3 -2
- package/package.json +4 -4
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +63 -1
- package/schemas/plugins/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.json +2 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +3 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
- package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
- package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssParserOptions.json +3 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
- package/types.d.ts +147 -21
@@ -81,7 +81,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
81
81
|
);
|
82
82
|
const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
|
83
83
|
const hasJsMatcher = compileBooleanMatcher(conditionMap);
|
84
|
-
const initialChunkIds = getInitialChunkIds(chunk, chunkGraph);
|
84
|
+
const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
|
85
85
|
|
86
86
|
const outputName = this.compilation.getPath(
|
87
87
|
getChunkFilenameTemplate(chunk, this.compilation.outputOptions),
|
@@ -68,7 +68,9 @@ module.exports = options => (compiler, callback) => {
|
|
68
68
|
req.socket.setNoDelay(true);
|
69
69
|
res.writeHead(200, {
|
70
70
|
"content-type": "text/event-stream",
|
71
|
-
"Access-Control-Allow-Origin": "*"
|
71
|
+
"Access-Control-Allow-Origin": "*",
|
72
|
+
"Access-Control-Allow-Methods": "*",
|
73
|
+
"Access-Control-Allow-Headers": "*"
|
72
74
|
});
|
73
75
|
res.write("\n");
|
74
76
|
let moduleActivated = false;
|
package/lib/index.js
CHANGED
@@ -19,6 +19,7 @@ const memoize = require("./util/memoize");
|
|
19
19
|
/** @typedef {import("../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
20
20
|
/** @typedef {import("../declarations/WebpackOptions").RuleSetUse} RuleSetUse */
|
21
21
|
/** @typedef {import("../declarations/WebpackOptions").RuleSetUseItem} RuleSetUseItem */
|
22
|
+
/** @typedef {import("../declarations/WebpackOptions").StatsOptions} StatsOptions */
|
22
23
|
/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} Configuration */
|
23
24
|
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptionsNormalized */
|
24
25
|
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
|
@@ -27,6 +28,8 @@ const memoize = require("./util/memoize");
|
|
27
28
|
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
28
29
|
/** @typedef {import("./MultiStats")} MultiStats */
|
29
30
|
/** @typedef {import("./Parser").ParserState} ParserState */
|
31
|
+
/** @typedef {import("./ResolverFactory").ResolvePluginInstance} ResolvePluginInstance */
|
32
|
+
/** @typedef {import("./ResolverFactory").Resolver} Resolver */
|
30
33
|
/** @typedef {import("./Watching")} Watching */
|
31
34
|
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsAsset} StatsAsset */
|
32
35
|
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsChunk} StatsChunk */
|
@@ -45,7 +45,7 @@ class ArrayPushCallbackChunkFormatPlugin {
|
|
45
45
|
const { chunk, chunkGraph, runtimeTemplate } = renderContext;
|
46
46
|
const hotUpdateChunk =
|
47
47
|
chunk instanceof HotUpdateChunk ? chunk : null;
|
48
|
-
const globalObject = runtimeTemplate.
|
48
|
+
const globalObject = runtimeTemplate.globalObject;
|
49
49
|
const source = new ConcatSource();
|
50
50
|
const runtimeModules =
|
51
51
|
chunkGraph.getChunkRuntimeModulesInOrder(chunk);
|
@@ -138,7 +138,7 @@ class ArrayPushCallbackChunkFormatPlugin {
|
|
138
138
|
(chunk, hash, { chunkGraph, runtimeTemplate }) => {
|
139
139
|
if (chunk.hasRuntime()) return;
|
140
140
|
hash.update(
|
141
|
-
`ArrayPushCallbackChunkFormatPlugin1${runtimeTemplate.outputOptions.chunkLoadingGlobal}${runtimeTemplate.outputOptions.hotUpdateGlobal}${runtimeTemplate.
|
141
|
+
`ArrayPushCallbackChunkFormatPlugin1${runtimeTemplate.outputOptions.chunkLoadingGlobal}${runtimeTemplate.outputOptions.hotUpdateGlobal}${runtimeTemplate.globalObject}`
|
142
142
|
);
|
143
143
|
const entries = Array.from(
|
144
144
|
chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
const Entrypoint = require("../Entrypoint");
|
9
|
+
|
10
|
+
/** @typedef {import("../Chunk")} Chunk */
|
11
|
+
|
12
|
+
/**
|
13
|
+
* @param {Entrypoint} entrypoint a chunk group
|
14
|
+
* @param {Chunk} excludedChunk1 current chunk which is excluded
|
15
|
+
* @param {Chunk} excludedChunk2 runtime chunk which is excluded
|
16
|
+
* @returns {Set<Chunk>} chunks
|
17
|
+
*/
|
18
|
+
const getAllChunks = (entrypoint, excludedChunk1, excludedChunk2) => {
|
19
|
+
const queue = new Set([entrypoint]);
|
20
|
+
const chunks = new Set();
|
21
|
+
for (const entrypoint of queue) {
|
22
|
+
for (const chunk of entrypoint.chunks) {
|
23
|
+
if (chunk === excludedChunk1) continue;
|
24
|
+
if (chunk === excludedChunk2) continue;
|
25
|
+
chunks.add(chunk);
|
26
|
+
}
|
27
|
+
for (const parent of entrypoint.parentsIterable) {
|
28
|
+
if (parent instanceof Entrypoint) queue.add(parent);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
return chunks;
|
32
|
+
};
|
33
|
+
exports.getAllChunks = getAllChunks;
|
@@ -199,6 +199,7 @@ class JavascriptGenerator extends Generator {
|
|
199
199
|
runtime: generateContext.runtime,
|
200
200
|
runtimeRequirements: generateContext.runtimeRequirements,
|
201
201
|
concatenationScope: generateContext.concatenationScope,
|
202
|
+
codeGenerationResults: generateContext.codeGenerationResults,
|
202
203
|
initFragments
|
203
204
|
};
|
204
205
|
|
@@ -935,6 +935,13 @@ class JavascriptParser extends Parser {
|
|
935
935
|
.setString("undefined")
|
936
936
|
.setRange(expr.range);
|
937
937
|
});
|
938
|
+
this.hooks.evaluate.for("Identifier").tap("JavascriptParser", expr => {
|
939
|
+
if (/** @type {IdentifierNode} */ (expr).name === "undefined") {
|
940
|
+
return new BasicEvaluatedExpression()
|
941
|
+
.setUndefined()
|
942
|
+
.setRange(expr.range);
|
943
|
+
}
|
944
|
+
});
|
938
945
|
/**
|
939
946
|
* @param {string} exprType expression type name
|
940
947
|
* @param {function(ExpressionNode): GetInfoResult | undefined} getInfo get info
|
@@ -1189,14 +1196,15 @@ class JavascriptParser extends Parser {
|
|
1189
1196
|
const node = /** @type {TaggedTemplateExpressionNode} */ (_node);
|
1190
1197
|
const tag = this.evaluateExpression(node.tag);
|
1191
1198
|
|
1192
|
-
if (tag.isIdentifier() && tag.identifier
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1199
|
+
if (tag.isIdentifier() && tag.identifier === "String.raw") {
|
1200
|
+
const { quasis, parts } = getSimplifiedTemplateResult(
|
1201
|
+
"raw",
|
1202
|
+
node.quasi
|
1203
|
+
);
|
1204
|
+
return new BasicEvaluatedExpression()
|
1205
|
+
.setTemplateString(quasis, parts, "raw")
|
1206
|
+
.setRange(node.range);
|
1207
|
+
}
|
1200
1208
|
});
|
1201
1209
|
|
1202
1210
|
this.hooks.evaluateCallExpressionMember
|
@@ -5,11 +5,10 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
const Entrypoint = require("../Entrypoint");
|
9
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
10
9
|
const Template = require("../Template");
|
11
10
|
const { isSubset } = require("../util/SetHelpers");
|
12
|
-
const {
|
11
|
+
const { getAllChunks } = require("./ChunkHelpers");
|
13
12
|
|
14
13
|
/** @typedef {import("../util/Hash")} Hash */
|
15
14
|
/** @typedef {import("../Chunk")} Chunk */
|
@@ -19,30 +18,6 @@ const { chunkHasJs } = require("./JavascriptModulesPlugin");
|
|
19
18
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
20
19
|
/** @typedef {(string|number)[]} EntryItem */
|
21
20
|
|
22
|
-
// TODO move to this file to ../javascript/ChunkHelpers.js
|
23
|
-
|
24
|
-
/**
|
25
|
-
* @param {Entrypoint} entrypoint a chunk group
|
26
|
-
* @param {Chunk} excludedChunk1 current chunk which is excluded
|
27
|
-
* @param {Chunk} excludedChunk2 runtime chunk which is excluded
|
28
|
-
* @returns {Set<Chunk>} chunks
|
29
|
-
*/
|
30
|
-
const getAllChunks = (entrypoint, excludedChunk1, excludedChunk2) => {
|
31
|
-
const queue = new Set([entrypoint]);
|
32
|
-
const chunks = new Set();
|
33
|
-
for (const entrypoint of queue) {
|
34
|
-
for (const chunk of entrypoint.chunks) {
|
35
|
-
if (chunk === excludedChunk1) continue;
|
36
|
-
if (chunk === excludedChunk2) continue;
|
37
|
-
chunks.add(chunk);
|
38
|
-
}
|
39
|
-
for (const parent of entrypoint.parentsIterable) {
|
40
|
-
if (parent instanceof Entrypoint) queue.add(parent);
|
41
|
-
}
|
42
|
-
}
|
43
|
-
return chunks;
|
44
|
-
};
|
45
|
-
|
46
21
|
const EXPORT_PREFIX = "var __webpack_exports__ = ";
|
47
22
|
|
48
23
|
/**
|
@@ -143,12 +118,13 @@ exports.updateHashForEntryStartup = (hash, chunkGraph, entries, chunk) => {
|
|
143
118
|
/**
|
144
119
|
* @param {Chunk} chunk the chunk
|
145
120
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
121
|
+
* @param {function(Chunk, ChunkGraph): boolean} filterFn filter function
|
146
122
|
* @returns {Set<number | string>} initially fulfilled chunk ids
|
147
123
|
*/
|
148
|
-
exports.getInitialChunkIds = (chunk, chunkGraph) => {
|
124
|
+
exports.getInitialChunkIds = (chunk, chunkGraph, filterFn) => {
|
149
125
|
const initialChunkIds = new Set(chunk.ids);
|
150
126
|
for (const c of chunk.getAllInitialChunks()) {
|
151
|
-
if (c === chunk ||
|
127
|
+
if (c === chunk || filterFn(c, chunkGraph)) continue;
|
152
128
|
for (const id of c.ids) initialChunkIds.add(id);
|
153
129
|
}
|
154
130
|
return initialChunkIds;
|
@@ -92,7 +92,7 @@ const accessWithInit = (accessor, existingLength, initLast = false) => {
|
|
92
92
|
* @property {LibraryType} type
|
93
93
|
* @property {string[] | "global"} prefix name prefix
|
94
94
|
* @property {string | false} declare declare name as variable
|
95
|
-
* @property {"error"|"copy"|"assign"} unnamed behavior for unnamed library name
|
95
|
+
* @property {"error"|"static"|"copy"|"assign"} unnamed behavior for unnamed library name
|
96
96
|
* @property {"copy"|"assign"=} named behavior for named library name
|
97
97
|
*/
|
98
98
|
|
@@ -174,7 +174,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
|
|
174
174
|
|
175
175
|
_getPrefix(compilation) {
|
176
176
|
return this.prefix === "global"
|
177
|
-
? [compilation.
|
177
|
+
? [compilation.runtimeTemplate.globalObject]
|
178
178
|
: this.prefix;
|
179
179
|
}
|
180
180
|
|
@@ -261,19 +261,42 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
|
|
261
261
|
* @param {LibraryContext<T>} libraryContext context
|
262
262
|
* @returns {Source} source with library export
|
263
263
|
*/
|
264
|
-
renderStartup(
|
264
|
+
renderStartup(
|
265
|
+
source,
|
266
|
+
module,
|
267
|
+
{ moduleGraph, chunk },
|
268
|
+
{ options, compilation }
|
269
|
+
) {
|
265
270
|
const fullNameResolved = this._getResolvedFullName(
|
266
271
|
options,
|
267
272
|
chunk,
|
268
273
|
compilation
|
269
274
|
);
|
275
|
+
const staticExports = this.unnamed === "static";
|
270
276
|
const exportAccess = options.export
|
271
277
|
? propertyAccess(
|
272
278
|
Array.isArray(options.export) ? options.export : [options.export]
|
273
279
|
)
|
274
280
|
: "";
|
275
281
|
const result = new ConcatSource(source);
|
276
|
-
if (
|
282
|
+
if (staticExports) {
|
283
|
+
const exportsInfo = moduleGraph.getExportsInfo(module);
|
284
|
+
const exportTarget = accessWithInit(
|
285
|
+
fullNameResolved,
|
286
|
+
this._getPrefix(compilation).length,
|
287
|
+
true
|
288
|
+
);
|
289
|
+
for (const exportInfo of exportsInfo.orderedExports) {
|
290
|
+
if (!exportInfo.provided) continue;
|
291
|
+
const nameAccess = propertyAccess([exportInfo.name]);
|
292
|
+
result.add(
|
293
|
+
`${exportTarget}${nameAccess} = __webpack_exports__${exportAccess}${nameAccess};\n`
|
294
|
+
);
|
295
|
+
}
|
296
|
+
result.add(
|
297
|
+
`Object.defineProperty(${exportTarget}, "__esModule", { value: true });\n`
|
298
|
+
);
|
299
|
+
} else if (options.name ? this.named === "copy" : this.unnamed === "copy") {
|
277
300
|
result.add(
|
278
301
|
`var __webpack_export_target__ = ${accessWithInit(
|
279
302
|
fullNameResolved,
|
@@ -325,15 +348,10 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
|
|
325
348
|
*/
|
326
349
|
chunkHash(chunk, hash, chunkHashContext, { options, compilation }) {
|
327
350
|
hash.update("AssignLibraryPlugin");
|
328
|
-
const
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
const fullName = options.name ? prefix.concat(options.name) : prefix;
|
333
|
-
const fullNameResolved = fullName.map(n =>
|
334
|
-
compilation.getPath(n, {
|
335
|
-
chunk
|
336
|
-
})
|
351
|
+
const fullNameResolved = this._getResolvedFullName(
|
352
|
+
options,
|
353
|
+
chunk,
|
354
|
+
compilation
|
337
355
|
);
|
338
356
|
if (options.name ? this.named === "copy" : this.unnamed === "copy") {
|
339
357
|
hash.update("copy");
|
@@ -167,6 +167,17 @@ class EnableLibraryPlugin {
|
|
167
167
|
}).apply(compiler);
|
168
168
|
break;
|
169
169
|
}
|
170
|
+
case "commonjs-static": {
|
171
|
+
//@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697
|
172
|
+
const AssignLibraryPlugin = require("./AssignLibraryPlugin");
|
173
|
+
new AssignLibraryPlugin({
|
174
|
+
type,
|
175
|
+
prefix: ["exports"],
|
176
|
+
declare: false,
|
177
|
+
unnamed: "static"
|
178
|
+
}).apply(compiler);
|
179
|
+
break;
|
180
|
+
}
|
170
181
|
case "commonjs2":
|
171
182
|
case "commonjs-module": {
|
172
183
|
//@ts-expect-error https://github.com/microsoft/TypeScript/issues/41697
|
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const util = require("util");
|
8
9
|
const Watchpack = require("watchpack");
|
9
10
|
|
10
11
|
/** @typedef {import("../../declarations/WebpackOptions").WatchOptions} WatchOptions */
|
@@ -68,7 +69,22 @@ class NodeWatchFileSystem {
|
|
68
69
|
if (callbackUndelayed) {
|
69
70
|
this.watcher.once("change", callbackUndelayed);
|
70
71
|
}
|
72
|
+
|
73
|
+
const fetchTimeInfo = () => {
|
74
|
+
const fileTimeInfoEntries = new Map();
|
75
|
+
const contextTimeInfoEntries = new Map();
|
76
|
+
if (this.watcher) {
|
77
|
+
this.watcher.collectTimeInfoEntries(
|
78
|
+
fileTimeInfoEntries,
|
79
|
+
contextTimeInfoEntries
|
80
|
+
);
|
81
|
+
}
|
82
|
+
return { fileTimeInfoEntries, contextTimeInfoEntries };
|
83
|
+
};
|
71
84
|
this.watcher.once("aggregated", (changes, removals) => {
|
85
|
+
// pause emitting events (avoids clearing aggregated changes and removals on timeout)
|
86
|
+
this.watcher.pause();
|
87
|
+
|
72
88
|
if (this.inputFileSystem && this.inputFileSystem.purge) {
|
73
89
|
const fs = this.inputFileSystem;
|
74
90
|
for (const item of changes) {
|
@@ -78,8 +94,14 @@ class NodeWatchFileSystem {
|
|
78
94
|
fs.purge(item);
|
79
95
|
}
|
80
96
|
}
|
81
|
-
const
|
82
|
-
callback(
|
97
|
+
const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
|
98
|
+
callback(
|
99
|
+
null,
|
100
|
+
fileTimeInfoEntries,
|
101
|
+
contextTimeInfoEntries,
|
102
|
+
changes,
|
103
|
+
removals
|
104
|
+
);
|
83
105
|
});
|
84
106
|
|
85
107
|
this.watcher.watch({ files, directories, missing, startTime });
|
@@ -99,39 +121,71 @@ class NodeWatchFileSystem {
|
|
99
121
|
this.watcher.pause();
|
100
122
|
}
|
101
123
|
},
|
102
|
-
getAggregatedRemovals: (
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
124
|
+
getAggregatedRemovals: util.deprecate(
|
125
|
+
() => {
|
126
|
+
const items = this.watcher && this.watcher.aggregatedRemovals;
|
127
|
+
if (items && this.inputFileSystem && this.inputFileSystem.purge) {
|
128
|
+
const fs = this.inputFileSystem;
|
129
|
+
for (const item of items) {
|
130
|
+
fs.purge(item);
|
131
|
+
}
|
108
132
|
}
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
133
|
+
return items;
|
134
|
+
},
|
135
|
+
"Watcher.getAggregatedRemovals is deprecated in favor of Watcher.getInfo since that's more performant.",
|
136
|
+
"DEP_WEBPACK_WATCHER_GET_AGGREGATED_REMOVALS"
|
137
|
+
),
|
138
|
+
getAggregatedChanges: util.deprecate(
|
139
|
+
() => {
|
140
|
+
const items = this.watcher && this.watcher.aggregatedChanges;
|
141
|
+
if (items && this.inputFileSystem && this.inputFileSystem.purge) {
|
142
|
+
const fs = this.inputFileSystem;
|
143
|
+
for (const item of items) {
|
144
|
+
fs.purge(item);
|
145
|
+
}
|
146
|
+
}
|
147
|
+
return items;
|
148
|
+
},
|
149
|
+
"Watcher.getAggregatedChanges is deprecated in favor of Watcher.getInfo since that's more performant.",
|
150
|
+
"DEP_WEBPACK_WATCHER_GET_AGGREGATED_CHANGES"
|
151
|
+
),
|
152
|
+
getFileTimeInfoEntries: util.deprecate(
|
153
|
+
() => {
|
154
|
+
return fetchTimeInfo().fileTimeInfoEntries;
|
155
|
+
},
|
156
|
+
"Watcher.getFileTimeInfoEntries is deprecated in favor of Watcher.getInfo since that's more performant.",
|
157
|
+
"DEP_WEBPACK_WATCHER_FILE_TIME_INFO_ENTRIES"
|
158
|
+
),
|
159
|
+
getContextTimeInfoEntries: util.deprecate(
|
160
|
+
() => {
|
161
|
+
return fetchTimeInfo().contextTimeInfoEntries;
|
162
|
+
},
|
163
|
+
"Watcher.getContextTimeInfoEntries is deprecated in favor of Watcher.getInfo since that's more performant.",
|
164
|
+
"DEP_WEBPACK_WATCHER_CONTEXT_TIME_INFO_ENTRIES"
|
165
|
+
),
|
166
|
+
getInfo: () => {
|
167
|
+
const removals = this.watcher && this.watcher.aggregatedRemovals;
|
168
|
+
const changes = this.watcher && this.watcher.aggregatedChanges;
|
169
|
+
if (this.inputFileSystem && this.inputFileSystem.purge) {
|
115
170
|
const fs = this.inputFileSystem;
|
116
|
-
|
117
|
-
|
171
|
+
if (removals) {
|
172
|
+
for (const item of removals) {
|
173
|
+
fs.purge(item);
|
174
|
+
}
|
175
|
+
}
|
176
|
+
if (changes) {
|
177
|
+
for (const item of changes) {
|
178
|
+
fs.purge(item);
|
179
|
+
}
|
118
180
|
}
|
119
181
|
}
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
}
|
128
|
-
},
|
129
|
-
getContextTimeInfoEntries: () => {
|
130
|
-
if (this.watcher) {
|
131
|
-
return this.watcher.getTimeInfoEntries();
|
132
|
-
} else {
|
133
|
-
return new Map();
|
134
|
-
}
|
182
|
+
const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
|
183
|
+
return {
|
184
|
+
changes,
|
185
|
+
removals,
|
186
|
+
fileTimeInfoEntries,
|
187
|
+
contextTimeInfoEntries
|
188
|
+
};
|
135
189
|
}
|
136
190
|
};
|
137
191
|
}
|
@@ -46,7 +46,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
|
46
46
|
);
|
47
47
|
const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
|
48
48
|
const hasJsMatcher = compileBooleanMatcher(conditionMap);
|
49
|
-
const initialChunkIds = getInitialChunkIds(chunk, chunkGraph);
|
49
|
+
const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
|
50
50
|
|
51
51
|
const outputName = this.compilation.getPath(
|
52
52
|
getChunkFilenameTemplate(chunk, this.compilation.outputOptions),
|
@@ -46,7 +46,7 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
|
46
46
|
);
|
47
47
|
const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
|
48
48
|
const hasJsMatcher = compileBooleanMatcher(conditionMap);
|
49
|
-
const initialChunkIds = getInitialChunkIds(chunk, chunkGraph);
|
49
|
+
const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
|
50
50
|
|
51
51
|
const outputName = this.compilation.getPath(
|
52
52
|
getChunkFilenameTemplate(chunk, this.compilation.outputOptions),
|
@@ -39,6 +39,7 @@ const {
|
|
39
39
|
/** @typedef {import("webpack-sources").Source} Source */
|
40
40
|
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
41
41
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
42
|
+
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
42
43
|
/** @typedef {import("../Compilation")} Compilation */
|
43
44
|
/** @typedef {import("../Dependency")} Dependency */
|
44
45
|
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
@@ -1077,7 +1078,8 @@ class ConcatenatedModule extends Module {
|
|
1077
1078
|
runtimeTemplate,
|
1078
1079
|
moduleGraph,
|
1079
1080
|
chunkGraph,
|
1080
|
-
runtime: generationRuntime
|
1081
|
+
runtime: generationRuntime,
|
1082
|
+
codeGenerationResults
|
1081
1083
|
}) {
|
1082
1084
|
/** @type {Set<string>} */
|
1083
1085
|
const runtimeRequirements = new Set();
|
@@ -1104,7 +1106,8 @@ class ConcatenatedModule extends Module {
|
|
1104
1106
|
runtimeTemplate,
|
1105
1107
|
moduleGraph,
|
1106
1108
|
chunkGraph,
|
1107
|
-
runtime
|
1109
|
+
runtime,
|
1110
|
+
codeGenerationResults
|
1108
1111
|
);
|
1109
1112
|
}
|
1110
1113
|
|
@@ -1634,6 +1637,7 @@ ${defineGetters}`
|
|
1634
1637
|
* @param {ModuleGraph} moduleGraph moduleGraph
|
1635
1638
|
* @param {ChunkGraph} chunkGraph chunkGraph
|
1636
1639
|
* @param {RuntimeSpec} runtime runtime
|
1640
|
+
* @param {CodeGenerationResults} codeGenerationResults codeGenerationResults
|
1637
1641
|
*/
|
1638
1642
|
_analyseModule(
|
1639
1643
|
modulesMap,
|
@@ -1642,7 +1646,8 @@ ${defineGetters}`
|
|
1642
1646
|
runtimeTemplate,
|
1643
1647
|
moduleGraph,
|
1644
1648
|
chunkGraph,
|
1645
|
-
runtime
|
1649
|
+
runtime,
|
1650
|
+
codeGenerationResults
|
1646
1651
|
) {
|
1647
1652
|
if (info.type === "concatenated") {
|
1648
1653
|
const m = info.module;
|
@@ -1657,7 +1662,8 @@ ${defineGetters}`
|
|
1657
1662
|
moduleGraph,
|
1658
1663
|
chunkGraph,
|
1659
1664
|
runtime,
|
1660
|
-
concatenationScope
|
1665
|
+
concatenationScope,
|
1666
|
+
codeGenerationResults
|
1661
1667
|
});
|
1662
1668
|
const source = codeGenResult.sources.get("javascript");
|
1663
1669
|
const data = codeGenResult.data;
|
@@ -103,9 +103,16 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|
103
103
|
]
|
104
104
|
)};`,
|
105
105
|
`var getInvalidSingletonVersionMessage = ${runtimeTemplate.basicFunction(
|
106
|
-
"key, version, requiredVersion",
|
106
|
+
"scope, key, version, requiredVersion",
|
107
107
|
[
|
108
|
-
`return "Unsatisfied version " + version + " of shared singleton module " + key + " (required " + rangeToString(requiredVersion) + ")"`
|
108
|
+
`return "Unsatisfied version " + version + " from " + (version && scope[key][version].from) + " of shared singleton module " + key + " (required " + rangeToString(requiredVersion) + ")"`
|
109
|
+
]
|
110
|
+
)};`,
|
111
|
+
`var getSingleton = ${runtimeTemplate.basicFunction(
|
112
|
+
"scope, scopeName, key, requiredVersion",
|
113
|
+
[
|
114
|
+
"var version = findSingletonVersionKey(scope, key);",
|
115
|
+
"return get(scope[key][version]);"
|
109
116
|
]
|
110
117
|
)};`,
|
111
118
|
`var getSingletonVersion = ${runtimeTemplate.basicFunction(
|
@@ -113,7 +120,7 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|
113
120
|
[
|
114
121
|
"var version = findSingletonVersionKey(scope, key);",
|
115
122
|
"if (!satisfy(requiredVersion, version)) " +
|
116
|
-
'typeof console !== "undefined" && console.warn && console.warn(getInvalidSingletonVersionMessage(key, version, requiredVersion));',
|
123
|
+
'typeof console !== "undefined" && console.warn && console.warn(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));',
|
117
124
|
"return get(scope[key][version]);"
|
118
125
|
]
|
119
126
|
)};`,
|
@@ -122,7 +129,7 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|
122
129
|
[
|
123
130
|
"var version = findSingletonVersionKey(scope, key);",
|
124
131
|
"if (!satisfy(requiredVersion, version)) " +
|
125
|
-
"throw new Error(getInvalidSingletonVersionMessage(key, version, requiredVersion));",
|
132
|
+
"throw new Error(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));",
|
126
133
|
"return get(scope[key][version]);"
|
127
134
|
]
|
128
135
|
)};`,
|
@@ -202,6 +209,13 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|
202
209
|
"return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));"
|
203
210
|
]
|
204
211
|
)});`,
|
212
|
+
`var loadSingleton = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
|
213
|
+
"scopeName, scope, key",
|
214
|
+
[
|
215
|
+
"ensureExistence(scopeName, key);",
|
216
|
+
"return getSingleton(scope, scopeName, key);"
|
217
|
+
]
|
218
|
+
)});`,
|
205
219
|
`var loadSingletonVersionCheck = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
|
206
220
|
"scopeName, scope, key, version",
|
207
221
|
[
|
@@ -230,6 +244,13 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|
230
244
|
"return get(findValidVersion(scope, key, version) || warnInvalidVersion(scope, scopeName, key, version) || findVersion(scope, key));"
|
231
245
|
]
|
232
246
|
)});`,
|
247
|
+
`var loadSingletonFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
|
248
|
+
"scopeName, scope, key, fallback",
|
249
|
+
[
|
250
|
+
`if(!scope || !${RuntimeGlobals.hasOwnProperty}(scope, key)) return fallback();`,
|
251
|
+
"return getSingleton(scope, scopeName, key);"
|
252
|
+
]
|
253
|
+
)});`,
|
233
254
|
`var loadSingletonVersionCheckFallback = /*#__PURE__*/ init(${runtimeTemplate.basicFunction(
|
234
255
|
"scopeName, scope, key, version, fallback",
|
235
256
|
[
|
@@ -1160,7 +1160,7 @@ const AVAILABLE_FORMATS = {
|
|
1160
1160
|
},
|
1161
1161
|
{ regExp: /(\(module has no exports\))/g, format: red },
|
1162
1162
|
{ regExp: /\(possible exports: (.+)\)/g, format: green },
|
1163
|
-
{ regExp:
|
1163
|
+
{ regExp: /(?:^|\n)(.* doesn't exist)/g, format: red },
|
1164
1164
|
{ regExp: /('\w+' option has not been set)/g, format: red },
|
1165
1165
|
{
|
1166
1166
|
regExp: /(Emitted value instead of an instance of Error)/g,
|
@@ -9,11 +9,18 @@ const memoize = require("./memoize");
|
|
9
9
|
|
10
10
|
const getValidate = memoize(() => require("schema-utils").validate);
|
11
11
|
|
12
|
-
const createSchemaValidation = (check
|
12
|
+
const createSchemaValidation = (check, getSchema, options) => {
|
13
13
|
getSchema = memoize(getSchema);
|
14
14
|
return value => {
|
15
|
-
if (!check(value)) {
|
15
|
+
if (check && !check(value)) {
|
16
16
|
getValidate()(getSchema(), value, options);
|
17
|
+
if (check) {
|
18
|
+
require("util").deprecate(
|
19
|
+
() => {},
|
20
|
+
"webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
|
21
|
+
"DEP_WEBPACK_PRE_COMPILED_SCHEMA_INVALID"
|
22
|
+
)();
|
23
|
+
}
|
17
24
|
}
|
18
25
|
};
|
19
26
|
};
|
@@ -11,5 +11,8 @@
|
|
11
11
|
*/
|
12
12
|
module.exports = function extractUrlAndGlobal(urlAndGlobal) {
|
13
13
|
const index = urlAndGlobal.indexOf("@");
|
14
|
+
if (index <= 0 || index === urlAndGlobal.length - 1) {
|
15
|
+
throw new Error(`Invalid request "${urlAndGlobal}"`);
|
16
|
+
}
|
14
17
|
return [urlAndGlobal.substring(index + 1), urlAndGlobal.substring(0, index)];
|
15
18
|
};
|
package/lib/util/fs.js
CHANGED
@@ -61,6 +61,15 @@ const path = require("path");
|
|
61
61
|
/** @typedef {function((NodeJS.ErrnoException | Error | null)=, any=): void} ReadJsonCallback */
|
62
62
|
/** @typedef {function((NodeJS.ErrnoException | Error | null)=, IStats|string=): void} LstatReadlinkAbsoluteCallback */
|
63
63
|
|
64
|
+
/**
|
65
|
+
* @typedef {Object} WatcherInfo
|
66
|
+
* @property {Set<string>} changes get current aggregated changes that have not yet send to callback
|
67
|
+
* @property {Set<string>} removals get current aggregated removals that have not yet send to callback
|
68
|
+
* @property {Map<string, FileSystemInfoEntry | "ignore">} fileTimeInfoEntries get info about files
|
69
|
+
* @property {Map<string, FileSystemInfoEntry | "ignore">} contextTimeInfoEntries get info about directories
|
70
|
+
*/
|
71
|
+
|
72
|
+
// TODO webpack 6 deprecate missing getInfo
|
64
73
|
/**
|
65
74
|
* @typedef {Object} Watcher
|
66
75
|
* @property {function(): void} close closes the watcher and all underlying file watchers
|
@@ -69,6 +78,7 @@ const path = require("path");
|
|
69
78
|
* @property {function(): Set<string>=} getAggregatedRemovals get current aggregated removals that have not yet send to callback
|
70
79
|
* @property {function(): Map<string, FileSystemInfoEntry | "ignore">} getFileTimeInfoEntries get info about files
|
71
80
|
* @property {function(): Map<string, FileSystemInfoEntry | "ignore">} getContextTimeInfoEntries get info about directories
|
81
|
+
* @property {function(): WatcherInfo=} getInfo get info about timestamps and changes
|
72
82
|
*/
|
73
83
|
|
74
84
|
/**
|