webpack 5.106.2 → 5.107.1
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/APIPlugin.js +1 -1
- package/lib/BannerPlugin.js +3 -4
- package/lib/Cache.js +3 -6
- package/lib/Chunk.js +21 -25
- package/lib/ChunkGroup.js +57 -15
- package/lib/CompatibilityPlugin.js +8 -7
- package/lib/Compilation.js +67 -37
- package/lib/Compiler.js +4 -13
- package/lib/ContextModule.js +2 -2
- package/lib/DefinePlugin.js +2 -2
- package/lib/Dependency.js +22 -1
- package/lib/DependencyTemplate.js +2 -1
- package/lib/EnvironmentPlugin.js +1 -1
- package/lib/EvalSourceMapDevToolPlugin.js +8 -10
- package/lib/ExportsInfo.js +30 -34
- package/lib/ExternalModule.js +91 -26
- package/lib/ExternalModuleFactoryPlugin.js +7 -1
- package/lib/FileSystemInfo.js +187 -72
- package/lib/Generator.js +3 -3
- package/lib/HotModuleReplacementPlugin.js +26 -8
- package/lib/IgnorePlugin.js +2 -1
- package/lib/Module.js +20 -19
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleNotFoundError.js +3 -84
- package/lib/ModuleSourceTypeConstants.js +51 -19
- package/lib/ModuleTypeConstants.js +12 -3
- package/lib/MultiCompiler.js +2 -2
- package/lib/NodeStuffPlugin.js +1 -1
- package/lib/NormalModule.js +119 -77
- package/lib/NormalModuleFactory.js +47 -27
- package/lib/Parser.js +1 -1
- package/lib/ProgressPlugin.js +129 -56
- package/lib/RuntimeGlobals.js +5 -5
- package/lib/RuntimeModule.js +9 -7
- package/lib/RuntimePlugin.js +12 -1
- package/lib/SourceMapDevToolPlugin.js +250 -49
- package/lib/Template.js +1 -1
- package/lib/TemplatedPathPlugin.js +22 -4
- package/lib/WarnCaseSensitiveModulesPlugin.js +70 -2
- package/lib/WarnDeprecatedOptionPlugin.js +1 -1
- package/lib/WarnNoModeSetPlugin.js +16 -1
- package/lib/Watching.js +2 -3
- package/lib/WebpackError.js +3 -77
- package/lib/WebpackIsIncludedPlugin.js +1 -1
- package/lib/WebpackOptionsApply.js +13 -1
- package/lib/asset/AssetBytesGenerator.js +12 -8
- package/lib/asset/AssetGenerator.js +36 -22
- package/lib/asset/AssetModulesPlugin.js +6 -8
- package/lib/asset/AssetSourceGenerator.js +12 -8
- package/lib/buildChunkGraph.js +4 -6
- package/lib/cache/PackFileCacheStrategy.js +4 -4
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +197 -10
- package/lib/config/normalization.js +3 -1
- package/lib/css/CssGenerator.js +320 -105
- package/lib/css/CssInjectStyleRuntimeModule.js +44 -42
- package/lib/css/CssLoadingRuntimeModule.js +22 -4
- package/lib/{CssModule.js → css/CssModule.js} +15 -15
- package/lib/css/CssModulesPlugin.js +168 -88
- package/lib/css/CssParser.js +566 -269
- package/lib/css/walkCssTokens.js +148 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +63 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +54 -10
- package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsFullRequireDependency.js +32 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +112 -4
- package/lib/dependencies/CommonJsRequireDependency.js +67 -4
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +1 -1
- package/lib/dependencies/CreateRequireParserPlugin.js +1 -1
- package/lib/dependencies/CriticalDependencyWarning.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +332 -67
- package/lib/dependencies/CssIcssImportDependency.js +49 -7
- package/lib/dependencies/CssIcssSymbolDependency.js +11 -3
- package/lib/dependencies/CssImportDependency.js +8 -0
- package/lib/dependencies/CssUrlDependency.js +28 -2
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +22 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +8 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +22 -14
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +110 -3
- package/lib/dependencies/HarmonyImportDependency.js +10 -2
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +22 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +1 -1
- package/lib/{HarmonyLinkingError.js → dependencies/HarmonyLinkingError.js} +5 -3
- package/lib/dependencies/HtmlInlineScriptDependency.js +133 -0
- package/lib/dependencies/HtmlInlineStyleDependency.js +101 -0
- package/lib/dependencies/HtmlScriptSrcDependency.js +557 -0
- package/lib/dependencies/HtmlSourceDependency.js +128 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportParserPlugin.js +2 -2
- package/lib/dependencies/ImportPhase.js +1 -1
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +1 -1
- package/lib/{RequireJsStuffPlugin.js → dependencies/RequireJsStuffPlugin.js} +7 -7
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/WebAssemblyImportDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/{DelegatedModule.js → dll/DelegatedModule.js} +31 -31
- package/lib/{DelegatedModuleFactoryPlugin.js → dll/DelegatedModuleFactoryPlugin.js} +4 -4
- package/lib/{DelegatedPlugin.js → dll/DelegatedPlugin.js} +2 -2
- package/lib/{DllEntryPlugin.js → dll/DllEntryPlugin.js} +4 -4
- package/lib/{DllModule.js → dll/DllModule.js} +24 -24
- package/lib/{DllModuleFactory.js → dll/DllModuleFactory.js} +4 -4
- package/lib/{DllPlugin.js → dll/DllPlugin.js} +6 -5
- package/lib/{DllReferencePlugin.js → dll/DllReferencePlugin.js} +14 -14
- package/lib/{LibManifestPlugin.js → dll/LibManifestPlugin.js} +9 -9
- package/lib/{AsyncDependencyToInitialChunkError.js → errors/AsyncDependencyToInitialChunkError.js} +2 -2
- package/lib/errors/BuildCycleError.js +1 -1
- package/lib/{ChunkRenderError.js → errors/ChunkRenderError.js} +1 -1
- package/lib/{CodeGenerationError.js → errors/CodeGenerationError.js} +1 -1
- package/lib/{CommentCompilationWarning.js → errors/CommentCompilationWarning.js} +3 -3
- package/lib/{ConcurrentCompilationError.js → errors/ConcurrentCompilationError.js} +4 -2
- package/lib/{EnvironmentNotSupportAsyncWarning.js → errors/EnvironmentNotSupportAsyncWarning.js} +4 -4
- package/lib/{HookWebpackError.js → errors/HookWebpackError.js} +5 -5
- package/lib/{IgnoreErrorModuleFactory.js → errors/IgnoreErrorModuleFactory.js} +4 -4
- package/lib/{InvalidDependenciesModuleWarning.js → errors/InvalidDependenciesModuleWarning.js} +3 -3
- package/lib/errors/JSONParseError.js +114 -0
- package/lib/{ModuleBuildError.js → errors/ModuleBuildError.js} +5 -5
- package/lib/{ModuleDependencyError.js → errors/ModuleDependencyError.js} +2 -2
- package/lib/{ModuleDependencyWarning.js → errors/ModuleDependencyWarning.js} +4 -4
- package/lib/{ModuleError.js → errors/ModuleError.js} +5 -5
- package/lib/{ModuleHashingError.js → errors/ModuleHashingError.js} +1 -1
- package/lib/errors/ModuleNotFoundError.js +91 -0
- package/lib/{ModuleParseError.js → errors/ModuleParseError.js} +8 -6
- package/lib/{ModuleRestoreError.js → errors/ModuleRestoreError.js} +1 -1
- package/lib/{ModuleStoreError.js → errors/ModuleStoreError.js} +1 -1
- package/lib/{ModuleWarning.js → errors/ModuleWarning.js} +5 -5
- package/lib/{NodeStuffInWebError.js → errors/NodeStuffInWebError.js} +4 -4
- package/lib/errors/NonErrorEmittedError.js +28 -0
- package/lib/{UnhandledSchemeError.js → errors/UnhandledSchemeError.js} +2 -2
- package/lib/{UnsupportedFeatureWarning.js → errors/UnsupportedFeatureWarning.js} +3 -3
- package/lib/errors/WebpackError.js +84 -0
- package/lib/html/HtmlGenerator.js +379 -0
- package/lib/html/HtmlModulesPlugin.js +429 -0
- package/lib/html/HtmlParser.js +1489 -0
- package/lib/html/walkHtmlTokens.js +3249 -0
- package/lib/ids/IdHelpers.js +2 -1
- package/lib/index.js +36 -15
- package/lib/javascript/JavascriptModulesPlugin.js +91 -10
- package/lib/javascript/JavascriptParser.js +197 -16
- package/lib/javascript/JavascriptParserHelpers.js +1 -1
- package/lib/json/JsonParser.js +7 -16
- package/lib/library/AbstractLibraryPlugin.js +1 -1
- package/lib/library/EnableLibraryPlugin.js +1 -1
- package/lib/{FalseIIFEUmdWarning.js → library/FalseIIFEUmdWarning.js} +1 -1
- package/lib/library/ModuleLibraryPlugin.js +74 -0
- package/lib/node/NodeEnvironmentPlugin.js +4 -2
- package/lib/node/nodeConsole.js +113 -64
- package/lib/optimize/ConcatenatedModule.js +51 -6
- package/lib/optimize/InnerGraph.js +1 -1
- package/lib/optimize/InnerGraphPlugin.js +11 -1
- package/lib/optimize/MinMaxSizeWarning.js +4 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +15 -7
- package/lib/optimize/RealContentHashPlugin.js +89 -26
- package/lib/optimize/SideEffectsFlagPlugin.js +112 -5
- package/lib/optimize/SplitChunksPlugin.js +5 -5
- package/lib/performance/AssetsOverSizeLimitWarning.js +2 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
- package/lib/performance/NoAsyncChunksWarning.js +5 -3
- package/lib/performance/SizeLimitsPlugin.js +1 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -1
- package/lib/rules/UseEffectRulePlugin.js +4 -3
- package/lib/runtime/AutoPublicPathRuntimeModule.js +3 -3
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -5
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +119 -13
- package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +35 -0
- package/lib/schemes/DataUriPlugin.js +13 -1
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/sharing/ConsumeSharedPlugin.js +4 -10
- package/lib/sharing/ConsumeSharedRuntimeModule.js +8 -4
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +5 -5
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +2 -2
- package/lib/stats/DefaultStatsPresetPlugin.js +1 -1
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/stats/StatsFactory.js +1 -1
- package/lib/typescript/TypeScriptPlugin.js +210 -0
- package/lib/url/URLParserPlugin.js +2 -2
- package/lib/util/AsyncQueue.js +2 -2
- package/lib/util/Hash.js +2 -2
- package/lib/util/LocConverter.js +53 -0
- package/lib/util/SortableSet.js +1 -1
- package/lib/util/cleverMerge.js +2 -2
- package/lib/util/comparators.js +3 -3
- package/lib/util/concatenate.js +3 -3
- package/lib/util/conventions.js +42 -1
- package/lib/util/createMappings.js +118 -0
- package/lib/{formatLocation.js → util/formatLocation.js} +2 -2
- package/lib/{SizeFormatHelpers.js → util/formatSize.js} +3 -1
- package/lib/util/fs.js +8 -8
- package/lib/util/hash/md4.js +1 -1
- package/lib/util/hash/xxhash64.js +1 -1
- package/lib/util/identifier.js +48 -0
- package/lib/util/internalSerializables.js +35 -19
- package/lib/util/magicComment.js +10 -7
- package/lib/util/parseJson.js +2 -73
- package/lib/util/source.js +21 -0
- package/lib/util/topologicalSort.js +69 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -4
- package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +1 -1
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +5 -3
- package/lib/webpack.js +3 -1
- package/package.json +24 -22
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +129 -12
- package/schemas/plugins/{DllPlugin.check.d.ts → HtmlGeneratorOptions.check.d.ts} +1 -1
- package/schemas/plugins/HtmlGeneratorOptions.check.js +6 -0
- package/schemas/plugins/HtmlGeneratorOptions.json +3 -0
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +22 -0
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
- package/schemas/plugins/{DllReferencePlugin.check.d.ts → css/CssAutoOrModuleParserOptions.check.d.ts} +1 -1
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.json +3 -0
- package/schemas/plugins/dll/DllPlugin.check.d.ts +7 -0
- package/schemas/plugins/dll/DllReferencePlugin.check.d.ts +7 -0
- package/types.d.ts +1153 -233
- package/lib/CaseSensitiveModulesWarning.js +0 -80
- package/lib/GraphHelpers.js +0 -49
- package/lib/NoModeWarning.js +0 -23
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +0 -57
- /package/lib/{AbstractMethodError.js → errors/AbstractMethodError.js} +0 -0
- /package/schemas/plugins/{DllPlugin.check.js → dll/DllPlugin.check.js} +0 -0
- /package/schemas/plugins/{DllPlugin.json → dll/DllPlugin.json} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.check.js → dll/DllReferencePlugin.check.js} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.json → dll/DllReferencePlugin.json} +0 -0
package/README.md
CHANGED
|
@@ -302,12 +302,12 @@ For information about the governance of the webpack project, see [GOVERNANCE.md]
|
|
|
302
302
|
|
|
303
303
|
- [alexander-akait](https://github.com/alexander-akait) -
|
|
304
304
|
**Alexander Akait** <<sheo13666q@gmail.com>> (he/him)
|
|
305
|
+
- [avivkeller](https://github.com/avivkeller) -
|
|
306
|
+
**Aviv Keller** <<me@aviv.sh>> (he/him)
|
|
305
307
|
- [evenstensberg](https://github.com/evenstensberg) -
|
|
306
308
|
**Even Stensberg** <<evenstensberg@gmail.com>> (he/him)
|
|
307
309
|
- [ovflowd](https://github.com/ovflowd) -
|
|
308
310
|
**Claudio Wunder** <<cwunder@gnome.org>> (he/they)
|
|
309
|
-
- [snitin315](https://github.com/snitin315) -
|
|
310
|
-
**Nitin Kumar** <<snitin315@gmail.com>> (he/him)
|
|
311
311
|
- [thelarkinn](https://github.com/thelarkinn) -
|
|
312
312
|
**Sean Larkin** <<selarkin@microsoft.com>> (he/him)
|
|
313
313
|
|
package/lib/APIPlugin.js
CHANGED
|
@@ -14,10 +14,10 @@ const {
|
|
|
14
14
|
JAVASCRIPT_MODULE_TYPE_ESM
|
|
15
15
|
} = require("./ModuleTypeConstants");
|
|
16
16
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
|
17
|
-
const WebpackError = require("./WebpackError");
|
|
18
17
|
const ConstDependency = require("./dependencies/ConstDependency");
|
|
19
18
|
const ModuleInitFragmentDependency = require("./dependencies/ModuleInitFragmentDependency");
|
|
20
19
|
const RuntimeRequirementsDependency = require("./dependencies/RuntimeRequirementsDependency");
|
|
20
|
+
const WebpackError = require("./errors/WebpackError");
|
|
21
21
|
const BasicEvaluatedExpression = require("./javascript/BasicEvaluatedExpression");
|
|
22
22
|
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
|
|
23
23
|
const {
|
package/lib/BannerPlugin.js
CHANGED
|
@@ -13,10 +13,9 @@ const Template = require("./Template");
|
|
|
13
13
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
14
14
|
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginArgument} BannerPluginArgument */
|
|
15
15
|
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginOptions} BannerPluginOptions */
|
|
16
|
-
/** @typedef {import("./Compilation").
|
|
16
|
+
/** @typedef {import("./Compilation").PathDataChunk} PathDataChunk */
|
|
17
17
|
/** @typedef {import("./Compiler")} Compiler */
|
|
18
18
|
/** @typedef {import("./Chunk")} Chunk */
|
|
19
|
-
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
|
20
19
|
|
|
21
20
|
/** @typedef {(data: { hash?: string, chunk: Chunk, filename: string }) => string} BannerFunction */
|
|
22
21
|
|
|
@@ -117,11 +116,11 @@ class BannerPlugin {
|
|
|
117
116
|
continue;
|
|
118
117
|
}
|
|
119
118
|
|
|
120
|
-
/** @type {
|
|
119
|
+
/** @type {PathDataChunk} */
|
|
121
120
|
const data = { chunk, filename: file };
|
|
122
121
|
|
|
123
122
|
const comment = compilation.getPath(
|
|
124
|
-
/** @type {
|
|
123
|
+
/** @type {string | import("./TemplatedPathPlugin").TemplatePathFn<PathDataChunk>} */
|
|
125
124
|
(banner),
|
|
126
125
|
data
|
|
127
126
|
);
|
package/lib/Cache.js
CHANGED
|
@@ -9,9 +9,7 @@ const { AsyncParallelHook, AsyncSeriesBailHook, SyncHook } = require("tapable");
|
|
|
9
9
|
const {
|
|
10
10
|
makeWebpackError,
|
|
11
11
|
makeWebpackErrorCallback
|
|
12
|
-
} = require("./HookWebpackError");
|
|
13
|
-
|
|
14
|
-
/** @typedef {import("./WebpackError")} WebpackError */
|
|
12
|
+
} = require("./errors/HookWebpackError");
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
15
|
* Cache validation token whose string representation identifies the build
|
|
@@ -21,11 +19,10 @@ const {
|
|
|
21
19
|
*/
|
|
22
20
|
|
|
23
21
|
/**
|
|
24
|
-
* Completion callback used by cache operations that either fail with a
|
|
25
|
-
* `WebpackError` or resolve with a typed result.
|
|
22
|
+
* Completion callback used by cache operations that either fail with a `Error` or resolve with a typed result.
|
|
26
23
|
* @template T
|
|
27
24
|
* @callback CallbackCache
|
|
28
|
-
* @param {
|
|
25
|
+
* @param {Error | null} err
|
|
29
26
|
* @param {T=} result
|
|
30
27
|
* @returns {void}
|
|
31
28
|
*/
|
package/lib/Chunk.js
CHANGED
|
@@ -26,7 +26,9 @@ const { mergeRuntime } = require("./util/runtime");
|
|
|
26
26
|
/** @typedef {import("./ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */
|
|
27
27
|
/** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
|
|
28
28
|
/** @typedef {import("./Module")} Module */
|
|
29
|
-
/** @typedef {import("./
|
|
29
|
+
/** @typedef {import("./Compilation").PathDataChunk} PathDataChunk */
|
|
30
|
+
/** @typedef {import("./TemplatedPathPlugin").TemplatePathFn<PathDataChunk>} ChunkFilenameTemplateFn */
|
|
31
|
+
/** @typedef {string | ChunkFilenameTemplateFn} ChunkFilenameTemplate */
|
|
30
32
|
/** @typedef {import("./util/Hash")} Hash */
|
|
31
33
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
|
32
34
|
|
|
@@ -98,9 +100,9 @@ class Chunk {
|
|
|
98
100
|
this.idNameHints = new SortableSet();
|
|
99
101
|
/** @type {boolean} */
|
|
100
102
|
this.preventIntegration = false;
|
|
101
|
-
/** @type {
|
|
103
|
+
/** @type {ChunkFilenameTemplate | undefined} */
|
|
102
104
|
this.filenameTemplate = undefined;
|
|
103
|
-
/** @type {
|
|
105
|
+
/** @type {ChunkFilenameTemplate | undefined} */
|
|
104
106
|
this.cssFilenameTemplate = undefined;
|
|
105
107
|
/**
|
|
106
108
|
* @private
|
|
@@ -792,26 +794,21 @@ class Chunk {
|
|
|
792
794
|
for (const group of this.groupsIterable) {
|
|
793
795
|
if (group.chunks[group.chunks.length - 1] === this) {
|
|
794
796
|
for (const childGroup of group.childrenIterable) {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
list
|
|
804
|
-
|
|
805
|
-
/** @type {number} */
|
|
806
|
-
(
|
|
807
|
-
childGroup.options[
|
|
808
|
-
/** @type {keyof ChunkGroupOptions} */
|
|
809
|
-
(key)
|
|
810
|
-
]
|
|
811
|
-
),
|
|
812
|
-
group: childGroup
|
|
813
|
-
});
|
|
797
|
+
const edgeOptions = group.getChildOrderOptions(
|
|
798
|
+
childGroup,
|
|
799
|
+
chunkGraph
|
|
800
|
+
);
|
|
801
|
+
for (const key of Object.keys(edgeOptions)) {
|
|
802
|
+
const name = key.slice(0, key.length - "Order".length);
|
|
803
|
+
let list = lists.get(name);
|
|
804
|
+
if (list === undefined) {
|
|
805
|
+
list = [];
|
|
806
|
+
lists.set(name, list);
|
|
814
807
|
}
|
|
808
|
+
list.push({
|
|
809
|
+
order: edgeOptions[key],
|
|
810
|
+
group: childGroup
|
|
811
|
+
});
|
|
815
812
|
}
|
|
816
813
|
}
|
|
817
814
|
}
|
|
@@ -850,9 +847,8 @@ class Chunk {
|
|
|
850
847
|
const list = [];
|
|
851
848
|
for (const group of this.groupsIterable) {
|
|
852
849
|
for (const childGroup of group.childrenIterable) {
|
|
853
|
-
const
|
|
854
|
-
|
|
855
|
-
(childGroup.options[/** @type {keyof ChunkGroupOptions} */ (type)]);
|
|
850
|
+
const edgeOptions = group.getChildOrderOptions(childGroup, chunkGraph);
|
|
851
|
+
const order = edgeOptions[type];
|
|
856
852
|
if (order === undefined) continue;
|
|
857
853
|
list.push({
|
|
858
854
|
order,
|
package/lib/ChunkGroup.js
CHANGED
|
@@ -544,6 +544,53 @@ class ChunkGroup {
|
|
|
544
544
|
);
|
|
545
545
|
}
|
|
546
546
|
|
|
547
|
+
/**
|
|
548
|
+
* Aggregates per-block `*Order` options for the blocks that bridge this
|
|
549
|
+
* chunk group to the given child chunk group. `*Order` options are tied to
|
|
550
|
+
* the originating `import()` call and must not be sourced from the child's
|
|
551
|
+
* shared options, otherwise a webpackPrefetch/Preload directive from one
|
|
552
|
+
* parent would leak into other parents that share the child by name.
|
|
553
|
+
* @param {ChunkGroup} childGroup the child chunk group
|
|
554
|
+
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
555
|
+
* @returns {Record<string, number>} merged `*Order` options for the edge from this group to `childGroup`
|
|
556
|
+
*/
|
|
557
|
+
getChildOrderOptions(childGroup, chunkGraph) {
|
|
558
|
+
/** @type {Record<string, number>} */
|
|
559
|
+
const result = Object.create(null);
|
|
560
|
+
let bridged = false;
|
|
561
|
+
for (const block of childGroup.blocksIterable) {
|
|
562
|
+
const rootModule = /** @type {Module} */ (block.getRootBlock());
|
|
563
|
+
if (!chunkGraph.isModuleInChunkGroup(rootModule, this)) continue;
|
|
564
|
+
bridged = true;
|
|
565
|
+
const opts = block.groupOptions;
|
|
566
|
+
if (!opts) continue;
|
|
567
|
+
for (const key of Object.keys(opts)) {
|
|
568
|
+
if (!key.endsWith("Order")) continue;
|
|
569
|
+
const value =
|
|
570
|
+
/** @type {number} */
|
|
571
|
+
(opts[/** @type {keyof ChunkGroupOptions} */ (key)]);
|
|
572
|
+
if (typeof value !== "number") continue;
|
|
573
|
+
if (result[key] === undefined || value > result[key]) {
|
|
574
|
+
result[key] = value;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
// Fall back to the child's own options only when no block bridges
|
|
579
|
+
// this edge (e.g. a chunk group created by APIs that don't go through
|
|
580
|
+
// an AsyncDependenciesBlock). Otherwise we'd reintroduce the leak.
|
|
581
|
+
if (!bridged) {
|
|
582
|
+
for (const key of Object.keys(childGroup.options)) {
|
|
583
|
+
if (!key.endsWith("Order")) continue;
|
|
584
|
+
const value =
|
|
585
|
+
childGroup.options[/** @type {keyof ChunkGroupOptions} */ (key)];
|
|
586
|
+
if (typeof value === "number") {
|
|
587
|
+
result[key] = value;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return result;
|
|
592
|
+
}
|
|
593
|
+
|
|
547
594
|
/**
|
|
548
595
|
* Groups child chunk groups by their `*Order` options and sorts each group
|
|
549
596
|
* by descending order and deterministic chunk-group comparison.
|
|
@@ -555,22 +602,17 @@ class ChunkGroup {
|
|
|
555
602
|
/** @type {Map<string, { order: number, group: ChunkGroup }[]>} */
|
|
556
603
|
const lists = new Map();
|
|
557
604
|
for (const childGroup of this._children) {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}
|
|
565
|
-
list.push({
|
|
566
|
-
order:
|
|
567
|
-
/** @type {number} */
|
|
568
|
-
(
|
|
569
|
-
childGroup.options[/** @type {keyof ChunkGroupOptions} */ (key)]
|
|
570
|
-
),
|
|
571
|
-
group: childGroup
|
|
572
|
-
});
|
|
605
|
+
const edgeOptions = this.getChildOrderOptions(childGroup, chunkGraph);
|
|
606
|
+
for (const key of Object.keys(edgeOptions)) {
|
|
607
|
+
const name = key.slice(0, key.length - "Order".length);
|
|
608
|
+
let list = lists.get(name);
|
|
609
|
+
if (list === undefined) {
|
|
610
|
+
lists.set(name, (list = []));
|
|
573
611
|
}
|
|
612
|
+
list.push({
|
|
613
|
+
order: edgeOptions[key],
|
|
614
|
+
group: childGroup
|
|
615
|
+
});
|
|
574
616
|
}
|
|
575
617
|
}
|
|
576
618
|
/** @type {Record<string, ChunkGroup[]>} */
|
|
@@ -186,13 +186,14 @@ class CompatibilityPlugin {
|
|
|
186
186
|
(declarator.id.name === RuntimeGlobals.exports ||
|
|
187
187
|
declarator.id.name === RuntimeGlobals.require)
|
|
188
188
|
) {
|
|
189
|
-
const {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
189
|
+
const tagData = /** @type {CompatibilitySettings | undefined} */ (
|
|
190
|
+
parser.getTagData(
|
|
191
|
+
declarator.id.name,
|
|
192
|
+
nestedWebpackIdentifierTag
|
|
193
|
+
)
|
|
194
|
+
);
|
|
195
|
+
if (!tagData) return;
|
|
196
|
+
const { name, declaration } = tagData;
|
|
196
197
|
if (!declaration.updated) {
|
|
197
198
|
const dep = new ConstDependency(name, declaration.range);
|
|
198
199
|
dep.loc = declaration.loc;
|
package/lib/Compilation.js
CHANGED
|
@@ -21,42 +21,37 @@ const { MultiItemCache } = require("./CacheFacade");
|
|
|
21
21
|
const Chunk = require("./Chunk");
|
|
22
22
|
const ChunkGraph = require("./ChunkGraph");
|
|
23
23
|
const ChunkGroup = require("./ChunkGroup");
|
|
24
|
-
const ChunkRenderError = require("./ChunkRenderError");
|
|
25
24
|
const ChunkTemplate = require("./ChunkTemplate");
|
|
26
|
-
const CodeGenerationError = require("./CodeGenerationError");
|
|
27
25
|
const CodeGenerationResults = require("./CodeGenerationResults");
|
|
28
26
|
const Dependency = require("./Dependency");
|
|
29
27
|
const DependencyTemplates = require("./DependencyTemplates");
|
|
30
28
|
const Entrypoint = require("./Entrypoint");
|
|
31
29
|
const ErrorHelpers = require("./ErrorHelpers");
|
|
32
30
|
const FileSystemInfo = require("./FileSystemInfo");
|
|
33
|
-
const {
|
|
34
|
-
connectChunkGroupAndChunk,
|
|
35
|
-
connectChunkGroupParentAndChild,
|
|
36
|
-
connectEntrypointAndDependOn
|
|
37
|
-
} = require("./GraphHelpers");
|
|
38
|
-
const {
|
|
39
|
-
makeWebpackError,
|
|
40
|
-
tryRunOrWebpackError
|
|
41
|
-
} = require("./HookWebpackError");
|
|
42
31
|
const MainTemplate = require("./MainTemplate");
|
|
43
32
|
const Module = require("./Module");
|
|
44
|
-
const ModuleDependencyError = require("./ModuleDependencyError");
|
|
45
|
-
const ModuleDependencyWarning = require("./ModuleDependencyWarning");
|
|
46
33
|
const ModuleGraph = require("./ModuleGraph");
|
|
47
|
-
const ModuleHashingError = require("./ModuleHashingError");
|
|
48
|
-
const ModuleNotFoundError = require("./ModuleNotFoundError");
|
|
49
34
|
const ModuleProfile = require("./ModuleProfile");
|
|
50
|
-
const ModuleRestoreError = require("./ModuleRestoreError");
|
|
51
|
-
const ModuleStoreError = require("./ModuleStoreError");
|
|
52
35
|
const ModuleTemplate = require("./ModuleTemplate");
|
|
53
36
|
const { WEBPACK_MODULE_TYPE_RUNTIME } = require("./ModuleTypeConstants");
|
|
54
37
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
|
55
38
|
const RuntimeTemplate = require("./RuntimeTemplate");
|
|
56
39
|
const Stats = require("./Stats");
|
|
57
|
-
const WebpackError = require("./WebpackError");
|
|
58
40
|
const buildChunkGraph = require("./buildChunkGraph");
|
|
59
41
|
const BuildCycleError = require("./errors/BuildCycleError");
|
|
42
|
+
const ChunkRenderError = require("./errors/ChunkRenderError");
|
|
43
|
+
const CodeGenerationError = require("./errors/CodeGenerationError");
|
|
44
|
+
const {
|
|
45
|
+
makeWebpackError,
|
|
46
|
+
tryRunOrWebpackError
|
|
47
|
+
} = require("./errors/HookWebpackError");
|
|
48
|
+
const ModuleDependencyError = require("./errors/ModuleDependencyError");
|
|
49
|
+
const ModuleDependencyWarning = require("./errors/ModuleDependencyWarning");
|
|
50
|
+
const ModuleHashingError = require("./errors/ModuleHashingError");
|
|
51
|
+
const ModuleNotFoundError = require("./errors/ModuleNotFoundError");
|
|
52
|
+
const ModuleRestoreError = require("./errors/ModuleRestoreError");
|
|
53
|
+
const ModuleStoreError = require("./errors/ModuleStoreError");
|
|
54
|
+
const WebpackError = require("./errors/WebpackError");
|
|
60
55
|
const { LogType, Logger } = require("./logging/Logger");
|
|
61
56
|
const StatsFactory = require("./stats/StatsFactory");
|
|
62
57
|
const StatsPrinter = require("./stats/StatsPrinter");
|
|
@@ -377,6 +372,24 @@ const { isSourceEqual } = require("./util/source");
|
|
|
377
372
|
* @property {PrepareIdFunction=} prepareId
|
|
378
373
|
*/
|
|
379
374
|
|
|
375
|
+
/**
|
|
376
|
+
* Path data narrowed for the chunk filename / chunk asset interpolation context,
|
|
377
|
+
* where `chunk` is always provided. Use as the type parameter to `TemplatePathFn`
|
|
378
|
+
* for callbacks that receive a chunk context (for example `output.filename`,
|
|
379
|
+
* `output.chunkFilename`, `output.cssFilename`, `output.cssChunkFilename`,
|
|
380
|
+
* `optimization.splitChunks.cacheGroups[*].filename`).
|
|
381
|
+
* @typedef {PathData & { chunk: Chunk | ChunkPathData }} PathDataChunk
|
|
382
|
+
*/
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Path data narrowed for the module asset interpolation context, where `module`
|
|
386
|
+
* and `chunkGraph` are always provided. Use as the type parameter to
|
|
387
|
+
* `TemplatePathFn` for callbacks that receive a module context (for example
|
|
388
|
+
* `output.assetModuleFilename`, the per-module `generator.filename` /
|
|
389
|
+
* `generator.outputPath`, and `module.parser.css.localIdentName`).
|
|
390
|
+
* @typedef {PathData & { module: Module | ModulePathData, chunkGraph: ChunkGraph }} PathDataModule
|
|
391
|
+
*/
|
|
392
|
+
|
|
380
393
|
/** @typedef {"module" | "chunk" | "root-of-chunk" | "nested"} ExcludeModulesType */
|
|
381
394
|
|
|
382
395
|
/**
|
|
@@ -3214,7 +3227,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3214
3227
|
let hasProblems = this.reportDependencyErrorsAndWarnings(module, [
|
|
3215
3228
|
module
|
|
3216
3229
|
]);
|
|
3217
|
-
const errors = module.getErrors();
|
|
3230
|
+
const errors = /** @type {WebpackError[]} */ (module.getErrors());
|
|
3218
3231
|
if (errors !== undefined) {
|
|
3219
3232
|
for (const error of errors) {
|
|
3220
3233
|
if (!error.module) {
|
|
@@ -3224,7 +3237,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3224
3237
|
hasProblems = true;
|
|
3225
3238
|
}
|
|
3226
3239
|
}
|
|
3227
|
-
const warnings = module.getWarnings();
|
|
3240
|
+
const warnings = /** @type {WebpackError[]} */ (module.getWarnings());
|
|
3228
3241
|
if (warnings !== undefined) {
|
|
3229
3242
|
for (const warning of warnings) {
|
|
3230
3243
|
if (!warning.module) {
|
|
@@ -3312,7 +3325,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3312
3325
|
this.namedChunkGroups.set(name, entrypoint);
|
|
3313
3326
|
this.entrypoints.set(name, entrypoint);
|
|
3314
3327
|
this.chunkGroups.push(entrypoint);
|
|
3315
|
-
|
|
3328
|
+
|
|
3329
|
+
if (entrypoint.pushChunk(chunk)) {
|
|
3330
|
+
chunk.addGroup(entrypoint);
|
|
3331
|
+
}
|
|
3316
3332
|
|
|
3317
3333
|
/** @type {Set<Module>} */
|
|
3318
3334
|
const entryModules = new Set();
|
|
@@ -3403,8 +3419,12 @@ Remove the 'runtime' option from the entrypoint.`);
|
|
|
3403
3419
|
entry.setRuntimeChunk(entryChunk);
|
|
3404
3420
|
continue outer;
|
|
3405
3421
|
}
|
|
3406
|
-
|
|
3407
|
-
|
|
3422
|
+
|
|
3423
|
+
entry.addDependOn(dependency);
|
|
3424
|
+
|
|
3425
|
+
if (dependency.addChild(entry)) {
|
|
3426
|
+
entry.addParent(dependency);
|
|
3427
|
+
}
|
|
3408
3428
|
}
|
|
3409
3429
|
} else if (runtime) {
|
|
3410
3430
|
const entry = /** @type {Entrypoint} */ (this.entrypoints.get(name));
|
|
@@ -4156,7 +4176,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4156
4176
|
}
|
|
4157
4177
|
const chunk = this.addChunk(name);
|
|
4158
4178
|
|
|
4159
|
-
|
|
4179
|
+
if (chunkGroup.pushChunk(chunk)) {
|
|
4180
|
+
chunk.addGroup(chunkGroup);
|
|
4181
|
+
}
|
|
4160
4182
|
|
|
4161
4183
|
this.chunkGroups.push(chunkGroup);
|
|
4162
4184
|
if (name) {
|
|
@@ -4200,7 +4222,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4200
4222
|
}
|
|
4201
4223
|
this.chunkGroups.push(entrypoint);
|
|
4202
4224
|
this.asyncEntrypoints.push(entrypoint);
|
|
4203
|
-
|
|
4225
|
+
if (entrypoint.pushChunk(chunk)) {
|
|
4226
|
+
chunk.addGroup(entrypoint);
|
|
4227
|
+
}
|
|
4204
4228
|
if (module) {
|
|
4205
4229
|
entrypoint.addOrigin(module, loc, request);
|
|
4206
4230
|
}
|
|
@@ -5233,7 +5257,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
5233
5257
|
);
|
|
5234
5258
|
|
|
5235
5259
|
assetCacheItem.get((err, sourceFromCache) => {
|
|
5236
|
-
/** @type {
|
|
5260
|
+
/** @type {string | import("./TemplatedPathPlugin").TemplatePathFn<EXPECTED_ANY>} */
|
|
5237
5261
|
let filenameTemplate;
|
|
5238
5262
|
/** @type {string} */
|
|
5239
5263
|
let file;
|
|
@@ -5351,11 +5375,12 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
5351
5375
|
|
|
5352
5376
|
/**
|
|
5353
5377
|
* Returns interpolated path.
|
|
5354
|
-
* @
|
|
5355
|
-
* @param {
|
|
5378
|
+
* @template {PathData} [T=PathData]
|
|
5379
|
+
* @param {string | import("./TemplatedPathPlugin").TemplatePathFn<T>} filename used to get asset path with hash
|
|
5380
|
+
* @param {T=} data context data
|
|
5356
5381
|
* @returns {string} interpolated path
|
|
5357
5382
|
*/
|
|
5358
|
-
getPath(filename, data = {}) {
|
|
5383
|
+
getPath(filename, data = /** @type {T} */ ({})) {
|
|
5359
5384
|
if (!data.hash) {
|
|
5360
5385
|
data = {
|
|
5361
5386
|
hash: this.hash,
|
|
@@ -5367,11 +5392,12 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
5367
5392
|
|
|
5368
5393
|
/**
|
|
5369
5394
|
* Gets path with info.
|
|
5370
|
-
* @
|
|
5371
|
-
* @param {
|
|
5395
|
+
* @template {PathData} [T=PathData]
|
|
5396
|
+
* @param {string | import("./TemplatedPathPlugin").TemplatePathFn<T>} filename used to get asset path with hash
|
|
5397
|
+
* @param {T=} data context data
|
|
5372
5398
|
* @returns {InterpolatedPathAndAssetInfo} interpolated path and asset info
|
|
5373
5399
|
*/
|
|
5374
|
-
getPathWithInfo(filename, data = {}) {
|
|
5400
|
+
getPathWithInfo(filename, data = /** @type {T} */ ({})) {
|
|
5375
5401
|
if (!data.hash) {
|
|
5376
5402
|
data = {
|
|
5377
5403
|
hash: this.hash,
|
|
@@ -5383,8 +5409,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
5383
5409
|
|
|
5384
5410
|
/**
|
|
5385
5411
|
* Returns interpolated path.
|
|
5386
|
-
* @
|
|
5387
|
-
* @param {
|
|
5412
|
+
* @template {PathData} [T=PathData]
|
|
5413
|
+
* @param {string | import("./TemplatedPathPlugin").TemplatePathFn<T>} filename used to get asset path with hash
|
|
5414
|
+
* @param {T} data context data
|
|
5388
5415
|
* @returns {string} interpolated path
|
|
5389
5416
|
*/
|
|
5390
5417
|
getAssetPath(filename, data) {
|
|
@@ -5397,8 +5424,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
5397
5424
|
|
|
5398
5425
|
/**
|
|
5399
5426
|
* Gets asset path with info.
|
|
5400
|
-
* @
|
|
5401
|
-
* @param {
|
|
5427
|
+
* @template {PathData} [T=PathData]
|
|
5428
|
+
* @param {string | import("./TemplatedPathPlugin").TemplatePathFn<T>} filename used to get asset path with hash
|
|
5429
|
+
* @param {T} data context data
|
|
5402
5430
|
* @returns {InterpolatedPathAndAssetInfo} interpolated path and asset info
|
|
5403
5431
|
*/
|
|
5404
5432
|
getAssetPathWithInfo(filename, data) {
|
|
@@ -5493,7 +5521,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
5493
5521
|
...options.entryOptions
|
|
5494
5522
|
});
|
|
5495
5523
|
chunkGraph.connectChunkAndEntryModule(chunk, module, entrypoint);
|
|
5496
|
-
|
|
5524
|
+
if (entrypoint.pushChunk(chunk)) {
|
|
5525
|
+
chunk.addGroup(entrypoint);
|
|
5526
|
+
}
|
|
5497
5527
|
entrypoint.setRuntimeChunk(chunk);
|
|
5498
5528
|
entrypoint.setEntrypointChunk(chunk);
|
|
5499
5529
|
|
package/lib/Compiler.js
CHANGED
|
@@ -17,7 +17,6 @@ const Cache = require("./Cache");
|
|
|
17
17
|
const CacheFacade = require("./CacheFacade");
|
|
18
18
|
const ChunkGraph = require("./ChunkGraph");
|
|
19
19
|
const Compilation = require("./Compilation");
|
|
20
|
-
const ConcurrentCompilationError = require("./ConcurrentCompilationError");
|
|
21
20
|
const ContextModuleFactory = require("./ContextModuleFactory");
|
|
22
21
|
const ModuleGraph = require("./ModuleGraph");
|
|
23
22
|
const NormalModuleFactory = require("./NormalModuleFactory");
|
|
@@ -25,7 +24,8 @@ const RequestShortener = require("./RequestShortener");
|
|
|
25
24
|
const ResolverFactory = require("./ResolverFactory");
|
|
26
25
|
const Stats = require("./Stats");
|
|
27
26
|
const Watching = require("./Watching");
|
|
28
|
-
const
|
|
27
|
+
const ConcurrentCompilationError = require("./errors/ConcurrentCompilationError");
|
|
28
|
+
const WebpackError = require("./errors/WebpackError");
|
|
29
29
|
const { Logger } = require("./logging/Logger");
|
|
30
30
|
const { dirname, join, mkdirp } = require("./util/fs");
|
|
31
31
|
const { makePathsRelative } = require("./util/identifier");
|
|
@@ -1477,12 +1477,7 @@ ${other}`);
|
|
|
1477
1477
|
// // If we have precompiled schema let's use it
|
|
1478
1478
|
if (check) {
|
|
1479
1479
|
if (!check(value)) {
|
|
1480
|
-
getValidate()(
|
|
1481
|
-
getSchema(),
|
|
1482
|
-
/** @type {EXPECTED_OBJECT | EXPECTED_OBJECT[]} */
|
|
1483
|
-
(value),
|
|
1484
|
-
options
|
|
1485
|
-
);
|
|
1480
|
+
getValidate()(getSchema(), value, options);
|
|
1486
1481
|
require("util").deprecate(
|
|
1487
1482
|
() => {},
|
|
1488
1483
|
"webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
|
|
@@ -1493,11 +1488,7 @@ ${other}`);
|
|
|
1493
1488
|
}
|
|
1494
1489
|
|
|
1495
1490
|
// Otherwise let's standard validation
|
|
1496
|
-
getValidate()(
|
|
1497
|
-
getSchema(),
|
|
1498
|
-
/** @type {EXPECTED_OBJECT | EXPECTED_OBJECT[]} */ (value),
|
|
1499
|
-
options
|
|
1500
|
-
);
|
|
1491
|
+
getValidate()(getSchema(), value, options);
|
|
1501
1492
|
}
|
|
1502
1493
|
}
|
|
1503
1494
|
|
package/lib/ContextModule.js
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
const { OriginalSource, RawSource } = require("webpack-sources");
|
|
9
9
|
const AsyncDependenciesBlock = require("./AsyncDependenciesBlock");
|
|
10
|
-
const { makeWebpackError } = require("./HookWebpackError");
|
|
11
10
|
const Module = require("./Module");
|
|
12
11
|
const {
|
|
13
12
|
JAVASCRIPT_TYPE,
|
|
@@ -16,11 +15,12 @@ const {
|
|
|
16
15
|
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
|
|
17
16
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
|
18
17
|
const Template = require("./Template");
|
|
19
|
-
const WebpackError = require("./WebpackError");
|
|
20
18
|
const {
|
|
21
19
|
getOutgoingAsyncModules
|
|
22
20
|
} = require("./async-modules/AsyncModuleHelpers");
|
|
23
21
|
const { ImportPhase, ImportPhaseUtils } = require("./dependencies/ImportPhase");
|
|
22
|
+
const { makeWebpackError } = require("./errors/HookWebpackError");
|
|
23
|
+
const WebpackError = require("./errors/WebpackError");
|
|
24
24
|
const {
|
|
25
25
|
compareLocations,
|
|
26
26
|
compareModulesById,
|
package/lib/DefinePlugin.js
CHANGED
|
@@ -12,8 +12,8 @@ const {
|
|
|
12
12
|
JAVASCRIPT_MODULE_TYPE_ESM
|
|
13
13
|
} = require("./ModuleTypeConstants");
|
|
14
14
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
|
15
|
-
const WebpackError = require("./WebpackError");
|
|
16
15
|
const ConstDependency = require("./dependencies/ConstDependency");
|
|
16
|
+
const WebpackError = require("./errors/WebpackError");
|
|
17
17
|
const BasicEvaluatedExpression = require("./javascript/BasicEvaluatedExpression");
|
|
18
18
|
const { VariableInfo } = require("./javascript/JavascriptParser");
|
|
19
19
|
const {
|
|
@@ -319,7 +319,7 @@ const toCacheVersion = (code) => {
|
|
|
319
319
|
const items = Object.keys(code).map((key) => ({
|
|
320
320
|
key,
|
|
321
321
|
value: toCacheVersion(
|
|
322
|
-
/** @type {Record<string,
|
|
322
|
+
/** @type {Record<string, CodeValue>} */
|
|
323
323
|
(code)[key]
|
|
324
324
|
)
|
|
325
325
|
}));
|
package/lib/Dependency.js
CHANGED
|
@@ -14,7 +14,7 @@ const memoize = require("./util/memoize");
|
|
|
14
14
|
/** @typedef {import("./ModuleGraphConnection")} ModuleGraphConnection */
|
|
15
15
|
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
16
16
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
|
17
|
-
/** @typedef {import("./WebpackError")} WebpackError */
|
|
17
|
+
/** @typedef {import("./errors/WebpackError")} WebpackError */
|
|
18
18
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
19
19
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
20
20
|
/** @typedef {import("./util/Hash")} Hash */
|
|
@@ -325,6 +325,14 @@ class Dependency {
|
|
|
325
325
|
return getIgnoredModule();
|
|
326
326
|
}
|
|
327
327
|
|
|
328
|
+
/**
|
|
329
|
+
* Returns true if this dependency can be concatenated
|
|
330
|
+
* @returns {boolean} true if this dependency can be concatenated
|
|
331
|
+
*/
|
|
332
|
+
canConcatenate() {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
|
|
328
336
|
/**
|
|
329
337
|
* Serializes this instance into the provided serializer context.
|
|
330
338
|
* @param {ObjectSerializerContext} context context
|
|
@@ -394,6 +402,19 @@ Object.defineProperty(Dependency.prototype, "module", {
|
|
|
394
402
|
Dependency.isLowPriorityDependency = (dependency) =>
|
|
395
403
|
/** @type {ModuleDependency} */ (dependency).sourceOrder === Infinity;
|
|
396
404
|
|
|
405
|
+
// TODO in webpack 6, call canConcatenate() directly on the dependency instance instead of using this static method.
|
|
406
|
+
/**
|
|
407
|
+
* Returns true if the dependency can be concatenated (scope hoisting).
|
|
408
|
+
* @param {Dependency} dependency dep
|
|
409
|
+
* @returns {boolean} true if this dependency supports concatenation
|
|
410
|
+
*/
|
|
411
|
+
Dependency.canConcatenate = (dependency) => {
|
|
412
|
+
if (typeof dependency.canConcatenate === "function") {
|
|
413
|
+
return dependency.canConcatenate();
|
|
414
|
+
}
|
|
415
|
+
return false;
|
|
416
|
+
};
|
|
417
|
+
|
|
397
418
|
// TODO remove in webpack 6
|
|
398
419
|
Object.defineProperty(Dependency.prototype, "disconnect", {
|
|
399
420
|
/**
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
* @typedef {object} CssData
|
|
53
53
|
* @property {boolean} esModule whether export __esModule
|
|
54
54
|
* @property {Map<string, string>} exports the css exports
|
|
55
|
+
* @property {Map<string, { line: number, column: number }>=} exportLocs source position (line is 1-based, column is 0-based) of each export's defining identifier in the original CSS, used to emit fine-grained JS-to-CSS source mappings
|
|
55
56
|
*/
|
|
56
57
|
|
|
57
58
|
/** @typedef {DependencyTemplateContext & CssDependencyTemplateContextExtras} CssDependencyTemplateContext */
|
|
@@ -67,7 +68,7 @@ class DependencyTemplate {
|
|
|
67
68
|
* @returns {void}
|
|
68
69
|
*/
|
|
69
70
|
apply(dependency, source, templateContext) {
|
|
70
|
-
const AbstractMethodError = require("./AbstractMethodError");
|
|
71
|
+
const AbstractMethodError = require("./errors/AbstractMethodError");
|
|
71
72
|
|
|
72
73
|
throw new AbstractMethodError();
|
|
73
74
|
}
|
package/lib/EnvironmentPlugin.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const DefinePlugin = require("./DefinePlugin");
|
|
9
|
-
const WebpackError = require("./WebpackError");
|
|
9
|
+
const WebpackError = require("./errors/WebpackError");
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("./Compiler")} Compiler */
|
|
12
12
|
/** @typedef {import("./DefinePlugin").CodeValue} CodeValue */
|