webpack 5.97.1 → 5.99.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/README.md +345 -392
- package/lib/AsyncDependenciesBlock.js +3 -1
- package/lib/BannerPlugin.js +1 -1
- package/lib/Cache.js +9 -7
- package/lib/CacheFacade.js +5 -5
- package/lib/Chunk.js +2 -2
- package/lib/ChunkGraph.js +21 -16
- package/lib/ChunkTemplate.js +6 -6
- package/lib/CleanPlugin.js +10 -10
- package/lib/CodeGenerationResults.js +4 -3
- package/lib/CompatibilityPlugin.js +4 -1
- package/lib/Compilation.js +343 -167
- package/lib/Compiler.js +13 -18
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +5 -3
- package/lib/ContextModule.js +4 -2
- package/lib/ContextModuleFactory.js +3 -3
- package/lib/ContextReplacementPlugin.js +43 -16
- package/lib/DefinePlugin.js +25 -24
- package/lib/DelegatedModule.js +4 -2
- package/lib/DelegatedModuleFactoryPlugin.js +2 -1
- package/lib/Dependency.js +19 -13
- package/lib/DependencyTemplates.js +4 -3
- package/lib/DllModule.js +4 -2
- package/lib/DllModuleFactory.js +2 -2
- package/lib/DllReferencePlugin.js +2 -1
- package/lib/DynamicEntryPlugin.js +1 -1
- package/lib/EnvironmentPlugin.js +4 -2
- package/lib/ExportsInfo.js +72 -40
- package/lib/ExternalModule.js +14 -5
- package/lib/ExternalModuleFactoryPlugin.js +24 -12
- package/lib/FileSystemInfo.js +129 -94
- package/lib/FlagDependencyExportsPlugin.js +6 -4
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +29 -1
- package/lib/HookWebpackError.js +2 -2
- package/lib/HotModuleReplacementPlugin.js +3 -9
- package/lib/IgnoreErrorModuleFactory.js +2 -2
- package/lib/IgnorePlugin.js +0 -5
- package/lib/InitFragment.js +1 -1
- package/lib/LoaderOptionsPlugin.js +8 -5
- package/lib/MainTemplate.js +7 -7
- package/lib/Module.js +44 -21
- package/lib/ModuleBuildError.js +3 -1
- package/lib/ModuleDependencyError.js +4 -3
- package/lib/ModuleDependencyWarning.js +4 -3
- package/lib/ModuleFactory.js +9 -3
- package/lib/ModuleFilenameHelpers.js +21 -39
- package/lib/ModuleGraph.js +20 -14
- package/lib/ModuleGraphConnection.js +7 -13
- package/lib/ModuleNotFoundError.js +1 -1
- package/lib/ModuleParseError.js +2 -1
- package/lib/ModuleSourceTypesConstants.js +11 -0
- package/lib/ModuleTemplate.js +5 -5
- package/lib/ModuleTypeConstants.js +15 -0
- package/lib/MultiCompiler.js +4 -4
- package/lib/MultiStats.js +1 -1
- package/lib/NormalModule.js +101 -54
- package/lib/NormalModuleFactory.js +38 -33
- package/lib/NormalModuleReplacementPlugin.js +3 -2
- package/lib/NullFactory.js +2 -2
- package/lib/Parser.js +4 -3
- package/lib/ProgressPlugin.js +1 -2
- package/lib/RawModule.js +4 -2
- package/lib/RecordIdsPlugin.js +6 -2
- package/lib/RequestShortener.js +3 -1
- package/lib/ResolverFactory.js +12 -9
- package/lib/RuntimeModule.js +4 -2
- package/lib/RuntimeTemplate.js +2 -1
- package/lib/SelfModuleFactory.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +0 -8
- package/lib/Template.js +6 -5
- package/lib/TemplatedPathPlugin.js +15 -12
- package/lib/WebpackOptionsApply.js +1 -1
- package/lib/asset/AssetGenerator.js +237 -170
- package/lib/asset/AssetModulesPlugin.js +52 -10
- package/lib/asset/AssetSourceGenerator.js +18 -0
- package/lib/asset/RawDataUrlModule.js +4 -2
- package/lib/buildChunkGraph.js +14 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
- package/lib/cache/PackFileCacheStrategy.js +137 -121
- package/lib/cache/ResolverCachePlugin.js +15 -7
- package/lib/cache/getLazyHashedEtag.js +4 -3
- package/lib/cli.js +23 -15
- package/lib/config/defaults.js +104 -28
- package/lib/config/normalization.js +14 -13
- package/lib/config/target.js +8 -8
- package/lib/container/ContainerEntryModule.js +4 -2
- package/lib/container/ContainerEntryModuleFactory.js +2 -2
- package/lib/container/FallbackModule.js +4 -2
- package/lib/container/FallbackModuleFactory.js +2 -2
- package/lib/container/RemoteModule.js +4 -2
- package/lib/container/options.js +5 -5
- package/lib/css/CssGenerator.js +71 -9
- package/lib/css/CssLoadingRuntimeModule.js +5 -2
- package/lib/css/CssModulesPlugin.js +41 -9
- package/lib/css/CssParser.js +37 -17
- package/lib/css/walkCssTokens.js +17 -17
- package/lib/debug/ProfilingPlugin.js +98 -38
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +10 -4
- package/lib/dependencies/AMDPlugin.js +5 -2
- package/lib/dependencies/AMDRequireArrayDependency.js +4 -3
- package/lib/dependencies/AMDRequireContextDependency.js +2 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +15 -7
- package/lib/dependencies/AMDRuntimeModules.js +3 -1
- package/lib/dependencies/CommonJsExportRequireDependency.js +4 -5
- package/lib/dependencies/CommonJsExportsParserPlugin.js +3 -3
- package/lib/dependencies/CommonJsImportsParserPlugin.js +38 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -1
- package/lib/dependencies/ContextDependencyHelpers.js +13 -6
- package/lib/dependencies/CssIcssExportDependency.js +15 -12
- package/lib/dependencies/CssIcssImportDependency.js +4 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +18 -15
- package/lib/dependencies/ExportsInfoDependency.js +6 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +5 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +22 -15
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +23 -8
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +2 -2
- package/lib/dependencies/HarmonyImportDependency.js +8 -6
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -14
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +5 -5
- package/lib/dependencies/ImportContextDependency.js +2 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -4
- package/lib/dependencies/JsonExportsDependency.js +49 -27
- package/lib/dependencies/LoaderPlugin.js +4 -14
- package/lib/dependencies/RequireContextDependency.js +2 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +6 -3
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +3 -2
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +11 -5
- package/lib/dependencies/RequireResolveContextDependency.js +1 -1
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +1 -1
- package/lib/dependencies/WorkerDependency.js +6 -3
- package/lib/dependencies/WorkerPlugin.js +100 -41
- package/lib/esm/ModuleChunkFormatPlugin.js +5 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +3 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +32 -24
- package/lib/hmr/lazyCompilationBackend.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +2 -1
- package/lib/ids/IdHelpers.js +15 -14
- package/lib/ids/SyncModuleIdsPlugin.js +9 -5
- package/lib/index.js +5 -5
- package/lib/javascript/BasicEvaluatedExpression.js +6 -6
- package/lib/javascript/JavascriptGenerator.js +11 -1
- package/lib/javascript/JavascriptModulesPlugin.js +54 -34
- package/lib/javascript/JavascriptParser.js +272 -188
- package/lib/javascript/JavascriptParserHelpers.js +10 -9
- package/lib/javascript/StartupHelpers.js +4 -1
- package/lib/json/JsonData.js +4 -4
- package/lib/json/JsonGenerator.js +54 -22
- package/lib/json/JsonModulesPlugin.js +16 -3
- package/lib/json/JsonParser.js +10 -4
- package/lib/library/AbstractLibraryPlugin.js +7 -3
- package/lib/library/AssignLibraryPlugin.js +29 -1
- package/lib/library/EnableLibraryPlugin.js +7 -10
- package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
- package/lib/library/ModuleLibraryPlugin.js +121 -15
- package/lib/logging/Logger.js +2 -2
- package/lib/logging/createConsoleLogger.js +4 -4
- package/lib/node/NodeEnvironmentPlugin.js +6 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -2
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -2
- package/lib/node/nodeConsole.js +3 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +19 -12
- package/lib/optimize/InnerGraph.js +3 -2
- package/lib/optimize/InnerGraphPlugin.js +13 -7
- package/lib/optimize/LimitChunkCountPlugin.js +20 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +10 -7
- package/lib/optimize/RealContentHashPlugin.js +8 -4
- package/lib/optimize/SideEffectsFlagPlugin.js +4 -2
- package/lib/optimize/SplitChunksPlugin.js +90 -65
- package/lib/rules/BasicEffectRulePlugin.js +9 -1
- package/lib/rules/BasicMatcherRulePlugin.js +15 -4
- package/lib/rules/ObjectMatcherRulePlugin.js +12 -3
- package/lib/rules/RuleSetCompiler.js +25 -14
- package/lib/rules/UseEffectRulePlugin.js +47 -17
- package/lib/runtime/AutoPublicPathRuntimeModule.js +1 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +6 -6
- package/lib/schemes/HttpUriPlugin.js +38 -17
- package/lib/serialization/BinaryMiddleware.js +52 -19
- package/lib/serialization/FileMiddleware.js +78 -48
- package/lib/serialization/ObjectMiddleware.js +78 -29
- package/lib/serialization/PlainObjectSerializer.js +1 -1
- package/lib/serialization/Serializer.js +15 -10
- package/lib/serialization/SerializerMiddleware.js +80 -41
- package/lib/serialization/SingleItemMiddleware.js +10 -7
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +4 -2
- package/lib/sharing/ProvideSharedModule.js +4 -2
- package/lib/sharing/ProvideSharedModuleFactory.js +5 -3
- package/lib/sharing/utils.js +2 -2
- package/lib/stats/DefaultStatsFactoryPlugin.js +81 -79
- package/lib/stats/DefaultStatsPresetPlugin.js +43 -23
- package/lib/stats/DefaultStatsPrinterPlugin.js +85 -43
- package/lib/stats/StatsFactory.js +11 -11
- package/lib/stats/StatsPrinter.js +7 -7
- package/lib/util/ArrayHelpers.js +2 -4
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +4 -4
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/LazyBucketSortedSet.js +41 -23
- package/lib/util/LazySet.js +3 -2
- package/lib/util/MapHelpers.js +1 -1
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/Semaphore.js +3 -3
- package/lib/util/SetHelpers.js +1 -1
- package/lib/util/SortableSet.js +9 -7
- package/lib/util/TupleQueue.js +9 -8
- package/lib/util/TupleSet.js +2 -2
- package/lib/util/WeakTupleMap.js +12 -11
- package/lib/util/binarySearchBounds.js +2 -1
- package/lib/util/cleverMerge.js +84 -54
- package/lib/util/comparators.js +22 -21
- package/lib/util/compileBooleanMatcher.js +3 -3
- package/lib/util/concatenate.js +6 -4
- package/lib/util/create-schema-validation.js +4 -4
- package/lib/util/createHash.js +2 -2
- package/lib/util/deprecation.js +35 -33
- package/lib/util/deterministicGrouping.js +6 -6
- package/lib/util/findGraphRoots.js +1 -1
- package/lib/util/fs.js +39 -39
- package/lib/util/hash/wasm-hash.js +2 -2
- package/lib/util/identifier.js +15 -18
- package/lib/util/makeSerializable.js +1 -1
- package/lib/util/memoize.js +4 -1
- package/lib/util/objectToMap.js +3 -2
- package/lib/util/processAsyncTree.js +2 -2
- package/lib/util/propertyName.js +0 -1
- package/lib/util/registerExternalSerializer.js +15 -18
- package/lib/util/removeBOM.js +25 -0
- package/lib/util/runtime.js +34 -27
- package/lib/util/semver.js +18 -8
- package/lib/util/serialization.js +5 -16
- package/lib/util/smartGrouping.js +3 -3
- package/lib/validateSchema.js +4 -7
- package/lib/wasm/EnableWasmLoadingPlugin.js +2 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +11 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +10 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -2
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +4 -0
- package/lib/wasm-sync/WebAssemblyGenerator.js +28 -12
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +10 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyParser.js +9 -4
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -2
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +30 -25
- package/package.json +27 -26
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +48 -13
- package/schemas/plugins/JsonModulesPluginGenerator.check.d.ts +7 -0
- package/schemas/plugins/JsonModulesPluginGenerator.check.js +6 -0
- package/schemas/plugins/JsonModulesPluginGenerator.json +11 -0
- package/schemas/plugins/JsonModulesPluginParser.check.js +1 -1
- package/schemas/plugins/JsonModulesPluginParser.json +4 -0
- package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
- package/types.d.ts +888 -583
- package/lib/library/ModernModuleLibraryPlugin.js +0 -144
package/lib/cli.js
CHANGED
@@ -8,23 +8,25 @@
|
|
8
8
|
const path = require("path");
|
9
9
|
const webpackSchema = require("../schemas/WebpackOptions.json");
|
10
10
|
|
11
|
-
/** @typedef {
|
11
|
+
/** @typedef {Parameters<import("schema-utils").validate>[0] & { absolutePath: boolean, instanceof: string, cli: { helper?: boolean, exclude?: boolean, description?: string, negatedDescription?: string, resetDescription?: string } }} Schema */
|
12
12
|
|
13
13
|
// TODO add originPath to PathItem for better errors
|
14
14
|
/**
|
15
15
|
* @typedef {object} PathItem
|
16
|
-
* @property {
|
16
|
+
* @property {Schema} schema the part of the schema
|
17
17
|
* @property {string} path the path in the config
|
18
18
|
*/
|
19
19
|
|
20
20
|
/** @typedef {"unknown-argument" | "unexpected-non-array-in-path" | "unexpected-non-object-in-path" | "multiple-values-unexpected" | "invalid-value"} ProblemType */
|
21
21
|
|
22
|
+
/** @typedef {string | number | boolean | RegExp} Value */
|
23
|
+
|
22
24
|
/**
|
23
25
|
* @typedef {object} Problem
|
24
26
|
* @property {ProblemType} type
|
25
27
|
* @property {string} path
|
26
28
|
* @property {string} argument
|
27
|
-
* @property {
|
29
|
+
* @property {Value=} value
|
28
30
|
* @property {number=} index
|
29
31
|
* @property {string=} expected
|
30
32
|
*/
|
@@ -36,6 +38,10 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
|
|
36
38
|
* @property {string=} expected
|
37
39
|
*/
|
38
40
|
|
41
|
+
/** @typedef {{ [key: string]: EnumValue }} EnumValueObject */
|
42
|
+
/** @typedef {EnumValue[]} EnumValueArray */
|
43
|
+
/** @typedef {string | number | boolean | EnumValueObject | EnumValueArray | null} EnumValue */
|
44
|
+
|
39
45
|
/**
|
40
46
|
* @typedef {object} ArgumentConfig
|
41
47
|
* @property {string | undefined} description
|
@@ -43,7 +49,7 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
|
|
43
49
|
* @property {string} path
|
44
50
|
* @property {boolean} multiple
|
45
51
|
* @property {"enum"|"string"|"path"|"number"|"boolean"|"RegExp"|"reset"} type
|
46
|
-
* @property {
|
52
|
+
* @property {EnumValue[]=} values
|
47
53
|
*/
|
48
54
|
|
49
55
|
/** @typedef {"string" | "number" | "boolean"} SimpleType */
|
@@ -56,8 +62,6 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
|
|
56
62
|
* @property {ArgumentConfig[]} configs
|
57
63
|
*/
|
58
64
|
|
59
|
-
/** @typedef {string | number | boolean | RegExp | (string | number | boolean | RegExp)} Value */
|
60
|
-
|
61
65
|
/** @typedef {Record<string, Argument>} Flags */
|
62
66
|
|
63
67
|
/**
|
@@ -93,7 +97,7 @@ const getArguments = (schema = webpackSchema) => {
|
|
93
97
|
let schemaPart = schema;
|
94
98
|
|
95
99
|
for (let i = 1; i < newPath.length; i++) {
|
96
|
-
const inner = schemaPart[newPath[i]];
|
100
|
+
const inner = schemaPart[/** @type {keyof Schema} */ (newPath[i])];
|
97
101
|
|
98
102
|
if (!inner) {
|
99
103
|
break;
|
@@ -147,7 +151,7 @@ const getArguments = (schema = webpackSchema) => {
|
|
147
151
|
|
148
152
|
/**
|
149
153
|
* @param {Schema} schemaPart schema
|
150
|
-
* @returns {Pick<ArgumentConfig, "type"|"values"> | undefined} partial argument config
|
154
|
+
* @returns {Pick<ArgumentConfig, "type" | "values"> | undefined} partial argument config
|
151
155
|
*/
|
152
156
|
const schemaToArgumentConfig = schemaPart => {
|
153
157
|
if (schemaPart.enum) {
|
@@ -272,7 +276,7 @@ const getArguments = (schema = webpackSchema) => {
|
|
272
276
|
/**
|
273
277
|
* @param {Schema} schemaPart the current schema
|
274
278
|
* @param {string} schemaPath the current path in the schema
|
275
|
-
* @param {
|
279
|
+
* @param {PathItem[]} path all previous visited schemaParts
|
276
280
|
* @param {string | null} inArray if inside of an array, the path to the array
|
277
281
|
* @returns {number} added arguments
|
278
282
|
*/
|
@@ -291,6 +295,7 @@ const getArguments = (schema = webpackSchema) => {
|
|
291
295
|
|
292
296
|
if (schemaPart.cli && schemaPart.cli.exclude) return 0;
|
293
297
|
|
298
|
+
/** @type {PathItem[]} */
|
294
299
|
const fullPath = [{ schema: schemaPart, path: schemaPath }, ...path];
|
295
300
|
|
296
301
|
let addedArguments = 0;
|
@@ -423,7 +428,7 @@ const cliAddedItems = new WeakMap();
|
|
423
428
|
* @param {Configuration} config configuration
|
424
429
|
* @param {string} schemaPath path in the config
|
425
430
|
* @param {number | undefined} index index of value when multiple values are provided, otherwise undefined
|
426
|
-
* @returns {{ problem?: LocalProblem, object?:
|
431
|
+
* @returns {{ problem?: LocalProblem, object?: TODO, property?: Property, value?: EXPECTED_OBJECT | EXPECTED_ANY[] }} problem or object with property and value
|
427
432
|
*/
|
428
433
|
const getObjectAndProperty = (config, schemaPath, index = 0) => {
|
429
434
|
if (!schemaPath) return { value: config };
|
@@ -522,7 +527,7 @@ const getObjectAndProperty = (config, schemaPath, index = 0) => {
|
|
522
527
|
/**
|
523
528
|
* @param {Configuration} config configuration
|
524
529
|
* @param {string} schemaPath path in the config
|
525
|
-
* @param {
|
530
|
+
* @param {ParsedValue} value parsed value
|
526
531
|
* @param {number | undefined} index index of value when multiple values are provided, otherwise undefined
|
527
532
|
* @returns {LocalProblem | null} problem or null for success
|
528
533
|
*/
|
@@ -587,10 +592,12 @@ const getExpectedValue = argConfig => {
|
|
587
592
|
}
|
588
593
|
};
|
589
594
|
|
595
|
+
/** @typedef {null | string | number | boolean | RegExp | EnumValue | []} ParsedValue */
|
596
|
+
|
590
597
|
/**
|
591
598
|
* @param {ArgumentConfig} argConfig processing instructions
|
592
599
|
* @param {Value} value the value
|
593
|
-
* @returns {
|
600
|
+
* @returns {ParsedValue | undefined} parsed value
|
594
601
|
*/
|
595
602
|
const parseValueForArgumentConfig = (argConfig, value) => {
|
596
603
|
switch (argConfig.type) {
|
@@ -627,9 +634,10 @@ const parseValueForArgumentConfig = (argConfig, value) => {
|
|
627
634
|
break;
|
628
635
|
case "enum": {
|
629
636
|
const values =
|
630
|
-
/** @type {
|
637
|
+
/** @type {EnumValue[]} */
|
631
638
|
(argConfig.values);
|
632
|
-
if (values.includes(value))
|
639
|
+
if (values.includes(/** @type {Exclude<Value, RegExp>} */ (value)))
|
640
|
+
return value;
|
633
641
|
for (const item of values) {
|
634
642
|
if (`${item}` === value) return item;
|
635
643
|
}
|
@@ -641,7 +649,7 @@ const parseValueForArgumentConfig = (argConfig, value) => {
|
|
641
649
|
}
|
642
650
|
};
|
643
651
|
|
644
|
-
/** @typedef {
|
652
|
+
/** @typedef {TODO} Configuration */
|
645
653
|
|
646
654
|
/**
|
647
655
|
* @param {Flags} args object of arguments
|
package/lib/config/defaults.js
CHANGED
@@ -47,6 +47,7 @@ const {
|
|
47
47
|
/** @typedef {import("../../declarations/WebpackOptions").GeneratorOptionsByModuleTypeKnown} GeneratorOptionsByModuleTypeKnown */
|
48
48
|
/** @typedef {import("../../declarations/WebpackOptions").InfrastructureLogging} InfrastructureLogging */
|
49
49
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
50
|
+
/** @typedef {import("../../declarations/WebpackOptions").JsonGeneratorOptions} JsonGeneratorOptions */
|
50
51
|
/** @typedef {import("../../declarations/WebpackOptions").Library} Library */
|
51
52
|
/** @typedef {import("../../declarations/WebpackOptions").LibraryName} LibraryName */
|
52
53
|
/** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
|
@@ -78,6 +79,10 @@ const {
|
|
78
79
|
|
79
80
|
const NODE_MODULES_REGEXP = /[\\/]node_modules[\\/]/i;
|
80
81
|
const DEFAULT_CACHE_NAME = "default";
|
82
|
+
const DEFAULTS = {
|
83
|
+
// TODO webpack 6 - use xxhash64
|
84
|
+
HASH_FUNCTION: "md4"
|
85
|
+
};
|
81
86
|
|
82
87
|
/**
|
83
88
|
* Sets a constant default value when undefined
|
@@ -100,7 +105,7 @@ const D = (obj, prop, value) => {
|
|
100
105
|
* @template {keyof T} P
|
101
106
|
* @param {T} obj an object
|
102
107
|
* @param {P} prop a property of this object
|
103
|
-
* @param {
|
108
|
+
* @param {() => T[P]} factory a default value factory for the property
|
104
109
|
* @returns {void}
|
105
110
|
*/
|
106
111
|
const F = (obj, prop, factory) => {
|
@@ -118,7 +123,7 @@ const F = (obj, prop, factory) => {
|
|
118
123
|
* @template {keyof T} P
|
119
124
|
* @param {T} obj an object
|
120
125
|
* @param {P} prop a property of this object
|
121
|
-
* @param {
|
126
|
+
* @param {() => T[P]} factory a default value factory for the property
|
122
127
|
* @returns {void}
|
123
128
|
*/
|
124
129
|
const A = (obj, prop, factory) => {
|
@@ -220,6 +225,7 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
|
|
220
225
|
mode: mode || "production",
|
221
226
|
development,
|
222
227
|
cacheUnaffected: options.experiments.cacheUnaffected,
|
228
|
+
futureDefaults,
|
223
229
|
compilerIndex
|
224
230
|
});
|
225
231
|
const cache = Boolean(options.cache);
|
@@ -261,8 +267,9 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
|
|
261
267
|
(options.experiments.css),
|
262
268
|
futureDefaults,
|
263
269
|
isNode: targetProperties && targetProperties.node === true,
|
264
|
-
uniqueName: options.output.uniqueName,
|
265
|
-
targetProperties
|
270
|
+
uniqueName: /** @type {string} */ (options.output.uniqueName),
|
271
|
+
targetProperties,
|
272
|
+
mode: options.mode
|
266
273
|
});
|
267
274
|
|
268
275
|
applyExternalsPresetsDefaults(options.externalsPresets, {
|
@@ -396,6 +403,7 @@ const applyExperimentsDefaults = (
|
|
396
403
|
* @param {object} options options
|
397
404
|
* @param {string} options.name name
|
398
405
|
* @param {Mode} options.mode mode
|
406
|
+
* @param {boolean} options.futureDefaults is future defaults enabled
|
399
407
|
* @param {boolean} options.development is development mode
|
400
408
|
* @param {number} [options.compilerIndex] index of compiler
|
401
409
|
* @param {Experiments["cacheUnaffected"]} options.cacheUnaffected the cacheUnaffected experiment is enabled
|
@@ -403,7 +411,7 @@ const applyExperimentsDefaults = (
|
|
403
411
|
*/
|
404
412
|
const applyCacheDefaults = (
|
405
413
|
cache,
|
406
|
-
{ name, mode, development, cacheUnaffected, compilerIndex }
|
414
|
+
{ name, mode, development, cacheUnaffected, compilerIndex, futureDefaults }
|
407
415
|
) => {
|
408
416
|
if (cache === false) return;
|
409
417
|
switch (cache.type) {
|
@@ -446,7 +454,7 @@ const applyCacheDefaults = (
|
|
446
454
|
/** @type {NonNullable<FileCacheOptions["name"]>} */ (cache.name)
|
447
455
|
)
|
448
456
|
);
|
449
|
-
D(cache, "hashAlgorithm", "md4");
|
457
|
+
D(cache, "hashAlgorithm", futureDefaults ? "xxhash64" : "md4");
|
450
458
|
D(cache, "store", "pack");
|
451
459
|
D(cache, "compression", false);
|
452
460
|
D(cache, "profile", false);
|
@@ -580,6 +588,14 @@ const applyJavascriptParserOptionsDefaults = (
|
|
580
588
|
if (futureDefaults) D(parserOptions, "exportsPresence", "error");
|
581
589
|
};
|
582
590
|
|
591
|
+
/**
|
592
|
+
* @param {JsonGeneratorOptions} generatorOptions generator options
|
593
|
+
* @returns {void}
|
594
|
+
*/
|
595
|
+
const applyJsonGeneratorOptionsDefaults = generatorOptions => {
|
596
|
+
D(generatorOptions, "JSONParse", true);
|
597
|
+
};
|
598
|
+
|
583
599
|
/**
|
584
600
|
* @param {CssGeneratorOptions} generatorOptions generator options
|
585
601
|
* @param {object} options options
|
@@ -609,6 +625,7 @@ const applyCssGeneratorOptionsDefaults = (
|
|
609
625
|
* @param {string} options.uniqueName the unique name
|
610
626
|
* @param {boolean} options.isNode is node target platform
|
611
627
|
* @param {TargetProperties | false} options.targetProperties target properties
|
628
|
+
* @param {Mode | undefined} options.mode mode
|
612
629
|
* @returns {void}
|
613
630
|
*/
|
614
631
|
const applyModuleDefaults = (
|
@@ -621,7 +638,8 @@ const applyModuleDefaults = (
|
|
621
638
|
futureDefaults,
|
622
639
|
isNode,
|
623
640
|
uniqueName,
|
624
|
-
targetProperties
|
641
|
+
targetProperties,
|
642
|
+
mode
|
625
643
|
}
|
626
644
|
) => {
|
627
645
|
if (cache) {
|
@@ -643,19 +661,19 @@ const applyModuleDefaults = (
|
|
643
661
|
|
644
662
|
F(module.parser, ASSET_MODULE_TYPE, () => ({}));
|
645
663
|
F(
|
646
|
-
/** @type {NonNullable<ParserOptionsByModuleTypeKnown[
|
664
|
+
/** @type {NonNullable<ParserOptionsByModuleTypeKnown[ASSET_MODULE_TYPE]>} */
|
647
665
|
(module.parser[ASSET_MODULE_TYPE]),
|
648
666
|
"dataUrlCondition",
|
649
667
|
() => ({})
|
650
668
|
);
|
651
669
|
if (
|
652
670
|
typeof (
|
653
|
-
/** @type {NonNullable<ParserOptionsByModuleTypeKnown[
|
671
|
+
/** @type {NonNullable<ParserOptionsByModuleTypeKnown[ASSET_MODULE_TYPE]>} */
|
654
672
|
(module.parser[ASSET_MODULE_TYPE]).dataUrlCondition
|
655
673
|
) === "object"
|
656
674
|
) {
|
657
675
|
D(
|
658
|
-
/** @type {NonNullable<ParserOptionsByModuleTypeKnown[
|
676
|
+
/** @type {NonNullable<ParserOptionsByModuleTypeKnown[ASSET_MODULE_TYPE]>} */
|
659
677
|
(module.parser[ASSET_MODULE_TYPE]).dataUrlCondition,
|
660
678
|
"maxSize",
|
661
679
|
8096
|
@@ -663,6 +681,12 @@ const applyModuleDefaults = (
|
|
663
681
|
}
|
664
682
|
|
665
683
|
F(module.parser, "javascript", () => ({}));
|
684
|
+
F(module.parser, JSON_MODULE_TYPE, () => ({}));
|
685
|
+
D(
|
686
|
+
module.parser[JSON_MODULE_TYPE],
|
687
|
+
"exportsDepth",
|
688
|
+
mode === "development" ? 1 : Infinity
|
689
|
+
);
|
666
690
|
|
667
691
|
applyJavascriptParserOptionsDefaults(
|
668
692
|
/** @type {NonNullable<ParserOptionsByModuleTypeKnown["javascript"]>} */
|
@@ -673,17 +697,38 @@ const applyModuleDefaults = (
|
|
673
697
|
}
|
674
698
|
);
|
675
699
|
|
700
|
+
F(module.generator, "json", () => ({}));
|
701
|
+
applyJsonGeneratorOptionsDefaults(
|
702
|
+
/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown["json"]>} */
|
703
|
+
(module.generator.json)
|
704
|
+
);
|
705
|
+
|
676
706
|
if (css) {
|
677
707
|
F(module.parser, CSS_MODULE_TYPE, () => ({}));
|
678
708
|
|
679
|
-
D(
|
680
|
-
|
681
|
-
|
709
|
+
D(
|
710
|
+
/** @type {NonNullable<ParserOptionsByModuleTypeKnown[CSS_MODULE_TYPE]>} */
|
711
|
+
(module.parser[CSS_MODULE_TYPE]),
|
712
|
+
"import",
|
713
|
+
true
|
714
|
+
);
|
715
|
+
D(
|
716
|
+
/** @type {NonNullable<ParserOptionsByModuleTypeKnown[CSS_MODULE_TYPE]>} */
|
717
|
+
(module.parser[CSS_MODULE_TYPE]),
|
718
|
+
"url",
|
719
|
+
true
|
720
|
+
);
|
721
|
+
D(
|
722
|
+
/** @type {NonNullable<ParserOptionsByModuleTypeKnown[CSS_MODULE_TYPE]>} */
|
723
|
+
(module.parser[CSS_MODULE_TYPE]),
|
724
|
+
"namedExports",
|
725
|
+
true
|
726
|
+
);
|
682
727
|
|
683
728
|
F(module.generator, CSS_MODULE_TYPE, () => ({}));
|
684
729
|
|
685
730
|
applyCssGeneratorOptionsDefaults(
|
686
|
-
/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[
|
731
|
+
/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE]>} */
|
687
732
|
(module.generator[CSS_MODULE_TYPE]),
|
688
733
|
{ targetProperties }
|
689
734
|
);
|
@@ -692,24 +737,46 @@ const applyModuleDefaults = (
|
|
692
737
|
uniqueName.length > 0 ? "[uniqueName]-[id]-[local]" : "[id]-[local]";
|
693
738
|
|
694
739
|
F(module.generator, CSS_MODULE_TYPE_AUTO, () => ({}));
|
695
|
-
D(
|
696
|
-
|
740
|
+
D(
|
741
|
+
/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_AUTO]>} */
|
742
|
+
(module.generator[CSS_MODULE_TYPE_AUTO]),
|
743
|
+
"localIdentName",
|
744
|
+
localIdentName
|
745
|
+
);
|
746
|
+
D(
|
747
|
+
/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_AUTO]>} */
|
748
|
+
(module.generator[CSS_MODULE_TYPE_AUTO]),
|
749
|
+
"exportsConvention",
|
750
|
+
"as-is"
|
751
|
+
);
|
697
752
|
|
698
753
|
F(module.generator, CSS_MODULE_TYPE_MODULE, () => ({}));
|
699
754
|
D(
|
700
|
-
|
755
|
+
/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_MODULE]>} */
|
756
|
+
(module.generator[CSS_MODULE_TYPE_MODULE]),
|
701
757
|
"localIdentName",
|
702
758
|
localIdentName
|
703
759
|
);
|
704
|
-
D(
|
760
|
+
D(
|
761
|
+
/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_MODULE]>} */
|
762
|
+
(module.generator[CSS_MODULE_TYPE_MODULE]),
|
763
|
+
"exportsConvention",
|
764
|
+
"as-is"
|
765
|
+
);
|
705
766
|
|
706
767
|
F(module.generator, CSS_MODULE_TYPE_GLOBAL, () => ({}));
|
707
768
|
D(
|
708
|
-
|
769
|
+
/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_GLOBAL]>} */
|
770
|
+
(module.generator[CSS_MODULE_TYPE_GLOBAL]),
|
709
771
|
"localIdentName",
|
710
772
|
localIdentName
|
711
773
|
);
|
712
|
-
D(
|
774
|
+
D(
|
775
|
+
/** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_GLOBAL]>} */
|
776
|
+
(module.generator[CSS_MODULE_TYPE_GLOBAL]),
|
777
|
+
"exportsConvention",
|
778
|
+
"as-is"
|
779
|
+
);
|
713
780
|
}
|
714
781
|
|
715
782
|
A(module, "defaultRules", () => {
|
@@ -1075,7 +1142,7 @@ const applyOutputDefaults = (
|
|
1075
1142
|
D(output, "assetModuleFilename", "[hash][ext][query]");
|
1076
1143
|
D(output, "webassemblyModuleFilename", "[hash].module.wasm");
|
1077
1144
|
D(output, "compareBeforeEmit", true);
|
1078
|
-
D(output, "charset",
|
1145
|
+
D(output, "charset", !futureDefaults);
|
1079
1146
|
const uniqueNameId = Template.toIdentifier(
|
1080
1147
|
/** @type {NonNullable<Output["uniqueName"]>} */ (output.uniqueName)
|
1081
1148
|
);
|
@@ -1216,7 +1283,14 @@ const applyOutputDefaults = (
|
|
1216
1283
|
);
|
1217
1284
|
D(output, "workerPublicPath", "");
|
1218
1285
|
D(output, "chunkLoadTimeout", 120000);
|
1219
|
-
|
1286
|
+
F(output, "hashFunction", () => {
|
1287
|
+
if (futureDefaults) {
|
1288
|
+
DEFAULTS.HASH_FUNCTION = "xxhash64";
|
1289
|
+
return "xxhash64";
|
1290
|
+
}
|
1291
|
+
|
1292
|
+
return "md4";
|
1293
|
+
});
|
1220
1294
|
D(output, "hashDigest", "hex");
|
1221
1295
|
D(output, "hashDigestLength", futureDefaults ? 16 : 20);
|
1222
1296
|
D(output, "strictModuleErrorHandling", false);
|
@@ -1235,7 +1309,7 @@ const applyOutputDefaults = (
|
|
1235
1309
|
}
|
1236
1310
|
|
1237
1311
|
/**
|
1238
|
-
* @param {
|
1312
|
+
* @param {(entryDescription: EntryDescription) => void} fn iterator
|
1239
1313
|
* @returns {void}
|
1240
1314
|
*/
|
1241
1315
|
const forEachEntry = fn => {
|
@@ -1477,7 +1551,7 @@ const applyOptimizationDefaults = (
|
|
1477
1551
|
passes: 2
|
1478
1552
|
}
|
1479
1553
|
}
|
1480
|
-
}).apply(compiler);
|
1554
|
+
}).apply(/** @type {TODO} */ (compiler));
|
1481
1555
|
}
|
1482
1556
|
}
|
1483
1557
|
]);
|
@@ -1554,14 +1628,14 @@ const getResolveDefaults = ({
|
|
1554
1628
|
const browserField =
|
1555
1629
|
tp && tp.web && (!tp.node || (tp.electron && tp.electronRenderer));
|
1556
1630
|
|
1557
|
-
/** @type {
|
1631
|
+
/** @type {() => ResolveOptions} */
|
1558
1632
|
const cjsDeps = () => ({
|
1559
1633
|
aliasFields: browserField ? ["browser"] : [],
|
1560
1634
|
mainFields: browserField ? ["browser", "module", "..."] : ["module", "..."],
|
1561
1635
|
conditionNames: ["require", "module", "..."],
|
1562
1636
|
extensions: [...jsExtensions]
|
1563
1637
|
});
|
1564
|
-
/** @type {
|
1638
|
+
/** @type {() => ResolveOptions} */
|
1565
1639
|
const esmDeps = () => ({
|
1566
1640
|
aliasFields: browserField ? ["browser"] : [],
|
1567
1641
|
mainFields: browserField ? ["browser", "module", "..."] : ["module", "..."],
|
@@ -1610,7 +1684,8 @@ const getResolveDefaults = ({
|
|
1610
1684
|
styleConditions.push(mode === "development" ? "development" : "production");
|
1611
1685
|
styleConditions.push("style");
|
1612
1686
|
|
1613
|
-
|
1687
|
+
/** @type {NonNullable<ResolveOptions["byDependency"]>} */
|
1688
|
+
(resolveOptions.byDependency)["css-import"] = {
|
1614
1689
|
// We avoid using any main files because we have to be consistent with CSS `@import`
|
1615
1690
|
// and CSS `@import` does not handle `main` files in directories,
|
1616
1691
|
// you should always specify the full URL for styles
|
@@ -1651,7 +1726,7 @@ const getResolveLoaderDefaults = ({ cache }) => {
|
|
1651
1726
|
const applyInfrastructureLoggingDefaults = infrastructureLogging => {
|
1652
1727
|
F(infrastructureLogging, "stream", () => process.stderr);
|
1653
1728
|
const tty =
|
1654
|
-
/** @type {
|
1729
|
+
/** @type {EXPECTED_ANY} */ (infrastructureLogging.stream).isTTY &&
|
1655
1730
|
process.env.TERM !== "dumb";
|
1656
1731
|
D(infrastructureLogging, "level", "info");
|
1657
1732
|
D(infrastructureLogging, "debug", false);
|
@@ -1662,3 +1737,4 @@ const applyInfrastructureLoggingDefaults = infrastructureLogging => {
|
|
1662
1737
|
module.exports.applyWebpackOptionsBaseDefaults =
|
1663
1738
|
applyWebpackOptionsBaseDefaults;
|
1664
1739
|
module.exports.applyWebpackOptionsDefaults = applyWebpackOptionsDefaults;
|
1740
|
+
module.exports.DEFAULTS = DEFAULTS;
|
@@ -44,8 +44,8 @@ const handledDeprecatedNoEmitOnErrors = util.deprecate(
|
|
44
44
|
/**
|
45
45
|
* @template T
|
46
46
|
* @template R
|
47
|
-
* @param {T|undefined} value value or not
|
48
|
-
* @param {
|
47
|
+
* @param {T | undefined} value value or not
|
48
|
+
* @param {(value: T) => R} fn nested handler
|
49
49
|
* @returns {R} result value
|
50
50
|
*/
|
51
51
|
const nestedConfig = (value, fn) =>
|
@@ -60,9 +60,9 @@ const cloneObject = value => /** @type {T} */ ({ ...value });
|
|
60
60
|
/**
|
61
61
|
* @template T
|
62
62
|
* @template R
|
63
|
-
* @param {T|undefined} value value or not
|
64
|
-
* @param {
|
65
|
-
* @returns {R|undefined} result value
|
63
|
+
* @param {T | undefined} value value or not
|
64
|
+
* @param {(value: T) => R} fn nested handler
|
65
|
+
* @returns {R | undefined} result value
|
66
66
|
*/
|
67
67
|
const optionalNestedConfig = (value, fn) =>
|
68
68
|
value === undefined ? undefined : fn(value);
|
@@ -70,18 +70,18 @@ const optionalNestedConfig = (value, fn) =>
|
|
70
70
|
/**
|
71
71
|
* @template T
|
72
72
|
* @template R
|
73
|
-
* @param {T[]|undefined} value array or not
|
74
|
-
* @param {
|
75
|
-
* @returns {R[]|undefined} cloned value
|
73
|
+
* @param {T[] | undefined} value array or not
|
74
|
+
* @param {(value: T[]) => R[]} fn nested handler
|
75
|
+
* @returns {R[] | undefined} cloned value
|
76
76
|
*/
|
77
77
|
const nestedArray = (value, fn) => (Array.isArray(value) ? fn(value) : fn([]));
|
78
78
|
|
79
79
|
/**
|
80
80
|
* @template T
|
81
81
|
* @template R
|
82
|
-
* @param {T[]|undefined} value array or not
|
83
|
-
* @param {
|
84
|
-
* @returns {R[]|undefined} cloned value
|
82
|
+
* @param {T[] | undefined} value array or not
|
83
|
+
* @param {(value: T[]) => R[]} fn nested handler
|
84
|
+
* @returns {R[] | undefined} cloned value
|
85
85
|
*/
|
86
86
|
const optionalNestedArray = (value, fn) =>
|
87
87
|
Array.isArray(value) ? fn(value) : undefined;
|
@@ -90,8 +90,8 @@ const optionalNestedArray = (value, fn) =>
|
|
90
90
|
* @template T
|
91
91
|
* @template R
|
92
92
|
* @param {Record<string, T>|undefined} value value or not
|
93
|
-
* @param {
|
94
|
-
* @param {Record<string,
|
93
|
+
* @param {(value: T) => R} fn nested handler
|
94
|
+
* @param {Record<string, (value: T) => R>=} customKeys custom nested handler for some keys
|
95
95
|
* @returns {Record<string, R>} result value
|
96
96
|
*/
|
97
97
|
const keyedNestedConfig = (value, fn, customKeys) => {
|
@@ -346,6 +346,7 @@ const getNormalizedWebpackOptions = config => ({
|
|
346
346
|
importFunctionName: output.importFunctionName,
|
347
347
|
importMetaName: output.importMetaName,
|
348
348
|
scriptType: output.scriptType,
|
349
|
+
// TODO webpack6 remove `libraryTarget`/`auxiliaryComment`/`amdContainer`/etc in favor of the `library` option
|
349
350
|
library: libraryBase && {
|
350
351
|
type:
|
351
352
|
output.libraryTarget !== undefined
|
package/lib/config/target.js
CHANGED
@@ -22,12 +22,12 @@ const getDefaultTarget = context => {
|
|
22
22
|
|
23
23
|
/**
|
24
24
|
* @typedef {object} PlatformTargetProperties
|
25
|
-
* @property {boolean | null} web web platform, importing of http(s) and std: is available
|
26
|
-
* @property {boolean | null} browser browser platform, running in a normal web browser
|
27
|
-
* @property {boolean | null} webworker (Web)Worker platform, running in a web/shared/service worker
|
28
|
-
* @property {boolean | null} node node platform, require of node built-in modules is available
|
29
|
-
* @property {boolean | null} nwjs nwjs platform, require of legacy nw.gui is available
|
30
|
-
* @property {boolean | null} electron electron platform, require of some electron built-in modules is available
|
25
|
+
* @property {boolean | null} [web] web platform, importing of http(s) and std: is available
|
26
|
+
* @property {boolean | null} [browser] browser platform, running in a normal web browser
|
27
|
+
* @property {boolean | null} [webworker] (Web)Worker platform, running in a web/shared/service worker
|
28
|
+
* @property {boolean | null} [node] node platform, require of node built-in modules is available
|
29
|
+
* @property {boolean | null} [nwjs] nwjs platform, require of legacy nw.gui is available
|
30
|
+
* @property {boolean | null} [electron] electron platform, require of some electron built-in modules is available
|
31
31
|
*/
|
32
32
|
|
33
33
|
/**
|
@@ -341,7 +341,7 @@ const mergeTargetProperties = targetProperties => {
|
|
341
341
|
keys.add(/** @type {keyof TargetProperties} */ (key));
|
342
342
|
}
|
343
343
|
}
|
344
|
-
/** @type {
|
344
|
+
/** @type {TargetProperties} */
|
345
345
|
const result = {};
|
346
346
|
for (const key of keys) {
|
347
347
|
let hasTrue = false;
|
@@ -361,7 +361,7 @@ const mergeTargetProperties = targetProperties => {
|
|
361
361
|
/** @type {TargetProperties} */
|
362
362
|
(result)[key] = hasFalse && hasTrue ? null : Boolean(hasTrue);
|
363
363
|
}
|
364
|
-
return
|
364
|
+
return result;
|
365
365
|
};
|
366
366
|
|
367
367
|
/**
|
@@ -20,9 +20,11 @@ const ContainerExposedDependency = require("./ContainerExposedDependency");
|
|
20
20
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
21
21
|
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
22
22
|
/** @typedef {import("../Compilation")} Compilation */
|
23
|
+
/** @typedef {import("../Module").BuildCallback} BuildCallback */
|
23
24
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
24
25
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
25
26
|
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
27
|
+
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
|
26
28
|
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
|
27
29
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
28
30
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
@@ -91,7 +93,7 @@ class ContainerEntryModule extends Module {
|
|
91
93
|
|
92
94
|
/**
|
93
95
|
* @param {NeedBuildContext} context context info
|
94
|
-
* @param {
|
96
|
+
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
|
95
97
|
* @returns {void}
|
96
98
|
*/
|
97
99
|
needBuild(context, callback) {
|
@@ -103,7 +105,7 @@ class ContainerEntryModule extends Module {
|
|
103
105
|
* @param {Compilation} compilation the compilation
|
104
106
|
* @param {ResolverWithOptions} resolver the resolver
|
105
107
|
* @param {InputFileSystem} fs the file system
|
106
|
-
* @param {
|
108
|
+
* @param {BuildCallback} callback callback function
|
107
109
|
* @returns {void}
|
108
110
|
*/
|
109
111
|
build(options, compilation, resolver, fs, callback) {
|
@@ -8,14 +8,14 @@
|
|
8
8
|
const ModuleFactory = require("../ModuleFactory");
|
9
9
|
const ContainerEntryModule = require("./ContainerEntryModule");
|
10
10
|
|
11
|
+
/** @typedef {import("../ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
|
11
12
|
/** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
|
12
|
-
/** @typedef {import("../ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
|
13
13
|
/** @typedef {import("./ContainerEntryDependency")} ContainerEntryDependency */
|
14
14
|
|
15
15
|
module.exports = class ContainerEntryModuleFactory extends ModuleFactory {
|
16
16
|
/**
|
17
17
|
* @param {ModuleFactoryCreateData} data data object
|
18
|
-
* @param {
|
18
|
+
* @param {ModuleFactoryCallback} callback callback
|
19
19
|
* @returns {void}
|
20
20
|
*/
|
21
21
|
create({ dependencies: [dependency] }, callback) {
|
@@ -19,9 +19,11 @@ const FallbackItemDependency = require("./FallbackItemDependency");
|
|
19
19
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
20
20
|
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
21
21
|
/** @typedef {import("../Compilation")} Compilation */
|
22
|
+
/** @typedef {import("../Module").BuildCallback} BuildCallback */
|
22
23
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
23
24
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
24
25
|
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
26
|
+
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
|
25
27
|
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
|
26
28
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
27
29
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
@@ -80,7 +82,7 @@ class FallbackModule extends Module {
|
|
80
82
|
|
81
83
|
/**
|
82
84
|
* @param {NeedBuildContext} context context info
|
83
|
-
* @param {
|
85
|
+
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
|
84
86
|
* @returns {void}
|
85
87
|
*/
|
86
88
|
needBuild(context, callback) {
|
@@ -92,7 +94,7 @@ class FallbackModule extends Module {
|
|
92
94
|
* @param {Compilation} compilation the compilation
|
93
95
|
* @param {ResolverWithOptions} resolver the resolver
|
94
96
|
* @param {InputFileSystem} fs the file system
|
95
|
-
* @param {
|
97
|
+
* @param {BuildCallback} callback callback function
|
96
98
|
* @returns {void}
|
97
99
|
*/
|
98
100
|
build(options, compilation, resolver, fs, callback) {
|
@@ -8,14 +8,14 @@
|
|
8
8
|
const ModuleFactory = require("../ModuleFactory");
|
9
9
|
const FallbackModule = require("./FallbackModule");
|
10
10
|
|
11
|
+
/** @typedef {import("../ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
|
11
12
|
/** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
|
12
|
-
/** @typedef {import("../ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
|
13
13
|
/** @typedef {import("./FallbackDependency")} FallbackDependency */
|
14
14
|
|
15
15
|
module.exports = class FallbackModuleFactory extends ModuleFactory {
|
16
16
|
/**
|
17
17
|
* @param {ModuleFactoryCreateData} data data object
|
18
|
-
* @param {
|
18
|
+
* @param {ModuleFactoryCallback} callback callback
|
19
19
|
* @returns {void}
|
20
20
|
*/
|
21
21
|
create({ dependencies: [dependency] }, callback) {
|