webpack 5.69.0 → 5.69.1
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/ContextModule.js +24 -79
- package/lib/ContextModuleFactory.js +21 -60
- package/lib/cache/ResolverCachePlugin.js +28 -80
- package/package.json +2 -2
- package/types.d.ts +2 -7
package/lib/ContextModule.js
CHANGED
@@ -61,7 +61,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
61
61
|
|
62
62
|
/**
|
63
63
|
* @typedef {Object} ContextModuleOptionsExtras
|
64
|
-
* @property {string
|
64
|
+
* @property {string} resource
|
65
65
|
* @property {string=} resourceQuery
|
66
66
|
* @property {string=} resourceFragment
|
67
67
|
* @property {TODO} resolveOptions
|
@@ -92,36 +92,23 @@ class ContextModule extends Module {
|
|
92
92
|
* @param {ContextModuleOptions} options options object
|
93
93
|
*/
|
94
94
|
constructor(resolveDependencies, options) {
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
(options && options.resourceFragment) || parsed.fragment;
|
103
|
-
|
104
|
-
super("javascript/dynamic", resource);
|
105
|
-
/** @type {ContextModuleOptions} */
|
106
|
-
this.options = {
|
107
|
-
...options,
|
108
|
-
resource,
|
109
|
-
resourceQuery,
|
110
|
-
resourceFragment
|
111
|
-
};
|
112
|
-
} else {
|
113
|
-
super("javascript/dynamic");
|
114
|
-
/** @type {ContextModuleOptions} */
|
115
|
-
this.options = {
|
116
|
-
...options,
|
117
|
-
resource: options.resource,
|
118
|
-
resourceQuery: options.resourceQuery || "",
|
119
|
-
resourceFragment: options.resourceFragment || ""
|
120
|
-
};
|
121
|
-
}
|
95
|
+
const parsed = parseResource(options ? options.resource : "");
|
96
|
+
const resource = parsed.path;
|
97
|
+
const resourceQuery = (options && options.resourceQuery) || parsed.query;
|
98
|
+
const resourceFragment =
|
99
|
+
(options && options.resourceFragment) || parsed.fragment;
|
100
|
+
|
101
|
+
super("javascript/dynamic", resource);
|
122
102
|
|
123
103
|
// Info from Factory
|
124
104
|
this.resolveDependencies = resolveDependencies;
|
105
|
+
/** @type {ContextModuleOptions} */
|
106
|
+
this.options = {
|
107
|
+
...options,
|
108
|
+
resource,
|
109
|
+
resourceQuery,
|
110
|
+
resourceFragment
|
111
|
+
};
|
125
112
|
if (options && options.resolveOptions !== undefined) {
|
126
113
|
this.resolveOptions = options.resolveOptions;
|
127
114
|
}
|
@@ -168,11 +155,7 @@ class ContextModule extends Module {
|
|
168
155
|
}
|
169
156
|
|
170
157
|
_createIdentifier() {
|
171
|
-
let identifier =
|
172
|
-
this.context ||
|
173
|
-
(typeof this.options.resource === "string"
|
174
|
-
? this.options.resource
|
175
|
-
: this.options.resource.join("|"));
|
158
|
+
let identifier = this.context;
|
176
159
|
if (this.options.resourceQuery) {
|
177
160
|
identifier += `|${this.options.resourceQuery}`;
|
178
161
|
}
|
@@ -237,16 +220,7 @@ class ContextModule extends Module {
|
|
237
220
|
* @returns {string} a user readable identifier of the module
|
238
221
|
*/
|
239
222
|
readableIdentifier(requestShortener) {
|
240
|
-
let identifier;
|
241
|
-
if (this.context) {
|
242
|
-
identifier = requestShortener.shorten(this.context) + "/";
|
243
|
-
} else if (typeof this.options.resource === "string") {
|
244
|
-
identifier = requestShortener.shorten(this.options.resource) + "/";
|
245
|
-
} else {
|
246
|
-
identifier = this.options.resource
|
247
|
-
.map(r => requestShortener.shorten(r) + "/")
|
248
|
-
.join(" ");
|
249
|
-
}
|
223
|
+
let identifier = requestShortener.shorten(this.context) + "/";
|
250
224
|
if (this.options.resourceQuery) {
|
251
225
|
identifier += ` ${this.options.resourceQuery}`;
|
252
226
|
}
|
@@ -296,30 +270,11 @@ class ContextModule extends Module {
|
|
296
270
|
* @returns {string | null} an identifier for library inclusion
|
297
271
|
*/
|
298
272
|
libIdent(options) {
|
299
|
-
let identifier
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
this.context,
|
305
|
-
options.associatedObjectForCache
|
306
|
-
);
|
307
|
-
} else if (typeof this.options.resource === "string") {
|
308
|
-
identifier = contextify(
|
309
|
-
options.context,
|
310
|
-
this.options.resource,
|
311
|
-
options.associatedObjectForCache
|
312
|
-
);
|
313
|
-
} else {
|
314
|
-
const arr = [];
|
315
|
-
for (const res of this.options.resource) {
|
316
|
-
arr.push(
|
317
|
-
contextify(options.context, res, options.associatedObjectForCache)
|
318
|
-
);
|
319
|
-
}
|
320
|
-
identifier = arr.join(" ");
|
321
|
-
}
|
322
|
-
|
273
|
+
let identifier = contextify(
|
274
|
+
options.context,
|
275
|
+
this.context,
|
276
|
+
options.associatedObjectForCache
|
277
|
+
);
|
323
278
|
if (this.layer) identifier = `(${this.layer})/${identifier}`;
|
324
279
|
if (this.options.mode) {
|
325
280
|
identifier += ` ${this.options.mode}`;
|
@@ -487,11 +442,7 @@ class ContextModule extends Module {
|
|
487
442
|
compilation.fileSystemInfo.createSnapshot(
|
488
443
|
startTime,
|
489
444
|
null,
|
490
|
-
this.context
|
491
|
-
? [this.context]
|
492
|
-
: typeof this.options.resource === "string"
|
493
|
-
? [this.options.resource]
|
494
|
-
: this.options.resource,
|
445
|
+
[this.context],
|
495
446
|
null,
|
496
447
|
SNAPSHOT_OPTIONS,
|
497
448
|
(err, snapshot) => {
|
@@ -515,13 +466,7 @@ class ContextModule extends Module {
|
|
515
466
|
missingDependencies,
|
516
467
|
buildDependencies
|
517
468
|
) {
|
518
|
-
|
519
|
-
contextDependencies.add(this.context);
|
520
|
-
} else if (typeof this.options.resource === "string") {
|
521
|
-
contextDependencies.add(this.options.resource);
|
522
|
-
} else {
|
523
|
-
for (const res of this.options.resource) contextDependencies.add(res);
|
524
|
-
}
|
469
|
+
contextDependencies.add(this.context);
|
525
470
|
}
|
526
471
|
|
527
472
|
/**
|
@@ -167,9 +167,6 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
167
167
|
asyncLib.parallel(
|
168
168
|
[
|
169
169
|
callback => {
|
170
|
-
const results = [];
|
171
|
-
const yield_ = obj => results.push(obj);
|
172
|
-
|
173
170
|
contextResolver.resolve(
|
174
171
|
{},
|
175
172
|
context,
|
@@ -177,12 +174,11 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
177
174
|
{
|
178
175
|
fileDependencies,
|
179
176
|
missingDependencies,
|
180
|
-
contextDependencies
|
181
|
-
yield: yield_
|
177
|
+
contextDependencies
|
182
178
|
},
|
183
|
-
err => {
|
179
|
+
(err, result) => {
|
184
180
|
if (err) return callback(err);
|
185
|
-
callback(null,
|
181
|
+
callback(null, result);
|
186
182
|
}
|
187
183
|
);
|
188
184
|
},
|
@@ -217,20 +213,15 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
217
213
|
contextDependencies
|
218
214
|
});
|
219
215
|
}
|
220
|
-
|
216
|
+
|
221
217
|
this.hooks.afterResolve.callAsync(
|
222
218
|
{
|
223
219
|
addon:
|
224
220
|
loadersPrefix +
|
225
|
-
|
226
|
-
(
|
227
|
-
resource:
|
228
|
-
contextResult.length > 1
|
229
|
-
? contextResult.map(r => r.path)
|
230
|
-
: contextResult[0].path,
|
221
|
+
result[1].join("!") +
|
222
|
+
(result[1].length > 0 ? "!" : ""),
|
223
|
+
resource: result[0],
|
231
224
|
resolveDependencies: this.resolveDependencies.bind(this),
|
232
|
-
resourceQuery: contextResult[0].query,
|
233
|
-
resourceFragment: contextResult[0].fragment,
|
234
225
|
...beforeResolveResult
|
235
226
|
},
|
236
227
|
(err, result) => {
|
@@ -287,28 +278,26 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
287
278
|
} = options;
|
288
279
|
if (!regExp || !resource) return callback(null, []);
|
289
280
|
|
290
|
-
|
291
|
-
const addDirectoryChecked = (ctx, directory, visited, callback) => {
|
281
|
+
const addDirectoryChecked = (directory, visited, callback) => {
|
292
282
|
fs.realpath(directory, (err, realPath) => {
|
293
283
|
if (err) return callback(err);
|
294
284
|
if (visited.has(realPath)) return callback(null, []);
|
295
285
|
let recursionStack;
|
296
286
|
addDirectory(
|
297
|
-
ctx,
|
298
287
|
directory,
|
299
|
-
(
|
288
|
+
(dir, callback) => {
|
300
289
|
if (recursionStack === undefined) {
|
301
290
|
recursionStack = new Set(visited);
|
302
291
|
recursionStack.add(realPath);
|
303
292
|
}
|
304
|
-
addDirectoryChecked(
|
293
|
+
addDirectoryChecked(dir, recursionStack, callback);
|
305
294
|
},
|
306
295
|
callback
|
307
296
|
);
|
308
297
|
});
|
309
298
|
};
|
310
299
|
|
311
|
-
const addDirectory = (
|
300
|
+
const addDirectory = (directory, addSubDirectory, callback) => {
|
312
301
|
fs.readdir(directory, (err, files) => {
|
313
302
|
if (err) return callback(err);
|
314
303
|
const processedFiles = cmf.hooks.contextModuleFiles.call(
|
@@ -335,15 +324,16 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
335
324
|
|
336
325
|
if (stat.isDirectory()) {
|
337
326
|
if (!recursive) return callback();
|
338
|
-
addSubDirectory(
|
327
|
+
addSubDirectory(subResource, callback);
|
339
328
|
} else if (
|
340
329
|
stat.isFile() &&
|
341
330
|
(!include || subResource.match(include))
|
342
331
|
) {
|
343
332
|
const obj = {
|
344
|
-
context:
|
333
|
+
context: resource,
|
345
334
|
request:
|
346
|
-
"." +
|
335
|
+
"." +
|
336
|
+
subResource.substr(resource.length).replace(/\\/g, "/")
|
347
337
|
};
|
348
338
|
|
349
339
|
this.hooks.alternativeRequests.callAsync(
|
@@ -354,11 +344,8 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
354
344
|
alternatives = alternatives
|
355
345
|
.filter(obj => regExp.test(obj.request))
|
356
346
|
.map(obj => {
|
357
|
-
const request = severalContexts
|
358
|
-
? join(fs, obj.context, obj.request)
|
359
|
-
: obj.request;
|
360
347
|
const dep = new ContextElementDependency(
|
361
|
-
request + resourceQuery + resourceFragment,
|
348
|
+
obj.request + resourceQuery + resourceFragment,
|
362
349
|
obj.request,
|
363
350
|
typePrefix,
|
364
351
|
category,
|
@@ -395,38 +382,12 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|
395
382
|
});
|
396
383
|
};
|
397
384
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
const visitResource = (resource, callback) => {
|
402
|
-
if (typeof fs.realpath === "function") {
|
403
|
-
addDirectoryChecked(resource, resource, new Set(), callback);
|
404
|
-
} else {
|
405
|
-
addDirectory(resource, resource, addSubDirectory, callback);
|
406
|
-
}
|
407
|
-
};
|
408
|
-
|
409
|
-
if (typeof resource === "string") {
|
410
|
-
visitResource(resource, callback);
|
385
|
+
if (typeof fs.realpath === "function") {
|
386
|
+
addDirectoryChecked(resource, new Set(), callback);
|
411
387
|
} else {
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
// result dependencies should have unique userRequest
|
417
|
-
// ordered by resolve result
|
418
|
-
const temp = new Set();
|
419
|
-
const res = [];
|
420
|
-
for (let i = 0; i < result.length; i++) {
|
421
|
-
const inner = result[i];
|
422
|
-
for (const el of inner) {
|
423
|
-
if (temp.has(el.userRequest)) continue;
|
424
|
-
res.push(el);
|
425
|
-
temp.add(el.userRequest);
|
426
|
-
}
|
427
|
-
}
|
428
|
-
callback(null, res);
|
429
|
-
});
|
388
|
+
const addSubDirectory = (dir, callback) =>
|
389
|
+
addDirectory(dir, addSubDirectory, callback);
|
390
|
+
addDirectory(resource, addSubDirectory, callback);
|
430
391
|
}
|
431
392
|
}
|
432
393
|
};
|
@@ -128,11 +128,6 @@ class ResolverCachePlugin {
|
|
128
128
|
fileDependencies: new LazySet(),
|
129
129
|
contextDependencies: new LazySet()
|
130
130
|
};
|
131
|
-
let yieldResult;
|
132
|
-
if (typeof newResolveContext.yield === "function") {
|
133
|
-
yieldResult = [];
|
134
|
-
newResolveContext.yield = obj => yieldResult.push(obj);
|
135
|
-
}
|
136
131
|
const propagate = key => {
|
137
132
|
if (resolveContext[key]) {
|
138
133
|
addAllToSet(resolveContext[key], newResolveContext[key]);
|
@@ -160,19 +155,15 @@ class ResolverCachePlugin {
|
|
160
155
|
snapshotOptions,
|
161
156
|
(err, snapshot) => {
|
162
157
|
if (err) return callback(err);
|
163
|
-
const resolveResult = result || yieldResult;
|
164
158
|
if (!snapshot) {
|
165
|
-
if (
|
159
|
+
if (result) return callback(null, result);
|
166
160
|
return callback();
|
167
161
|
}
|
168
|
-
itemCache.store(
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
callback();
|
174
|
-
}
|
175
|
-
);
|
162
|
+
itemCache.store(new CacheEntry(result, snapshot), storeErr => {
|
163
|
+
if (storeErr) return callback(storeErr);
|
164
|
+
if (result) return callback(null, result);
|
165
|
+
callback();
|
166
|
+
});
|
176
167
|
}
|
177
168
|
);
|
178
169
|
}
|
@@ -182,8 +173,6 @@ class ResolverCachePlugin {
|
|
182
173
|
factory(type, hook) {
|
183
174
|
/** @type {Map<string, (function(Error=, Object=): void)[]>} */
|
184
175
|
const activeRequests = new Map();
|
185
|
-
/** @type {Map<string, [function(Error=, Object=): void, function(Error=, Object=): void][]>} */
|
186
|
-
const activeRequestsWithYield = new Map();
|
187
176
|
hook.tap(
|
188
177
|
"ResolverCachePlugin",
|
189
178
|
/**
|
@@ -208,63 +197,29 @@ class ResolverCachePlugin {
|
|
208
197
|
if (request._ResolverCachePluginCacheMiss || !fileSystemInfo) {
|
209
198
|
return callback();
|
210
199
|
}
|
211
|
-
const
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
if (
|
217
|
-
|
218
|
-
|
219
|
-
activeRequest[0].push(callback);
|
220
|
-
activeRequest[1].push(resolveContext.yield);
|
221
|
-
return;
|
222
|
-
}
|
223
|
-
} else {
|
224
|
-
const activeRequest = activeRequests.get(identifier);
|
225
|
-
if (activeRequest) {
|
226
|
-
activeRequest.push(callback);
|
227
|
-
return;
|
228
|
-
}
|
200
|
+
const identifier = `${type}${optionsIdent}${objectToString(
|
201
|
+
request,
|
202
|
+
!cacheWithContext
|
203
|
+
)}`;
|
204
|
+
const activeRequest = activeRequests.get(identifier);
|
205
|
+
if (activeRequest) {
|
206
|
+
activeRequest.push(callback);
|
207
|
+
return;
|
229
208
|
}
|
230
209
|
const itemCache = cache.getItemCache(identifier, null);
|
231
|
-
let callbacks
|
232
|
-
const done =
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
} else {
|
245
|
-
for (let i = 0; i < callbacks.length; i++) {
|
246
|
-
const cb = callbacks[i];
|
247
|
-
const yield_ = yields[i];
|
248
|
-
if (result) for (const r of result) yield_(r);
|
249
|
-
cb(null, null);
|
250
|
-
}
|
251
|
-
activeRequestsWithYield.delete(identifier);
|
252
|
-
yields = undefined;
|
253
|
-
callbacks = false;
|
254
|
-
}
|
255
|
-
}
|
256
|
-
: (err, result) => {
|
257
|
-
if (callbacks === undefined) {
|
258
|
-
callback(err, result);
|
259
|
-
callbacks = false;
|
260
|
-
} else {
|
261
|
-
for (const callback of callbacks) {
|
262
|
-
callback(err, result);
|
263
|
-
}
|
264
|
-
activeRequests.delete(identifier);
|
265
|
-
callbacks = false;
|
266
|
-
}
|
267
|
-
};
|
210
|
+
let callbacks;
|
211
|
+
const done = (err, result) => {
|
212
|
+
if (callbacks === undefined) {
|
213
|
+
callback(err, result);
|
214
|
+
callbacks = false;
|
215
|
+
} else {
|
216
|
+
for (const callback of callbacks) {
|
217
|
+
callback(err, result);
|
218
|
+
}
|
219
|
+
activeRequests.delete(identifier);
|
220
|
+
callbacks = false;
|
221
|
+
}
|
222
|
+
};
|
268
223
|
/**
|
269
224
|
* @param {Error=} err error if any
|
270
225
|
* @param {CacheEntry=} cacheEntry cache entry
|
@@ -321,14 +276,7 @@ class ResolverCachePlugin {
|
|
321
276
|
}
|
322
277
|
};
|
323
278
|
itemCache.get(processCacheResult);
|
324
|
-
if (
|
325
|
-
callbacks = [callback];
|
326
|
-
yields = [resolveContext.yield];
|
327
|
-
activeRequestsWithYield.set(
|
328
|
-
identifier,
|
329
|
-
/** @type {[any, any]} */ ([callbacks, yields])
|
330
|
-
);
|
331
|
-
} else if (callbacks === undefined) {
|
279
|
+
if (callbacks === undefined) {
|
332
280
|
callbacks = [callback];
|
333
281
|
activeRequests.set(identifier, callbacks);
|
334
282
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.69.
|
3
|
+
"version": "5.69.1",
|
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",
|
@@ -14,7 +14,7 @@
|
|
14
14
|
"acorn-import-assertions": "^1.7.6",
|
15
15
|
"browserslist": "^4.14.5",
|
16
16
|
"chrome-trace-event": "^1.0.2",
|
17
|
-
"enhanced-resolve": "^5.
|
17
|
+
"enhanced-resolve": "^5.8.3",
|
18
18
|
"es-module-lexer": "^0.9.0",
|
19
19
|
"eslint-scope": "5.1.1",
|
20
20
|
"events": "^3.2.0",
|
package/types.d.ts
CHANGED
@@ -2526,7 +2526,7 @@ declare interface ContextModuleOptions {
|
|
2526
2526
|
* exports referenced from modules (won't be mangled)
|
2527
2527
|
*/
|
2528
2528
|
referencedExports?: string[][];
|
2529
|
-
resource: string
|
2529
|
+
resource: string;
|
2530
2530
|
resourceQuery?: string;
|
2531
2531
|
resourceFragment?: string;
|
2532
2532
|
resolveOptions: any;
|
@@ -9405,11 +9405,6 @@ declare interface ResolveContext {
|
|
9405
9405
|
* log function
|
9406
9406
|
*/
|
9407
9407
|
log?: (arg0: string) => void;
|
9408
|
-
|
9409
|
-
/**
|
9410
|
-
* yield result, if provided plugins can return several results
|
9411
|
-
*/
|
9412
|
-
yield?: (arg0: ResolveRequest) => void;
|
9413
9408
|
}
|
9414
9409
|
declare interface ResolveData {
|
9415
9410
|
contextInfo: ModuleFactoryCreateDataContextInfo;
|
@@ -11856,7 +11851,7 @@ declare interface UserResolveOptions {
|
|
11856
11851
|
restrictions?: (string | RegExp)[];
|
11857
11852
|
|
11858
11853
|
/**
|
11859
|
-
* Use only the sync
|
11854
|
+
* Use only the sync constiants of the file system calls
|
11860
11855
|
*/
|
11861
11856
|
useSyncFileSystemCalls?: boolean;
|
11862
11857
|
|