webpack 5.106.2 → 5.107.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 +2 -2
- package/lib/APIPlugin.js +1 -1
- package/lib/Cache.js +3 -6
- package/lib/CompatibilityPlugin.js +8 -7
- package/lib/Compilation.js +34 -26
- 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 -9
- package/lib/ExternalModule.js +76 -15
- package/lib/ExternalModuleFactoryPlugin.js +5 -0
- 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 +19 -18
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleSourceTypeConstants.js +31 -1
- package/lib/ModuleTypeConstants.js +12 -3
- package/lib/MultiCompiler.js +2 -2
- package/lib/NodeStuffPlugin.js +1 -1
- package/lib/NormalModule.js +13 -31
- package/lib/NormalModuleFactory.js +10 -2
- 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 +11 -0
- 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 +6 -2
- package/lib/asset/AssetGenerator.js +22 -8
- package/lib/asset/AssetModulesPlugin.js +3 -1
- package/lib/asset/AssetSourceGenerator.js +6 -2
- 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 +166 -86
- 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 +4 -3
- 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 +25 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +1 -1
- 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 +318 -0
- package/lib/dependencies/HtmlSourceDependency.js +127 -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/{ModuleNotFoundError.js → errors/ModuleNotFoundError.js} +2 -2
- 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 +433 -0
- package/lib/html/HtmlParser.js +1489 -0
- package/lib/html/walkHtmlTokens.js +2733 -0
- package/lib/ids/IdHelpers.js +2 -1
- package/lib/index.js +34 -15
- package/lib/javascript/JavascriptModulesPlugin.js +89 -8
- 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 +111 -3
- package/lib/optimize/SplitChunksPlugin.js +1 -1
- 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/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 +2 -2
- package/lib/sharing/ConsumeSharedRuntimeModule.js +8 -4
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +1 -1
- 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 +2 -2
- 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 +22 -20
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +118 -3
- 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/{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 +810 -101
- 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/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
|
*/
|
|
@@ -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");
|
|
@@ -3214,7 +3209,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3214
3209
|
let hasProblems = this.reportDependencyErrorsAndWarnings(module, [
|
|
3215
3210
|
module
|
|
3216
3211
|
]);
|
|
3217
|
-
const errors = module.getErrors();
|
|
3212
|
+
const errors = /** @type {WebpackError[]} */ (module.getErrors());
|
|
3218
3213
|
if (errors !== undefined) {
|
|
3219
3214
|
for (const error of errors) {
|
|
3220
3215
|
if (!error.module) {
|
|
@@ -3224,7 +3219,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3224
3219
|
hasProblems = true;
|
|
3225
3220
|
}
|
|
3226
3221
|
}
|
|
3227
|
-
const warnings = module.getWarnings();
|
|
3222
|
+
const warnings = /** @type {WebpackError[]} */ (module.getWarnings());
|
|
3228
3223
|
if (warnings !== undefined) {
|
|
3229
3224
|
for (const warning of warnings) {
|
|
3230
3225
|
if (!warning.module) {
|
|
@@ -3312,7 +3307,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
3312
3307
|
this.namedChunkGroups.set(name, entrypoint);
|
|
3313
3308
|
this.entrypoints.set(name, entrypoint);
|
|
3314
3309
|
this.chunkGroups.push(entrypoint);
|
|
3315
|
-
|
|
3310
|
+
|
|
3311
|
+
if (entrypoint.pushChunk(chunk)) {
|
|
3312
|
+
chunk.addGroup(entrypoint);
|
|
3313
|
+
}
|
|
3316
3314
|
|
|
3317
3315
|
/** @type {Set<Module>} */
|
|
3318
3316
|
const entryModules = new Set();
|
|
@@ -3403,8 +3401,12 @@ Remove the 'runtime' option from the entrypoint.`);
|
|
|
3403
3401
|
entry.setRuntimeChunk(entryChunk);
|
|
3404
3402
|
continue outer;
|
|
3405
3403
|
}
|
|
3406
|
-
|
|
3407
|
-
|
|
3404
|
+
|
|
3405
|
+
entry.addDependOn(dependency);
|
|
3406
|
+
|
|
3407
|
+
if (dependency.addChild(entry)) {
|
|
3408
|
+
entry.addParent(dependency);
|
|
3409
|
+
}
|
|
3408
3410
|
}
|
|
3409
3411
|
} else if (runtime) {
|
|
3410
3412
|
const entry = /** @type {Entrypoint} */ (this.entrypoints.get(name));
|
|
@@ -4156,7 +4158,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4156
4158
|
}
|
|
4157
4159
|
const chunk = this.addChunk(name);
|
|
4158
4160
|
|
|
4159
|
-
|
|
4161
|
+
if (chunkGroup.pushChunk(chunk)) {
|
|
4162
|
+
chunk.addGroup(chunkGroup);
|
|
4163
|
+
}
|
|
4160
4164
|
|
|
4161
4165
|
this.chunkGroups.push(chunkGroup);
|
|
4162
4166
|
if (name) {
|
|
@@ -4200,7 +4204,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4200
4204
|
}
|
|
4201
4205
|
this.chunkGroups.push(entrypoint);
|
|
4202
4206
|
this.asyncEntrypoints.push(entrypoint);
|
|
4203
|
-
|
|
4207
|
+
if (entrypoint.pushChunk(chunk)) {
|
|
4208
|
+
chunk.addGroup(entrypoint);
|
|
4209
|
+
}
|
|
4204
4210
|
if (module) {
|
|
4205
4211
|
entrypoint.addOrigin(module, loc, request);
|
|
4206
4212
|
}
|
|
@@ -5493,7 +5499,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
|
5493
5499
|
...options.entryOptions
|
|
5494
5500
|
});
|
|
5495
5501
|
chunkGraph.connectChunkAndEntryModule(chunk, module, entrypoint);
|
|
5496
|
-
|
|
5502
|
+
if (entrypoint.pushChunk(chunk)) {
|
|
5503
|
+
chunk.addGroup(entrypoint);
|
|
5504
|
+
}
|
|
5497
5505
|
entrypoint.setRuntimeChunk(chunk);
|
|
5498
5506
|
entrypoint.setEntrypointChunk(chunk);
|
|
5499
5507
|
|
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 */
|
|
@@ -103,17 +103,12 @@ class EvalSourceMapDevToolPlugin {
|
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
if (m instanceof NormalModule) {
|
|
106
|
-
|
|
107
|
-
if (!matchModule(module.resource)) {
|
|
106
|
+
if (!matchModule(m.resource)) {
|
|
108
107
|
return result(source);
|
|
109
108
|
}
|
|
110
109
|
} else if (m instanceof ConcatenatedModule) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const module = /** @type {NormalModule} */ (
|
|
114
|
-
concatModule.rootModule
|
|
115
|
-
);
|
|
116
|
-
if (!matchModule(module.resource)) {
|
|
110
|
+
if (m.rootModule instanceof NormalModule) {
|
|
111
|
+
if (!matchModule(m.rootModule.resource)) {
|
|
117
112
|
return result(source);
|
|
118
113
|
}
|
|
119
114
|
} else {
|
|
@@ -146,9 +141,13 @@ class EvalSourceMapDevToolPlugin {
|
|
|
146
141
|
sourceMap = { ...sourceMap };
|
|
147
142
|
const context = compiler.context;
|
|
148
143
|
const root = compiler.root;
|
|
144
|
+
const cachedAbsolutify = makePathsAbsolute.bindContextCache(
|
|
145
|
+
context,
|
|
146
|
+
root
|
|
147
|
+
);
|
|
149
148
|
const modules = sourceMap.sources.map((source) => {
|
|
150
149
|
if (!source.startsWith("webpack://")) return source;
|
|
151
|
-
source =
|
|
150
|
+
source = cachedAbsolutify(source.slice(10));
|
|
152
151
|
const module = compilation.findModule(source);
|
|
153
152
|
return module || source;
|
|
154
153
|
});
|
package/lib/ExternalModule.js
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
const { SyncBailHook } = require("tapable");
|
|
9
9
|
const { OriginalSource, RawSource } = require("webpack-sources");
|
|
10
10
|
const ConcatenationScope = require("./ConcatenationScope");
|
|
11
|
-
const EnvironmentNotSupportAsyncWarning = require("./EnvironmentNotSupportAsyncWarning");
|
|
12
11
|
const { UsageState } = require("./ExportsInfo");
|
|
13
12
|
const InitFragment = require("./InitFragment");
|
|
14
13
|
const Module = require("./Module");
|
|
@@ -22,7 +21,9 @@ const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
|
|
|
22
21
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
|
23
22
|
const Template = require("./Template");
|
|
24
23
|
const { DEFAULTS } = require("./config/defaults");
|
|
24
|
+
const { ImportPhaseUtils } = require("./dependencies/ImportPhase");
|
|
25
25
|
const StaticExportsDependency = require("./dependencies/StaticExportsDependency");
|
|
26
|
+
const EnvironmentNotSupportAsyncWarning = require("./errors/EnvironmentNotSupportAsyncWarning");
|
|
26
27
|
const createHash = require("./util/createHash");
|
|
27
28
|
const extractUrlAndGlobal = require("./util/extractUrlAndGlobal");
|
|
28
29
|
const makeSerializable = require("./util/makeSerializable");
|
|
@@ -62,13 +63,14 @@ const { register } = require("./util/serialization");
|
|
|
62
63
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
|
63
64
|
/** @typedef {import("./javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
|
|
64
65
|
/** @typedef {import("./javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
|
66
|
+
/** @typedef {import("./dependencies/ImportPhase").ImportPhaseType} ImportPhaseType */
|
|
65
67
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
66
68
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
67
69
|
/** @typedef {import("./util/Hash")} Hash */
|
|
68
70
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
69
71
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
|
70
72
|
|
|
71
|
-
/** @typedef {{ attributes?: ImportAttributes, externalType: "import" | "module" | undefined }} ImportDependencyMeta */
|
|
73
|
+
/** @typedef {{ attributes?: ImportAttributes, phase?: ImportPhaseType, externalType: "import" | "module" | undefined }} ImportDependencyMeta */
|
|
72
74
|
/** @typedef {{ layer?: string, supports?: string, media?: string }} CssImportDependencyMeta */
|
|
73
75
|
/** @typedef {{ sourceType: "css-url" }} AssetDependencyMeta */
|
|
74
76
|
|
|
@@ -202,15 +204,25 @@ const getSourceForImportExternal = (
|
|
|
202
204
|
runtimeTemplate,
|
|
203
205
|
dependencyMeta
|
|
204
206
|
) => {
|
|
205
|
-
const
|
|
207
|
+
const baseImportName = runtimeTemplate.outputOptions.importFunctionName;
|
|
206
208
|
if (
|
|
207
209
|
!runtimeTemplate.supportsDynamicImport() &&
|
|
208
|
-
(
|
|
210
|
+
(baseImportName === "import" || baseImportName === "module-import")
|
|
209
211
|
) {
|
|
210
212
|
throw new Error(
|
|
211
213
|
"The target environment doesn't support 'import()' so it's not possible to use external type 'import'"
|
|
212
214
|
);
|
|
213
215
|
}
|
|
216
|
+
const phase = dependencyMeta && dependencyMeta.phase;
|
|
217
|
+
// `import.defer(…)` and `import.source(…)` are only valid forms of the
|
|
218
|
+
// native `import(…)` function, so we only emit the phase suffix when the
|
|
219
|
+
// importFunctionName is the default `"import"`.
|
|
220
|
+
const importName =
|
|
221
|
+
baseImportName === "import" && ImportPhaseUtils.isDefer(phase)
|
|
222
|
+
? "import.defer"
|
|
223
|
+
: baseImportName === "import" && ImportPhaseUtils.isSource(phase)
|
|
224
|
+
? "import.source"
|
|
225
|
+
: baseImportName;
|
|
214
226
|
const attributes =
|
|
215
227
|
dependencyMeta && dependencyMeta.attributes
|
|
216
228
|
? dependencyMeta.attributes._isLegacyAssert
|
|
@@ -293,7 +305,9 @@ class ModuleExternalInitFragment extends InitFragment {
|
|
|
293
305
|
"",
|
|
294
306
|
InitFragment.STAGE_HARMONY_IMPORTS,
|
|
295
307
|
0,
|
|
296
|
-
`external module import ${ident} ${
|
|
308
|
+
`external module import ${ident} ${
|
|
309
|
+
imported === true ? imported : imported.join(" ")
|
|
310
|
+
}`
|
|
297
311
|
);
|
|
298
312
|
this._ident = ident;
|
|
299
313
|
this._request = request;
|
|
@@ -332,23 +346,34 @@ class ModuleExternalInitFragment extends InitFragment {
|
|
|
332
346
|
} = this;
|
|
333
347
|
const attributes =
|
|
334
348
|
dependencyMeta && dependencyMeta.attributes
|
|
335
|
-
? dependencyMeta.attributes._isLegacyAssert
|
|
336
|
-
dependencyMeta.attributes._isLegacyAssert
|
|
349
|
+
? dependencyMeta.attributes._isLegacyAssert
|
|
337
350
|
? ` assert ${JSON.stringify(
|
|
338
351
|
dependencyMeta.attributes,
|
|
339
352
|
importAssertionReplacer
|
|
340
353
|
)}`
|
|
341
354
|
: ` with ${JSON.stringify(dependencyMeta.attributes)}`
|
|
342
355
|
: "";
|
|
356
|
+
const phase = dependencyMeta && dependencyMeta.phase;
|
|
343
357
|
let content = "";
|
|
344
358
|
if (imported === true) {
|
|
345
359
|
// namespace
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
360
|
+
const phaseKeyword = ImportPhaseUtils.isDefer(phase) ? "defer " : "";
|
|
361
|
+
content = `import ${phaseKeyword}* as ${identifier} from ${JSON.stringify(
|
|
362
|
+
request
|
|
363
|
+
)}${attributes};\n`;
|
|
349
364
|
} else if (imported.length === 0) {
|
|
350
365
|
// just import, no use
|
|
351
366
|
content = `import ${JSON.stringify(request)}${attributes};\n`;
|
|
367
|
+
} else if (
|
|
368
|
+
ImportPhaseUtils.isSource(phase) &&
|
|
369
|
+
imported.length === 1 &&
|
|
370
|
+
imported[0][0] === "default"
|
|
371
|
+
) {
|
|
372
|
+
// `import source x from "…"` — the source-phase form binds the source
|
|
373
|
+
// object directly to a single identifier (no namespace, no destructuring).
|
|
374
|
+
content = `import source ${imported[0][1]} from ${JSON.stringify(
|
|
375
|
+
request
|
|
376
|
+
)}${attributes};\n`;
|
|
352
377
|
} else {
|
|
353
378
|
content = `import { ${imported
|
|
354
379
|
.map(([name, finalName]) => {
|
|
@@ -469,6 +494,7 @@ const getSourceForModuleExternal = (
|
|
|
469
494
|
dependencyMeta,
|
|
470
495
|
concatenationScope
|
|
471
496
|
) => {
|
|
497
|
+
const phase = dependencyMeta && dependencyMeta.phase;
|
|
472
498
|
/** @type {Imported} */
|
|
473
499
|
let imported = true;
|
|
474
500
|
if (concatenationScope) {
|
|
@@ -497,6 +523,14 @@ const getSourceForModuleExternal = (
|
|
|
497
523
|
imported = true;
|
|
498
524
|
}
|
|
499
525
|
|
|
526
|
+
// `import defer …` is only valid as `import defer * as ns from "…"`, so
|
|
527
|
+
// keep the namespace form even if usage analysis would otherwise narrow
|
|
528
|
+
// the import down to specific names. Defer + concatenation is semantically
|
|
529
|
+
// at odds (lazy vs. eager), so we preserve the user-written shape here.
|
|
530
|
+
if (ImportPhaseUtils.isDefer(phase)) {
|
|
531
|
+
imported = true;
|
|
532
|
+
}
|
|
533
|
+
|
|
500
534
|
const initFragment = new ModuleExternalInitFragment(
|
|
501
535
|
moduleAndSpecifiers[0],
|
|
502
536
|
imported,
|
|
@@ -751,7 +785,21 @@ class ExternalModule extends Module {
|
|
|
751
785
|
* @returns {string} a unique identifier of the module
|
|
752
786
|
*/
|
|
753
787
|
identifier() {
|
|
754
|
-
|
|
788
|
+
let id = `external ${this._resolveExternalType(
|
|
789
|
+
this.externalType
|
|
790
|
+
)} ${JSON.stringify(this.request)}`;
|
|
791
|
+
const meta = /** @type {ImportDependencyMeta | undefined} */ (
|
|
792
|
+
this.dependencyMeta
|
|
793
|
+
);
|
|
794
|
+
if (meta) {
|
|
795
|
+
if (meta.phase) {
|
|
796
|
+
id += `|phase=${ImportPhaseUtils.stringify(meta.phase)}`;
|
|
797
|
+
}
|
|
798
|
+
if (meta.attributes) {
|
|
799
|
+
id += `|attributes=${JSON.stringify(meta.attributes)}`;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
return id;
|
|
755
803
|
}
|
|
756
804
|
|
|
757
805
|
/**
|
|
@@ -1126,7 +1174,9 @@ class ExternalModule extends Module {
|
|
|
1126
1174
|
scope.registerRawExport(specifier, finalName);
|
|
1127
1175
|
}
|
|
1128
1176
|
} else if (concatenationScope) {
|
|
1129
|
-
sourceString = `${runtimeTemplate.renderConst()} ${
|
|
1177
|
+
sourceString = `${runtimeTemplate.renderConst()} ${
|
|
1178
|
+
ConcatenationScope.NAMESPACE_OBJECT_EXPORT
|
|
1179
|
+
} = ${sourceString};`;
|
|
1130
1180
|
concatenationScope.registerNamespaceExport(
|
|
1131
1181
|
ConcatenationScope.NAMESPACE_OBJECT_EXPORT
|
|
1132
1182
|
);
|
|
@@ -1194,10 +1244,21 @@ class ExternalModule extends Module {
|
|
|
1194
1244
|
updateHash(hash, context) {
|
|
1195
1245
|
const { chunkGraph } = context;
|
|
1196
1246
|
hash.update(
|
|
1197
|
-
`${this._resolveExternalType(this.externalType)}${JSON.stringify(
|
|
1198
|
-
|
|
1199
|
-
)}`
|
|
1247
|
+
`${this._resolveExternalType(this.externalType)}${JSON.stringify(
|
|
1248
|
+
this.request
|
|
1249
|
+
)}${this.isOptional(chunkGraph.moduleGraph)}`
|
|
1250
|
+
);
|
|
1251
|
+
const meta = /** @type {ImportDependencyMeta | undefined} */ (
|
|
1252
|
+
this.dependencyMeta
|
|
1200
1253
|
);
|
|
1254
|
+
if (meta) {
|
|
1255
|
+
if (meta.phase) {
|
|
1256
|
+
hash.update(`|phase=${ImportPhaseUtils.stringify(meta.phase)}`);
|
|
1257
|
+
}
|
|
1258
|
+
if (meta.attributes) {
|
|
1259
|
+
hash.update(`|attributes=${JSON.stringify(meta.attributes)}`);
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1201
1262
|
super.updateHash(hash, context);
|
|
1202
1263
|
}
|
|
1203
1264
|
|
|
@@ -193,6 +193,11 @@ class ExternalModuleFactoryPlugin {
|
|
|
193
193
|
|
|
194
194
|
dependencyMeta = {
|
|
195
195
|
attributes: dependency.attributes,
|
|
196
|
+
phase:
|
|
197
|
+
dependency instanceof HarmonyImportDependency ||
|
|
198
|
+
dependency instanceof ImportDependency
|
|
199
|
+
? dependency.phase
|
|
200
|
+
: undefined,
|
|
196
201
|
externalType
|
|
197
202
|
};
|
|
198
203
|
} else if (dependency instanceof CssImportDependency) {
|