webpack 5.99.9 → 5.100.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.
- package/bin/webpack.js +8 -2
- package/hot/log.js +15 -15
- package/hot/poll.js +1 -0
- package/lib/APIPlugin.js +3 -3
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -0
- package/lib/BannerPlugin.js +1 -1
- package/lib/CaseSensitiveModulesWarning.js +4 -4
- package/lib/Chunk.js +6 -6
- package/lib/ChunkGraph.js +37 -31
- package/lib/ChunkGroup.js +4 -4
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +94 -17
- package/lib/CodeGenerationResults.js +1 -1
- package/lib/CompatibilityPlugin.js +5 -2
- package/lib/Compilation.js +67 -45
- package/lib/Compiler.js +46 -16
- package/lib/ConcatenationScope.js +15 -6
- package/lib/ConstPlugin.js +5 -3
- package/lib/ContextModule.js +16 -12
- package/lib/ContextModuleFactory.js +4 -3
- package/lib/ContextReplacementPlugin.js +4 -2
- package/lib/CssModule.js +2 -2
- package/lib/DefinePlugin.js +111 -3
- package/lib/DelegatedModuleFactoryPlugin.js +18 -18
- package/lib/Dependency.js +11 -4
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DllEntryPlugin.js +3 -1
- package/lib/DllPlugin.js +4 -3
- package/lib/DllReferencePlugin.js +2 -2
- package/lib/DynamicEntryPlugin.js +1 -1
- package/lib/EntryOptionPlugin.js +5 -0
- package/lib/ErrorHelpers.js +4 -4
- package/lib/EvalDevToolModulePlugin.js +3 -3
- package/lib/EvalSourceMapDevToolPlugin.js +7 -7
- package/lib/ExportsInfo.js +48 -39
- package/lib/ExternalModule.js +15 -11
- package/lib/ExternalModuleFactoryPlugin.js +5 -2
- package/lib/FileSystemInfo.js +51 -36
- package/lib/FlagDependencyExportsPlugin.js +14 -7
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +14 -1
- package/lib/HookWebpackError.js +1 -0
- package/lib/HotModuleReplacementPlugin.js +77 -50
- package/lib/IgnorePlugin.js +5 -2
- package/lib/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +0 -1
- package/lib/LibManifestPlugin.js +4 -2
- package/lib/LoaderOptionsPlugin.js +6 -4
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +21 -6
- package/lib/ModuleFactory.js +1 -0
- package/lib/ModuleGraph.js +24 -2
- package/lib/ModuleGraphConnection.js +5 -5
- package/lib/ModuleInfoHeaderPlugin.js +2 -1
- package/lib/ModuleParseError.js +1 -0
- package/lib/ModuleSourceTypesConstants.js +12 -12
- package/lib/ModuleTemplate.js +1 -1
- package/lib/ModuleTypeConstants.js +21 -21
- package/lib/MultiCompiler.js +6 -6
- package/lib/NormalModule.js +31 -44
- package/lib/NormalModuleFactory.js +34 -20
- package/lib/NormalModuleReplacementPlugin.js +1 -1
- package/lib/NullFactory.js +1 -0
- package/lib/OptimizationStages.js +1 -1
- package/lib/Parser.js +1 -0
- package/lib/ProgressPlugin.js +12 -5
- package/lib/ProvidePlugin.js +5 -1
- package/lib/RawModule.js +14 -0
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/RuntimeGlobals.js +175 -155
- package/lib/RuntimeModule.js +1 -0
- package/lib/RuntimePlugin.js +33 -7
- package/lib/RuntimeTemplate.js +111 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
- package/lib/SourceMapDevToolPlugin.js +19 -17
- package/lib/Template.js +2 -2
- package/lib/TemplatedPathPlugin.js +1 -1
- package/lib/WarnDeprecatedOptionPlugin.js +7 -8
- package/lib/WatchIgnorePlugin.js +4 -3
- package/lib/WebpackIsIncludedPlugin.js +2 -1
- package/lib/WebpackOptionsApply.js +115 -27
- package/lib/asset/AssetGenerator.js +15 -11
- package/lib/asset/AssetModulesPlugin.js +19 -17
- package/lib/asset/AssetSourceGenerator.js +4 -4
- package/lib/asset/RawDataUrlModule.js +4 -2
- package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
- package/lib/buildChunkGraph.js +6 -3
- package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
- package/lib/cache/IdleFileCachePlugin.js +7 -4
- package/lib/cache/MemoryCachePlugin.js +1 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +26 -20
- package/lib/cache/ResolverCachePlugin.js +16 -8
- package/lib/cli.js +15 -10
- package/lib/config/browserslistTargetHandler.js +3 -3
- package/lib/config/defaults.js +25 -17
- package/lib/config/normalization.js +2 -1
- package/lib/config/target.js +6 -5
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackModule.js +2 -1
- package/lib/container/HoistContainerReferencesPlugin.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +2 -2
- package/lib/container/RemoteModule.js +1 -1
- package/lib/css/CssGenerator.js +9 -6
- package/lib/css/CssModulesPlugin.js +44 -31
- package/lib/css/CssParser.js +6 -4
- package/lib/css/walkCssTokens.js +33 -37
- package/lib/debug/ProfilingPlugin.js +6 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
- package/lib/dependencies/AMDPlugin.js +12 -8
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
- package/lib/dependencies/CachedConstDependency.js +1 -5
- package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
- package/lib/dependencies/CommonJsPlugin.js +15 -16
- package/lib/dependencies/ContextDependencyHelpers.js +2 -1
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/DynamicExports.js +9 -9
- package/lib/dependencies/ExportsInfoDependency.js +1 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +11 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
- package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
- package/lib/dependencies/ImportMetaPlugin.js +2 -2
- package/lib/dependencies/ImportParserPlugin.js +40 -9
- package/lib/dependencies/ImportPlugin.js +3 -1
- package/lib/dependencies/LoaderPlugin.js +1 -0
- package/lib/dependencies/ModuleDependency.js +3 -1
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +3 -1
- package/lib/dependencies/RequireEnsurePlugin.js +6 -6
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
- package/lib/dependencies/RequireIncludePlugin.js +1 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLContextDependency.js +65 -0
- package/lib/dependencies/URLPlugin.js +17 -157
- package/lib/dependencies/WorkerPlugin.js +23 -10
- package/lib/dependencies/processExportInfo.js +2 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
- package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +70 -3
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
- package/lib/hmr/LazyCompilationPlugin.js +4 -2
- package/lib/hmr/lazyCompilationBackend.js +4 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
- package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
- package/lib/ids/HashedModuleIdsPlugin.js +5 -4
- package/lib/ids/IdHelpers.js +21 -17
- package/lib/ids/NamedChunkIdsPlugin.js +5 -5
- package/lib/ids/NamedModuleIdsPlugin.js +4 -4
- package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -3
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
- package/lib/javascript/BasicEvaluatedExpression.js +2 -1
- package/lib/javascript/ChunkHelpers.js +1 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
- package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
- package/lib/javascript/JavascriptGenerator.js +14 -2
- package/lib/javascript/JavascriptModulesPlugin.js +68 -27
- package/lib/javascript/JavascriptParser.js +117 -76
- package/lib/javascript/JavascriptParserHelpers.js +41 -41
- package/lib/javascript/StartupHelpers.js +17 -17
- package/lib/json/JsonGenerator.js +4 -2
- package/lib/json/JsonModulesPlugin.js +2 -2
- package/lib/json/JsonParser.js +1 -1
- package/lib/library/AbstractLibraryPlugin.js +6 -2
- package/lib/library/AssignLibraryPlugin.js +21 -6
- package/lib/library/EnableLibraryPlugin.js +23 -3
- package/lib/library/UmdLibraryPlugin.js +15 -6
- package/lib/logging/createConsoleLogger.js +3 -3
- package/lib/logging/runtime.js +9 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/nodeConsole.js +4 -2
- package/lib/optimize/AggressiveMergingPlugin.js +45 -46
- package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
- package/lib/optimize/ConcatenatedModule.js +227 -57
- package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
- package/lib/optimize/InnerGraph.js +115 -112
- package/lib/optimize/InnerGraphPlugin.js +2 -2
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +4 -3
- package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
- package/lib/optimize/MinChunkSizePlugin.js +6 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
- package/lib/optimize/RealContentHashPlugin.js +26 -20
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
- package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
- package/lib/optimize/SplitChunksPlugin.js +16 -13
- package/lib/rules/BasicEffectRulePlugin.js +4 -2
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
- package/lib/rules/RuleSetCompiler.js +19 -5
- package/lib/rules/UseEffectRulePlugin.js +17 -9
- package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +27 -19
- package/lib/schemes/VirtualUrlPlugin.js +222 -0
- package/lib/serialization/AggregateErrorSerializer.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +5 -4
- package/lib/serialization/FileMiddleware.js +7 -4
- package/lib/serialization/ObjectMiddleware.js +14 -8
- package/lib/serialization/Serializer.js +5 -3
- package/lib/serialization/SerializerMiddleware.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ConsumeSharedPlugin.js +3 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +3 -2
- package/lib/sharing/SharePlugin.js +2 -1
- package/lib/sharing/ShareRuntimeModule.js +3 -5
- package/lib/sharing/utils.js +34 -34
- package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
- package/lib/stats/DefaultStatsPresetPlugin.js +13 -13
- package/lib/stats/DefaultStatsPrinterPlugin.js +15 -9
- package/lib/stats/StatsFactory.js +6 -3
- package/lib/stats/StatsPrinter.js +6 -7
- package/lib/url/URLParserPlugin.js +266 -0
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Hash.js +2 -0
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/LazyBucketSortedSet.js +2 -1
- package/lib/util/LazySet.js +11 -6
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/SetHelpers.js +3 -3
- package/lib/util/SortableSet.js +2 -2
- package/lib/util/StackedCacheMap.js +3 -1
- package/lib/util/StackedMap.js +2 -2
- package/lib/util/StringXor.js +1 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -1
- package/lib/util/cleverMerge.js +95 -58
- package/lib/util/comparators.js +154 -127
- package/lib/util/compileBooleanMatcher.js +8 -3
- package/lib/util/concatenate.js +8 -7
- package/lib/util/conventions.js +72 -73
- package/lib/util/create-schema-validation.js +2 -1
- package/lib/util/createHash.js +10 -4
- package/lib/util/deprecation.js +69 -66
- package/lib/util/deterministicGrouping.js +4 -2
- package/lib/util/extractUrlAndGlobal.js +1 -1
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +30 -23
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +4 -2
- package/lib/util/identifier.js +13 -12
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/magicComment.js +5 -5
- package/lib/util/processAsyncTree.js +1 -1
- package/lib/util/propertyAccess.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -2
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +29 -21
- package/lib/util/semver.js +1 -1
- package/lib/util/serialization.js +3 -0
- package/lib/util/source.js +3 -2
- package/lib/validateSchema.js +1 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
- package/lib/webpack.js +4 -5
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
- package/package.json +119 -113
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +17 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
- package/types.d.ts +1243 -409
|
@@ -13,7 +13,7 @@ const createSchemaValidation = require("../util/create-schema-validation");
|
|
|
13
13
|
/** @typedef {import("../Compiler")} Compiler */
|
|
14
14
|
|
|
15
15
|
const validate = createSchemaValidation(
|
|
16
|
-
require("../../schemas/plugins/optimize/MinChunkSizePlugin.check
|
|
16
|
+
require("../../schemas/plugins/optimize/MinChunkSizePlugin.check"),
|
|
17
17
|
() => require("../../schemas/plugins/optimize/MinChunkSizePlugin.json"),
|
|
18
18
|
{
|
|
19
19
|
name: "Min Chunk Size Plugin",
|
|
@@ -65,13 +65,15 @@ class MinChunkSizePlugin {
|
|
|
65
65
|
if (chunkGraph.getChunkSize(a, equalOptions) < minChunkSize) {
|
|
66
66
|
smallChunks.push(a);
|
|
67
67
|
for (const b of visitedChunks) {
|
|
68
|
-
if (chunkGraph.canChunksBeIntegrated(b, a))
|
|
68
|
+
if (chunkGraph.canChunksBeIntegrated(b, a)) {
|
|
69
69
|
combinations.push([b, a]);
|
|
70
|
+
}
|
|
70
71
|
}
|
|
71
72
|
} else {
|
|
72
73
|
for (const b of smallChunks) {
|
|
73
|
-
if (chunkGraph.canChunksBeIntegrated(b, a))
|
|
74
|
+
if (chunkGraph.canChunksBeIntegrated(b, a)) {
|
|
74
75
|
combinations.push([b, a]);
|
|
76
|
+
}
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
chunkSizesMap.set(a, chunkGraph.getChunkSize(a, options));
|
|
@@ -112,4 +114,5 @@ class MinChunkSizePlugin {
|
|
|
112
114
|
});
|
|
113
115
|
}
|
|
114
116
|
}
|
|
117
|
+
|
|
115
118
|
module.exports = MinChunkSizePlugin;
|
|
@@ -13,11 +13,11 @@ const { STAGE_DEFAULT } = require("../OptimizationStages");
|
|
|
13
13
|
const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
|
|
14
14
|
const { compareModulesByIdentifier } = require("../util/comparators");
|
|
15
15
|
const {
|
|
16
|
+
filterRuntime,
|
|
16
17
|
intersectRuntime,
|
|
18
|
+
mergeRuntime,
|
|
17
19
|
mergeRuntimeOwned,
|
|
18
|
-
|
|
19
|
-
runtimeToString,
|
|
20
|
-
mergeRuntime
|
|
20
|
+
runtimeToString
|
|
21
21
|
} = require("../util/runtime");
|
|
22
22
|
const ConcatenatedModule = require("./ConcatenatedModule");
|
|
23
23
|
|
|
@@ -223,6 +223,11 @@ class ModuleConcatenationPlugin {
|
|
|
223
223
|
canBeInner = false;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
if (moduleGraph.isDeferred(module)) {
|
|
227
|
+
setInnerBailoutReason(module, "Module is deferred");
|
|
228
|
+
canBeInner = false;
|
|
229
|
+
}
|
|
230
|
+
|
|
226
231
|
if (canBeRoot) relevantModules.push(module);
|
|
227
232
|
if (canBeInner) possibleInners.add(module);
|
|
228
233
|
}
|
|
@@ -585,25 +590,27 @@ class ModuleConcatenationPlugin {
|
|
|
585
590
|
}
|
|
586
591
|
|
|
587
592
|
// Module must be in the correct chunks
|
|
588
|
-
const missingChunks =
|
|
589
|
-
chunkGraph.getModuleChunksIterable(config.rootModule)
|
|
590
|
-
|
|
593
|
+
const missingChunks = [
|
|
594
|
+
...chunkGraph.getModuleChunksIterable(config.rootModule)
|
|
595
|
+
].filter(chunk => !chunkGraph.isModuleInChunk(module, chunk));
|
|
591
596
|
if (missingChunks.length > 0) {
|
|
592
597
|
/**
|
|
593
598
|
* @param {RequestShortener} requestShortener request shortener
|
|
594
599
|
* @returns {string} problem description
|
|
595
600
|
*/
|
|
596
601
|
const problem = requestShortener => {
|
|
597
|
-
const missingChunksList =
|
|
598
|
-
new Set(
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
602
|
+
const missingChunksList = [
|
|
603
|
+
...new Set(
|
|
604
|
+
missingChunks.map(chunk => chunk.name || "unnamed chunk(s)")
|
|
605
|
+
)
|
|
606
|
+
].sort();
|
|
607
|
+
const chunks = [
|
|
608
|
+
...new Set(
|
|
609
|
+
[...chunkGraph.getModuleChunksIterable(module)].map(
|
|
603
610
|
chunk => chunk.name || "unnamed chunk(s)"
|
|
604
611
|
)
|
|
605
612
|
)
|
|
606
|
-
|
|
613
|
+
].sort();
|
|
607
614
|
return `Module ${module.readableIdentifier(
|
|
608
615
|
requestShortener
|
|
609
616
|
)} is not in the same chunk(s) (expected in chunk(s) ${missingChunksList.join(
|
|
@@ -638,7 +645,7 @@ class ModuleConcatenationPlugin {
|
|
|
638
645
|
const importingExplanations = new Set(
|
|
639
646
|
activeNonModulesConnections.map(c => c.explanation).filter(Boolean)
|
|
640
647
|
);
|
|
641
|
-
const explanations =
|
|
648
|
+
const explanations = [...importingExplanations].sort();
|
|
642
649
|
return `Module ${module.readableIdentifier(
|
|
643
650
|
requestShortener
|
|
644
651
|
)} is referenced ${
|
|
@@ -672,12 +679,13 @@ class ModuleConcatenationPlugin {
|
|
|
672
679
|
const activeConnections = connections.filter(connection =>
|
|
673
680
|
connection.isActive(runtime)
|
|
674
681
|
);
|
|
675
|
-
if (activeConnections.length > 0)
|
|
682
|
+
if (activeConnections.length > 0) {
|
|
676
683
|
incomingConnectionsFromModules.set(originModule, activeConnections);
|
|
684
|
+
}
|
|
677
685
|
}
|
|
678
686
|
}
|
|
679
687
|
|
|
680
|
-
const incomingModules =
|
|
688
|
+
const incomingModules = [...incomingConnectionsFromModules.keys()];
|
|
681
689
|
|
|
682
690
|
// Module must be in the same chunks like the referencing module
|
|
683
691
|
const otherChunkModules = incomingModules.filter(originModule => {
|
|
@@ -718,8 +726,9 @@ class ModuleConcatenationPlugin {
|
|
|
718
726
|
!connection.dependency ||
|
|
719
727
|
!(connection.dependency instanceof HarmonyImportDependency)
|
|
720
728
|
);
|
|
721
|
-
if (selected.length > 0)
|
|
729
|
+
if (selected.length > 0) {
|
|
722
730
|
nonHarmonyConnections.set(originModule, connections);
|
|
731
|
+
}
|
|
723
732
|
}
|
|
724
733
|
if (nonHarmonyConnections.size > 0) {
|
|
725
734
|
/**
|
|
@@ -727,18 +736,18 @@ class ModuleConcatenationPlugin {
|
|
|
727
736
|
* @returns {string} problem description
|
|
728
737
|
*/
|
|
729
738
|
const problem = requestShortener => {
|
|
730
|
-
const names =
|
|
739
|
+
const names = [...nonHarmonyConnections]
|
|
731
740
|
.map(
|
|
732
741
|
([originModule, connections]) =>
|
|
733
742
|
`${originModule.readableIdentifier(
|
|
734
743
|
requestShortener
|
|
735
|
-
)} (referenced with ${
|
|
736
|
-
new Set(
|
|
744
|
+
)} (referenced with ${[
|
|
745
|
+
...new Set(
|
|
737
746
|
connections
|
|
738
747
|
.map(c => c.dependency && c.dependency.type)
|
|
739
748
|
.filter(Boolean)
|
|
740
749
|
)
|
|
741
|
-
|
|
750
|
+
]
|
|
742
751
|
.sort()
|
|
743
752
|
.join(", ")})`
|
|
744
753
|
)
|
|
@@ -898,7 +907,7 @@ class ConcatConfiguration {
|
|
|
898
907
|
*/
|
|
899
908
|
getWarningsSorted() {
|
|
900
909
|
return new Map(
|
|
901
|
-
|
|
910
|
+
[...this.warnings].sort((a, b) => {
|
|
902
911
|
const ai = a[0].identifier();
|
|
903
912
|
const bi = b[0].identifier();
|
|
904
913
|
if (ai < bi) return -1;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const { SyncBailHook } = require("tapable");
|
|
9
|
-
const {
|
|
9
|
+
const { CachedSource, CompatSource, RawSource } = require("webpack-sources");
|
|
10
10
|
const Compilation = require("../Compilation");
|
|
11
11
|
const WebpackError = require("../WebpackError");
|
|
12
12
|
const { compareSelect, compareStrings } = require("../util/comparators");
|
|
@@ -214,7 +214,7 @@ class RealContentHashPlugin {
|
|
|
214
214
|
}
|
|
215
215
|
const etag = cacheAnalyse.mergeEtags(
|
|
216
216
|
cacheAnalyse.getLazyHashedEtag(source),
|
|
217
|
-
|
|
217
|
+
[...hashes].join("|")
|
|
218
218
|
);
|
|
219
219
|
[asset.referencedHashes, asset.ownHashes] =
|
|
220
220
|
await cacheAnalyse.providePromise(name, etag, () => {
|
|
@@ -288,6 +288,7 @@ ${referencingAssets
|
|
|
288
288
|
a => a.name
|
|
289
289
|
)})`;
|
|
290
290
|
};
|
|
291
|
+
/** @type {Set<string>} */
|
|
291
292
|
const hashesInOrder = new Set();
|
|
292
293
|
for (const hash of hashToAssets.keys()) {
|
|
293
294
|
/**
|
|
@@ -316,6 +317,7 @@ ${referencingAssets
|
|
|
316
317
|
if (hashesInOrder.has(hash)) continue;
|
|
317
318
|
add(hash, new Set());
|
|
318
319
|
}
|
|
320
|
+
/** @type {Map<string, string>} */
|
|
319
321
|
const hashToNewHash = new Map();
|
|
320
322
|
/**
|
|
321
323
|
* @param {AssetInfoForRealContentHash} asset asset info
|
|
@@ -338,10 +340,9 @@ ${referencingAssets
|
|
|
338
340
|
return (asset.contentComputePromise = (async () => {
|
|
339
341
|
if (
|
|
340
342
|
/** @type {OwnHashes} */ (asset.ownHashes).size > 0 ||
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
).some(hash => hashToNewHash.get(hash) !== hash)
|
|
343
|
+
[
|
|
344
|
+
.../** @type {ReferencedHashes} */ (asset.referencedHashes)
|
|
345
|
+
].some(hash => hashToNewHash.get(hash) !== hash)
|
|
345
346
|
) {
|
|
346
347
|
const identifier = asset.name;
|
|
347
348
|
const etag = getEtag(asset);
|
|
@@ -349,8 +350,9 @@ ${referencingAssets
|
|
|
349
350
|
identifier,
|
|
350
351
|
etag,
|
|
351
352
|
() => {
|
|
352
|
-
const newContent = asset.content.replace(
|
|
353
|
-
|
|
353
|
+
const newContent = asset.content.replace(
|
|
354
|
+
hashRegExp,
|
|
355
|
+
hash => /** @type {string} */ (hashToNewHash.get(hash))
|
|
354
356
|
);
|
|
355
357
|
return new RawSource(newContent);
|
|
356
358
|
}
|
|
@@ -363,15 +365,15 @@ ${referencingAssets
|
|
|
363
365
|
* @returns {Promise<void>}
|
|
364
366
|
*/
|
|
365
367
|
const computeNewContentWithoutOwn = asset => {
|
|
366
|
-
if (asset.contentComputeWithoutOwnPromise)
|
|
368
|
+
if (asset.contentComputeWithoutOwnPromise) {
|
|
367
369
|
return asset.contentComputeWithoutOwnPromise;
|
|
370
|
+
}
|
|
368
371
|
return (asset.contentComputeWithoutOwnPromise = (async () => {
|
|
369
372
|
if (
|
|
370
373
|
/** @type {OwnHashes} */ (asset.ownHashes).size > 0 ||
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
).some(hash => hashToNewHash.get(hash) !== hash)
|
|
374
|
+
[
|
|
375
|
+
.../** @type {ReferencedHashes} */ (asset.referencedHashes)
|
|
376
|
+
].some(hash => hashToNewHash.get(hash) !== hash)
|
|
375
377
|
) {
|
|
376
378
|
const identifier = `${asset.name}|without-own`;
|
|
377
379
|
const etag = getEtag(asset);
|
|
@@ -383,11 +385,12 @@ ${referencingAssets
|
|
|
383
385
|
hashRegExp,
|
|
384
386
|
hash => {
|
|
385
387
|
if (
|
|
386
|
-
/** @type {OwnHashes} */
|
|
388
|
+
/** @type {OwnHashes} */
|
|
389
|
+
(asset.ownHashes).has(hash)
|
|
387
390
|
) {
|
|
388
391
|
return "";
|
|
389
392
|
}
|
|
390
|
-
return hashToNewHash.get(hash);
|
|
393
|
+
return /** @type {string} */ (hashToNewHash.get(hash));
|
|
391
394
|
}
|
|
392
395
|
);
|
|
393
396
|
return new RawSource(newContent);
|
|
@@ -436,15 +439,18 @@ ${referencingAssets
|
|
|
436
439
|
await Promise.all(
|
|
437
440
|
assetsWithInfo.map(async asset => {
|
|
438
441
|
await computeNewContent(asset);
|
|
439
|
-
const newName = asset.name.replace(
|
|
440
|
-
|
|
442
|
+
const newName = asset.name.replace(
|
|
443
|
+
hashRegExp,
|
|
444
|
+
hash => /** @type {string} */ (hashToNewHash.get(hash))
|
|
441
445
|
);
|
|
442
446
|
|
|
443
447
|
const infoUpdate = {};
|
|
444
|
-
const hash = asset.info.contenthash;
|
|
448
|
+
const hash = /** @type {string} */ (asset.info.contenthash);
|
|
445
449
|
infoUpdate.contenthash = Array.isArray(hash)
|
|
446
|
-
? hash.map(
|
|
447
|
-
|
|
450
|
+
? hash.map(
|
|
451
|
+
hash => /** @type {string} */ (hashToNewHash.get(hash))
|
|
452
|
+
)
|
|
453
|
+
: /** @type {string} */ (hashToNewHash.get(hash));
|
|
448
454
|
|
|
449
455
|
if (asset.newSource !== undefined) {
|
|
450
456
|
compilation.updateAsset(
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const {
|
|
8
|
+
const { STAGE_ADVANCED, STAGE_BASIC } = require("../OptimizationStages");
|
|
9
9
|
|
|
10
10
|
/** @typedef {import("../Chunk")} Chunk */
|
|
11
11
|
/** @typedef {import("../Compiler")} Compiler */
|
|
@@ -56,4 +56,5 @@ class RemoveEmptyChunksPlugin {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
|
|
59
60
|
module.exports = RemoveEmptyChunksPlugin;
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
const glob2regexp = require("glob-to-regexp");
|
|
9
9
|
const {
|
|
10
10
|
JAVASCRIPT_MODULE_TYPE_AUTO,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
|
12
|
+
JAVASCRIPT_MODULE_TYPE_ESM
|
|
13
13
|
} = require("../ModuleTypeConstants");
|
|
14
14
|
const { STAGE_DEFAULT } = require("../OptimizationStages");
|
|
15
15
|
const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency");
|
|
@@ -400,4 +400,5 @@ class SideEffectsFlagPlugin {
|
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
+
|
|
403
404
|
module.exports = SideEffectsFlagPlugin;
|
|
@@ -12,8 +12,8 @@ const { requestToId } = require("../ids/IdHelpers");
|
|
|
12
12
|
const { isSubset } = require("../util/SetHelpers");
|
|
13
13
|
const SortableSet = require("../util/SortableSet");
|
|
14
14
|
const {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
compareIterables,
|
|
16
|
+
compareModulesByIdentifier
|
|
17
17
|
} = require("../util/comparators");
|
|
18
18
|
const createHash = require("../util/createHash");
|
|
19
19
|
const deterministicGrouping = require("../util/deterministicGrouping");
|
|
@@ -279,10 +279,10 @@ const INITIAL_CHUNK_FILTER = chunk => chunk.canBeInitial();
|
|
|
279
279
|
*/
|
|
280
280
|
const ASYNC_CHUNK_FILTER = chunk => !chunk.canBeInitial();
|
|
281
281
|
/**
|
|
282
|
-
* @param {Chunk}
|
|
282
|
+
* @param {Chunk} _chunk the chunk
|
|
283
283
|
* @returns {boolean} always true
|
|
284
284
|
*/
|
|
285
|
-
const ALL_CHUNK_FILTER =
|
|
285
|
+
const ALL_CHUNK_FILTER = _chunk => true;
|
|
286
286
|
|
|
287
287
|
/**
|
|
288
288
|
* @param {OptimizationSplitChunksSizes | undefined} value the sizes
|
|
@@ -853,7 +853,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
853
853
|
chunk,
|
|
854
854
|
index | BigInt((Math.random() * 0x7fffffff) | 0)
|
|
855
855
|
);
|
|
856
|
-
index
|
|
856
|
+
index <<= ONE;
|
|
857
857
|
}
|
|
858
858
|
/**
|
|
859
859
|
* @param {Iterable<Chunk>} chunks list of chunks
|
|
@@ -871,7 +871,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
871
871
|
/** @type {bigint} */ (chunkIndexMap.get(result.value));
|
|
872
872
|
while (!(result = iterator.next()).done) {
|
|
873
873
|
const raw = chunkIndexMap.get(result.value);
|
|
874
|
-
key
|
|
874
|
+
key ^= /** @type {bigint} */ (raw);
|
|
875
875
|
}
|
|
876
876
|
return key;
|
|
877
877
|
};
|
|
@@ -931,7 +931,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
931
931
|
/** @type {Set<Chunk>} */
|
|
932
932
|
const singleChunkSets = new Set();
|
|
933
933
|
for (const module of compilation.modules) {
|
|
934
|
-
const groupedChunks =
|
|
934
|
+
const groupedChunks = [...groupChunksByExports(module)];
|
|
935
935
|
groupedByExportsMap.set(module, groupedChunks);
|
|
936
936
|
for (const chunks of groupedChunks) {
|
|
937
937
|
if (chunks.length === 1) {
|
|
@@ -1270,8 +1270,9 @@ module.exports = class SplitChunksPlugin {
|
|
|
1270
1270
|
(groupedByExportsMap.get(module));
|
|
1271
1271
|
for (const chunks of groupedByUsedExports) {
|
|
1272
1272
|
const chunksKey = getKey(chunks);
|
|
1273
|
-
for (const comb of getExportsCombinations(chunksKey))
|
|
1273
|
+
for (const comb of getExportsCombinations(chunksKey)) {
|
|
1274
1274
|
set.add(comb);
|
|
1275
|
+
}
|
|
1275
1276
|
}
|
|
1276
1277
|
return set;
|
|
1277
1278
|
});
|
|
@@ -1489,10 +1490,11 @@ module.exports = class SplitChunksPlugin {
|
|
|
1489
1490
|
// Were some (invalid) chunks removed from usedChunks?
|
|
1490
1491
|
// => readd all modules to the queue, as things could have been changed
|
|
1491
1492
|
if (usedChunks.size < item.chunks.size) {
|
|
1492
|
-
if (isExistingChunk)
|
|
1493
|
+
if (isExistingChunk) {
|
|
1493
1494
|
usedChunks.add(/** @type {Chunk} */ (newChunk));
|
|
1495
|
+
}
|
|
1494
1496
|
if (usedChunks.size >= item.cacheGroup.minChunks) {
|
|
1495
|
-
const chunksArr =
|
|
1497
|
+
const chunksArr = [...usedChunks];
|
|
1496
1498
|
for (const module of item.modules) {
|
|
1497
1499
|
addModuleToChunksInfoMap(
|
|
1498
1500
|
item.cacheGroup,
|
|
@@ -1618,7 +1620,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
1618
1620
|
: item.cacheGroup.maxInitialSize,
|
|
1619
1621
|
automaticNameDelimiter: item.cacheGroup.automaticNameDelimiter,
|
|
1620
1622
|
keys: oldMaxSizeSettings
|
|
1621
|
-
? oldMaxSizeSettings.keys
|
|
1623
|
+
? [...oldMaxSizeSettings.keys, item.cacheGroup.key]
|
|
1622
1624
|
: [item.cacheGroup.key]
|
|
1623
1625
|
});
|
|
1624
1626
|
}
|
|
@@ -1672,7 +1674,7 @@ module.exports = class SplitChunksPlugin {
|
|
|
1672
1674
|
|
|
1673
1675
|
// Make sure that maxSize is fulfilled
|
|
1674
1676
|
const { fallbackCacheGroup } = this.options;
|
|
1675
|
-
for (const chunk of
|
|
1677
|
+
for (const chunk of compilation.chunks) {
|
|
1676
1678
|
const chunkConfig = maxSizeQueueMap.get(chunk);
|
|
1677
1679
|
const {
|
|
1678
1680
|
minSize,
|
|
@@ -1680,8 +1682,9 @@ module.exports = class SplitChunksPlugin {
|
|
|
1680
1682
|
maxInitialSize,
|
|
1681
1683
|
automaticNameDelimiter
|
|
1682
1684
|
} = chunkConfig || fallbackCacheGroup;
|
|
1683
|
-
if (!chunkConfig && !fallbackCacheGroup.chunksFilter(chunk))
|
|
1685
|
+
if (!chunkConfig && !fallbackCacheGroup.chunksFilter(chunk)) {
|
|
1684
1686
|
continue;
|
|
1687
|
+
}
|
|
1685
1688
|
/** @type {SplitChunksSizes} */
|
|
1686
1689
|
let maxSize;
|
|
1687
1690
|
if (chunk.isOnlyInitial()) {
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
/** @typedef {KeysOfTypes<RuleSetRule, string | boolean | { [k: string]: EXPECTED_ANY }>} BasicEffectRuleKeys */
|
|
18
18
|
|
|
19
|
+
const PLUGIN_NAME = "BasicEffectRulePlugin";
|
|
20
|
+
|
|
19
21
|
class BasicEffectRulePlugin {
|
|
20
22
|
/**
|
|
21
23
|
* @param {BasicEffectRuleKeys} ruleProperty the rule property
|
|
@@ -32,8 +34,8 @@ class BasicEffectRulePlugin {
|
|
|
32
34
|
*/
|
|
33
35
|
apply(ruleSetCompiler) {
|
|
34
36
|
ruleSetCompiler.hooks.rule.tap(
|
|
35
|
-
|
|
36
|
-
(path, rule, unhandledProperties, result
|
|
37
|
+
PLUGIN_NAME,
|
|
38
|
+
(path, rule, unhandledProperties, result) => {
|
|
37
39
|
if (unhandledProperties.has(this.ruleProperty)) {
|
|
38
40
|
unhandledProperties.delete(this.ruleProperty);
|
|
39
41
|
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
/** @typedef {KeysOfTypes<RuleSetRule, RuleSetConditionOrConditions | RuleSetConditionOrConditionsAbsolute>} BasicMatcherRuleKeys */
|
|
22
22
|
|
|
23
|
+
const PLUGIN_NAME = "BasicMatcherRulePlugin";
|
|
24
|
+
|
|
23
25
|
class BasicMatcherRulePlugin {
|
|
24
26
|
/**
|
|
25
27
|
* @param {BasicMatcherRuleKeys} ruleProperty the rule property
|
|
@@ -38,7 +40,7 @@ class BasicMatcherRulePlugin {
|
|
|
38
40
|
*/
|
|
39
41
|
apply(ruleSetCompiler) {
|
|
40
42
|
ruleSetCompiler.hooks.rule.tap(
|
|
41
|
-
|
|
43
|
+
PLUGIN_NAME,
|
|
42
44
|
(path, rule, unhandledProperties, result) => {
|
|
43
45
|
if (unhandledProperties.has(this.ruleProperty)) {
|
|
44
46
|
unhandledProperties.delete(this.ruleProperty);
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
/** @typedef {KeysOfTypes<RuleSetRule, { [k: string]: RuleSetConditionOrConditions }>} ObjectMatcherRuleKeys */
|
|
22
22
|
|
|
23
|
+
const PLUGIN_NAME = "ObjectMatcherRulePlugin";
|
|
24
|
+
|
|
23
25
|
class ObjectMatcherRulePlugin {
|
|
24
26
|
/**
|
|
25
27
|
* @param {ObjectMatcherRuleKeys} ruleProperty the rule property
|
|
@@ -39,7 +41,7 @@ class ObjectMatcherRulePlugin {
|
|
|
39
41
|
apply(ruleSetCompiler) {
|
|
40
42
|
const { ruleProperty, dataProperty } = this;
|
|
41
43
|
ruleSetCompiler.hooks.rule.tap(
|
|
42
|
-
|
|
44
|
+
PLUGIN_NAME,
|
|
43
45
|
(path, rule, unhandledProperties, result) => {
|
|
44
46
|
if (unhandledProperties.has(ruleProperty)) {
|
|
45
47
|
unhandledProperties.delete(ruleProperty);
|
|
@@ -10,6 +10,7 @@ const { SyncHook } = require("tapable");
|
|
|
10
10
|
/** @typedef {import("../../declarations/WebpackOptions").Falsy} Falsy */
|
|
11
11
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetLoaderOptions} RuleSetLoaderOptions */
|
|
12
12
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
|
13
|
+
/** @typedef {import("../NormalModule").LoaderItem} LoaderItem */
|
|
13
14
|
|
|
14
15
|
/** @typedef {(Falsy | RuleSetRule)[]} RuleSetRules */
|
|
15
16
|
|
|
@@ -54,12 +55,22 @@ const { SyncHook } = require("tapable");
|
|
|
54
55
|
* @property {CompiledRule[]=} oneOf
|
|
55
56
|
*/
|
|
56
57
|
|
|
58
|
+
/** @typedef {"use" | "use-pre" | "use-post"} EffectUseType */
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @typedef {object} EffectUse
|
|
62
|
+
* @property {EffectUseType} type
|
|
63
|
+
* @property {{ loader: string, options?: string | null | Record<string, EXPECTED_ANY>, ident?: string }} value
|
|
64
|
+
*/
|
|
65
|
+
|
|
57
66
|
/**
|
|
58
|
-
* @typedef {object}
|
|
67
|
+
* @typedef {object} EffectBasic
|
|
59
68
|
* @property {string} type
|
|
60
|
-
* @property {
|
|
69
|
+
* @property {EXPECTED_ANY} value
|
|
61
70
|
*/
|
|
62
71
|
|
|
72
|
+
/** @typedef {EffectUse | EffectBasic} Effect */
|
|
73
|
+
|
|
63
74
|
/** @typedef {Map<string, RuleSetLoaderOptions>} References */
|
|
64
75
|
|
|
65
76
|
/**
|
|
@@ -208,6 +219,7 @@ class RuleSetCompiler {
|
|
|
208
219
|
* @returns {CompiledRule} normalized and compiled rule for processing
|
|
209
220
|
*/
|
|
210
221
|
compileRule(path, rule, refs) {
|
|
222
|
+
/** @type {Set<string>} */
|
|
211
223
|
const unhandledProperties = new Set(
|
|
212
224
|
Object.keys(rule).filter(
|
|
213
225
|
key => rule[/** @type {keyof RuleSetRule} */ (key)] !== undefined
|
|
@@ -227,16 +239,18 @@ class RuleSetCompiler {
|
|
|
227
239
|
if (unhandledProperties.has("rules")) {
|
|
228
240
|
unhandledProperties.delete("rules");
|
|
229
241
|
const rules = rule.rules;
|
|
230
|
-
if (!Array.isArray(rules))
|
|
242
|
+
if (!Array.isArray(rules)) {
|
|
231
243
|
throw this.error(path, rules, "Rule.rules must be an array of rules");
|
|
244
|
+
}
|
|
232
245
|
compiledRule.rules = this.compileRules(`${path}.rules`, rules, refs);
|
|
233
246
|
}
|
|
234
247
|
|
|
235
248
|
if (unhandledProperties.has("oneOf")) {
|
|
236
249
|
unhandledProperties.delete("oneOf");
|
|
237
250
|
const oneOf = rule.oneOf;
|
|
238
|
-
if (!Array.isArray(oneOf))
|
|
251
|
+
if (!Array.isArray(oneOf)) {
|
|
239
252
|
throw this.error(path, oneOf, "Rule.oneOf must be an array of rules");
|
|
253
|
+
}
|
|
240
254
|
compiledRule.oneOf = this.compileRules(`${path}.oneOf`, oneOf, refs);
|
|
241
255
|
}
|
|
242
256
|
|
|
@@ -244,7 +258,7 @@ class RuleSetCompiler {
|
|
|
244
258
|
throw this.error(
|
|
245
259
|
path,
|
|
246
260
|
rule,
|
|
247
|
-
`Properties ${
|
|
261
|
+
`Properties ${[...unhandledProperties].join(", ")} are unknown`
|
|
248
262
|
);
|
|
249
263
|
}
|
|
250
264
|
|
|
@@ -16,6 +16,9 @@ const util = require("util");
|
|
|
16
16
|
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
|
17
17
|
/** @typedef {import("./RuleSetCompiler").Effect} Effect */
|
|
18
18
|
/** @typedef {import("./RuleSetCompiler").EffectData} EffectData */
|
|
19
|
+
/** @typedef {import("./RuleSetCompiler").EffectUseType} EffectUseType */
|
|
20
|
+
|
|
21
|
+
const PLUGIN_NAME = "UseEffectRulePlugin";
|
|
19
22
|
|
|
20
23
|
class UseEffectRulePlugin {
|
|
21
24
|
/**
|
|
@@ -24,7 +27,7 @@ class UseEffectRulePlugin {
|
|
|
24
27
|
*/
|
|
25
28
|
apply(ruleSetCompiler) {
|
|
26
29
|
ruleSetCompiler.hooks.rule.tap(
|
|
27
|
-
|
|
30
|
+
PLUGIN_NAME,
|
|
28
31
|
(path, rule, unhandledProperties, result, references) => {
|
|
29
32
|
/**
|
|
30
33
|
* @param {keyof RuleSetRule} property property
|
|
@@ -50,7 +53,9 @@ class UseEffectRulePlugin {
|
|
|
50
53
|
const use = /** @type {RuleSetUse} */ (rule.use);
|
|
51
54
|
const enforce = rule.enforce;
|
|
52
55
|
|
|
53
|
-
const type =
|
|
56
|
+
const type =
|
|
57
|
+
/** @type {EffectUseType} */
|
|
58
|
+
(enforce ? `use-${enforce}` : "use");
|
|
54
59
|
|
|
55
60
|
/**
|
|
56
61
|
* @param {string} path options path
|
|
@@ -87,7 +92,7 @@ class UseEffectRulePlugin {
|
|
|
87
92
|
}
|
|
88
93
|
};
|
|
89
94
|
}
|
|
90
|
-
const loader = item.loader;
|
|
95
|
+
const loader = /** @type {string} */ (item.loader);
|
|
91
96
|
const options = item.options;
|
|
92
97
|
let ident = item.ident;
|
|
93
98
|
if (options && typeof options === "object") {
|
|
@@ -205,12 +210,15 @@ class UseEffectRulePlugin {
|
|
|
205
210
|
|
|
206
211
|
const ident =
|
|
207
212
|
options && typeof options === "object" ? path : undefined;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
213
|
+
|
|
214
|
+
if (ident) {
|
|
215
|
+
references.set(
|
|
216
|
+
ident,
|
|
217
|
+
/** @type {RuleSetLoaderOptions} */
|
|
218
|
+
(options)
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
214
222
|
result.effects.push({
|
|
215
223
|
type: enforce ? `use-${enforce}` : "use",
|
|
216
224
|
value: {
|