webpack 5.59.0 → 5.76.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/README.md +22 -24
- package/bin/webpack.js +0 -0
- package/hot/dev-server.js +17 -4
- package/hot/lazy-compilation-node.js +3 -1
- package/hot/poll.js +1 -1
- package/hot/signal.js +1 -1
- package/lib/APIPlugin.js +33 -0
- package/lib/BannerPlugin.js +13 -5
- package/lib/Cache.js +1 -1
- package/lib/CacheFacade.js +4 -11
- package/lib/Chunk.js +6 -3
- package/lib/ChunkGraph.js +94 -8
- package/lib/ChunkGroup.js +1 -1
- package/lib/CleanPlugin.js +81 -20
- package/lib/Compilation.js +188 -93
- package/lib/Compiler.js +87 -18
- package/lib/ConstPlugin.js +2 -2
- package/lib/ContextModule.js +142 -51
- package/lib/ContextModuleFactory.js +65 -25
- package/lib/DelegatedModule.js +1 -1
- package/lib/DelegatedModuleFactoryPlugin.js +1 -1
- package/lib/Dependency.js +17 -0
- package/lib/DependencyTemplate.js +9 -0
- package/lib/DependencyTemplates.js +1 -1
- package/lib/DllModule.js +1 -1
- package/lib/DllReferencePlugin.js +1 -1
- package/lib/EntryOptionPlugin.js +2 -0
- package/lib/ErrorHelpers.js +2 -2
- package/lib/EvalDevToolModulePlugin.js +16 -1
- package/lib/EvalSourceMapDevToolPlugin.js +25 -4
- package/lib/ExportsInfo.js +5 -5
- package/lib/ExternalModule.js +94 -54
- package/lib/ExternalModuleFactoryPlugin.js +5 -5
- package/lib/FileSystemInfo.js +124 -58
- package/lib/Generator.js +3 -0
- package/lib/HookWebpackError.js +1 -1
- package/lib/HotModuleReplacementPlugin.js +3 -1
- package/lib/LoaderOptionsPlugin.js +1 -1
- package/lib/Module.js +28 -4
- package/lib/ModuleFilenameHelpers.js +8 -4
- package/lib/ModuleHashingError.js +29 -0
- package/lib/MultiCompiler.js +1 -1
- package/lib/MultiWatching.js +1 -1
- package/lib/NodeStuffPlugin.js +13 -3
- package/lib/NormalModule.js +51 -33
- package/lib/NormalModuleFactory.js +42 -37
- package/lib/ProgressPlugin.js +4 -5
- package/lib/RawModule.js +1 -1
- package/lib/RuntimeGlobals.js +29 -1
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +84 -1
- package/lib/RuntimeTemplate.js +114 -2
- package/lib/Template.js +3 -2
- package/lib/TemplatedPathPlugin.js +48 -23
- package/lib/WatchIgnorePlugin.js +19 -7
- package/lib/Watching.js +33 -19
- package/lib/WebpackOptionsApply.js +79 -11
- package/lib/asset/AssetGenerator.js +228 -71
- package/lib/asset/AssetModulesPlugin.js +3 -0
- package/lib/asset/AssetParser.js +1 -0
- package/lib/asset/AssetSourceGenerator.js +31 -6
- package/lib/asset/AssetSourceParser.js +1 -0
- package/lib/asset/RawDataUrlModule.js +148 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -4
- package/lib/buildChunkGraph.js +38 -7
- package/lib/cache/PackFileCacheStrategy.js +15 -8
- package/lib/cache/ResolverCachePlugin.js +90 -29
- package/lib/cli.js +44 -3
- package/lib/config/browserslistTargetHandler.js +41 -6
- package/lib/config/defaults.js +123 -19
- package/lib/config/normalization.js +10 -2
- package/lib/config/target.js +10 -0
- package/lib/container/ContainerEntryModule.js +8 -5
- package/lib/container/FallbackModule.js +4 -4
- package/lib/container/ModuleFederationPlugin.js +2 -0
- package/lib/container/RemoteModule.js +4 -2
- package/lib/container/RemoteRuntimeModule.js +8 -7
- package/lib/css/CssExportsGenerator.js +139 -0
- package/lib/css/CssGenerator.js +109 -0
- package/lib/css/CssLoadingRuntimeModule.js +442 -0
- package/lib/css/CssModulesPlugin.js +462 -0
- package/lib/css/CssParser.js +618 -0
- package/lib/css/walkCssTokens.js +659 -0
- package/lib/debug/ProfilingPlugin.js +24 -21
- package/lib/dependencies/AMDRequireDependency.js +6 -6
- package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -2
- package/lib/dependencies/CommonJsFullRequireDependency.js +5 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +344 -61
- package/lib/dependencies/CommonJsRequireContextDependency.js +6 -2
- package/lib/dependencies/CommonJsRequireDependency.js +2 -1
- package/lib/dependencies/ContextDependency.js +16 -2
- package/lib/dependencies/ContextDependencyHelpers.js +21 -8
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +4 -1
- package/lib/dependencies/ContextElementDependency.js +25 -3
- package/lib/dependencies/CreateScriptUrlDependency.js +12 -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/ExportsInfoDependency.js +6 -0
- package/lib/dependencies/HarmonyAcceptImportDependency.js +5 -3
- package/lib/dependencies/HarmonyCompatibilityDependency.js +5 -5
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +127 -0
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +12 -3
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +25 -17
- package/lib/dependencies/HarmonyExportInitFragment.js +4 -1
- package/lib/dependencies/HarmonyImportDependency.js +23 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +142 -45
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -22
- package/lib/dependencies/HarmonyModulesPlugin.js +10 -0
- package/lib/dependencies/ImportContextDependency.js +0 -2
- package/lib/dependencies/ImportMetaContextDependency.js +35 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +252 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +59 -0
- package/lib/dependencies/ImportMetaPlugin.js +22 -3
- package/lib/dependencies/ImportParserPlugin.js +35 -29
- package/lib/dependencies/JsonExportsDependency.js +17 -21
- package/lib/dependencies/LoaderDependency.js +13 -0
- package/lib/dependencies/LoaderImportDependency.js +13 -0
- package/lib/dependencies/LoaderPlugin.js +4 -2
- package/lib/dependencies/ModuleDependency.js +11 -1
- package/lib/dependencies/ProvidedDependency.js +31 -8
- package/lib/dependencies/RequireContextDependency.js +0 -16
- package/lib/dependencies/RequireEnsureDependency.js +2 -2
- package/lib/dependencies/RequireResolveContextDependency.js +2 -2
- package/lib/dependencies/RequireResolveDependency.js +2 -1
- package/lib/dependencies/URLDependency.js +3 -8
- package/lib/dependencies/URLPlugin.js +22 -1
- package/lib/dependencies/WorkerPlugin.js +2 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +74 -49
- package/lib/esm/ModuleChunkLoadingPlugin.js +3 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +25 -9
- package/lib/hmr/HotModuleReplacement.runtime.js +29 -14
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/lib/hmr/LazyCompilationPlugin.js +54 -26
- package/lib/hmr/lazyCompilationBackend.js +51 -12
- package/lib/ids/DeterministicModuleIdsPlugin.js +55 -35
- package/lib/ids/HashedModuleIdsPlugin.js +11 -14
- package/lib/ids/IdHelpers.js +26 -12
- package/lib/ids/NamedModuleIdsPlugin.js +6 -9
- package/lib/ids/NaturalModuleIdsPlugin.js +10 -13
- package/lib/ids/OccurrenceModuleIdsPlugin.js +13 -10
- package/lib/ids/SyncModuleIdsPlugin.js +140 -0
- package/lib/index.js +20 -0
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +2 -2
- package/lib/javascript/BasicEvaluatedExpression.js +5 -2
- package/lib/javascript/ChunkHelpers.js +33 -0
- package/lib/javascript/JavascriptGenerator.js +1 -0
- package/lib/javascript/JavascriptModulesPlugin.js +27 -2
- package/lib/javascript/JavascriptParser.js +143 -73
- package/lib/javascript/StartupHelpers.js +7 -30
- package/lib/json/JsonData.js +8 -0
- package/lib/json/JsonParser.js +4 -6
- package/lib/library/AssignLibraryPlugin.js +39 -15
- package/lib/library/EnableLibraryPlugin.js +11 -0
- package/lib/library/UmdLibraryPlugin.js +5 -3
- package/lib/node/NodeTargetPlugin.js +3 -0
- package/lib/node/NodeWatchFileSystem.js +85 -31
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +23 -8
- package/lib/node/RequireChunkLoadingRuntimeModule.js +24 -9
- package/lib/optimize/ConcatenatedModule.js +62 -26
- package/lib/optimize/ModuleConcatenationPlugin.js +26 -4
- package/lib/optimize/RealContentHashPlugin.js +45 -15
- package/lib/optimize/SplitChunksPlugin.js +8 -1
- package/lib/runtime/AsyncModuleRuntimeModule.js +50 -66
- package/lib/runtime/BaseUriRuntimeModule.js +31 -0
- package/lib/runtime/CreateScriptRuntimeModule.js +36 -0
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +9 -34
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +76 -0
- package/lib/runtime/LoadScriptRuntimeModule.js +11 -9
- package/lib/runtime/NonceRuntimeModule.js +24 -0
- package/lib/schemes/HttpUriPlugin.js +77 -14
- package/lib/serialization/FileMiddleware.js +44 -9
- package/lib/sharing/ConsumeSharedModule.js +8 -2
- package/lib/sharing/ConsumeSharedRuntimeModule.js +26 -5
- package/lib/sharing/ProvideSharedModule.js +4 -2
- package/lib/sharing/ProvideSharedPlugin.js +1 -2
- package/lib/sharing/ShareRuntimeModule.js +1 -1
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +113 -68
- package/lib/stats/DefaultStatsPrinterPlugin.js +90 -25
- package/lib/util/ArrayHelpers.js +30 -0
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/compileBooleanMatcher.js +1 -1
- package/lib/util/create-schema-validation.js +9 -2
- package/lib/util/createHash.js +12 -0
- package/lib/util/deprecation.js +10 -2
- package/lib/util/deterministicGrouping.js +1 -1
- package/lib/util/extractUrlAndGlobal.js +3 -0
- package/lib/util/fs.js +11 -0
- package/lib/util/hash/BatchedHash.js +7 -4
- package/lib/util/hash/md4.js +20 -0
- package/lib/util/hash/wasm-hash.js +163 -0
- package/lib/util/hash/xxhash64.js +5 -139
- package/lib/util/identifier.js +65 -44
- package/lib/util/internalSerializables.js +15 -0
- package/lib/util/nonNumericOnlyHash.js +22 -0
- package/lib/util/semver.js +17 -10
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +9 -3
- package/lib/wasm-sync/WebAssemblyParser.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +31 -18
- package/lib/webpack.js +10 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +33 -22
- package/module.d.ts +215 -0
- package/package.json +28 -32
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +321 -30
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +4 -0
- 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/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.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/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.json +4 -0
- package/types.d.ts +869 -296
@@ -30,8 +30,8 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|
30
30
|
}
|
31
31
|
|
32
32
|
merge(other) {
|
33
|
-
const promises = new Set(
|
34
|
-
for (const p of
|
33
|
+
const promises = new Set(other.promises);
|
34
|
+
for (const p of this.promises) {
|
35
35
|
promises.add(p);
|
36
36
|
}
|
37
37
|
return new AwaitDependenciesInitFragment(promises);
|
@@ -51,7 +51,7 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|
51
51
|
for (const p of promises) {
|
52
52
|
return Template.asString([
|
53
53
|
`var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${p}]);`,
|
54
|
-
`${p} = (__webpack_async_dependencies__.then ? await __webpack_async_dependencies__ : __webpack_async_dependencies__)[0];`,
|
54
|
+
`${p} = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];`,
|
55
55
|
""
|
56
56
|
]);
|
57
57
|
}
|
@@ -60,7 +60,7 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|
60
60
|
// TODO check if destructuring is supported
|
61
61
|
return Template.asString([
|
62
62
|
`var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${sepPromises}]);`,
|
63
|
-
`([${sepPromises}] = __webpack_async_dependencies__.then ? await __webpack_async_dependencies__ : __webpack_async_dependencies__);`,
|
63
|
+
`([${sepPromises}] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);`,
|
64
64
|
""
|
65
65
|
]);
|
66
66
|
}
|
package/lib/buildChunkGraph.js
CHANGED
@@ -50,6 +50,8 @@ const { getEntryRuntime, mergeRuntime } = require("./util/runtime");
|
|
50
50
|
* @property {Set<ChunkGroupInfo>} availableChildren set of chunk groups which depend on the this chunk group as availableSource
|
51
51
|
* @property {number} preOrderIndex next pre order index
|
52
52
|
* @property {number} postOrderIndex next post order index
|
53
|
+
* @property {boolean} chunkLoading has a chunk loading mechanism
|
54
|
+
* @property {boolean} asyncChunks create async chunks
|
53
55
|
*/
|
54
56
|
|
55
57
|
/**
|
@@ -304,7 +306,15 @@ const visitModules = (
|
|
304
306
|
availableSources: undefined,
|
305
307
|
availableChildren: undefined,
|
306
308
|
preOrderIndex: 0,
|
307
|
-
postOrderIndex: 0
|
309
|
+
postOrderIndex: 0,
|
310
|
+
chunkLoading:
|
311
|
+
chunkGroup.options.chunkLoading !== undefined
|
312
|
+
? chunkGroup.options.chunkLoading !== false
|
313
|
+
: compilation.outputOptions.chunkLoading !== false,
|
314
|
+
asyncChunks:
|
315
|
+
chunkGroup.options.asyncChunks !== undefined
|
316
|
+
? chunkGroup.options.asyncChunks
|
317
|
+
: compilation.outputOptions.asyncChunks !== false
|
308
318
|
};
|
309
319
|
chunkGroup.index = nextChunkGroupIndex++;
|
310
320
|
if (chunkGroup.getNumberOfParents() > 0) {
|
@@ -418,7 +428,15 @@ const visitModules = (
|
|
418
428
|
availableSources: undefined,
|
419
429
|
availableChildren: undefined,
|
420
430
|
preOrderIndex: 0,
|
421
|
-
postOrderIndex: 0
|
431
|
+
postOrderIndex: 0,
|
432
|
+
chunkLoading:
|
433
|
+
entryOptions.chunkLoading !== undefined
|
434
|
+
? entryOptions.chunkLoading !== false
|
435
|
+
: chunkGroupInfo.chunkLoading,
|
436
|
+
asyncChunks:
|
437
|
+
entryOptions.asyncChunks !== undefined
|
438
|
+
? entryOptions.asyncChunks
|
439
|
+
: chunkGroupInfo.asyncChunks
|
422
440
|
};
|
423
441
|
chunkGroupInfoMap.set(entrypoint, cgi);
|
424
442
|
|
@@ -442,8 +460,18 @@ const visitModules = (
|
|
442
460
|
chunkGroup: entrypoint,
|
443
461
|
chunkGroupInfo: cgi
|
444
462
|
});
|
463
|
+
} else if (!chunkGroupInfo.asyncChunks || !chunkGroupInfo.chunkLoading) {
|
464
|
+
// Just queue the block into the current chunk group
|
465
|
+
queue.push({
|
466
|
+
action: PROCESS_BLOCK,
|
467
|
+
block: b,
|
468
|
+
module: module,
|
469
|
+
chunk,
|
470
|
+
chunkGroup,
|
471
|
+
chunkGroupInfo
|
472
|
+
});
|
445
473
|
} else {
|
446
|
-
cgi = namedChunkGroups.get(chunkName);
|
474
|
+
cgi = chunkName && namedChunkGroups.get(chunkName);
|
447
475
|
if (!cgi) {
|
448
476
|
c = compilation.addChunkInGroup(
|
449
477
|
b.groupOptions || b.chunkName,
|
@@ -464,7 +492,9 @@ const visitModules = (
|
|
464
492
|
availableSources: undefined,
|
465
493
|
availableChildren: undefined,
|
466
494
|
preOrderIndex: 0,
|
467
|
-
postOrderIndex: 0
|
495
|
+
postOrderIndex: 0,
|
496
|
+
chunkLoading: chunkGroupInfo.chunkLoading,
|
497
|
+
asyncChunks: chunkGroupInfo.asyncChunks
|
468
498
|
};
|
469
499
|
allCreatedChunkGroups.add(c);
|
470
500
|
chunkGroupInfoMap.set(c, cgi);
|
@@ -478,8 +508,9 @@ const visitModules = (
|
|
478
508
|
new AsyncDependencyToInitialChunkError(chunkName, module, b.loc)
|
479
509
|
);
|
480
510
|
c = chunkGroup;
|
511
|
+
} else {
|
512
|
+
c.addOptions(b.groupOptions);
|
481
513
|
}
|
482
|
-
c.addOptions(b.groupOptions);
|
483
514
|
c.addOrigin(module, b.loc, b.request);
|
484
515
|
}
|
485
516
|
blockConnections.set(b, []);
|
@@ -518,7 +549,7 @@ const visitModules = (
|
|
518
549
|
chunkGroup: c,
|
519
550
|
chunkGroupInfo: cgi
|
520
551
|
});
|
521
|
-
} else {
|
552
|
+
} else if (entrypoint !== undefined) {
|
522
553
|
chunkGroupInfo.chunkGroup.addAsyncEntrypoint(entrypoint);
|
523
554
|
}
|
524
555
|
};
|
@@ -875,7 +906,7 @@ const visitModules = (
|
|
875
906
|
const module = it.value;
|
876
907
|
if (
|
877
908
|
availableModules.has(module) ||
|
878
|
-
availableModules.plus.has(
|
909
|
+
availableModules.plus.has(module)
|
879
910
|
) {
|
880
911
|
cachedMinAvailableModules.add(module);
|
881
912
|
}
|
@@ -639,10 +639,14 @@ class PackContentItems {
|
|
639
639
|
} catch (e) {
|
640
640
|
rollback(s);
|
641
641
|
if (e === NOT_SERIALIZABLE) continue;
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
642
|
+
const msg = "Skipped not serializable cache item";
|
643
|
+
if (e.message.includes("ModuleBuildError")) {
|
644
|
+
logger.log(`${msg} (in build error): ${e.message}`);
|
645
|
+
logger.debug(`${msg} '${key}' (in build error): ${e.stack}`);
|
646
|
+
} else {
|
647
|
+
logger.warn(`${msg}: ${e.message}`);
|
648
|
+
logger.debug(`${msg} '${key}': ${e.stack}`);
|
649
|
+
}
|
646
650
|
}
|
647
651
|
}
|
648
652
|
write(null);
|
@@ -782,7 +786,7 @@ class PackContent {
|
|
782
786
|
this.logger.time(timeMessage);
|
783
787
|
}
|
784
788
|
const value = this.lazy();
|
785
|
-
if (
|
789
|
+
if ("then" in value) {
|
786
790
|
return value.then(data => {
|
787
791
|
const map = data.map;
|
788
792
|
if (timeMessage) {
|
@@ -830,7 +834,7 @@ class PackContent {
|
|
830
834
|
this.logger.time(timeMessage);
|
831
835
|
}
|
832
836
|
const value = this.lazy();
|
833
|
-
if (
|
837
|
+
if ("then" in value) {
|
834
838
|
return value.then(data => {
|
835
839
|
if (timeMessage) {
|
836
840
|
this.logger.timeEnd(timeMessage);
|
@@ -918,7 +922,7 @@ class PackContent {
|
|
918
922
|
}
|
919
923
|
const value = this.lazy();
|
920
924
|
this.outdated = false;
|
921
|
-
if (
|
925
|
+
if ("then" in value) {
|
922
926
|
// Move to state B1
|
923
927
|
this.lazy = write(() =>
|
924
928
|
value.then(data => {
|
@@ -991,7 +995,10 @@ class PackFileCacheStrategy {
|
|
991
995
|
allowCollectingMemory,
|
992
996
|
compression
|
993
997
|
}) {
|
994
|
-
this.fileSerializer = createFileSerializer(
|
998
|
+
this.fileSerializer = createFileSerializer(
|
999
|
+
fs,
|
1000
|
+
compiler.options.output.hashFunction
|
1001
|
+
);
|
995
1002
|
this.fileSystemInfo = new FileSystemInfo(fs, {
|
996
1003
|
managedPaths: snapshot.managedPaths,
|
997
1004
|
immutablePaths: snapshot.immutablePaths,
|
@@ -106,7 +106,7 @@ class ResolverCachePlugin {
|
|
106
106
|
* @param {Resolver} resolver the resolver
|
107
107
|
* @param {Object} resolveContext context for resolving meta info
|
108
108
|
* @param {Object} request the request info object
|
109
|
-
* @param {function(Error=, Object=): void} callback callback function
|
109
|
+
* @param {function((Error | null)=, Object=): void} callback callback function
|
110
110
|
* @returns {void}
|
111
111
|
*/
|
112
112
|
const doRealResolve = (
|
@@ -128,6 +128,13 @@ class ResolverCachePlugin {
|
|
128
128
|
fileDependencies: new LazySet(),
|
129
129
|
contextDependencies: new LazySet()
|
130
130
|
};
|
131
|
+
let yieldResult;
|
132
|
+
let withYield = false;
|
133
|
+
if (typeof newResolveContext.yield === "function") {
|
134
|
+
yieldResult = [];
|
135
|
+
withYield = true;
|
136
|
+
newResolveContext.yield = obj => yieldResult.push(obj);
|
137
|
+
}
|
131
138
|
const propagate = key => {
|
132
139
|
if (resolveContext[key]) {
|
133
140
|
addAllToSet(resolveContext[key], newResolveContext[key]);
|
@@ -155,15 +162,22 @@ class ResolverCachePlugin {
|
|
155
162
|
snapshotOptions,
|
156
163
|
(err, snapshot) => {
|
157
164
|
if (err) return callback(err);
|
165
|
+
const resolveResult = withYield ? yieldResult : result;
|
166
|
+
// since we intercept resolve hook
|
167
|
+
// we still can get result in callback
|
168
|
+
if (withYield && result) yieldResult.push(result);
|
158
169
|
if (!snapshot) {
|
159
|
-
if (
|
170
|
+
if (resolveResult) return callback(null, resolveResult);
|
160
171
|
return callback();
|
161
172
|
}
|
162
|
-
itemCache.store(
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
173
|
+
itemCache.store(
|
174
|
+
new CacheEntry(resolveResult, snapshot),
|
175
|
+
storeErr => {
|
176
|
+
if (storeErr) return callback(storeErr);
|
177
|
+
if (resolveResult) return callback(null, resolveResult);
|
178
|
+
callback();
|
179
|
+
}
|
180
|
+
);
|
167
181
|
}
|
168
182
|
);
|
169
183
|
}
|
@@ -173,6 +187,8 @@ class ResolverCachePlugin {
|
|
173
187
|
factory(type, hook) {
|
174
188
|
/** @type {Map<string, (function(Error=, Object=): void)[]>} */
|
175
189
|
const activeRequests = new Map();
|
190
|
+
/** @type {Map<string, [function(Error=, Object=): void, function(Error=, Object=): void][]>} */
|
191
|
+
const activeRequestsWithYield = new Map();
|
176
192
|
hook.tap(
|
177
193
|
"ResolverCachePlugin",
|
178
194
|
/**
|
@@ -197,29 +213,67 @@ class ResolverCachePlugin {
|
|
197
213
|
if (request._ResolverCachePluginCacheMiss || !fileSystemInfo) {
|
198
214
|
return callback();
|
199
215
|
}
|
200
|
-
const
|
201
|
-
|
202
|
-
|
203
|
-
)}`;
|
204
|
-
|
205
|
-
if (
|
206
|
-
activeRequest.
|
207
|
-
|
216
|
+
const withYield = typeof resolveContext.yield === "function";
|
217
|
+
const identifier = `${type}${
|
218
|
+
withYield ? "|yield" : "|default"
|
219
|
+
}${optionsIdent}${objectToString(request, !cacheWithContext)}`;
|
220
|
+
|
221
|
+
if (withYield) {
|
222
|
+
const activeRequest = activeRequestsWithYield.get(identifier);
|
223
|
+
if (activeRequest) {
|
224
|
+
activeRequest[0].push(callback);
|
225
|
+
activeRequest[1].push(resolveContext.yield);
|
226
|
+
return;
|
227
|
+
}
|
228
|
+
} else {
|
229
|
+
const activeRequest = activeRequests.get(identifier);
|
230
|
+
if (activeRequest) {
|
231
|
+
activeRequest.push(callback);
|
232
|
+
return;
|
233
|
+
}
|
208
234
|
}
|
209
235
|
const itemCache = cache.getItemCache(identifier, null);
|
210
|
-
let callbacks;
|
211
|
-
const done =
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
236
|
+
let callbacks, yields;
|
237
|
+
const done = withYield
|
238
|
+
? (err, result) => {
|
239
|
+
if (callbacks === undefined) {
|
240
|
+
if (err) {
|
241
|
+
callback(err);
|
242
|
+
} else {
|
243
|
+
if (result)
|
244
|
+
for (const r of result) resolveContext.yield(r);
|
245
|
+
callback(null, null);
|
246
|
+
}
|
247
|
+
yields = undefined;
|
248
|
+
callbacks = false;
|
249
|
+
} else {
|
250
|
+
if (err) {
|
251
|
+
for (const cb of callbacks) cb(err);
|
252
|
+
} else {
|
253
|
+
for (let i = 0; i < callbacks.length; i++) {
|
254
|
+
const cb = callbacks[i];
|
255
|
+
const yield_ = yields[i];
|
256
|
+
if (result) for (const r of result) yield_(r);
|
257
|
+
cb(null, null);
|
258
|
+
}
|
259
|
+
}
|
260
|
+
activeRequestsWithYield.delete(identifier);
|
261
|
+
yields = undefined;
|
262
|
+
callbacks = false;
|
263
|
+
}
|
264
|
+
}
|
265
|
+
: (err, result) => {
|
266
|
+
if (callbacks === undefined) {
|
267
|
+
callback(err, result);
|
268
|
+
callbacks = false;
|
269
|
+
} else {
|
270
|
+
for (const callback of callbacks) {
|
271
|
+
callback(err, result);
|
272
|
+
}
|
273
|
+
activeRequests.delete(identifier);
|
274
|
+
callbacks = false;
|
275
|
+
}
|
276
|
+
};
|
223
277
|
/**
|
224
278
|
* @param {Error=} err error if any
|
225
279
|
* @param {CacheEntry=} cacheEntry cache entry
|
@@ -276,7 +330,14 @@ class ResolverCachePlugin {
|
|
276
330
|
}
|
277
331
|
};
|
278
332
|
itemCache.get(processCacheResult);
|
279
|
-
if (callbacks === undefined) {
|
333
|
+
if (withYield && callbacks === undefined) {
|
334
|
+
callbacks = [callback];
|
335
|
+
yields = [resolveContext.yield];
|
336
|
+
activeRequestsWithYield.set(
|
337
|
+
identifier,
|
338
|
+
/** @type {[any, any]} */ ([callbacks, yields])
|
339
|
+
);
|
340
|
+
} else if (callbacks === undefined) {
|
280
341
|
callbacks = [callback];
|
281
342
|
activeRequests.set(identifier, callbacks);
|
282
343
|
}
|
package/lib/cli.js
CHANGED
@@ -37,6 +37,7 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
|
|
37
37
|
/**
|
38
38
|
* @typedef {Object} ArgumentConfig
|
39
39
|
* @property {string} description
|
40
|
+
* @property {string} [negatedDescription]
|
40
41
|
* @property {string} path
|
41
42
|
* @property {boolean} multiple
|
42
43
|
* @property {"enum"|"string"|"path"|"number"|"boolean"|"RegExp"|"reset"} type
|
@@ -96,11 +97,42 @@ const getArguments = (schema = webpackSchema) => {
|
|
96
97
|
*/
|
97
98
|
const getDescription = path => {
|
98
99
|
for (const { schema } of path) {
|
99
|
-
if (schema.cli
|
100
|
+
if (schema.cli) {
|
101
|
+
if (schema.cli.helper) continue;
|
102
|
+
if (schema.cli.description) return schema.cli.description;
|
103
|
+
}
|
100
104
|
if (schema.description) return schema.description;
|
101
105
|
}
|
102
106
|
};
|
103
107
|
|
108
|
+
/**
|
109
|
+
*
|
110
|
+
* @param {PathItem[]} path path in the schema
|
111
|
+
* @returns {string | undefined} negative description
|
112
|
+
*/
|
113
|
+
const getNegatedDescription = path => {
|
114
|
+
for (const { schema } of path) {
|
115
|
+
if (schema.cli) {
|
116
|
+
if (schema.cli.helper) continue;
|
117
|
+
if (schema.cli.negatedDescription) return schema.cli.negatedDescription;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
};
|
121
|
+
|
122
|
+
/**
|
123
|
+
*
|
124
|
+
* @param {PathItem[]} path path in the schema
|
125
|
+
* @returns {string | undefined} reset description
|
126
|
+
*/
|
127
|
+
const getResetDescription = path => {
|
128
|
+
for (const { schema } of path) {
|
129
|
+
if (schema.cli) {
|
130
|
+
if (schema.cli.helper) continue;
|
131
|
+
if (schema.cli.resetDescription) return schema.cli.resetDescription;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
};
|
135
|
+
|
104
136
|
/**
|
105
137
|
*
|
106
138
|
* @param {any} schemaPart schema
|
@@ -142,13 +174,17 @@ const getArguments = (schema = webpackSchema) => {
|
|
142
174
|
const addResetFlag = path => {
|
143
175
|
const schemaPath = path[0].path;
|
144
176
|
const name = pathToArgumentName(`${schemaPath}.reset`);
|
145
|
-
const description =
|
177
|
+
const description =
|
178
|
+
getResetDescription(path) ||
|
179
|
+
`Clear all items provided in '${schemaPath}' configuration. ${getDescription(
|
180
|
+
path
|
181
|
+
)}`;
|
146
182
|
flags[name] = {
|
147
183
|
configs: [
|
148
184
|
{
|
149
185
|
type: "reset",
|
150
186
|
multiple: false,
|
151
|
-
description
|
187
|
+
description,
|
152
188
|
path: schemaPath
|
153
189
|
}
|
154
190
|
],
|
@@ -167,6 +203,7 @@ const getArguments = (schema = webpackSchema) => {
|
|
167
203
|
const argConfigBase = schemaToArgumentConfig(path[0].schema);
|
168
204
|
if (!argConfigBase) return 0;
|
169
205
|
|
206
|
+
const negatedDescription = getNegatedDescription(path);
|
170
207
|
const name = pathToArgumentName(path[0].path);
|
171
208
|
/** @type {ArgumentConfig} */
|
172
209
|
const argConfig = {
|
@@ -176,6 +213,10 @@ const getArguments = (schema = webpackSchema) => {
|
|
176
213
|
path: path[0].path
|
177
214
|
};
|
178
215
|
|
216
|
+
if (negatedDescription) {
|
217
|
+
argConfig.negatedDescription = negatedDescription;
|
218
|
+
}
|
219
|
+
|
179
220
|
if (!flags[name]) {
|
180
221
|
flags[name] = {
|
181
222
|
configs: [],
|
@@ -121,8 +121,7 @@ const resolve = browsers => {
|
|
121
121
|
// baidu: Not supported
|
122
122
|
// and_uc: Not supported
|
123
123
|
// kaios: Not supported
|
124
|
-
|
125
|
-
node: [13, 14]
|
124
|
+
node: [12, 17]
|
126
125
|
});
|
127
126
|
|
128
127
|
return {
|
@@ -248,8 +247,7 @@ const resolve = browsers => {
|
|
248
247
|
// baidu: Not supported
|
249
248
|
// and_uc: Not supported
|
250
249
|
// kaios: Not supported
|
251
|
-
|
252
|
-
node: [13, 14]
|
250
|
+
node: [12, 17]
|
253
251
|
}),
|
254
252
|
dynamicImport: es6DynamicImport,
|
255
253
|
dynamicImportInWorker: es6DynamicImport && !anyNode,
|
@@ -272,9 +270,46 @@ const resolve = browsers => {
|
|
272
270
|
// baidu: Unknown support
|
273
271
|
// and_uc: Unknown support
|
274
272
|
// kaios: Unknown support
|
275
|
-
node:
|
273
|
+
node: 12
|
274
|
+
}),
|
275
|
+
optionalChaining: rawChecker({
|
276
|
+
chrome: 80,
|
277
|
+
and_chr: 80,
|
278
|
+
edge: 80,
|
279
|
+
firefox: 74,
|
280
|
+
and_ff: 79,
|
281
|
+
// ie: Not supported,
|
282
|
+
opera: 67,
|
283
|
+
op_mob: 64,
|
284
|
+
safari: [13, 1],
|
285
|
+
ios_saf: [13, 4],
|
286
|
+
samsung: 13,
|
287
|
+
android: 80,
|
288
|
+
// and_qq: Not supported
|
289
|
+
// baidu: Not supported
|
290
|
+
// and_uc: Not supported
|
291
|
+
// kaios: Not supported
|
292
|
+
node: 14
|
293
|
+
}),
|
294
|
+
templateLiteral: rawChecker({
|
295
|
+
chrome: 41,
|
296
|
+
and_chr: 41,
|
297
|
+
edge: 13,
|
298
|
+
firefox: 34,
|
299
|
+
and_ff: 34,
|
300
|
+
// ie: Not supported,
|
301
|
+
opera: 29,
|
302
|
+
op_mob: 64,
|
303
|
+
safari: [9, 1],
|
304
|
+
ios_saf: 9,
|
305
|
+
samsung: 4,
|
306
|
+
android: 41,
|
307
|
+
and_qq: [10, 4],
|
308
|
+
baidu: [7, 12],
|
309
|
+
and_uc: [12, 12],
|
310
|
+
kaios: [2, 5],
|
311
|
+
node: 4
|
276
312
|
}),
|
277
|
-
|
278
313
|
browser: browserProperty,
|
279
314
|
electron: false,
|
280
315
|
node: nodeProperty,
|