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
@@ -19,9 +19,11 @@ const makeSerializable = require("./util/makeSerializable");
|
|
19
19
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
20
20
|
/** @typedef {import("./util/Hash")} Hash */
|
21
21
|
|
22
|
+
/** @typedef {(ChunkGroupOptions & { entryOptions?: EntryOptions }) | string} GroupOptions */
|
23
|
+
|
22
24
|
class AsyncDependenciesBlock extends DependenciesBlock {
|
23
25
|
/**
|
24
|
-
* @param {
|
26
|
+
* @param {GroupOptions | null} groupOptions options for the group
|
25
27
|
* @param {(DependencyLocation | null)=} loc the line of code
|
26
28
|
* @param {(string | null)=} request the request
|
27
29
|
*/
|
package/lib/BannerPlugin.js
CHANGED
@@ -19,7 +19,7 @@ const createSchemaValidation = require("./util/create-schema-validation");
|
|
19
19
|
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
20
20
|
|
21
21
|
const validate = createSchemaValidation(
|
22
|
-
/** @type {(
|
22
|
+
/** @type {((value: typeof import("../schemas/plugins/BannerPlugin.json")) => boolean)} */
|
23
23
|
(require("../schemas/plugins/BannerPlugin.check.js")),
|
24
24
|
() => require("../schemas/plugins/BannerPlugin.json"),
|
25
25
|
{
|
package/lib/Cache.js
CHANGED
@@ -15,7 +15,7 @@ const {
|
|
15
15
|
|
16
16
|
/**
|
17
17
|
* @typedef {object} Etag
|
18
|
-
* @property {
|
18
|
+
* @property {() => string} toString
|
19
19
|
*/
|
20
20
|
|
21
21
|
/**
|
@@ -26,17 +26,19 @@ const {
|
|
26
26
|
* @returns {void}
|
27
27
|
*/
|
28
28
|
|
29
|
+
/** @typedef {TODO} Data */
|
30
|
+
|
29
31
|
/**
|
30
32
|
* @callback GotHandler
|
31
|
-
* @param {
|
32
|
-
* @param {
|
33
|
+
* @param {TODO} result
|
34
|
+
* @param {(err?: Error) => void} callback
|
33
35
|
* @returns {void}
|
34
36
|
*/
|
35
37
|
|
36
38
|
/**
|
37
39
|
* @param {number} times times
|
38
|
-
* @param {
|
39
|
-
* @returns {
|
40
|
+
* @param {(err?: Error) => void} callback callback
|
41
|
+
* @returns {(err?: Error) => void} callback
|
40
42
|
*/
|
41
43
|
const needCalls = (times, callback) => err => {
|
42
44
|
if (--times === 0) {
|
@@ -51,9 +53,9 @@ const needCalls = (times, callback) => err => {
|
|
51
53
|
class Cache {
|
52
54
|
constructor() {
|
53
55
|
this.hooks = {
|
54
|
-
/** @type {AsyncSeriesBailHook<[string, Etag | null, GotHandler[]],
|
56
|
+
/** @type {AsyncSeriesBailHook<[string, Etag | null, GotHandler[]], Data>} */
|
55
57
|
get: new AsyncSeriesBailHook(["identifier", "etag", "gotHandlers"]),
|
56
|
-
/** @type {AsyncParallelHook<[string, Etag | null,
|
58
|
+
/** @type {AsyncParallelHook<[string, Etag | null, Data]>} */
|
57
59
|
store: new AsyncParallelHook(["identifier", "etag", "data"]),
|
58
60
|
/** @type {AsyncParallelHook<[Iterable<string>]>} */
|
59
61
|
storeBuildDependencies: new AsyncParallelHook(["dependencies"]),
|
package/lib/CacheFacade.js
CHANGED
@@ -39,7 +39,7 @@ class MultiItemCache {
|
|
39
39
|
constructor(items) {
|
40
40
|
this._items = items;
|
41
41
|
// eslint-disable-next-line no-constructor-return
|
42
|
-
if (items.length === 1) return /** @type {
|
42
|
+
if (items.length === 1) return /** @type {TODO} */ (items[0]);
|
43
43
|
}
|
44
44
|
|
45
45
|
/**
|
@@ -160,7 +160,7 @@ class ItemCacheFacade {
|
|
160
160
|
|
161
161
|
/**
|
162
162
|
* @template T
|
163
|
-
* @param {
|
163
|
+
* @param {(callback: CallbackNormalErrorCache<T>) => void} computer function to compute the value if not cached
|
164
164
|
* @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved
|
165
165
|
* @returns {void}
|
166
166
|
*/
|
@@ -180,7 +180,7 @@ class ItemCacheFacade {
|
|
180
180
|
|
181
181
|
/**
|
182
182
|
* @template T
|
183
|
-
* @param {
|
183
|
+
* @param {() => Promise<T> | T} computer function to compute the value if not cached
|
184
184
|
* @returns {Promise<T>} promise with the data
|
185
185
|
*/
|
186
186
|
async providePromise(computer) {
|
@@ -310,7 +310,7 @@ class CacheFacade {
|
|
310
310
|
* @template T
|
311
311
|
* @param {string} identifier the cache identifier
|
312
312
|
* @param {Etag | null} etag the etag
|
313
|
-
* @param {
|
313
|
+
* @param {(callback: CallbackNormalErrorCache<T>) => void} computer function to compute the value if not cached
|
314
314
|
* @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved
|
315
315
|
* @returns {void}
|
316
316
|
*/
|
@@ -332,7 +332,7 @@ class CacheFacade {
|
|
332
332
|
* @template T
|
333
333
|
* @param {string} identifier the cache identifier
|
334
334
|
* @param {Etag | null} etag the etag
|
335
|
-
* @param {
|
335
|
+
* @param {() => Promise<T> | T} computer function to compute the value if not cached
|
336
336
|
* @returns {Promise<T>} promise with the data
|
337
337
|
*/
|
338
338
|
async providePromise(identifier, etag, computer) {
|
package/lib/Chunk.js
CHANGED
@@ -66,7 +66,7 @@ let debugId = 1000;
|
|
66
66
|
*/
|
67
67
|
class Chunk {
|
68
68
|
/**
|
69
|
-
* @param {string=} name of chunk being created, is optional (for subclasses)
|
69
|
+
* @param {(string | null)=} name of chunk being created, is optional (for subclasses)
|
70
70
|
* @param {boolean} backCompat enable backward-compatibility
|
71
71
|
*/
|
72
72
|
constructor(name, backCompat = true) {
|
@@ -76,7 +76,7 @@ class Chunk {
|
|
76
76
|
this.ids = null;
|
77
77
|
/** @type {number} */
|
78
78
|
this.debugId = debugId++;
|
79
|
-
/** @type {string | undefined} */
|
79
|
+
/** @type {string | null | undefined} */
|
80
80
|
this.name = name;
|
81
81
|
/** @type {SortableSet<string>} */
|
82
82
|
this.idNameHints = new SortableSet();
|
package/lib/ChunkGraph.js
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
const util = require("util");
|
9
9
|
const Entrypoint = require("./Entrypoint");
|
10
10
|
const ModuleGraphConnection = require("./ModuleGraphConnection");
|
11
|
+
const { DEFAULTS } = require("./config/defaults");
|
11
12
|
const { first } = require("./util/SetHelpers");
|
12
13
|
const SortableSet = require("./util/SortableSet");
|
13
14
|
const {
|
@@ -35,6 +36,7 @@ const {
|
|
35
36
|
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
|
36
37
|
/** @typedef {import("./Module")} Module */
|
37
38
|
/** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
39
|
+
/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
|
38
40
|
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
39
41
|
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
|
40
42
|
/** @typedef {import("./RuntimeModule")} RuntimeModule */
|
@@ -61,7 +63,7 @@ const compareModuleIterables = compareIterables(compareModulesByIdentifier);
|
|
61
63
|
class ModuleHashInfo {
|
62
64
|
/**
|
63
65
|
* @param {string} hash hash
|
64
|
-
* @param {string} renderedHash
|
66
|
+
* @param {string} renderedHash rendered hash
|
65
67
|
*/
|
66
68
|
constructor(hash, renderedHash) {
|
67
69
|
this.hash = hash;
|
@@ -69,8 +71,6 @@ class ModuleHashInfo {
|
|
69
71
|
}
|
70
72
|
}
|
71
73
|
|
72
|
-
/** @template T @typedef {(set: SortableSet<T>) => T[]} SetToArrayFunction<T> */
|
73
|
-
|
74
74
|
/**
|
75
75
|
* @template T
|
76
76
|
* @param {SortableSet<T>} set the set
|
@@ -92,7 +92,7 @@ const getModuleRuntimes = chunks => {
|
|
92
92
|
|
93
93
|
/**
|
94
94
|
* @param {WeakMap<Module, Set<string>> | undefined} sourceTypesByModule sourceTypesByModule
|
95
|
-
* @returns {
|
95
|
+
* @returns {(set: SortableSet<Module>) => Map<string, SortableSet<Module>>} modules by source type
|
96
96
|
*/
|
97
97
|
const modulesBySourceType = sourceTypesByModule => set => {
|
98
98
|
/** @type {Map<string, SortableSet<Module>>} */
|
@@ -121,19 +121,22 @@ const modulesBySourceType = sourceTypesByModule => set => {
|
|
121
121
|
};
|
122
122
|
const defaultModulesBySourceType = modulesBySourceType(undefined);
|
123
123
|
|
124
|
+
/**
|
125
|
+
* @typedef {(set: SortableSet<Module>) => Module[]} ModuleSetToArrayFunction
|
126
|
+
*/
|
127
|
+
|
124
128
|
/**
|
125
129
|
* @template T
|
126
|
-
* @type {WeakMap<
|
130
|
+
* @type {WeakMap<ModuleComparator, ModuleSetToArrayFunction>}
|
127
131
|
*/
|
128
132
|
const createOrderedArrayFunctionMap = new WeakMap();
|
129
133
|
|
130
134
|
/**
|
131
135
|
* @template T
|
132
|
-
* @param {
|
133
|
-
* @returns {
|
136
|
+
* @param {ModuleComparator} comparator comparator function
|
137
|
+
* @returns {ModuleSetToArrayFunction} set as ordered array
|
134
138
|
*/
|
135
139
|
const createOrderedArrayFunction = comparator => {
|
136
|
-
/** @type {SetToArrayFunction<T>} */
|
137
140
|
let fn = createOrderedArrayFunctionMap.get(comparator);
|
138
141
|
if (fn !== undefined) return fn;
|
139
142
|
fn = set => {
|
@@ -205,11 +208,11 @@ class ChunkGraphModule {
|
|
205
208
|
this.hashes = undefined;
|
206
209
|
/** @type {ModuleId | null} */
|
207
210
|
this.id = null;
|
208
|
-
/** @type {RuntimeSpecMap<Set<string
|
211
|
+
/** @type {RuntimeSpecMap<Set<string>, RuntimeRequirements> | undefined} */
|
209
212
|
this.runtimeRequirements = undefined;
|
210
|
-
/** @type {RuntimeSpecMap<string> | undefined} */
|
213
|
+
/** @type {RuntimeSpecMap<string, bigint> | undefined} */
|
211
214
|
this.graphHashes = undefined;
|
212
|
-
/** @type {RuntimeSpecMap<string> | undefined} */
|
215
|
+
/** @type {RuntimeSpecMap<string, string> | undefined} */
|
213
216
|
this.graphHashesWithConnections = undefined;
|
214
217
|
}
|
215
218
|
}
|
@@ -237,12 +240,14 @@ class ChunkGraphChunk {
|
|
237
240
|
}
|
238
241
|
}
|
239
242
|
|
243
|
+
/** @typedef {(a: Module, b: Module) => -1 | 0 | 1} ModuleComparator */
|
244
|
+
|
240
245
|
class ChunkGraph {
|
241
246
|
/**
|
242
247
|
* @param {ModuleGraph} moduleGraph the module graph
|
243
248
|
* @param {string | Hash} hashFunction the hash function to use
|
244
249
|
*/
|
245
|
-
constructor(moduleGraph, hashFunction =
|
250
|
+
constructor(moduleGraph, hashFunction = DEFAULTS.HASH_FUNCTION) {
|
246
251
|
/**
|
247
252
|
* @private
|
248
253
|
* @type {WeakMap<Module, ChunkGraphModule>}
|
@@ -535,7 +540,7 @@ class ChunkGraph {
|
|
535
540
|
|
536
541
|
/**
|
537
542
|
* @param {Module} module the module
|
538
|
-
* @param {
|
543
|
+
* @param {(a: Chunk, b: Chunk) => -1 | 0 | 1} sortFn sort function
|
539
544
|
* @returns {Iterable<Chunk>} iterable of chunks (do not modify)
|
540
545
|
*/
|
541
546
|
getOrderedModuleChunksIterable(module, sortFn) {
|
@@ -686,7 +691,7 @@ class ChunkGraph {
|
|
686
691
|
|
687
692
|
/**
|
688
693
|
* @param {Chunk} chunk the chunk
|
689
|
-
* @param {
|
694
|
+
* @param {ModuleComparator} comparator comparator function
|
690
695
|
* @returns {Iterable<Module>} return the modules for this chunk
|
691
696
|
*/
|
692
697
|
getOrderedChunkModulesIterable(chunk, comparator) {
|
@@ -698,7 +703,7 @@ class ChunkGraph {
|
|
698
703
|
/**
|
699
704
|
* @param {Chunk} chunk the chunk
|
700
705
|
* @param {string} sourceType source type
|
701
|
-
* @param {
|
706
|
+
* @param {ModuleComparator} comparator comparator function
|
702
707
|
* @returns {Iterable<Module> | undefined} return the modules for this chunk
|
703
708
|
*/
|
704
709
|
getOrderedChunkModulesIterableBySourceType(chunk, sourceType, comparator) {
|
@@ -722,7 +727,7 @@ class ChunkGraph {
|
|
722
727
|
|
723
728
|
/**
|
724
729
|
* @param {Chunk} chunk the chunk
|
725
|
-
* @param {
|
730
|
+
* @param {ModuleComparator} comparator comparator function
|
726
731
|
* @returns {Module[]} return the modules for this chunk (cached, do not modify)
|
727
732
|
*/
|
728
733
|
getOrderedChunkModules(chunk, comparator) {
|
package/lib/ChunkTemplate.js
CHANGED
@@ -42,7 +42,7 @@ class ChunkTemplate {
|
|
42
42
|
/**
|
43
43
|
* @template AdditionalOptions
|
44
44
|
* @param {string | Tap & IfSet<AdditionalOptions>} options options
|
45
|
-
* @param {
|
45
|
+
* @param {(renderManifestEntries: RenderManifestEntry[], renderManifestOptions: RenderManifestOptions) => RenderManifestEntry[]} fn function
|
46
46
|
*/
|
47
47
|
(options, fn) => {
|
48
48
|
compilation.hooks.renderManifest.tap(
|
@@ -62,7 +62,7 @@ class ChunkTemplate {
|
|
62
62
|
/**
|
63
63
|
* @template AdditionalOptions
|
64
64
|
* @param {string | Tap & IfSet<AdditionalOptions>} options options
|
65
|
-
* @param {
|
65
|
+
* @param {(source: Source, moduleTemplate: ModuleTemplate, renderContext: RenderContext) => Source} fn function
|
66
66
|
*/
|
67
67
|
(options, fn) => {
|
68
68
|
getJavascriptModulesPlugin()
|
@@ -84,7 +84,7 @@ class ChunkTemplate {
|
|
84
84
|
/**
|
85
85
|
* @template AdditionalOptions
|
86
86
|
* @param {string | Tap & IfSet<AdditionalOptions>} options options
|
87
|
-
* @param {
|
87
|
+
* @param {(source: Source, moduleTemplate: ModuleTemplate, renderContext: RenderContext) => Source} fn function
|
88
88
|
*/
|
89
89
|
(options, fn) => {
|
90
90
|
getJavascriptModulesPlugin()
|
@@ -106,7 +106,7 @@ class ChunkTemplate {
|
|
106
106
|
/**
|
107
107
|
* @template AdditionalOptions
|
108
108
|
* @param {string | Tap & IfSet<AdditionalOptions>} options options
|
109
|
-
* @param {
|
109
|
+
* @param {(source: Source, chunk: Chunk) => Source} fn function
|
110
110
|
*/
|
111
111
|
(options, fn) => {
|
112
112
|
getJavascriptModulesPlugin()
|
@@ -132,7 +132,7 @@ class ChunkTemplate {
|
|
132
132
|
/**
|
133
133
|
* @template AdditionalOptions
|
134
134
|
* @param {string | Tap & IfSet<AdditionalOptions>} options options
|
135
|
-
* @param {
|
135
|
+
* @param {(hash: Hash) => void} fn function
|
136
136
|
*/
|
137
137
|
(options, fn) => {
|
138
138
|
compilation.hooks.fullHash.tap(options, fn);
|
@@ -146,7 +146,7 @@ class ChunkTemplate {
|
|
146
146
|
/**
|
147
147
|
* @template AdditionalOptions
|
148
148
|
* @param {string | Tap & IfSet<AdditionalOptions>} options options
|
149
|
-
* @param {
|
149
|
+
* @param {(hash: Hash, chunk: Chunk, chunkHashContext: ChunkHashContext) => void} fn function
|
150
150
|
*/
|
151
151
|
(options, fn) => {
|
152
152
|
getJavascriptModulesPlugin()
|
package/lib/CleanPlugin.js
CHANGED
@@ -19,9 +19,7 @@ const processAsyncTree = require("./util/processAsyncTree");
|
|
19
19
|
/** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
|
20
20
|
/** @typedef {import("./util/fs").StatsCallback} StatsCallback */
|
21
21
|
|
22
|
-
/** @typedef {(function(string):boolean)|RegExp} IgnoreItem */
|
23
22
|
/** @typedef {Map<string, number>} Assets */
|
24
|
-
/** @typedef {function(IgnoreItem): void} AddToIgnoreCallback */
|
25
23
|
|
26
24
|
/**
|
27
25
|
* @typedef {object} CleanPluginCompilationHooks
|
@@ -51,7 +49,7 @@ const validate = createSchemaValidation(
|
|
51
49
|
const _10sec = 10 * 1000;
|
52
50
|
|
53
51
|
/**
|
54
|
-
*
|
52
|
+
* merge assets map 2 into map 1
|
55
53
|
* @param {Assets} as1 assets
|
56
54
|
* @param {Assets} as2 assets
|
57
55
|
* @returns {void}
|
@@ -63,11 +61,13 @@ const mergeAssets = (as1, as2) => {
|
|
63
61
|
}
|
64
62
|
};
|
65
63
|
|
64
|
+
/** @typedef {Set<string>} Diff */
|
65
|
+
|
66
66
|
/**
|
67
67
|
* @param {OutputFileSystem} fs filesystem
|
68
68
|
* @param {string} outputPath output path
|
69
69
|
* @param {Map<string, number>} currentAssets filename of the current assets (must not start with .. or ., must only use / as path separator)
|
70
|
-
* @param {
|
70
|
+
* @param {(err?: Error | null, set?: Diff) => void} callback returns the filenames of the assets that shouldn't be there
|
71
71
|
* @returns {void}
|
72
72
|
*/
|
73
73
|
const getDiffToFs = (fs, outputPath, currentAssets, callback) => {
|
@@ -116,7 +116,7 @@ const getDiffToFs = (fs, outputPath, currentAssets, callback) => {
|
|
116
116
|
/**
|
117
117
|
* @param {Assets} currentAssets assets list
|
118
118
|
* @param {Assets} oldAssets old assets list
|
119
|
-
* @returns {
|
119
|
+
* @returns {Diff} diff
|
120
120
|
*/
|
121
121
|
const getDiffToOldAssets = (currentAssets, oldAssets) => {
|
122
122
|
const diff = new Set();
|
@@ -148,9 +148,9 @@ const doStat = (fs, filename, callback) => {
|
|
148
148
|
* @param {string} outputPath output path
|
149
149
|
* @param {boolean} dry only log instead of fs modification
|
150
150
|
* @param {Logger} logger logger
|
151
|
-
* @param {
|
152
|
-
* @param {
|
153
|
-
* @param {
|
151
|
+
* @param {Diff} diff filenames of the assets that shouldn't be there
|
152
|
+
* @param {(path: string) => boolean | void} isKept check if the entry is ignored
|
153
|
+
* @param {(err?: Error, assets?: Assets) => void} callback callback
|
154
154
|
* @returns {void}
|
155
155
|
*/
|
156
156
|
const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
|
@@ -402,7 +402,7 @@ class CleanPlugin {
|
|
402
402
|
|
403
403
|
/**
|
404
404
|
* @param {(Error | null)=} err err
|
405
|
-
* @param {
|
405
|
+
* @param {Diff=} diff diff
|
406
406
|
*/
|
407
407
|
const diffCallback = (err, diff) => {
|
408
408
|
if (err) {
|
@@ -415,7 +415,7 @@ class CleanPlugin {
|
|
415
415
|
outputPath,
|
416
416
|
dry,
|
417
417
|
logger,
|
418
|
-
/** @type {
|
418
|
+
/** @type {Diff} */ (diff),
|
419
419
|
isKept,
|
420
420
|
(err, keptAssets) => {
|
421
421
|
if (err) {
|
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const { DEFAULTS } = require("./config/defaults");
|
8
9
|
const { getOrInsert } = require("./util/MapHelpers");
|
9
10
|
const { first } = require("./util/SetHelpers");
|
10
11
|
const createHash = require("./util/createHash");
|
@@ -21,7 +22,7 @@ class CodeGenerationResults {
|
|
21
22
|
/**
|
22
23
|
* @param {string | Hash} hashFunction the hash function to use
|
23
24
|
*/
|
24
|
-
constructor(hashFunction =
|
25
|
+
constructor(hashFunction = DEFAULTS.HASH_FUNCTION) {
|
25
26
|
/** @type {Map<Module, RuntimeSpecMap<CodeGenerationResult>>} */
|
26
27
|
this.map = new Map();
|
27
28
|
this._hashFunction = hashFunction;
|
@@ -116,7 +117,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
116
117
|
* @param {Module} module the module
|
117
118
|
* @param {RuntimeSpec} runtime runtime(s)
|
118
119
|
* @param {string} key data key
|
119
|
-
* @returns {
|
120
|
+
* @returns {TODO | undefined} data generated by code generation
|
120
121
|
*/
|
121
122
|
getData(module, runtime, key) {
|
122
123
|
const data = this.get(module, runtime).data;
|
@@ -126,7 +127,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
126
127
|
/**
|
127
128
|
* @param {Module} module the module
|
128
129
|
* @param {RuntimeSpec} runtime runtime(s)
|
129
|
-
* @returns {
|
130
|
+
* @returns {string} hash of the code generation
|
130
131
|
*/
|
131
132
|
getHash(module, runtime) {
|
132
133
|
const info = this.get(module, runtime);
|
@@ -18,6 +18,7 @@ const ConstDependency = require("./dependencies/ConstDependency");
|
|
18
18
|
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
19
19
|
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
20
20
|
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
|
21
|
+
/** @typedef {import("./javascript/JavascriptParser").TagData} TagData */
|
21
22
|
|
22
23
|
const nestedWebpackIdentifierTag = Symbol("nested webpack identifier");
|
23
24
|
const PLUGIN_NAME = "CompatibilityPlugin";
|
@@ -145,7 +146,9 @@ class CompatibilityPlugin {
|
|
145
146
|
parser.hooks.expression
|
146
147
|
.for(nestedWebpackIdentifierTag)
|
147
148
|
.tap(PLUGIN_NAME, expr => {
|
148
|
-
const { name, declaration } =
|
149
|
+
const { name, declaration } =
|
150
|
+
/** @type {TagData} */
|
151
|
+
(parser.currentTagData);
|
149
152
|
if (!declaration.updated) {
|
150
153
|
const dep = new ConstDependency(name, declaration.range);
|
151
154
|
dep.loc = declaration.loc;
|