webpack 5.99.9 → 5.100.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.
- 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 +6 -1
- 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 +1 -1
- 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 +29 -19
- 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/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/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 +6 -3
- package/lib/rules/UseEffectRulePlugin.js +3 -1
- 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 +4 -2
- package/lib/stats/DefaultStatsPrinterPlugin.js +15 -9
- package/lib/stats/StatsFactory.js +4 -2
- package/lib/stats/StatsPrinter.js +3 -2
- 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 +12 -8
- 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 +1230 -360
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
|
-
ASSET_MODULE_TYPE_RESOURCE,
|
|
10
|
-
ASSET_MODULE_TYPE_INLINE,
|
|
11
9
|
ASSET_MODULE_TYPE,
|
|
10
|
+
ASSET_MODULE_TYPE_INLINE,
|
|
11
|
+
ASSET_MODULE_TYPE_RESOURCE,
|
|
12
12
|
ASSET_MODULE_TYPE_SOURCE
|
|
13
13
|
} = require("../ModuleTypeConstants");
|
|
14
14
|
const { cleverMerge } = require("../util/cleverMerge");
|
|
@@ -18,6 +18,7 @@ const memoize = require("../util/memoize");
|
|
|
18
18
|
|
|
19
19
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
20
20
|
/** @typedef {import("../../declarations/WebpackOptions").AssetParserOptions} AssetParserOptions */
|
|
21
|
+
/** @typedef {import("schema-utils").Schema} Schema */
|
|
21
22
|
/** @typedef {import("../Chunk")} Chunk */
|
|
22
23
|
/** @typedef {import("../Compilation").AssetInfo} AssetInfo */
|
|
23
24
|
/** @typedef {import("../Compiler")} Compiler */
|
|
@@ -28,10 +29,11 @@ const memoize = require("../util/memoize");
|
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* @param {string} name name of definitions
|
|
31
|
-
* @returns {
|
|
32
|
+
* @returns {Schema} definition
|
|
32
33
|
*/
|
|
33
34
|
const getSchema = name => {
|
|
34
35
|
const { definitions } = require("../../schemas/WebpackOptions.json");
|
|
36
|
+
|
|
35
37
|
return {
|
|
36
38
|
definitions,
|
|
37
39
|
oneOf: [{ $ref: `#/definitions/${name}` }]
|
|
@@ -44,24 +46,24 @@ const generatorValidationOptions = {
|
|
|
44
46
|
};
|
|
45
47
|
const validateGeneratorOptions = {
|
|
46
48
|
asset: createSchemaValidation(
|
|
47
|
-
require("../../schemas/plugins/asset/AssetGeneratorOptions.check
|
|
49
|
+
require("../../schemas/plugins/asset/AssetGeneratorOptions.check"),
|
|
48
50
|
() => getSchema("AssetGeneratorOptions"),
|
|
49
51
|
generatorValidationOptions
|
|
50
52
|
),
|
|
51
53
|
"asset/resource": createSchemaValidation(
|
|
52
|
-
require("../../schemas/plugins/asset/AssetResourceGeneratorOptions.check
|
|
54
|
+
require("../../schemas/plugins/asset/AssetResourceGeneratorOptions.check"),
|
|
53
55
|
() => getSchema("AssetResourceGeneratorOptions"),
|
|
54
56
|
generatorValidationOptions
|
|
55
57
|
),
|
|
56
58
|
"asset/inline": createSchemaValidation(
|
|
57
|
-
require("../../schemas/plugins/asset/AssetInlineGeneratorOptions.check
|
|
59
|
+
require("../../schemas/plugins/asset/AssetInlineGeneratorOptions.check"),
|
|
58
60
|
() => getSchema("AssetInlineGeneratorOptions"),
|
|
59
61
|
generatorValidationOptions
|
|
60
62
|
)
|
|
61
63
|
};
|
|
62
64
|
|
|
63
65
|
const validateParserOptions = createSchemaValidation(
|
|
64
|
-
require("../../schemas/plugins/asset/AssetParserOptions.check
|
|
66
|
+
require("../../schemas/plugins/asset/AssetParserOptions.check"),
|
|
65
67
|
() => getSchema("AssetParserOptions"),
|
|
66
68
|
{
|
|
67
69
|
name: "Asset Modules Plugin",
|
|
@@ -77,7 +79,7 @@ const getAssetSourceGenerator = memoize(() =>
|
|
|
77
79
|
);
|
|
78
80
|
|
|
79
81
|
const type = ASSET_MODULE_TYPE;
|
|
80
|
-
const
|
|
82
|
+
const PLUGIN_NAME = "AssetModulesPlugin";
|
|
81
83
|
|
|
82
84
|
class AssetModulesPlugin {
|
|
83
85
|
/**
|
|
@@ -87,11 +89,11 @@ class AssetModulesPlugin {
|
|
|
87
89
|
*/
|
|
88
90
|
apply(compiler) {
|
|
89
91
|
compiler.hooks.compilation.tap(
|
|
90
|
-
|
|
92
|
+
PLUGIN_NAME,
|
|
91
93
|
(compilation, { normalModuleFactory }) => {
|
|
92
94
|
normalModuleFactory.hooks.createParser
|
|
93
95
|
.for(ASSET_MODULE_TYPE)
|
|
94
|
-
.tap(
|
|
96
|
+
.tap(PLUGIN_NAME, parserOptions => {
|
|
95
97
|
validateParserOptions(parserOptions);
|
|
96
98
|
parserOptions = cleverMerge(
|
|
97
99
|
/** @type {AssetParserOptions} */
|
|
@@ -113,21 +115,21 @@ class AssetModulesPlugin {
|
|
|
113
115
|
});
|
|
114
116
|
normalModuleFactory.hooks.createParser
|
|
115
117
|
.for(ASSET_MODULE_TYPE_INLINE)
|
|
116
|
-
.tap(
|
|
118
|
+
.tap(PLUGIN_NAME, _parserOptions => {
|
|
117
119
|
const AssetParser = getAssetParser();
|
|
118
120
|
|
|
119
121
|
return new AssetParser(true);
|
|
120
122
|
});
|
|
121
123
|
normalModuleFactory.hooks.createParser
|
|
122
124
|
.for(ASSET_MODULE_TYPE_RESOURCE)
|
|
123
|
-
.tap(
|
|
125
|
+
.tap(PLUGIN_NAME, _parserOptions => {
|
|
124
126
|
const AssetParser = getAssetParser();
|
|
125
127
|
|
|
126
128
|
return new AssetParser(false);
|
|
127
129
|
});
|
|
128
130
|
normalModuleFactory.hooks.createParser
|
|
129
131
|
.for(ASSET_MODULE_TYPE_SOURCE)
|
|
130
|
-
.tap(
|
|
132
|
+
.tap(PLUGIN_NAME, _parserOptions => {
|
|
131
133
|
const AssetSourceParser = getAssetSourceParser();
|
|
132
134
|
|
|
133
135
|
return new AssetSourceParser();
|
|
@@ -140,7 +142,7 @@ class AssetModulesPlugin {
|
|
|
140
142
|
]) {
|
|
141
143
|
normalModuleFactory.hooks.createGenerator
|
|
142
144
|
.for(type)
|
|
143
|
-
.tap(
|
|
145
|
+
.tap(PLUGIN_NAME, generatorOptions => {
|
|
144
146
|
validateGeneratorOptions[type](generatorOptions);
|
|
145
147
|
|
|
146
148
|
let dataUrl;
|
|
@@ -178,13 +180,13 @@ class AssetModulesPlugin {
|
|
|
178
180
|
}
|
|
179
181
|
normalModuleFactory.hooks.createGenerator
|
|
180
182
|
.for(ASSET_MODULE_TYPE_SOURCE)
|
|
181
|
-
.tap(
|
|
183
|
+
.tap(PLUGIN_NAME, () => {
|
|
182
184
|
const AssetSourceGenerator = getAssetSourceGenerator();
|
|
183
185
|
|
|
184
186
|
return new AssetSourceGenerator(compilation.moduleGraph);
|
|
185
187
|
});
|
|
186
188
|
|
|
187
|
-
compilation.hooks.renderManifest.tap(
|
|
189
|
+
compilation.hooks.renderManifest.tap(PLUGIN_NAME, (result, options) => {
|
|
188
190
|
const { chunkGraph } = compilation;
|
|
189
191
|
const { chunk, codeGenerationResults, runtimeTemplate } = options;
|
|
190
192
|
|
|
@@ -270,7 +272,7 @@ class AssetModulesPlugin {
|
|
|
270
272
|
});
|
|
271
273
|
|
|
272
274
|
compilation.hooks.prepareModuleExecution.tap(
|
|
273
|
-
|
|
275
|
+
PLUGIN_NAME,
|
|
274
276
|
(options, context) => {
|
|
275
277
|
const { codeGenerationResult } = options;
|
|
276
278
|
const source = codeGenerationResult.sources.get(ASSET_MODULE_TYPE);
|
|
@@ -9,10 +9,10 @@ const { RawSource } = require("webpack-sources");
|
|
|
9
9
|
const ConcatenationScope = require("../ConcatenationScope");
|
|
10
10
|
const Generator = require("../Generator");
|
|
11
11
|
const {
|
|
12
|
-
NO_TYPES,
|
|
13
12
|
CSS_URL_TYPES,
|
|
13
|
+
JS_AND_CSS_URL_TYPES,
|
|
14
14
|
JS_TYPES,
|
|
15
|
-
|
|
15
|
+
NO_TYPES
|
|
16
16
|
} = require("../ModuleSourceTypesConstants");
|
|
17
17
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
18
18
|
|
|
@@ -53,7 +53,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
53
53
|
|
|
54
54
|
const content = originalSource.source();
|
|
55
55
|
const encodedSource =
|
|
56
|
-
typeof content === "string" ? content : content.toString("
|
|
56
|
+
typeof content === "string" ? content : content.toString("utf8");
|
|
57
57
|
|
|
58
58
|
let sourceContent;
|
|
59
59
|
if (concatenationScope) {
|
|
@@ -78,7 +78,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
78
78
|
|
|
79
79
|
const content = originalSource.source();
|
|
80
80
|
const encodedSource =
|
|
81
|
-
typeof content === "string" ? content : content.toString("
|
|
81
|
+
typeof content === "string" ? content : content.toString("utf8");
|
|
82
82
|
|
|
83
83
|
if (data) {
|
|
84
84
|
data.set("url", { [type]: encodedSource });
|
|
@@ -62,8 +62,9 @@ class RawDataUrlModule extends Module {
|
|
|
62
62
|
* @returns {number} the estimated size of the module (must be non-zero)
|
|
63
63
|
*/
|
|
64
64
|
size(type) {
|
|
65
|
-
if (this.url === undefined)
|
|
65
|
+
if (this.url === undefined) {
|
|
66
66
|
this.url = /** @type {Buffer} */ (this.urlBuffer).toString();
|
|
67
|
+
}
|
|
67
68
|
return Math.max(1, this.url.length);
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -107,8 +108,9 @@ class RawDataUrlModule extends Module {
|
|
|
107
108
|
* @returns {CodeGenerationResult} result
|
|
108
109
|
*/
|
|
109
110
|
codeGeneration(context) {
|
|
110
|
-
if (this.url === undefined)
|
|
111
|
+
if (this.url === undefined) {
|
|
111
112
|
this.url = /** @type {Buffer} */ (this.urlBuffer).toString();
|
|
113
|
+
}
|
|
112
114
|
const sources = new Map();
|
|
113
115
|
sources.set(
|
|
114
116
|
"javascript",
|
|
@@ -59,7 +59,7 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|
|
59
59
|
""
|
|
60
60
|
]);
|
|
61
61
|
}
|
|
62
|
-
const sepPromises =
|
|
62
|
+
const sepPromises = [...promises].join(", ");
|
|
63
63
|
// TODO check if destructuring is supported
|
|
64
64
|
return Template.asString([
|
|
65
65
|
`var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${sepPromises}]);`,
|
package/lib/buildChunkGraph.js
CHANGED
|
@@ -315,8 +315,9 @@ const visitModules = (
|
|
|
315
315
|
return map;
|
|
316
316
|
}
|
|
317
317
|
);
|
|
318
|
-
for (const [block, blockModules] of map)
|
|
318
|
+
for (const [block, blockModules] of map) {
|
|
319
319
|
blockModulesMap.set(block, blockModules);
|
|
320
|
+
}
|
|
320
321
|
return map.get(block);
|
|
321
322
|
}
|
|
322
323
|
logger.time("visitModules: prepare");
|
|
@@ -892,8 +893,9 @@ const visitModules = (
|
|
|
892
893
|
* @returns {bigint} The mask of available modules after the chunk group
|
|
893
894
|
*/
|
|
894
895
|
const calculateResultingAvailableModules = chunkGroupInfo => {
|
|
895
|
-
if (chunkGroupInfo.resultingAvailableModules !== undefined)
|
|
896
|
+
if (chunkGroupInfo.resultingAvailableModules !== undefined) {
|
|
896
897
|
return chunkGroupInfo.resultingAvailableModules;
|
|
898
|
+
}
|
|
897
899
|
|
|
898
900
|
let resultingAvailableModules = /** @type {bigint} */ (
|
|
899
901
|
chunkGroupInfo.minAvailableModules
|
|
@@ -1345,8 +1347,9 @@ const buildChunkGraph = (compilation, inputEntrypointsAndModules) => {
|
|
|
1345
1347
|
logger.timeEnd("connectChunkGroups");
|
|
1346
1348
|
|
|
1347
1349
|
for (const [chunkGroup, chunkGroupInfo] of chunkGroupInfoMap) {
|
|
1348
|
-
for (const chunk of chunkGroup.chunks)
|
|
1350
|
+
for (const chunk of chunkGroup.chunks) {
|
|
1349
1351
|
chunk.runtime = mergeRuntime(chunk.runtime, chunkGroupInfo.runtime);
|
|
1352
|
+
}
|
|
1350
1353
|
}
|
|
1351
1354
|
|
|
1352
1355
|
// Cleanup work
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
/** @typedef {import("../Compiler")} Compiler */
|
|
9
9
|
|
|
10
|
+
const PLUGIN_NAME = "AddBuildDependenciesPlugin";
|
|
11
|
+
|
|
10
12
|
class AddBuildDependenciesPlugin {
|
|
11
13
|
/**
|
|
12
14
|
* @param {Iterable<string>} buildDependencies list of build dependencies
|
|
@@ -21,12 +23,9 @@ class AddBuildDependenciesPlugin {
|
|
|
21
23
|
* @returns {void}
|
|
22
24
|
*/
|
|
23
25
|
apply(compiler) {
|
|
24
|
-
compiler.hooks.compilation.tap(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
compilation.buildDependencies.addAll(this.buildDependencies);
|
|
28
|
-
}
|
|
29
|
-
);
|
|
26
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
27
|
+
compilation.buildDependencies.addAll(this.buildDependencies);
|
|
28
|
+
});
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
|
|
@@ -52,7 +52,7 @@ class IdleFileCachePlugin {
|
|
|
52
52
|
let timeSpendInStore = 0;
|
|
53
53
|
let avgTimeSpendInStore = 0;
|
|
54
54
|
|
|
55
|
-
/** @type {Map<string | typeof BUILD_DEPENDENCIES_KEY, () => Promise<void>>} */
|
|
55
|
+
/** @type {Map<string | typeof BUILD_DEPENDENCIES_KEY, () => Promise<void | void[]>>} */
|
|
56
56
|
const pendingIdleTasks = new Map();
|
|
57
57
|
|
|
58
58
|
compiler.cache.hooks.store.tap(
|
|
@@ -111,7 +111,7 @@ class IdleFileCachePlugin {
|
|
|
111
111
|
}
|
|
112
112
|
isIdle = false;
|
|
113
113
|
const reportProgress = ProgressPlugin.getReporter(compiler);
|
|
114
|
-
const jobs =
|
|
114
|
+
const jobs = [...pendingIdleTasks.values()];
|
|
115
115
|
if (reportProgress) reportProgress(0, "process pending cache items");
|
|
116
116
|
const promises = jobs.map(fn => fn());
|
|
117
117
|
pendingIdleTasks.clear();
|
|
@@ -130,7 +130,7 @@ class IdleFileCachePlugin {
|
|
|
130
130
|
}
|
|
131
131
|
);
|
|
132
132
|
|
|
133
|
-
/** @type {Promise<
|
|
133
|
+
/** @type {Promise<void | void[]>} */
|
|
134
134
|
let currentIdlePromise = resolvedPromise;
|
|
135
135
|
let isIdle = false;
|
|
136
136
|
let isInitialStore = true;
|
|
@@ -146,7 +146,10 @@ class IdleFileCachePlugin {
|
|
|
146
146
|
promises.push(factory());
|
|
147
147
|
if (maxCount-- <= 0 || Date.now() > maxTime) break;
|
|
148
148
|
}
|
|
149
|
-
currentIdlePromise = Promise.all(
|
|
149
|
+
currentIdlePromise = Promise.all(
|
|
150
|
+
/** @type {Promise<void>[]} */
|
|
151
|
+
(promises)
|
|
152
|
+
);
|
|
150
153
|
currentIdlePromise.then(() => {
|
|
151
154
|
timeSpendInStore += Date.now() - startTime;
|
|
152
155
|
// Allow to exit the process between
|
|
@@ -13,8 +13,8 @@ const LazySet = require("../util/LazySet");
|
|
|
13
13
|
const makeSerializable = require("../util/makeSerializable");
|
|
14
14
|
const memoize = require("../util/memoize");
|
|
15
15
|
const {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
NOT_SERIALIZABLE,
|
|
17
|
+
createFileSerializer
|
|
18
18
|
} = require("../util/serialization");
|
|
19
19
|
|
|
20
20
|
/** @typedef {import("../../declarations/WebpackOptions").SnapshotOptions} SnapshotOptions */
|
|
@@ -292,8 +292,9 @@ class Pack {
|
|
|
292
292
|
return pack;
|
|
293
293
|
};
|
|
294
294
|
let pack = createNextPack();
|
|
295
|
-
if (this.requestsTimeout !== undefined)
|
|
295
|
+
if (this.requestsTimeout !== undefined) {
|
|
296
296
|
clearTimeout(this.requestsTimeout);
|
|
297
|
+
}
|
|
297
298
|
for (const identifier of this.requests) {
|
|
298
299
|
if (identifier === undefined) {
|
|
299
300
|
if (ignoreNextTimeTick) {
|
|
@@ -379,7 +380,9 @@ class Pack {
|
|
|
379
380
|
smallUnusedContentSize > MIN_CONTENT_SIZE
|
|
380
381
|
) {
|
|
381
382
|
mergedIndices = smallUnusedContents;
|
|
382
|
-
} else
|
|
383
|
+
} else {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
383
386
|
|
|
384
387
|
/** @type {PackContent[] } */
|
|
385
388
|
const mergedContent = [];
|
|
@@ -690,15 +693,17 @@ class PackContentItems {
|
|
|
690
693
|
const durationHr = process.hrtime(start);
|
|
691
694
|
const duration = durationHr[0] * 1000 + durationHr[1] / 1e6;
|
|
692
695
|
if (duration > 1) {
|
|
693
|
-
if (duration > 500)
|
|
696
|
+
if (duration > 500) {
|
|
694
697
|
logger.error(`Serialization of '${key}': ${duration} ms`);
|
|
695
|
-
else if (duration > 50)
|
|
698
|
+
} else if (duration > 50) {
|
|
696
699
|
logger.warn(`Serialization of '${key}': ${duration} ms`);
|
|
697
|
-
else if (duration > 10)
|
|
700
|
+
} else if (duration > 10) {
|
|
698
701
|
logger.info(`Serialization of '${key}': ${duration} ms`);
|
|
699
|
-
else if (duration > 5)
|
|
702
|
+
} else if (duration > 5) {
|
|
700
703
|
logger.log(`Serialization of '${key}': ${duration} ms`);
|
|
701
|
-
else
|
|
704
|
+
} else {
|
|
705
|
+
logger.debug(`Serialization of '${key}': ${duration} ms`);
|
|
706
|
+
}
|
|
702
707
|
}
|
|
703
708
|
} catch (err) {
|
|
704
709
|
rollback(s);
|
|
@@ -765,15 +770,17 @@ class PackContentItems {
|
|
|
765
770
|
const durationHr = process.hrtime(start);
|
|
766
771
|
const duration = durationHr[0] * 1000 + durationHr[1] / 1e6;
|
|
767
772
|
if (duration > 1) {
|
|
768
|
-
if (duration > 100)
|
|
773
|
+
if (duration > 100) {
|
|
769
774
|
logger.error(`Deserialization of '${key}': ${duration} ms`);
|
|
770
|
-
else if (duration > 20)
|
|
775
|
+
} else if (duration > 20) {
|
|
771
776
|
logger.warn(`Deserialization of '${key}': ${duration} ms`);
|
|
772
|
-
else if (duration > 5)
|
|
777
|
+
} else if (duration > 5) {
|
|
773
778
|
logger.info(`Deserialization of '${key}': ${duration} ms`);
|
|
774
|
-
else if (duration > 2)
|
|
779
|
+
} else if (duration > 2) {
|
|
775
780
|
logger.log(`Deserialization of '${key}': ${duration} ms`);
|
|
776
|
-
else
|
|
781
|
+
} else {
|
|
782
|
+
logger.debug(`Deserialization of '${key}': ${duration} ms`);
|
|
783
|
+
}
|
|
777
784
|
}
|
|
778
785
|
map.set(key, value);
|
|
779
786
|
key = read();
|
|
@@ -1202,7 +1209,7 @@ class PackFileCacheStrategy {
|
|
|
1202
1209
|
}
|
|
1203
1210
|
logger.time("check build dependencies");
|
|
1204
1211
|
return Promise.all([
|
|
1205
|
-
new Promise((resolve,
|
|
1212
|
+
new Promise((resolve, _reject) => {
|
|
1206
1213
|
this.fileSystemInfo.checkSnapshotValid(
|
|
1207
1214
|
packContainer.buildSnapshot,
|
|
1208
1215
|
(err, valid) => {
|
|
@@ -1224,7 +1231,7 @@ class PackFileCacheStrategy {
|
|
|
1224
1231
|
}
|
|
1225
1232
|
);
|
|
1226
1233
|
}),
|
|
1227
|
-
new Promise((resolve,
|
|
1234
|
+
new Promise((resolve, _reject) => {
|
|
1228
1235
|
this.fileSystemInfo.checkSnapshotValid(
|
|
1229
1236
|
packContainer.resolveBuildDependenciesSnapshot,
|
|
1230
1237
|
(err, valid) => {
|
|
@@ -1290,8 +1297,9 @@ class PackFileCacheStrategy {
|
|
|
1290
1297
|
pack.maxAge = this.maxAge;
|
|
1291
1298
|
this.buildSnapshot = buildSnapshot;
|
|
1292
1299
|
if (buildDependencies) this.buildDependencies = buildDependencies;
|
|
1293
|
-
if (newBuildDependencies)
|
|
1300
|
+
if (newBuildDependencies) {
|
|
1294
1301
|
this.newBuildDependencies.addAll(newBuildDependencies);
|
|
1302
|
+
}
|
|
1295
1303
|
this.resolveResults = resolveResults;
|
|
1296
1304
|
this.resolveBuildDependenciesSnapshot =
|
|
1297
1305
|
resolveBuildDependenciesSnapshot;
|
|
@@ -1370,9 +1378,7 @@ class PackFileCacheStrategy {
|
|
|
1370
1378
|
if (newBuildDependencies.size > 0 || !this.buildSnapshot) {
|
|
1371
1379
|
if (reportProgress) reportProgress(0.5, "resolve build dependencies");
|
|
1372
1380
|
this.logger.debug(
|
|
1373
|
-
`Capturing build dependencies... (${
|
|
1374
|
-
newBuildDependencies
|
|
1375
|
-
).join(", ")})`
|
|
1381
|
+
`Capturing build dependencies... (${[...newBuildDependencies].join(", ")})`
|
|
1376
1382
|
);
|
|
1377
1383
|
promise = new Promise(
|
|
1378
1384
|
/**
|
|
@@ -219,15 +219,18 @@ class ResolverCachePlugin {
|
|
|
219
219
|
const resolveResult = withYield ? yieldResult : result;
|
|
220
220
|
// since we intercept resolve hook
|
|
221
221
|
// we still can get result in callback
|
|
222
|
-
if (withYield && result)
|
|
223
|
-
/** @type {ResolveRequest[]} */
|
|
222
|
+
if (withYield && result) {
|
|
223
|
+
/** @type {ResolveRequest[]} */
|
|
224
|
+
(yieldResult).push(result);
|
|
225
|
+
}
|
|
224
226
|
if (!snapshot) {
|
|
225
|
-
if (resolveResult)
|
|
227
|
+
if (resolveResult) {
|
|
226
228
|
return callback(
|
|
227
229
|
null,
|
|
228
230
|
/** @type {ResolveRequest} */
|
|
229
231
|
(resolveResult)
|
|
230
232
|
);
|
|
233
|
+
}
|
|
231
234
|
return callback();
|
|
232
235
|
}
|
|
233
236
|
itemCache.store(
|
|
@@ -238,12 +241,13 @@ class ResolverCachePlugin {
|
|
|
238
241
|
),
|
|
239
242
|
storeErr => {
|
|
240
243
|
if (storeErr) return callback(storeErr);
|
|
241
|
-
if (resolveResult)
|
|
244
|
+
if (resolveResult) {
|
|
242
245
|
return callback(
|
|
243
246
|
null,
|
|
244
247
|
/** @type {ResolveRequest} */
|
|
245
248
|
(resolveResult)
|
|
246
249
|
);
|
|
250
|
+
}
|
|
247
251
|
callback();
|
|
248
252
|
}
|
|
249
253
|
);
|
|
@@ -266,8 +270,9 @@ class ResolverCachePlugin {
|
|
|
266
270
|
if (
|
|
267
271
|
/** @type {ResolveOptions & { cache: boolean }} */
|
|
268
272
|
(options).cache !== true
|
|
269
|
-
)
|
|
273
|
+
) {
|
|
270
274
|
return;
|
|
275
|
+
}
|
|
271
276
|
const optionsIdent = objectToString(userOptions, false);
|
|
272
277
|
const cacheWithContext =
|
|
273
278
|
options.cacheWithContext !== undefined
|
|
@@ -323,13 +328,14 @@ class ResolverCachePlugin {
|
|
|
323
328
|
if (err) {
|
|
324
329
|
callback(err);
|
|
325
330
|
} else {
|
|
326
|
-
if (result)
|
|
331
|
+
if (result) {
|
|
327
332
|
for (const r of /** @type {ResolveRequest[]} */ (
|
|
328
333
|
result
|
|
329
334
|
)) {
|
|
330
335
|
/** @type {Yield} */
|
|
331
336
|
(resolveContext.yield)(r);
|
|
332
337
|
}
|
|
338
|
+
}
|
|
333
339
|
callback(null, null);
|
|
334
340
|
}
|
|
335
341
|
yields = undefined;
|
|
@@ -345,11 +351,13 @@ class ResolverCachePlugin {
|
|
|
345
351
|
for (let i = 0; i < definedCallbacks.length; i++) {
|
|
346
352
|
const cb = definedCallbacks[i];
|
|
347
353
|
const yield_ = /** @type {Yield[]} */ (yields)[i];
|
|
348
|
-
if (result)
|
|
354
|
+
if (result) {
|
|
349
355
|
for (const r of /** @type {ResolveRequest[]} */ (
|
|
350
356
|
result
|
|
351
|
-
))
|
|
357
|
+
)) {
|
|
352
358
|
yield_(r);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
353
361
|
cb(null, null);
|
|
354
362
|
}
|
|
355
363
|
}
|
package/lib/cli.js
CHANGED
|
@@ -68,6 +68,8 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
|
|
|
68
68
|
|
|
69
69
|
/** @typedef {Record<string, Argument>} Flags */
|
|
70
70
|
|
|
71
|
+
/** @typedef {Record<string, EXPECTED_ANY>} ObjectConfiguration */
|
|
72
|
+
|
|
71
73
|
/**
|
|
72
74
|
* @param {Schema=} schema a json schema to create arguments for (by default webpack schema is used)
|
|
73
75
|
* @returns {Flags} object of arguments
|
|
@@ -429,10 +431,10 @@ const cliAddedItems = new WeakMap();
|
|
|
429
431
|
/** @typedef {string | number} Property */
|
|
430
432
|
|
|
431
433
|
/**
|
|
432
|
-
* @param {
|
|
434
|
+
* @param {ObjectConfiguration} config configuration
|
|
433
435
|
* @param {string} schemaPath path in the config
|
|
434
436
|
* @param {number | undefined} index index of value when multiple values are provided, otherwise undefined
|
|
435
|
-
* @returns {{ problem?: LocalProblem, object?:
|
|
437
|
+
* @returns {{ problem?: LocalProblem, object?: ObjectConfiguration, property?: Property, value?: EXPECTED_OBJECT | EXPECTED_ANY[] }} problem or object with property and value
|
|
436
438
|
*/
|
|
437
439
|
const getObjectAndProperty = (config, schemaPath, index = 0) => {
|
|
438
440
|
if (!schemaPath) return { value: config };
|
|
@@ -529,7 +531,7 @@ const getObjectAndProperty = (config, schemaPath, index = 0) => {
|
|
|
529
531
|
};
|
|
530
532
|
|
|
531
533
|
/**
|
|
532
|
-
* @param {
|
|
534
|
+
* @param {ObjectConfiguration} config configuration
|
|
533
535
|
* @param {string} schemaPath path in the config
|
|
534
536
|
* @param {ParsedValue} value parsed value
|
|
535
537
|
* @param {number | undefined} index index of value when multiple values are provided, otherwise undefined
|
|
@@ -542,13 +544,14 @@ const setValue = (config, schemaPath, value, index) => {
|
|
|
542
544
|
index
|
|
543
545
|
);
|
|
544
546
|
if (problem) return problem;
|
|
545
|
-
|
|
547
|
+
/** @type {ObjectConfiguration} */
|
|
548
|
+
(object)[/** @type {Property} */ (property)] = value;
|
|
546
549
|
return null;
|
|
547
550
|
};
|
|
548
551
|
|
|
549
552
|
/**
|
|
550
553
|
* @param {ArgumentConfig} argConfig processing instructions
|
|
551
|
-
* @param {
|
|
554
|
+
* @param {ObjectConfiguration} config configuration
|
|
552
555
|
* @param {Value} value the value
|
|
553
556
|
* @param {number | undefined} index the index if multiple values provided
|
|
554
557
|
* @returns {LocalProblem | null} a problem if any
|
|
@@ -632,16 +635,18 @@ const parseValueForArgumentConfig = (argConfig, value) => {
|
|
|
632
635
|
if (typeof value === "string") {
|
|
633
636
|
// cspell:word yugi
|
|
634
637
|
const match = /^\/(.*)\/([yugi]*)$/.exec(value);
|
|
635
|
-
if (match && !/[^\\]\//.test(match[1]))
|
|
638
|
+
if (match && !/[^\\]\//.test(match[1])) {
|
|
636
639
|
return new RegExp(match[1], match[2]);
|
|
640
|
+
}
|
|
637
641
|
}
|
|
638
642
|
break;
|
|
639
643
|
case "enum": {
|
|
640
644
|
const values =
|
|
641
645
|
/** @type {EnumValue[]} */
|
|
642
646
|
(argConfig.values);
|
|
643
|
-
if (values.includes(/** @type {Exclude<Value, RegExp>} */ (value)))
|
|
647
|
+
if (values.includes(/** @type {Exclude<Value, RegExp>} */ (value))) {
|
|
644
648
|
return value;
|
|
649
|
+
}
|
|
645
650
|
for (const item of values) {
|
|
646
651
|
if (`${item}` === value) return item;
|
|
647
652
|
}
|
|
@@ -653,12 +658,12 @@ const parseValueForArgumentConfig = (argConfig, value) => {
|
|
|
653
658
|
}
|
|
654
659
|
};
|
|
655
660
|
|
|
656
|
-
/** @typedef {
|
|
661
|
+
/** @typedef {Record<string, Value[]>} Values */
|
|
657
662
|
|
|
658
663
|
/**
|
|
659
664
|
* @param {Flags} args object of arguments
|
|
660
|
-
* @param {
|
|
661
|
-
* @param {
|
|
665
|
+
* @param {ObjectConfiguration} config configuration
|
|
666
|
+
* @param {Values} values object with values
|
|
662
667
|
* @returns {Problem[] | null} problems or null for success
|
|
663
668
|
*/
|
|
664
669
|
const processArguments = (args, config, values) => {
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const browserslist = require("browserslist");
|
|
9
8
|
const path = require("path");
|
|
9
|
+
const browserslist = require("browserslist");
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("./target").ApiTargetProperties} ApiTargetProperties */
|
|
12
12
|
/** @typedef {import("./target").EcmaTargetProperties} EcmaTargetProperties */
|
|
@@ -358,6 +358,6 @@ const resolve = browsers => {
|
|
|
358
358
|
};
|
|
359
359
|
|
|
360
360
|
module.exports = {
|
|
361
|
-
|
|
362
|
-
|
|
361
|
+
load,
|
|
362
|
+
resolve
|
|
363
363
|
};
|