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
@@ -9,6 +9,20 @@ const memoize = require("../util/memoize");
|
|
9
9
|
const LAZY_TARGET = Symbol("lazy serialization target");
|
10
10
|
const LAZY_SERIALIZED_VALUE = Symbol("lazy serialization data");
|
11
11
|
|
12
|
+
/** @typedef {TODO} Context */
|
13
|
+
|
14
|
+
/**
|
15
|
+
* @template LazyResult
|
16
|
+
* @typedef {() => LazyResult | Promise<LazyResult>} InternalLazyFunction
|
17
|
+
*/
|
18
|
+
|
19
|
+
/** @typedef {Record<string, any>} LazyOptions */
|
20
|
+
|
21
|
+
/**
|
22
|
+
* @template LazyResult
|
23
|
+
* @typedef {InternalLazyFunction<LazyResult> & { [LAZY_TARGET]: TODO, [LAZY_SERIALIZED_VALUE]?: TODO, options: LazyOptions }} LazyFunction
|
24
|
+
*/
|
25
|
+
|
12
26
|
/**
|
13
27
|
* @template DeserializedType
|
14
28
|
* @template SerializedType
|
@@ -18,8 +32,8 @@ class SerializerMiddleware {
|
|
18
32
|
/**
|
19
33
|
* @abstract
|
20
34
|
* @param {DeserializedType} data data
|
21
|
-
* @param {
|
22
|
-
* @returns {SerializedType|Promise<SerializedType>} serialized data
|
35
|
+
* @param {Context} context context object
|
36
|
+
* @returns {SerializedType | Promise<SerializedType> | null} serialized data
|
23
37
|
*/
|
24
38
|
serialize(data, context) {
|
25
39
|
const AbstractMethodError = require("../AbstractMethodError");
|
@@ -30,8 +44,8 @@ class SerializerMiddleware {
|
|
30
44
|
/**
|
31
45
|
* @abstract
|
32
46
|
* @param {SerializedType} data data
|
33
|
-
* @param {
|
34
|
-
* @returns {DeserializedType|Promise<DeserializedType>} deserialized data
|
47
|
+
* @param {Context} context context object
|
48
|
+
* @returns {DeserializedType | Promise<DeserializedType>} deserialized data
|
35
49
|
*/
|
36
50
|
deserialize(data, context) {
|
37
51
|
const AbstractMethodError = require("../AbstractMethodError");
|
@@ -39,23 +53,26 @@ class SerializerMiddleware {
|
|
39
53
|
}
|
40
54
|
|
41
55
|
/**
|
42
|
-
* @
|
56
|
+
* @template LazyResult
|
57
|
+
* @param {LazyFunction<LazyResult> | EXPECTED_ANY} value contained value or function to value
|
43
58
|
* @param {SerializerMiddleware<any, any>} target target middleware
|
44
|
-
* @param {
|
59
|
+
* @param {LazyOptions=} options lazy options
|
45
60
|
* @param {any=} serializedValue serialized value
|
46
|
-
* @returns {
|
61
|
+
* @returns {LazyFunction<LazyResult>} lazy function
|
47
62
|
*/
|
48
63
|
static createLazy(value, target, options = {}, serializedValue = undefined) {
|
49
64
|
if (SerializerMiddleware.isLazy(value, target)) return value;
|
50
|
-
const fn =
|
65
|
+
const fn =
|
66
|
+
/** @type {LazyFunction<LazyResult>} */
|
67
|
+
(typeof value === "function" ? value : () => value);
|
51
68
|
fn[LAZY_TARGET] = target;
|
52
|
-
|
69
|
+
fn.options = options;
|
53
70
|
fn[LAZY_SERIALIZED_VALUE] = serializedValue;
|
54
71
|
return fn;
|
55
72
|
}
|
56
73
|
|
57
74
|
/**
|
58
|
-
* @param {
|
75
|
+
* @param {EXPECTED_ANY} fn lazy function
|
59
76
|
* @param {SerializerMiddleware<any, any>=} target target middleware
|
60
77
|
* @returns {boolean} true, when fn is a lazy function (optionally of that target)
|
61
78
|
*/
|
@@ -66,8 +83,9 @@ class SerializerMiddleware {
|
|
66
83
|
}
|
67
84
|
|
68
85
|
/**
|
69
|
-
* @
|
70
|
-
* @
|
86
|
+
* @template LazyResult
|
87
|
+
* @param {LazyFunction<LazyResult>} fn lazy function
|
88
|
+
* @returns {LazyOptions | undefined} options
|
71
89
|
*/
|
72
90
|
static getLazyOptions(fn) {
|
73
91
|
if (typeof fn !== "function") return;
|
@@ -75,7 +93,8 @@ class SerializerMiddleware {
|
|
75
93
|
}
|
76
94
|
|
77
95
|
/**
|
78
|
-
* @
|
96
|
+
* @template LazyResult
|
97
|
+
* @param {LazyFunction<LazyResult> | EXPECTED_ANY} fn lazy function
|
79
98
|
* @returns {any | undefined} serialized value
|
80
99
|
*/
|
81
100
|
static getLazySerializedValue(fn) {
|
@@ -84,8 +103,9 @@ class SerializerMiddleware {
|
|
84
103
|
}
|
85
104
|
|
86
105
|
/**
|
87
|
-
* @
|
88
|
-
* @param {
|
106
|
+
* @template LazyResult
|
107
|
+
* @param {LazyFunction<LazyResult>} fn lazy function
|
108
|
+
* @param {TODO} value serialized value
|
89
109
|
* @returns {void}
|
90
110
|
*/
|
91
111
|
static setLazySerializedValue(fn, value) {
|
@@ -93,50 +113,69 @@ class SerializerMiddleware {
|
|
93
113
|
}
|
94
114
|
|
95
115
|
/**
|
96
|
-
* @
|
97
|
-
* @param {
|
98
|
-
* @
|
116
|
+
* @template LazyResult, R
|
117
|
+
* @param {LazyFunction<LazyResult>} lazy lazy function
|
118
|
+
* @param {(lazyResult: LazyResult) => Promise<R> | R} serialize serialize function
|
119
|
+
* @returns {LazyFunction<R>} new lazy
|
99
120
|
*/
|
100
121
|
static serializeLazy(lazy, serialize) {
|
101
|
-
const fn =
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
122
|
+
const fn = /** @type {LazyFunction<R>} */ (
|
123
|
+
memoize(() => {
|
124
|
+
const r = lazy();
|
125
|
+
if (
|
126
|
+
r &&
|
127
|
+
typeof (/** @type {Promise<LazyResult>} */ (r).then) === "function"
|
128
|
+
) {
|
129
|
+
return (
|
130
|
+
/** @type {Promise<LazyResult>} */
|
131
|
+
(r).then(data => data && serialize(data))
|
132
|
+
);
|
133
|
+
}
|
134
|
+
return serialize(/** @type {LazyResult} */ (r));
|
135
|
+
})
|
136
|
+
);
|
108
137
|
fn[LAZY_TARGET] = lazy[LAZY_TARGET];
|
109
|
-
|
138
|
+
fn.options = lazy.options;
|
110
139
|
lazy[LAZY_SERIALIZED_VALUE] = fn;
|
111
140
|
return fn;
|
112
141
|
}
|
113
142
|
|
114
143
|
/**
|
115
|
-
* @template
|
116
|
-
* @param {
|
117
|
-
* @param {
|
118
|
-
* @returns {
|
144
|
+
* @template LazyResult, R
|
145
|
+
* @param {LazyFunction<LazyResult>} lazy lazy function
|
146
|
+
* @param {(lazyResult: LazyResult) => Promise<R> | R} deserialize deserialize function
|
147
|
+
* @returns {LazyFunction<R>} new lazy
|
119
148
|
*/
|
120
149
|
static deserializeLazy(lazy, deserialize) {
|
121
|
-
const fn =
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
150
|
+
const fn = /** @type {LazyFunction<R>} */ (
|
151
|
+
memoize(() => {
|
152
|
+
const r = lazy();
|
153
|
+
if (
|
154
|
+
r &&
|
155
|
+
typeof (/** @type {Promise<LazyResult>} */ (r).then) === "function"
|
156
|
+
) {
|
157
|
+
return (
|
158
|
+
/** @type {Promise<LazyResult>} */
|
159
|
+
(r).then(data => deserialize(data))
|
160
|
+
);
|
161
|
+
}
|
162
|
+
return deserialize(/** @type {LazyResult} */ (r));
|
163
|
+
})
|
164
|
+
);
|
128
165
|
fn[LAZY_TARGET] = lazy[LAZY_TARGET];
|
129
|
-
|
166
|
+
fn.options = lazy.options;
|
130
167
|
fn[LAZY_SERIALIZED_VALUE] = lazy;
|
131
168
|
return fn;
|
132
169
|
}
|
133
170
|
|
134
171
|
/**
|
135
|
-
* @
|
136
|
-
* @
|
172
|
+
* @template LazyResult
|
173
|
+
* @param {LazyFunction<LazyResult> | EXPECTED_ANY} lazy lazy function
|
174
|
+
* @returns {LazyFunction<LazyResult> | EXPECTED_ANY} new lazy
|
137
175
|
*/
|
138
176
|
static unMemoizeLazy(lazy) {
|
139
177
|
if (!SerializerMiddleware.isLazy(lazy)) return lazy;
|
178
|
+
/** @type {LazyFunction<LazyResult>} */
|
140
179
|
const fn = () => {
|
141
180
|
throw new Error(
|
142
181
|
"A lazy value that has been unmemorized can't be called again"
|
@@ -146,7 +185,7 @@ class SerializerMiddleware {
|
|
146
185
|
lazy[LAZY_SERIALIZED_VALUE]
|
147
186
|
);
|
148
187
|
fn[LAZY_TARGET] = lazy[LAZY_TARGET];
|
149
|
-
fn.options =
|
188
|
+
fn.options = lazy.options;
|
150
189
|
return fn;
|
151
190
|
}
|
152
191
|
}
|
@@ -6,16 +6,19 @@
|
|
6
6
|
|
7
7
|
const SerializerMiddleware = require("./SerializerMiddleware");
|
8
8
|
|
9
|
+
/** @typedef {import("./SerializerMiddleware").Context} Context */
|
10
|
+
|
11
|
+
/** @typedef {any} DeserializedType */
|
12
|
+
/** @typedef {any[]} SerializedType */
|
13
|
+
|
9
14
|
/**
|
10
|
-
* @
|
11
|
-
* @typedef {any[]} SerializedType
|
12
|
-
* @extends {SerializerMiddleware<any, any[]>}
|
15
|
+
* @extends {SerializerMiddleware<DeserializedType, SerializedType>}
|
13
16
|
*/
|
14
17
|
class SingleItemMiddleware extends SerializerMiddleware {
|
15
18
|
/**
|
16
19
|
* @param {DeserializedType} data data
|
17
|
-
* @param {
|
18
|
-
* @returns {SerializedType|Promise<SerializedType>} serialized data
|
20
|
+
* @param {Context} context context object
|
21
|
+
* @returns {SerializedType | Promise<SerializedType> | null} serialized data
|
19
22
|
*/
|
20
23
|
serialize(data, context) {
|
21
24
|
return [data];
|
@@ -23,8 +26,8 @@ class SingleItemMiddleware extends SerializerMiddleware {
|
|
23
26
|
|
24
27
|
/**
|
25
28
|
* @param {SerializedType} data data
|
26
|
-
* @param {
|
27
|
-
* @returns {DeserializedType|Promise<DeserializedType>} deserialized data
|
29
|
+
* @param {Context} context context object
|
30
|
+
* @returns {DeserializedType | Promise<DeserializedType>} deserialized data
|
28
31
|
*/
|
29
32
|
deserialize(data, context) {
|
30
33
|
return data[0];
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
"use strict";
|
6
6
|
|
7
|
-
/** @typedef {undefined | null | number | string | boolean | Buffer |
|
7
|
+
/** @typedef {undefined | null | number | string | boolean | Buffer | EXPECTED_OBJECT | (() => ComplexSerializableType[] | Promise<ComplexSerializableType[]>)} ComplexSerializableType */
|
8
8
|
|
9
9
|
/** @typedef {undefined | null | number | bigint | string | boolean | Buffer | (() => PrimitiveSerializableType[] | Promise<PrimitiveSerializableType[]>)} PrimitiveSerializableType */
|
10
10
|
|
@@ -22,9 +22,11 @@ const ConsumeSharedFallbackDependency = require("./ConsumeSharedFallbackDependen
|
|
22
22
|
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
23
23
|
/** @typedef {import("../Compilation")} Compilation */
|
24
24
|
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
25
|
+
/** @typedef {import("../Module").BuildCallback} BuildCallback */
|
25
26
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
26
27
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
27
28
|
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
29
|
+
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
|
28
30
|
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
|
29
31
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
30
32
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
@@ -115,7 +117,7 @@ class ConsumeSharedModule extends Module {
|
|
115
117
|
|
116
118
|
/**
|
117
119
|
* @param {NeedBuildContext} context context info
|
118
|
-
* @param {
|
120
|
+
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
|
119
121
|
* @returns {void}
|
120
122
|
*/
|
121
123
|
needBuild(context, callback) {
|
@@ -127,7 +129,7 @@ class ConsumeSharedModule extends Module {
|
|
127
129
|
* @param {Compilation} compilation the compilation
|
128
130
|
* @param {ResolverWithOptions} resolver the resolver
|
129
131
|
* @param {InputFileSystem} fs the file system
|
130
|
-
* @param {
|
132
|
+
* @param {BuildCallback} callback callback function
|
131
133
|
* @returns {void}
|
132
134
|
*/
|
133
135
|
build(options, compilation, resolver, fs, callback) {
|
@@ -18,9 +18,11 @@ const ProvideForSharedDependency = require("./ProvideForSharedDependency");
|
|
18
18
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
19
19
|
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
20
20
|
/** @typedef {import("../Compilation")} Compilation */
|
21
|
+
/** @typedef {import("../Module").BuildCallback} BuildCallback */
|
21
22
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
22
23
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
23
24
|
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
25
|
+
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
|
24
26
|
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
|
25
27
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
26
28
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
@@ -77,7 +79,7 @@ class ProvideSharedModule extends Module {
|
|
77
79
|
|
78
80
|
/**
|
79
81
|
* @param {NeedBuildContext} context context info
|
80
|
-
* @param {
|
82
|
+
* @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
|
81
83
|
* @returns {void}
|
82
84
|
*/
|
83
85
|
needBuild(context, callback) {
|
@@ -89,7 +91,7 @@ class ProvideSharedModule extends Module {
|
|
89
91
|
* @param {Compilation} compilation the compilation
|
90
92
|
* @param {ResolverWithOptions} resolver the resolver
|
91
93
|
* @param {InputFileSystem} fs the file system
|
92
|
-
* @param {
|
94
|
+
* @param {BuildCallback} callback callback function
|
93
95
|
* @returns {void}
|
94
96
|
*/
|
95
97
|
build(options, compilation, resolver, fs, callback) {
|
@@ -8,18 +8,20 @@
|
|
8
8
|
const ModuleFactory = require("../ModuleFactory");
|
9
9
|
const ProvideSharedModule = require("./ProvideSharedModule");
|
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("./ProvideSharedDependency")} ProvideSharedDependency */
|
14
14
|
|
15
15
|
class ProvideSharedModuleFactory 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(data, callback) {
|
22
|
-
const dep =
|
22
|
+
const dep =
|
23
|
+
/** @type {ProvideSharedDependency} */
|
24
|
+
(data.dependencies[0]);
|
23
25
|
callback(null, {
|
24
26
|
module: new ProvideSharedModule(
|
25
27
|
dep.shareScope,
|
package/lib/sharing/utils.js
CHANGED
@@ -326,8 +326,8 @@ module.exports.normalizeVersion = normalizeVersion;
|
|
326
326
|
* @param {InputFileSystem} fs file system
|
327
327
|
* @param {string} directory directory to start looking into
|
328
328
|
* @param {string[]} descriptionFiles possible description filenames
|
329
|
-
* @param {
|
330
|
-
* @param {
|
329
|
+
* @param {(err?: Error | null, descriptionFile?: DescriptionFile, paths?: string[]) => void} callback callback
|
330
|
+
* @param {(descriptionFile?: DescriptionFile) => boolean} satisfiesDescriptionFileData file data compliance check
|
331
331
|
* @param {Set<string>} checkedFilePaths set of file paths that have been checked
|
332
332
|
*/
|
333
333
|
const getDescriptionFile = (
|