webpack 5.105.0 → 5.105.2
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 +2 -2
- package/lib/AsyncDependenciesBlock.js +5 -2
- package/lib/AsyncDependencyToInitialChunkError.js +2 -0
- package/lib/BannerPlugin.js +3 -1
- package/lib/Chunk.js +4 -4
- package/lib/ChunkRenderError.js +7 -2
- package/lib/Compilation.js +4 -0
- package/lib/Compiler.js +1 -1
- package/lib/DefinePlugin.js +12 -7
- package/lib/DynamicEntryPlugin.js +7 -1
- package/lib/ExternalModuleFactoryPlugin.js +9 -2
- package/lib/ExternalsPlugin.js +2 -1
- package/lib/IgnoreWarningsPlugin.js +5 -2
- package/lib/ManifestPlugin.js +4 -0
- package/lib/ModuleError.js +2 -0
- package/lib/ModuleFilenameHelpers.js +2 -1
- package/lib/NormalModule.js +2 -0
- package/lib/UnsupportedFeatureWarning.js +2 -0
- package/lib/WebpackOptionsApply.js +1 -1
- package/lib/asset/AssetGenerator.js +9 -0
- package/lib/asset/AssetParser.js +4 -0
- package/lib/container/ContainerEntryDependency.js +3 -0
- package/lib/container/ContainerEntryModule.js +3 -0
- package/lib/container/ContainerExposedDependency.js +1 -0
- package/lib/container/FallbackDependency.js +1 -0
- package/lib/container/FallbackItemDependency.js +1 -0
- package/lib/container/FallbackModule.js +2 -0
- package/lib/container/ModuleFederationPlugin.js +1 -1
- package/lib/container/RemoteModule.js +5 -0
- package/lib/dependencies/CssIcssExportDependency.js +2 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +2 -1
- package/lib/dependencies/HarmonyImportDependency.js +1 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +14 -11
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +1 -1
- package/lib/electron/ElectronTargetPlugin.js +3 -1
- package/lib/ids/ChunkModuleIdRangePlugin.js +7 -7
- package/lib/ids/DeterministicChunkIdsPlugin.js +1 -0
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -0
- package/lib/ids/HashedModuleIdsPlugin.js +3 -8
- package/lib/ids/NamedChunkIdsPlugin.js +7 -5
- package/lib/ids/NamedModuleIdsPlugin.js +1 -0
- package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +3 -3
- package/lib/ids/SyncModuleIdsPlugin.js +25 -19
- package/lib/json/JsonGenerator.js +1 -0
- package/lib/json/JsonParser.js +3 -2
- package/lib/logging/Logger.js +9 -5
- package/lib/logging/createConsoleLogger.js +2 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +5 -4
- package/lib/node/NodeEnvironmentPlugin.js +1 -0
- package/lib/node/NodeTargetPlugin.js +9 -1
- package/lib/node/NodeTemplatePlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +3 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -0
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +5 -0
- package/lib/optimize/LimitChunkCountPlugin.js +3 -2
- package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -1
- package/lib/optimize/RealContentHashPlugin.js +2 -0
- package/lib/optimize/RuntimeChunkPlugin.js +3 -5
- package/lib/optimize/SplitChunksPlugin.js +9 -2
- package/lib/performance/SizeLimitsPlugin.js +6 -6
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +2 -0
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -0
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -0
- package/lib/rules/RuleSetCompiler.js +4 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +1 -0
- package/lib/runtime/GetFullHashRuntimeModule.js +1 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -0
- package/lib/schemes/HttpUriPlugin.js +12 -13
- package/lib/schemes/VirtualUrlPlugin.js +21 -0
- package/lib/stats/DefaultStatsFactoryPlugin.js +6 -0
- package/lib/url/URLParserPlugin.js +1 -0
- package/lib/util/hash/BatchedHash.js +1 -0
- package/lib/util/hash/BulkUpdateHash.js +1 -0
- package/lib/util/hash/wasm-hash.js +2 -1
- package/lib/wasm/EnableWasmLoadingPlugin.js +1 -0
- package/lib/webpack.js +3 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -0
- package/package.json +15 -10
- package/schemas/WebpackOptions.json +50 -50
- package/schemas/plugins/BannerPlugin.json +2 -2
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/ManifestPlugin.json +3 -3
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
- package/schemas/plugins/schemes/HttpUriPlugin.json +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +100 -43
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ or packaging just about any resource or asset.
|
|
|
69
69
|
|
|
70
70
|
**TL;DR**
|
|
71
71
|
|
|
72
|
-
- Bundles [ES Modules](https://www.2ality.com/2014/09/es6-modules-final.html), [CommonJS](
|
|
72
|
+
- Bundles [ES Modules](https://www.2ality.com/2014/09/es6-modules-final.html), [CommonJS](https://wiki.commonjs.org/), and [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules (even combined).
|
|
73
73
|
- Can create a single bundle or multiple chunks that are asynchronously loaded at runtime (to reduce initial loading time).
|
|
74
74
|
- Dependencies are resolved during compilation, reducing the runtime size.
|
|
75
75
|
- Loaders can preprocess files while compiling, e.g. TypeScript to JavaScript, Handlebars strings to compiled functions, images to Base64, etc.
|
|
@@ -636,7 +636,7 @@ Before we started using OpenCollective, donations were made anonymously. Now tha
|
|
|
636
636
|
|
|
637
637
|
<p>(In chronological order)</p>
|
|
638
638
|
|
|
639
|
-
- [@google](https://github.com/google) for [Google Web Toolkit (GWT)](
|
|
639
|
+
- [@google](https://github.com/google) for [Google Web Toolkit (GWT)](https://www.gwtproject.org/), which aims to compile Java to JavaScript. It features a similar [Code Splitting](https://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html) as webpack.
|
|
640
640
|
- [@medikoo](https://github.com/medikoo) for [modules-webmake](https://github.com/medikoo/modules-webmake), which is a similar project. webpack was born because of the desire for code splitting for modules such as Webmake. Interestingly, the [Code Splitting issue is still open](https://github.com/medikoo/modules-webmake/issues/7) (thanks also to @Phoscur for the discussion).
|
|
641
641
|
- [@substack](https://github.com/substack) for [browserify](https://browserify.org/), which is a similar project and source for many ideas.
|
|
642
642
|
- [@jrburke](https://github.com/jrburke) for [require.js](https://requirejs.org/), which is a similar project and source for many ideas.
|
|
@@ -16,11 +16,11 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
16
16
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
17
17
|
/** @typedef {import("./util/Hash")} Hash */
|
|
18
18
|
|
|
19
|
-
/** @typedef {(ChunkGroupOptions & { entryOptions?: EntryOptions } & { circular?: boolean })
|
|
19
|
+
/** @typedef {(ChunkGroupOptions & { entryOptions?: EntryOptions } & { circular?: boolean })} GroupOptions */
|
|
20
20
|
|
|
21
21
|
class AsyncDependenciesBlock extends DependenciesBlock {
|
|
22
22
|
/**
|
|
23
|
-
* @param {GroupOptions | null} groupOptions options for the group
|
|
23
|
+
* @param {GroupOptions | string | null} groupOptions options for the group
|
|
24
24
|
* @param {(DependencyLocation | null)=} loc the line of code
|
|
25
25
|
* @param {(string | null)=} request the request
|
|
26
26
|
*/
|
|
@@ -35,8 +35,11 @@ class AsyncDependenciesBlock extends DependenciesBlock {
|
|
|
35
35
|
// default allow circular references
|
|
36
36
|
groupOptions.circular = true;
|
|
37
37
|
}
|
|
38
|
+
/** @type {GroupOptions} */
|
|
38
39
|
this.groupOptions = groupOptions;
|
|
40
|
+
/** @type {DependencyLocation | null | undefined} */
|
|
39
41
|
this.loc = loc;
|
|
42
|
+
/** @type {string | null | undefined} */
|
|
40
43
|
this.request = request;
|
|
41
44
|
/** @type {undefined | string} */
|
|
42
45
|
this._stringifiedGroupOptions = undefined;
|
|
@@ -24,7 +24,9 @@ class AsyncDependencyToInitialChunkError extends WebpackError {
|
|
|
24
24
|
|
|
25
25
|
/** @type {string} */
|
|
26
26
|
this.name = "AsyncDependencyToInitialChunkError";
|
|
27
|
+
/** @type {Module} */
|
|
27
28
|
this.module = module;
|
|
29
|
+
/** @type {DependencyLocation} */
|
|
28
30
|
this.loc = loc;
|
|
29
31
|
}
|
|
30
32
|
}
|
package/lib/BannerPlugin.js
CHANGED
|
@@ -12,12 +12,14 @@ const Template = require("./Template");
|
|
|
12
12
|
const createSchemaValidation = require("./util/create-schema-validation");
|
|
13
13
|
|
|
14
14
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
15
|
-
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerFunction} BannerFunction */
|
|
16
15
|
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginArgument} BannerPluginArgument */
|
|
17
16
|
/** @typedef {import("./Compilation").PathData} PathData */
|
|
18
17
|
/** @typedef {import("./Compiler")} Compiler */
|
|
18
|
+
/** @typedef {import("./Chunk")} Chunk */
|
|
19
19
|
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
|
20
20
|
|
|
21
|
+
/** @typedef {(data: { hash?: string, chunk: Chunk, filename: string }) => string} BannerFunction */
|
|
22
|
+
|
|
21
23
|
const validate = createSchemaValidation(
|
|
22
24
|
/** @type {((value: typeof import("../schemas/plugins/BannerPlugin.json")) => boolean)} */
|
|
23
25
|
(require("../schemas/plugins/BannerPlugin.check")),
|
package/lib/Chunk.js
CHANGED
|
@@ -67,6 +67,7 @@ const ChunkFilesSet = createArrayToSetDeprecationSet("chunk.files");
|
|
|
67
67
|
/** @typedef {SortableSet<ChunkGroup>} SortableChunkGroups */
|
|
68
68
|
/** @typedef {Record<string, ChunkId[]>} ChunkChildIdsByOrdersMap */
|
|
69
69
|
/** @typedef {Record<string, ChunkChildIdsByOrdersMap>} ChunkChildIdsByOrdersMapByData */
|
|
70
|
+
/** @typedef {{ onChunks: Chunk[], chunks: Chunks }} ChunkChildOfTypeInOrder */
|
|
70
71
|
|
|
71
72
|
let debugId = 1000;
|
|
72
73
|
|
|
@@ -774,7 +775,7 @@ class Chunk {
|
|
|
774
775
|
/**
|
|
775
776
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
776
777
|
* @param {string} type option name
|
|
777
|
-
* @returns {
|
|
778
|
+
* @returns {ChunkChildOfTypeInOrder[] | undefined} referenced chunks for a specific type
|
|
778
779
|
*/
|
|
779
780
|
getChildrenOfTypeInOrder(chunkGraph, type) {
|
|
780
781
|
/** @type {{ order: number, group: ChunkGroup, childGroup: ChunkGroup }[]} */
|
|
@@ -798,10 +799,9 @@ class Chunk {
|
|
|
798
799
|
if (cmp !== 0) return cmp;
|
|
799
800
|
return a.group.compareTo(chunkGraph, b.group);
|
|
800
801
|
});
|
|
801
|
-
/** @
|
|
802
|
-
/** @type {Entry[]} */
|
|
802
|
+
/** @type {ChunkChildOfTypeInOrder[]} */
|
|
803
803
|
const result = [];
|
|
804
|
-
/** @type {undefined |
|
|
804
|
+
/** @type {undefined | ChunkChildOfTypeInOrder} */
|
|
805
805
|
let lastEntry;
|
|
806
806
|
for (const { group, childGroup } of list) {
|
|
807
807
|
if (lastEntry && lastEntry.onChunks === group.chunks) {
|
package/lib/ChunkRenderError.js
CHANGED
|
@@ -21,11 +21,16 @@ class ChunkRenderError extends WebpackError {
|
|
|
21
21
|
|
|
22
22
|
/** @type {string} */
|
|
23
23
|
this.name = "ChunkRenderError";
|
|
24
|
+
/** @type {Chunk} */
|
|
25
|
+
this.chunk = chunk;
|
|
26
|
+
/** @type {string} */
|
|
27
|
+
this.file = file;
|
|
28
|
+
/** @type {Error} */
|
|
24
29
|
this.error = error;
|
|
30
|
+
/** @type {string} */
|
|
25
31
|
this.message = error.message;
|
|
32
|
+
/** @type {string} */
|
|
26
33
|
this.details = error.stack;
|
|
27
|
-
this.file = file;
|
|
28
|
-
this.chunk = chunk;
|
|
29
34
|
}
|
|
30
35
|
}
|
|
31
36
|
|
package/lib/Compilation.js
CHANGED
|
@@ -491,6 +491,8 @@ const compareErrors = concatComparators(byModule, byLocation, byMessage);
|
|
|
491
491
|
* @typedef {Module & { restoreFromUnsafeCache?: (unsafeCacheData: UnsafeCacheData, moduleFactory: ModuleFactory, compilationParams: CompilationParams) => void }} ModuleWithRestoreFromUnsafeCache
|
|
492
492
|
*/
|
|
493
493
|
|
|
494
|
+
/** @typedef {(module: Module) => boolean} UnsafeCachePredicate */
|
|
495
|
+
|
|
494
496
|
/** @type {WeakMap<Dependency, ModuleWithRestoreFromUnsafeCache | null>} */
|
|
495
497
|
const unsafeCacheDependencies = new WeakMap();
|
|
496
498
|
|
|
@@ -1260,7 +1262,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1260
1262
|
this._codeGenerationCache = this.getCache("Compilation/codeGeneration");
|
|
1261
1263
|
|
|
1262
1264
|
const unsafeCache = options.module.unsafeCache;
|
|
1265
|
+
/** @type {boolean} */
|
|
1263
1266
|
this._unsafeCache = Boolean(unsafeCache);
|
|
1267
|
+
/** @type {UnsafeCachePredicate} */
|
|
1264
1268
|
this._unsafeCachePredicate =
|
|
1265
1269
|
typeof unsafeCache === "function" ? unsafeCache : () => true;
|
|
1266
1270
|
}
|
package/lib/Compiler.js
CHANGED
|
@@ -39,7 +39,7 @@ const webpack = require(".");
|
|
|
39
39
|
/** @typedef {import("../declarations/WebpackOptions").WatchOptions} WatchOptions */
|
|
40
40
|
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
|
41
41
|
/** @typedef {import("../declarations/WebpackOptions").Plugins} Plugins */
|
|
42
|
-
/** @typedef {import("
|
|
42
|
+
/** @typedef {import("./webpack").WebpackPluginFunction} WebpackPluginFunction */
|
|
43
43
|
/** @typedef {import("./Chunk")} Chunk */
|
|
44
44
|
/** @typedef {import("./Dependency")} Dependency */
|
|
45
45
|
/** @typedef {import("./HotModuleReplacementPlugin").ChunkHashes} ChunkHashes */
|
package/lib/DefinePlugin.js
CHANGED
|
@@ -55,12 +55,14 @@ class RuntimeValue {
|
|
|
55
55
|
* @param {true | string[] | RuntimeValueOptions=} options options
|
|
56
56
|
*/
|
|
57
57
|
constructor(fn, options) {
|
|
58
|
+
/** @type {GeneratorFn} */
|
|
58
59
|
this.fn = fn;
|
|
59
60
|
if (Array.isArray(options)) {
|
|
60
61
|
options = {
|
|
61
62
|
fileDependencies: options
|
|
62
63
|
};
|
|
63
64
|
}
|
|
65
|
+
/** @type {true | RuntimeValueOptions} */
|
|
64
66
|
this.options = options || {};
|
|
65
67
|
}
|
|
66
68
|
|
|
@@ -338,6 +340,8 @@ const WEBPACK_REQUIRE_IDENTIFIER_REGEXP = new RegExp(RuntimeGlobals.require);
|
|
|
338
340
|
* @property {SyncWaterfallHook<[Record<string, CodeValue>]>} definitions
|
|
339
341
|
*/
|
|
340
342
|
|
|
343
|
+
/** @typedef {Record<string, CodeValue>} Definitions */
|
|
344
|
+
|
|
341
345
|
/** @type {WeakMap<Compilation, DefinePluginHooks>} */
|
|
342
346
|
const compilationHooksMap = new WeakMap();
|
|
343
347
|
|
|
@@ -359,9 +363,10 @@ class DefinePlugin {
|
|
|
359
363
|
|
|
360
364
|
/**
|
|
361
365
|
* Create a new define plugin
|
|
362
|
-
* @param {
|
|
366
|
+
* @param {Definitions} definitions A map of global object definitions
|
|
363
367
|
*/
|
|
364
368
|
constructor(definitions) {
|
|
369
|
+
/** @type {Definitions} */
|
|
365
370
|
this.definitions = definitions;
|
|
366
371
|
}
|
|
367
372
|
|
|
@@ -464,7 +469,7 @@ class DefinePlugin {
|
|
|
464
469
|
|
|
465
470
|
/**
|
|
466
471
|
* Walk definitions
|
|
467
|
-
* @param {
|
|
472
|
+
* @param {Definitions} definitions Definitions map
|
|
468
473
|
* @param {string} prefix Prefix string
|
|
469
474
|
* @returns {void}
|
|
470
475
|
*/
|
|
@@ -478,7 +483,7 @@ class DefinePlugin {
|
|
|
478
483
|
!(code instanceof RegExp)
|
|
479
484
|
) {
|
|
480
485
|
walkDefinitions(
|
|
481
|
-
/** @type {
|
|
486
|
+
/** @type {Definitions} */ (code),
|
|
482
487
|
`${prefix + key}.`
|
|
483
488
|
);
|
|
484
489
|
applyObjectDefine(prefix + key, code);
|
|
@@ -537,7 +542,7 @@ class DefinePlugin {
|
|
|
537
542
|
if (destructed === undefined) {
|
|
538
543
|
return;
|
|
539
544
|
}
|
|
540
|
-
/** @type {
|
|
545
|
+
/** @type {Definitions} */
|
|
541
546
|
const obj = Object.create(null);
|
|
542
547
|
const finalSet = finalByNestedKey.get(nested);
|
|
543
548
|
for (const { id } of destructed) {
|
|
@@ -784,7 +789,7 @@ class DefinePlugin {
|
|
|
784
789
|
|
|
785
790
|
/**
|
|
786
791
|
* Walk definitions
|
|
787
|
-
* @param {
|
|
792
|
+
* @param {Definitions} definitions Definitions map
|
|
788
793
|
* @param {string} prefix Prefix string
|
|
789
794
|
* @returns {void}
|
|
790
795
|
*/
|
|
@@ -812,7 +817,7 @@ class DefinePlugin {
|
|
|
812
817
|
!(code instanceof RegExp)
|
|
813
818
|
) {
|
|
814
819
|
walkDefinitionsForValues(
|
|
815
|
-
/** @type {
|
|
820
|
+
/** @type {Definitions} */ (code),
|
|
816
821
|
`${prefix + key}.`
|
|
817
822
|
);
|
|
818
823
|
}
|
|
@@ -820,7 +825,7 @@ class DefinePlugin {
|
|
|
820
825
|
};
|
|
821
826
|
|
|
822
827
|
/**
|
|
823
|
-
* @param {
|
|
828
|
+
* @param {Definitions} definitions Definitions map
|
|
824
829
|
* @returns {void}
|
|
825
830
|
*/
|
|
826
831
|
const walkDefinitionsForKeys = (definitions) => {
|
|
@@ -10,18 +10,24 @@ const EntryPlugin = require("./EntryPlugin");
|
|
|
10
10
|
const EntryDependency = require("./dependencies/EntryDependency");
|
|
11
11
|
|
|
12
12
|
/** @typedef {import("../declarations/WebpackOptions").EntryDescriptionNormalized} EntryDescriptionNormalized */
|
|
13
|
-
/** @typedef {import("../declarations/WebpackOptions").
|
|
13
|
+
/** @typedef {import("../declarations/WebpackOptions").EntryStatic} EntryStatic */
|
|
14
|
+
/** @typedef {import("../declarations/WebpackOptions").EntryStaticNormalized} EntryStaticNormalized */
|
|
14
15
|
/** @typedef {import("./Compiler")} Compiler */
|
|
15
16
|
|
|
16
17
|
const PLUGIN_NAME = "DynamicEntryPlugin";
|
|
17
18
|
|
|
19
|
+
/** @typedef {() => EntryStatic | Promise<EntryStatic>} RawEntryDynamic */
|
|
20
|
+
/** @typedef {() => Promise<EntryStaticNormalized>} EntryDynamic */
|
|
21
|
+
|
|
18
22
|
class DynamicEntryPlugin {
|
|
19
23
|
/**
|
|
20
24
|
* @param {string} context the context path
|
|
21
25
|
* @param {EntryDynamic} entry the entry value
|
|
22
26
|
*/
|
|
23
27
|
constructor(context, entry) {
|
|
28
|
+
/** @type {string} */
|
|
24
29
|
this.context = context;
|
|
30
|
+
/** @type {EntryDynamic} */
|
|
25
31
|
this.entry = entry;
|
|
26
32
|
}
|
|
27
33
|
|
|
@@ -17,10 +17,12 @@ const { cachedSetProperty, resolveByProperty } = require("./util/cleverMerge");
|
|
|
17
17
|
/** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */
|
|
18
18
|
/** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
|
|
19
19
|
/** @typedef {import("../declarations/WebpackOptions").ExternalsType} ExternalsType */
|
|
20
|
+
/** @typedef {import("../declarations/WebpackOptions").ExternalItem} ExternalItem */
|
|
20
21
|
/** @typedef {import("../declarations/WebpackOptions").ExternalItemValue} ExternalItemValue */
|
|
21
22
|
/** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectKnown} ExternalItemObjectKnown */
|
|
22
23
|
/** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectUnknown} ExternalItemObjectUnknown */
|
|
23
24
|
/** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
|
|
25
|
+
/** @typedef {import("./Dependency")} Dependency */
|
|
24
26
|
/** @typedef {import("./ExternalModule").DependencyMeta} DependencyMeta */
|
|
25
27
|
/** @typedef {import("./ModuleFactory").IssuerLayer} IssuerLayer */
|
|
26
28
|
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateDataContextInfo} ModuleFactoryCreateDataContextInfo */
|
|
@@ -61,6 +63,7 @@ const callDeprecatedExternals = util.deprecate(
|
|
|
61
63
|
"DEP_WEBPACK_EXTERNALS_FUNCTION_PARAMETERS"
|
|
62
64
|
);
|
|
63
65
|
|
|
66
|
+
/** @typedef {(layer: string | null) => ExternalItem} ExternalItemByLayerFn */
|
|
64
67
|
/** @typedef {ExternalItemObjectKnown & ExternalItemObjectUnknown} ExternalItemObject */
|
|
65
68
|
|
|
66
69
|
/**
|
|
@@ -96,7 +99,7 @@ const PLUGIN_NAME = "ExternalModuleFactoryPlugin";
|
|
|
96
99
|
|
|
97
100
|
class ExternalModuleFactoryPlugin {
|
|
98
101
|
/**
|
|
99
|
-
* @param {ExternalsType} type default external type
|
|
102
|
+
* @param {ExternalsType | ((dependency: Dependency) => ExternalsType)} type default external type
|
|
100
103
|
* @param {Externals} externals externals config
|
|
101
104
|
*/
|
|
102
105
|
constructor(type, externals) {
|
|
@@ -159,7 +162,11 @@ class ExternalModuleFactoryPlugin {
|
|
|
159
162
|
}
|
|
160
163
|
}
|
|
161
164
|
|
|
162
|
-
const
|
|
165
|
+
const defaultType =
|
|
166
|
+
typeof globalType === "function"
|
|
167
|
+
? globalType(dependency)
|
|
168
|
+
: globalType;
|
|
169
|
+
const resolvedType = type || defaultType;
|
|
163
170
|
|
|
164
171
|
// TODO make it pluggable/add hooks to `ExternalModule` to allow output modules own externals?
|
|
165
172
|
/** @type {DependencyMeta | undefined} */
|
package/lib/ExternalsPlugin.js
CHANGED
|
@@ -13,12 +13,13 @@ const ConcatenatedModule = require("./optimize/ConcatenatedModule");
|
|
|
13
13
|
/** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
|
|
14
14
|
/** @typedef {import("./Compiler")} Compiler */
|
|
15
15
|
/** @typedef {import("./ExternalModule").Imported} Imported */
|
|
16
|
+
/** @typedef {import("./Dependency")} Dependency */
|
|
16
17
|
|
|
17
18
|
const PLUGIN_NAME = "ExternalsPlugin";
|
|
18
19
|
|
|
19
20
|
class ExternalsPlugin {
|
|
20
21
|
/**
|
|
21
|
-
* @param {ExternalsType} type default external type
|
|
22
|
+
* @param {ExternalsType | ((dependency: Dependency) => ExternalsType)} type default external type
|
|
22
23
|
* @param {Externals} externals externals config
|
|
23
24
|
*/
|
|
24
25
|
constructor(type, externals) {
|
|
@@ -5,16 +5,19 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
/** @typedef {import("../declarations/WebpackOptions").IgnoreWarningsNormalized} IgnoreWarningsNormalized */
|
|
9
8
|
/** @typedef {import("./Compiler")} Compiler */
|
|
9
|
+
/** @typedef {import("./Compilation")} Compilation */
|
|
10
|
+
|
|
11
|
+
/** @typedef {(warning: Error, compilation: Compilation) => boolean} IgnoreFn */
|
|
10
12
|
|
|
11
13
|
const PLUGIN_NAME = "IgnoreWarningsPlugin";
|
|
12
14
|
|
|
13
15
|
class IgnoreWarningsPlugin {
|
|
14
16
|
/**
|
|
15
|
-
* @param {
|
|
17
|
+
* @param {IgnoreFn[]} ignoreWarnings conditions to ignore warnings
|
|
16
18
|
*/
|
|
17
19
|
constructor(ignoreWarnings) {
|
|
20
|
+
/** @type {IgnoreFn[]} */
|
|
18
21
|
this._ignoreWarnings = ignoreWarnings;
|
|
19
22
|
}
|
|
20
23
|
|
package/lib/ManifestPlugin.js
CHANGED
|
@@ -22,6 +22,10 @@ const createSchemaValidation = require("./util/create-schema-validation");
|
|
|
22
22
|
/** @typedef {import("../declarations/plugins/ManifestPlugin").ManifestEntrypoint} ManifestEntrypoint */
|
|
23
23
|
/** @typedef {import("../declarations/plugins/ManifestPlugin").ManifestItem} ManifestItem */
|
|
24
24
|
|
|
25
|
+
/** @typedef {(item: ManifestItem) => boolean} Filter */
|
|
26
|
+
/** @typedef {(manifest: ManifestObject) => ManifestObject} Generate */
|
|
27
|
+
/** @typedef {(manifest: ManifestObject) => string} Serialize */
|
|
28
|
+
|
|
25
29
|
const PLUGIN_NAME = "ManifestPlugin";
|
|
26
30
|
|
|
27
31
|
const validate = createSchemaValidation(
|
package/lib/ModuleError.js
CHANGED
|
@@ -32,7 +32,9 @@ class ModuleError extends WebpackError {
|
|
|
32
32
|
|
|
33
33
|
/** @type {string} */
|
|
34
34
|
this.name = "ModuleError";
|
|
35
|
+
/** @type {Error} */
|
|
35
36
|
this.error = err;
|
|
37
|
+
/** @type {string | undefined} */
|
|
36
38
|
this.details =
|
|
37
39
|
err && typeof err === "object" && err.stack
|
|
38
40
|
? cleanUp(err.stack, this.message)
|
|
@@ -15,7 +15,8 @@ const memoize = require("./util/memoize");
|
|
|
15
15
|
/** @typedef {import("./Module")} Module */
|
|
16
16
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
|
17
17
|
|
|
18
|
-
/** @typedef {
|
|
18
|
+
/** @typedef {(str: string) => boolean} MatcherFn */
|
|
19
|
+
/** @typedef {string | RegExp | MatcherFn | (string | RegExp | MatcherFn)[]} Matcher */
|
|
19
20
|
/** @typedef {{ test?: Matcher, include?: Matcher, exclude?: Matcher }} MatchObject */
|
|
20
21
|
|
|
21
22
|
const ModuleFilenameHelpers = module.exports;
|
package/lib/NormalModule.js
CHANGED
|
@@ -116,6 +116,8 @@ const memoize = require("./util/memoize");
|
|
|
116
116
|
* @typedef {import("../declarations/LoaderContext").NormalModuleLoaderContext<T>} NormalModuleLoaderContext
|
|
117
117
|
*/
|
|
118
118
|
|
|
119
|
+
/** @typedef {(content: string) => boolean} NoParseFn */
|
|
120
|
+
|
|
119
121
|
const getInvalidDependenciesModuleWarning = memoize(() =>
|
|
120
122
|
require("./InvalidDependenciesModuleWarning")
|
|
121
123
|
);
|
|
@@ -74,7 +74,7 @@ const DefaultStatsPrinterPlugin = require("./stats/DefaultStatsPrinterPlugin");
|
|
|
74
74
|
|
|
75
75
|
const { cleverMerge } = require("./util/cleverMerge");
|
|
76
76
|
|
|
77
|
-
/** @typedef {import("
|
|
77
|
+
/** @typedef {import("./webpack").WebpackPluginFunction} WebpackPluginFunction */
|
|
78
78
|
/** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
79
79
|
/** @typedef {import("./config/normalization").WebpackOptionsInterception} WebpackOptionsInterception */
|
|
80
80
|
/** @typedef {import("./Compiler")} Compiler */
|
|
@@ -43,6 +43,7 @@ const getMimeTypes = memoize(() => require("mime-types"));
|
|
|
43
43
|
/** @typedef {import("../Compilation").AssetInfo} AssetInfo */
|
|
44
44
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
|
45
45
|
/** @typedef {import("../Generator").UpdateHashContext} UpdateHashContext */
|
|
46
|
+
/** @typedef {import("../Module")} Module */
|
|
46
47
|
/** @typedef {import("../Module").NameForCondition} NameForCondition */
|
|
47
48
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
48
49
|
/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
|
@@ -54,6 +55,8 @@ const getMimeTypes = memoize(() => require("mime-types"));
|
|
|
54
55
|
/** @typedef {import("../util/Hash")} Hash */
|
|
55
56
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
56
57
|
|
|
58
|
+
/** @typedef {(source: string | Buffer, context: { filename: string, module: Module }) => string} DataUrlFunction */
|
|
59
|
+
|
|
57
60
|
/**
|
|
58
61
|
* @template T
|
|
59
62
|
* @template U
|
|
@@ -205,11 +208,17 @@ class AssetGenerator extends Generator {
|
|
|
205
208
|
emit
|
|
206
209
|
) {
|
|
207
210
|
super();
|
|
211
|
+
/** @type {AssetGeneratorOptions["dataUrl"] | undefined} */
|
|
208
212
|
this.dataUrlOptions = dataUrlOptions;
|
|
213
|
+
/** @type {AssetModuleFilename | undefined} */
|
|
209
214
|
this.filename = filename;
|
|
215
|
+
/** @type {RawPublicPath | undefined} */
|
|
210
216
|
this.publicPath = publicPath;
|
|
217
|
+
/** @type {AssetModuleOutputPath | undefined} */
|
|
211
218
|
this.outputPath = outputPath;
|
|
219
|
+
/** @type {boolean | undefined} */
|
|
212
220
|
this.emit = emit;
|
|
221
|
+
/** @type {ModuleGraph} */
|
|
213
222
|
this._moduleGraph = moduleGraph;
|
|
214
223
|
}
|
|
215
224
|
|
package/lib/asset/AssetParser.js
CHANGED
|
@@ -9,17 +9,21 @@ const Parser = require("../Parser");
|
|
|
9
9
|
|
|
10
10
|
/** @typedef {import("../../declarations/WebpackOptions").AssetParserDataUrlOptions} AssetParserDataUrlOptions */
|
|
11
11
|
/** @typedef {import("../../declarations/WebpackOptions").AssetParserOptions} AssetParserOptions */
|
|
12
|
+
/** @typedef {import("../Module")} Module */
|
|
12
13
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
13
14
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
14
15
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
|
15
16
|
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
|
16
17
|
|
|
18
|
+
/** @typedef {((source: string | Buffer, context: { filename: string, module: Module }) => boolean)} AssetParserDataUrlFunction */
|
|
19
|
+
|
|
17
20
|
class AssetParser extends Parser {
|
|
18
21
|
/**
|
|
19
22
|
* @param {AssetParserOptions["dataUrlCondition"] | boolean} dataUrlCondition condition for inlining as DataUrl
|
|
20
23
|
*/
|
|
21
24
|
constructor(dataUrlCondition) {
|
|
22
25
|
super();
|
|
26
|
+
/** @type {AssetParserOptions["dataUrlCondition"] | boolean} */
|
|
23
27
|
this.dataUrlCondition = dataUrlCondition;
|
|
24
28
|
}
|
|
25
29
|
|
|
@@ -18,8 +18,11 @@ class ContainerEntryDependency extends Dependency {
|
|
|
18
18
|
*/
|
|
19
19
|
constructor(name, exposes, shareScope) {
|
|
20
20
|
super();
|
|
21
|
+
/** @type {string} */
|
|
21
22
|
this.name = name;
|
|
23
|
+
/** @type {ExposesList} */
|
|
22
24
|
this.exposes = exposes;
|
|
25
|
+
/** @type {string} */
|
|
23
26
|
this.shareScope = shareScope;
|
|
24
27
|
}
|
|
25
28
|
|
|
@@ -52,8 +52,11 @@ class ContainerEntryModule extends Module {
|
|
|
52
52
|
*/
|
|
53
53
|
constructor(name, exposes, shareScope) {
|
|
54
54
|
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);
|
|
55
|
+
/** @type {string} */
|
|
55
56
|
this._name = name;
|
|
57
|
+
/** @type {ExposesList} */
|
|
56
58
|
this._exposes = exposes;
|
|
59
|
+
/** @type {string} */
|
|
57
60
|
this._shareScope = shareScope;
|
|
58
61
|
}
|
|
59
62
|
|
|
@@ -45,7 +45,9 @@ class FallbackModule extends Module {
|
|
|
45
45
|
*/
|
|
46
46
|
constructor(requests) {
|
|
47
47
|
super(WEBPACK_MODULE_TYPE_FALLBACK);
|
|
48
|
+
/** @type {ExternalRequests} */
|
|
48
49
|
this.requests = requests;
|
|
50
|
+
/** @type {string} */
|
|
49
51
|
this._identifier = `fallback ${this.requests.join(" ")}`;
|
|
50
52
|
}
|
|
51
53
|
|
|
@@ -48,10 +48,15 @@ class RemoteModule extends Module {
|
|
|
48
48
|
*/
|
|
49
49
|
constructor(request, externalRequests, internalRequest, shareScope) {
|
|
50
50
|
super(WEBPACK_MODULE_TYPE_REMOTE);
|
|
51
|
+
/** @type {string} */
|
|
51
52
|
this.request = request;
|
|
53
|
+
/** @type {ExternalRequests} */
|
|
52
54
|
this.externalRequests = externalRequests;
|
|
55
|
+
/** @type {string} */
|
|
53
56
|
this.internalRequest = internalRequest;
|
|
57
|
+
/** @type {string} */
|
|
54
58
|
this.shareScope = shareScope;
|
|
59
|
+
/** @type {string} */
|
|
55
60
|
this._identifier = `remote (${shareScope}) ${this.externalRequests.join(
|
|
56
61
|
" "
|
|
57
62
|
)} ${this.internalRequest}`;
|
|
@@ -37,6 +37,8 @@ const getCssParser = memoize(() => require("../css/CssParser"));
|
|
|
37
37
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
38
38
|
/** @typedef {import("../css/CssParser").Range} Range */
|
|
39
39
|
|
|
40
|
+
/** @typedef {(name: string) => string} ExportsConventionFn */
|
|
41
|
+
|
|
40
42
|
/**
|
|
41
43
|
* @param {string} local css local
|
|
42
44
|
* @param {CssModule} module module
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const makeSerializable = require("../util/makeSerializable");
|
|
9
|
+
const { ExportPresenceModes } = require("./HarmonyImportDependency");
|
|
9
10
|
const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
|
|
10
11
|
const { ImportPhase } = require("./ImportPhase");
|
|
11
12
|
|
|
@@ -44,7 +45,7 @@ class HarmonyEvaluatedImportSpecifierDependency extends HarmonyImportSpecifierDe
|
|
|
44
45
|
ids,
|
|
45
46
|
name,
|
|
46
47
|
range,
|
|
47
|
-
|
|
48
|
+
ExportPresenceModes.NONE,
|
|
48
49
|
ImportPhase.Evaluation,
|
|
49
50
|
attributes,
|
|
50
51
|
[]
|
|
@@ -29,7 +29,7 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
29
29
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
30
30
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
31
31
|
|
|
32
|
-
/** @typedef {0 | 1 | 2 | 3
|
|
32
|
+
/** @typedef {0 | 1 | 2 | 3} ExportPresenceMode */
|
|
33
33
|
|
|
34
34
|
const ExportPresenceModes = {
|
|
35
35
|
NONE: /** @type {ExportPresenceMode} */ (0),
|