webpack 5.99.9 → 5.100.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/bin/webpack.js +8 -2
- package/hot/log.js +15 -15
- package/hot/poll.js +1 -0
- package/lib/APIPlugin.js +3 -3
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -0
- package/lib/BannerPlugin.js +1 -1
- package/lib/CaseSensitiveModulesWarning.js +4 -4
- package/lib/Chunk.js +6 -6
- package/lib/ChunkGraph.js +37 -31
- package/lib/ChunkGroup.js +4 -4
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +94 -17
- package/lib/CodeGenerationResults.js +1 -1
- package/lib/CompatibilityPlugin.js +5 -2
- package/lib/Compilation.js +67 -45
- package/lib/Compiler.js +46 -16
- package/lib/ConcatenationScope.js +15 -6
- package/lib/ConstPlugin.js +5 -3
- package/lib/ContextModule.js +16 -12
- package/lib/ContextModuleFactory.js +4 -3
- package/lib/ContextReplacementPlugin.js +4 -2
- package/lib/CssModule.js +2 -2
- package/lib/DefinePlugin.js +111 -3
- package/lib/DelegatedModuleFactoryPlugin.js +18 -18
- package/lib/Dependency.js +11 -4
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DllEntryPlugin.js +3 -1
- package/lib/DllPlugin.js +4 -3
- package/lib/DllReferencePlugin.js +2 -2
- package/lib/DynamicEntryPlugin.js +1 -1
- package/lib/EntryOptionPlugin.js +5 -0
- package/lib/ErrorHelpers.js +4 -4
- package/lib/EvalDevToolModulePlugin.js +3 -3
- package/lib/EvalSourceMapDevToolPlugin.js +7 -7
- package/lib/ExportsInfo.js +48 -39
- package/lib/ExternalModule.js +15 -11
- package/lib/ExternalModuleFactoryPlugin.js +5 -2
- package/lib/FileSystemInfo.js +51 -36
- package/lib/FlagDependencyExportsPlugin.js +14 -7
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +14 -1
- package/lib/HookWebpackError.js +1 -0
- package/lib/HotModuleReplacementPlugin.js +77 -50
- package/lib/IgnorePlugin.js +5 -2
- package/lib/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +0 -1
- package/lib/LibManifestPlugin.js +4 -2
- package/lib/LoaderOptionsPlugin.js +6 -4
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +21 -6
- package/lib/ModuleFactory.js +1 -0
- package/lib/ModuleGraph.js +24 -2
- package/lib/ModuleGraphConnection.js +5 -5
- package/lib/ModuleInfoHeaderPlugin.js +2 -1
- package/lib/ModuleParseError.js +1 -0
- package/lib/ModuleSourceTypesConstants.js +12 -12
- package/lib/ModuleTemplate.js +1 -1
- package/lib/ModuleTypeConstants.js +21 -21
- package/lib/MultiCompiler.js +6 -6
- package/lib/NormalModule.js +31 -44
- package/lib/NormalModuleFactory.js +34 -20
- package/lib/NormalModuleReplacementPlugin.js +1 -1
- package/lib/NullFactory.js +1 -0
- package/lib/OptimizationStages.js +1 -1
- package/lib/Parser.js +1 -0
- package/lib/ProgressPlugin.js +12 -5
- package/lib/ProvidePlugin.js +5 -1
- package/lib/RawModule.js +14 -0
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/RuntimeGlobals.js +175 -155
- package/lib/RuntimeModule.js +1 -0
- package/lib/RuntimePlugin.js +33 -7
- package/lib/RuntimeTemplate.js +111 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
- package/lib/SourceMapDevToolPlugin.js +19 -17
- package/lib/Template.js +2 -2
- package/lib/TemplatedPathPlugin.js +1 -1
- package/lib/WarnDeprecatedOptionPlugin.js +7 -8
- package/lib/WatchIgnorePlugin.js +4 -3
- package/lib/WebpackIsIncludedPlugin.js +2 -1
- package/lib/WebpackOptionsApply.js +115 -27
- package/lib/asset/AssetGenerator.js +15 -11
- package/lib/asset/AssetModulesPlugin.js +19 -17
- package/lib/asset/AssetSourceGenerator.js +4 -4
- package/lib/asset/RawDataUrlModule.js +4 -2
- package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
- package/lib/buildChunkGraph.js +6 -3
- package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
- package/lib/cache/IdleFileCachePlugin.js +7 -4
- package/lib/cache/MemoryCachePlugin.js +1 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +26 -20
- package/lib/cache/ResolverCachePlugin.js +16 -8
- package/lib/cli.js +15 -10
- package/lib/config/browserslistTargetHandler.js +3 -3
- package/lib/config/defaults.js +25 -17
- package/lib/config/normalization.js +2 -1
- package/lib/config/target.js +6 -5
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackModule.js +2 -1
- package/lib/container/HoistContainerReferencesPlugin.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +2 -2
- package/lib/container/RemoteModule.js +1 -1
- package/lib/css/CssGenerator.js +9 -6
- package/lib/css/CssModulesPlugin.js +44 -31
- package/lib/css/CssParser.js +6 -4
- package/lib/css/walkCssTokens.js +33 -37
- package/lib/debug/ProfilingPlugin.js +6 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
- package/lib/dependencies/AMDPlugin.js +12 -8
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
- package/lib/dependencies/CachedConstDependency.js +1 -5
- package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
- package/lib/dependencies/CommonJsPlugin.js +15 -16
- package/lib/dependencies/ContextDependencyHelpers.js +2 -1
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/DynamicExports.js +9 -9
- package/lib/dependencies/ExportsInfoDependency.js +1 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +11 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
- package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
- package/lib/dependencies/ImportMetaPlugin.js +2 -2
- package/lib/dependencies/ImportParserPlugin.js +40 -9
- package/lib/dependencies/ImportPlugin.js +3 -1
- package/lib/dependencies/LoaderPlugin.js +1 -0
- package/lib/dependencies/ModuleDependency.js +3 -1
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +3 -1
- package/lib/dependencies/RequireEnsurePlugin.js +6 -6
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
- package/lib/dependencies/RequireIncludePlugin.js +1 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLContextDependency.js +65 -0
- package/lib/dependencies/URLPlugin.js +17 -157
- package/lib/dependencies/WorkerPlugin.js +23 -10
- package/lib/dependencies/processExportInfo.js +2 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
- package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +70 -3
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
- package/lib/hmr/LazyCompilationPlugin.js +4 -2
- package/lib/hmr/lazyCompilationBackend.js +4 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
- package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
- package/lib/ids/HashedModuleIdsPlugin.js +5 -4
- package/lib/ids/IdHelpers.js +21 -17
- package/lib/ids/NamedChunkIdsPlugin.js +5 -5
- package/lib/ids/NamedModuleIdsPlugin.js +4 -4
- package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -3
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
- package/lib/javascript/BasicEvaluatedExpression.js +2 -1
- package/lib/javascript/ChunkHelpers.js +1 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
- package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
- package/lib/javascript/JavascriptGenerator.js +14 -2
- package/lib/javascript/JavascriptModulesPlugin.js +68 -27
- package/lib/javascript/JavascriptParser.js +117 -76
- package/lib/javascript/JavascriptParserHelpers.js +41 -41
- package/lib/javascript/StartupHelpers.js +17 -17
- package/lib/json/JsonGenerator.js +4 -2
- package/lib/json/JsonModulesPlugin.js +2 -2
- package/lib/json/JsonParser.js +1 -1
- package/lib/library/AbstractLibraryPlugin.js +6 -2
- package/lib/library/AssignLibraryPlugin.js +21 -6
- package/lib/library/EnableLibraryPlugin.js +23 -3
- package/lib/library/UmdLibraryPlugin.js +15 -6
- package/lib/logging/createConsoleLogger.js +3 -3
- package/lib/logging/runtime.js +9 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/nodeConsole.js +4 -2
- package/lib/optimize/AggressiveMergingPlugin.js +45 -46
- package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
- package/lib/optimize/ConcatenatedModule.js +227 -57
- package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
- package/lib/optimize/InnerGraph.js +115 -112
- package/lib/optimize/InnerGraphPlugin.js +2 -2
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +4 -3
- package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
- package/lib/optimize/MinChunkSizePlugin.js +6 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
- package/lib/optimize/RealContentHashPlugin.js +26 -20
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
- package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
- package/lib/optimize/SplitChunksPlugin.js +16 -13
- package/lib/rules/BasicEffectRulePlugin.js +4 -2
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
- package/lib/rules/RuleSetCompiler.js +19 -5
- package/lib/rules/UseEffectRulePlugin.js +17 -9
- package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +27 -19
- package/lib/schemes/VirtualUrlPlugin.js +222 -0
- package/lib/serialization/AggregateErrorSerializer.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +5 -4
- package/lib/serialization/FileMiddleware.js +7 -4
- package/lib/serialization/ObjectMiddleware.js +14 -8
- package/lib/serialization/Serializer.js +5 -3
- package/lib/serialization/SerializerMiddleware.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ConsumeSharedPlugin.js +3 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +3 -2
- package/lib/sharing/SharePlugin.js +2 -1
- package/lib/sharing/ShareRuntimeModule.js +3 -5
- package/lib/sharing/utils.js +34 -34
- package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
- package/lib/stats/DefaultStatsPresetPlugin.js +13 -13
- package/lib/stats/DefaultStatsPrinterPlugin.js +15 -9
- package/lib/stats/StatsFactory.js +6 -3
- package/lib/stats/StatsPrinter.js +6 -7
- package/lib/url/URLParserPlugin.js +266 -0
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Hash.js +2 -0
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/LazyBucketSortedSet.js +2 -1
- package/lib/util/LazySet.js +11 -6
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/SetHelpers.js +3 -3
- package/lib/util/SortableSet.js +2 -2
- package/lib/util/StackedCacheMap.js +3 -1
- package/lib/util/StackedMap.js +2 -2
- package/lib/util/StringXor.js +1 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -1
- package/lib/util/cleverMerge.js +95 -58
- package/lib/util/comparators.js +154 -127
- package/lib/util/compileBooleanMatcher.js +8 -3
- package/lib/util/concatenate.js +8 -7
- package/lib/util/conventions.js +72 -73
- package/lib/util/create-schema-validation.js +2 -1
- package/lib/util/createHash.js +10 -4
- package/lib/util/deprecation.js +69 -66
- package/lib/util/deterministicGrouping.js +4 -2
- package/lib/util/extractUrlAndGlobal.js +1 -1
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +30 -23
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +4 -2
- package/lib/util/identifier.js +13 -12
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/magicComment.js +5 -5
- package/lib/util/processAsyncTree.js +1 -1
- package/lib/util/propertyAccess.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -2
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +29 -21
- package/lib/util/semver.js +1 -1
- package/lib/util/serialization.js +3 -0
- package/lib/util/source.js +3 -2
- package/lib/validateSchema.js +1 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
- package/lib/webpack.js +4 -5
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
- package/package.json +119 -113
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +17 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
- package/types.d.ts +1243 -409
|
@@ -5,34 +5,37 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
const {
|
|
9
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
|
10
|
+
JAVASCRIPT_MODULE_TYPE_ESM
|
|
11
|
+
} = require("../ModuleTypeConstants");
|
|
8
12
|
const HarmonyAcceptDependency = require("./HarmonyAcceptDependency");
|
|
9
13
|
const HarmonyAcceptImportDependency = require("./HarmonyAcceptImportDependency");
|
|
10
14
|
const HarmonyCompatibilityDependency = require("./HarmonyCompatibilityDependency");
|
|
15
|
+
const HarmonyDetectionParserPlugin = require("./HarmonyDetectionParserPlugin");
|
|
11
16
|
const HarmonyEvaluatedImportSpecifierDependency = require("./HarmonyEvaluatedImportSpecifierDependency");
|
|
17
|
+
const HarmonyExportDependencyParserPlugin = require("./HarmonyExportDependencyParserPlugin");
|
|
12
18
|
const HarmonyExportExpressionDependency = require("./HarmonyExportExpressionDependency");
|
|
13
19
|
const HarmonyExportHeaderDependency = require("./HarmonyExportHeaderDependency");
|
|
14
20
|
const HarmonyExportImportedSpecifierDependency = require("./HarmonyExportImportedSpecifierDependency");
|
|
15
21
|
const HarmonyExportSpecifierDependency = require("./HarmonyExportSpecifierDependency");
|
|
22
|
+
const HarmonyImportDependencyParserPlugin = require("./HarmonyImportDependencyParserPlugin");
|
|
16
23
|
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
|
|
17
24
|
const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
|
|
18
25
|
|
|
19
|
-
const {
|
|
20
|
-
JAVASCRIPT_MODULE_TYPE_AUTO,
|
|
21
|
-
JAVASCRIPT_MODULE_TYPE_ESM
|
|
22
|
-
} = require("../ModuleTypeConstants");
|
|
23
|
-
const HarmonyDetectionParserPlugin = require("./HarmonyDetectionParserPlugin");
|
|
24
|
-
const HarmonyExportDependencyParserPlugin = require("./HarmonyExportDependencyParserPlugin");
|
|
25
|
-
const HarmonyImportDependencyParserPlugin = require("./HarmonyImportDependencyParserPlugin");
|
|
26
26
|
const HarmonyTopLevelThisParserPlugin = require("./HarmonyTopLevelThisParserPlugin");
|
|
27
27
|
|
|
28
28
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
29
29
|
/** @typedef {import("../Compiler")} Compiler */
|
|
30
30
|
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
|
31
|
+
/**
|
|
32
|
+
* @typedef HarmonyModulesPluginOptions
|
|
33
|
+
* @property {boolean=} topLevelAwait
|
|
34
|
+
* @property {boolean=} deferImport
|
|
35
|
+
*/
|
|
31
36
|
|
|
32
37
|
const PLUGIN_NAME = "HarmonyModulesPlugin";
|
|
33
38
|
|
|
34
|
-
/** @typedef {{ topLevelAwait?: boolean }} HarmonyModulesPluginOptions */
|
|
35
|
-
|
|
36
39
|
class HarmonyModulesPlugin {
|
|
37
40
|
/**
|
|
38
41
|
* @param {HarmonyModulesPluginOptions} options options
|
|
@@ -127,12 +130,19 @@ class HarmonyModulesPlugin {
|
|
|
127
130
|
*/
|
|
128
131
|
const handler = (parser, parserOptions) => {
|
|
129
132
|
// TODO webpack 6: rename harmony to esm or module
|
|
130
|
-
if (parserOptions.harmony !== undefined && !parserOptions.harmony)
|
|
133
|
+
if (parserOptions.harmony !== undefined && !parserOptions.harmony) {
|
|
131
134
|
return;
|
|
135
|
+
}
|
|
132
136
|
|
|
133
137
|
new HarmonyDetectionParserPlugin(this.options).apply(parser);
|
|
134
|
-
new HarmonyImportDependencyParserPlugin(
|
|
135
|
-
|
|
138
|
+
new HarmonyImportDependencyParserPlugin(
|
|
139
|
+
parserOptions,
|
|
140
|
+
this.options.deferImport
|
|
141
|
+
).apply(parser);
|
|
142
|
+
new HarmonyExportDependencyParserPlugin(
|
|
143
|
+
parserOptions,
|
|
144
|
+
this.options.deferImport
|
|
145
|
+
).apply(parser);
|
|
136
146
|
new HarmonyTopLevelThisParserPlugin().apply(parser);
|
|
137
147
|
};
|
|
138
148
|
|
|
@@ -146,4 +156,5 @@ class HarmonyModulesPlugin {
|
|
|
146
156
|
);
|
|
147
157
|
}
|
|
148
158
|
}
|
|
159
|
+
|
|
149
160
|
module.exports = HarmonyModulesPlugin;
|
|
@@ -15,9 +15,9 @@ const Template = require("../Template");
|
|
|
15
15
|
const BasicEvaluatedExpression = require("../javascript/BasicEvaluatedExpression");
|
|
16
16
|
const {
|
|
17
17
|
evaluateToIdentifier,
|
|
18
|
-
|
|
18
|
+
evaluateToNumber,
|
|
19
19
|
evaluateToString,
|
|
20
|
-
|
|
20
|
+
toConstantDependency
|
|
21
21
|
} = require("../javascript/JavascriptParserHelpers");
|
|
22
22
|
const memoize = require("../util/memoize");
|
|
23
23
|
const propertyAccess = require("../util/propertyAccess");
|
|
@@ -24,6 +24,8 @@ const ImportWeakDependency = require("./ImportWeakDependency");
|
|
|
24
24
|
/** @typedef {import("../javascript/JavascriptParser").ImportExpression} ImportExpression */
|
|
25
25
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
26
26
|
|
|
27
|
+
const PLUGIN_NAME = "ImportParserPlugin";
|
|
28
|
+
|
|
27
29
|
class ImportParserPlugin {
|
|
28
30
|
/**
|
|
29
31
|
* @param {JavascriptParserOptions} options options
|
|
@@ -44,7 +46,7 @@ class ImportParserPlugin {
|
|
|
44
46
|
*/
|
|
45
47
|
const exportsFromEnumerable = enumerable =>
|
|
46
48
|
Array.from(enumerable, e => [e]);
|
|
47
|
-
parser.hooks.importCall.tap(
|
|
49
|
+
parser.hooks.importCall.tap(PLUGIN_NAME, expr => {
|
|
48
50
|
const param = parser.evaluateExpression(expr.source);
|
|
49
51
|
|
|
50
52
|
let chunkName = null;
|
|
@@ -61,20 +63,26 @@ class ImportParserPlugin {
|
|
|
61
63
|
dynamicImportPrefetch,
|
|
62
64
|
dynamicImportFetchPriority
|
|
63
65
|
} = this.options;
|
|
64
|
-
if (
|
|
66
|
+
if (
|
|
67
|
+
dynamicImportPreload !== undefined &&
|
|
68
|
+
dynamicImportPreload !== false
|
|
69
|
+
) {
|
|
65
70
|
groupOptions.preloadOrder =
|
|
66
71
|
dynamicImportPreload === true ? 0 : dynamicImportPreload;
|
|
72
|
+
}
|
|
67
73
|
if (
|
|
68
74
|
dynamicImportPrefetch !== undefined &&
|
|
69
75
|
dynamicImportPrefetch !== false
|
|
70
|
-
)
|
|
76
|
+
) {
|
|
71
77
|
groupOptions.prefetchOrder =
|
|
72
78
|
dynamicImportPrefetch === true ? 0 : dynamicImportPrefetch;
|
|
79
|
+
}
|
|
73
80
|
if (
|
|
74
81
|
dynamicImportFetchPriority !== undefined &&
|
|
75
82
|
dynamicImportFetchPriority !== false
|
|
76
|
-
)
|
|
83
|
+
) {
|
|
77
84
|
groupOptions.fetchPriority = dynamicImportFetchPriority;
|
|
85
|
+
}
|
|
78
86
|
|
|
79
87
|
const { options: importOptions, errors: commentErrors } =
|
|
80
88
|
parser.parseCommentOptions(/** @type {Range} */ (expr.range));
|
|
@@ -91,6 +99,28 @@ class ImportParserPlugin {
|
|
|
91
99
|
}
|
|
92
100
|
}
|
|
93
101
|
|
|
102
|
+
let phase = expr.phase;
|
|
103
|
+
if (!phase && importOptions && importOptions.webpackDefer !== undefined) {
|
|
104
|
+
if (typeof importOptions.webpackDefer !== "boolean") {
|
|
105
|
+
parser.state.module.addWarning(
|
|
106
|
+
new UnsupportedFeatureWarning(
|
|
107
|
+
`\`webpackDefer\` expected a boolean, but received: ${importOptions.webpackDefer}.`,
|
|
108
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
|
109
|
+
)
|
|
110
|
+
);
|
|
111
|
+
} else if (importOptions.webpackDefer) {
|
|
112
|
+
phase = "defer";
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (phase === "defer") {
|
|
116
|
+
parser.state.module.addWarning(
|
|
117
|
+
new UnsupportedFeatureWarning(
|
|
118
|
+
"import.defer() is not implemented yet.",
|
|
119
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
|
120
|
+
)
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
94
124
|
if (importOptions) {
|
|
95
125
|
if (importOptions.webpackIgnore !== undefined) {
|
|
96
126
|
if (typeof importOptions.webpackIgnore !== "boolean") {
|
|
@@ -254,6 +284,7 @@ class ImportParserPlugin {
|
|
|
254
284
|
)
|
|
255
285
|
);
|
|
256
286
|
}
|
|
287
|
+
|
|
257
288
|
exports = exportsFromEnumerable(
|
|
258
289
|
[...referencedPropertiesInDestructuring].map(({ id }) => id)
|
|
259
290
|
);
|
|
@@ -315,11 +346,11 @@ class ImportParserPlugin {
|
|
|
315
346
|
include,
|
|
316
347
|
exclude,
|
|
317
348
|
mode,
|
|
318
|
-
namespaceObject:
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
349
|
+
namespaceObject:
|
|
350
|
+
/** @type {BuildMeta} */
|
|
351
|
+
(parser.state.module.buildMeta).strictHarmonyModule
|
|
352
|
+
? "strict"
|
|
353
|
+
: true,
|
|
323
354
|
typePrefix: "import()",
|
|
324
355
|
category: "esm",
|
|
325
356
|
referencedExports: exports,
|
|
@@ -74,8 +74,9 @@ class ImportPlugin {
|
|
|
74
74
|
* @returns {void}
|
|
75
75
|
*/
|
|
76
76
|
const handler = (parser, parserOptions) => {
|
|
77
|
-
if (parserOptions.import !== undefined && !parserOptions.import)
|
|
77
|
+
if (parserOptions.import !== undefined && !parserOptions.import) {
|
|
78
78
|
return;
|
|
79
|
+
}
|
|
79
80
|
|
|
80
81
|
new ImportParserPlugin(parserOptions).apply(parser);
|
|
81
82
|
};
|
|
@@ -93,4 +94,5 @@ class ImportPlugin {
|
|
|
93
94
|
);
|
|
94
95
|
}
|
|
95
96
|
}
|
|
97
|
+
|
|
96
98
|
module.exports = ImportPlugin;
|
|
@@ -61,11 +61,13 @@ class ModuleDependency extends Dependency {
|
|
|
61
61
|
* @returns {Module} ignored module
|
|
62
62
|
*/
|
|
63
63
|
createIgnoredModule(context) {
|
|
64
|
-
|
|
64
|
+
const module = new RawModule(
|
|
65
65
|
"/* (ignored) */",
|
|
66
66
|
`ignored|${context}|${this.request}`,
|
|
67
67
|
`${this.request} (ignored)`
|
|
68
68
|
);
|
|
69
|
+
module.factoryMeta = { sideEffectFree: true };
|
|
70
|
+
return module;
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
/**
|
|
@@ -57,8 +57,9 @@ class RequireContextPlugin {
|
|
|
57
57
|
if (
|
|
58
58
|
parserOptions.requireContext !== undefined &&
|
|
59
59
|
!parserOptions.requireContext
|
|
60
|
-
)
|
|
60
|
+
) {
|
|
61
61
|
return;
|
|
62
|
+
}
|
|
62
63
|
|
|
63
64
|
new RequireContextDependencyParserPlugin().apply(parser);
|
|
64
65
|
};
|
|
@@ -161,4 +162,5 @@ class RequireContextPlugin {
|
|
|
161
162
|
);
|
|
162
163
|
}
|
|
163
164
|
}
|
|
165
|
+
|
|
164
166
|
module.exports = RequireContextPlugin;
|
|
@@ -5,11 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const RequireEnsureDependency = require("./RequireEnsureDependency");
|
|
9
|
-
const RequireEnsureItemDependency = require("./RequireEnsureItemDependency");
|
|
10
|
-
|
|
11
|
-
const RequireEnsureDependenciesBlockParserPlugin = require("./RequireEnsureDependenciesBlockParserPlugin");
|
|
12
|
-
|
|
13
8
|
const {
|
|
14
9
|
JAVASCRIPT_MODULE_TYPE_AUTO,
|
|
15
10
|
JAVASCRIPT_MODULE_TYPE_DYNAMIC
|
|
@@ -18,6 +13,9 @@ const {
|
|
|
18
13
|
evaluateToString,
|
|
19
14
|
toConstantDependency
|
|
20
15
|
} = require("../javascript/JavascriptParserHelpers");
|
|
16
|
+
const RequireEnsureDependenciesBlockParserPlugin = require("./RequireEnsureDependenciesBlockParserPlugin");
|
|
17
|
+
const RequireEnsureDependency = require("./RequireEnsureDependency");
|
|
18
|
+
const RequireEnsureItemDependency = require("./RequireEnsureItemDependency");
|
|
21
19
|
|
|
22
20
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
23
21
|
/** @typedef {import("../Compiler")} Compiler */
|
|
@@ -58,8 +56,9 @@ class RequireEnsurePlugin {
|
|
|
58
56
|
if (
|
|
59
57
|
parserOptions.requireEnsure !== undefined &&
|
|
60
58
|
!parserOptions.requireEnsure
|
|
61
|
-
)
|
|
59
|
+
) {
|
|
62
60
|
return;
|
|
61
|
+
}
|
|
63
62
|
|
|
64
63
|
new RequireEnsureDependenciesBlockParserPlugin().apply(parser);
|
|
65
64
|
parser.hooks.evaluateTypeof
|
|
@@ -83,4 +82,5 @@ class RequireEnsurePlugin {
|
|
|
83
82
|
);
|
|
84
83
|
}
|
|
85
84
|
}
|
|
85
|
+
|
|
86
86
|
module.exports = RequireEnsurePlugin;
|
|
@@ -17,6 +17,8 @@ const RequireIncludeDependency = require("./RequireIncludeDependency");
|
|
|
17
17
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|
18
18
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
19
19
|
|
|
20
|
+
const PLUGIN_NAME = "RequireIncludeDependencyParserPlugin";
|
|
21
|
+
|
|
20
22
|
module.exports = class RequireIncludeDependencyParserPlugin {
|
|
21
23
|
/**
|
|
22
24
|
* @param {boolean} warn true: warn about deprecation, false: don't warn
|
|
@@ -31,32 +33,31 @@ module.exports = class RequireIncludeDependencyParserPlugin {
|
|
|
31
33
|
*/
|
|
32
34
|
apply(parser) {
|
|
33
35
|
const { warn } = this;
|
|
34
|
-
parser.hooks.call
|
|
35
|
-
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
const param = parser.evaluateExpression(expr.arguments[0]);
|
|
39
|
-
if (!param.isString()) return;
|
|
36
|
+
parser.hooks.call.for("require.include").tap(PLUGIN_NAME, expr => {
|
|
37
|
+
if (expr.arguments.length !== 1) return;
|
|
38
|
+
const param = parser.evaluateExpression(expr.arguments[0]);
|
|
39
|
+
if (!param.isString()) return;
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
)
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const dep = new RequireIncludeDependency(
|
|
50
|
-
/** @type {string} */ (param.string),
|
|
51
|
-
/** @type {Range} */ (expr.range)
|
|
41
|
+
if (warn) {
|
|
42
|
+
parser.state.module.addWarning(
|
|
43
|
+
new RequireIncludeDeprecationWarning(
|
|
44
|
+
/** @type {DependencyLocation} */
|
|
45
|
+
(expr.loc)
|
|
46
|
+
)
|
|
52
47
|
);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const dep = new RequireIncludeDependency(
|
|
51
|
+
/** @type {string} */ (param.string),
|
|
52
|
+
/** @type {Range} */ (expr.range)
|
|
53
|
+
);
|
|
54
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
55
|
+
parser.state.current.addDependency(dep);
|
|
56
|
+
return true;
|
|
57
|
+
});
|
|
57
58
|
parser.hooks.evaluateTypeof
|
|
58
59
|
.for("require.include")
|
|
59
|
-
.tap(
|
|
60
|
+
.tap(PLUGIN_NAME, expr => {
|
|
60
61
|
if (warn) {
|
|
61
62
|
parser.state.module.addWarning(
|
|
62
63
|
new RequireIncludeDeprecationWarning(
|
|
@@ -66,18 +67,16 @@ module.exports = class RequireIncludeDependencyParserPlugin {
|
|
|
66
67
|
}
|
|
67
68
|
return evaluateToString("function")(expr);
|
|
68
69
|
});
|
|
69
|
-
parser.hooks.typeof
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return toConstantDependency(parser, JSON.stringify("function"))(expr);
|
|
80
|
-
});
|
|
70
|
+
parser.hooks.typeof.for("require.include").tap(PLUGIN_NAME, expr => {
|
|
71
|
+
if (warn) {
|
|
72
|
+
parser.state.module.addWarning(
|
|
73
|
+
new RequireIncludeDeprecationWarning(
|
|
74
|
+
/** @type {DependencyLocation} */ (expr.loc)
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return toConstantDependency(parser, JSON.stringify("function"))(expr);
|
|
79
|
+
});
|
|
81
80
|
}
|
|
82
81
|
};
|
|
83
82
|
|
|
@@ -36,7 +36,7 @@ class RuntimeRequirementsDependency extends NullDependency {
|
|
|
36
36
|
*/
|
|
37
37
|
updateHash(hash, context) {
|
|
38
38
|
if (this._hashUpdate === undefined) {
|
|
39
|
-
this._hashUpdate = `${
|
|
39
|
+
this._hashUpdate = `${[...this.runtimeRequirements].join()}`;
|
|
40
40
|
}
|
|
41
41
|
hash.update(this._hashUpdate);
|
|
42
42
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Haijie Xie @hai-x
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const makeSerializable = require("../util/makeSerializable");
|
|
9
|
+
const ContextDependency = require("./ContextDependency");
|
|
10
|
+
const ContextDependencyTemplateAsRequireCall = require("./ContextDependencyTemplateAsRequireCall");
|
|
11
|
+
|
|
12
|
+
/** @typedef {import("../ContextModule").ContextOptions} ContextOptions */
|
|
13
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
14
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
15
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
16
|
+
|
|
17
|
+
/** @typedef {ContextOptions & { request: string }} ContextDependencyOptions */
|
|
18
|
+
|
|
19
|
+
class URLContextDependency extends ContextDependency {
|
|
20
|
+
/**
|
|
21
|
+
* @param {ContextDependencyOptions} options options
|
|
22
|
+
* @param {Range} range range
|
|
23
|
+
* @param {Range} valueRange value range
|
|
24
|
+
*/
|
|
25
|
+
constructor(options, range, valueRange) {
|
|
26
|
+
super(options);
|
|
27
|
+
this.range = range;
|
|
28
|
+
this.valueRange = valueRange;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get type() {
|
|
32
|
+
return "new URL() context";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get category() {
|
|
36
|
+
return "url";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {ObjectSerializerContext} context context
|
|
41
|
+
*/
|
|
42
|
+
serialize(context) {
|
|
43
|
+
const { write } = context;
|
|
44
|
+
write(this.valueRange);
|
|
45
|
+
super.serialize(context);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {ObjectDeserializerContext} context context
|
|
50
|
+
*/
|
|
51
|
+
deserialize(context) {
|
|
52
|
+
const { read } = context;
|
|
53
|
+
this.valueRange = read();
|
|
54
|
+
super.deserialize(context);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
makeSerializable(
|
|
59
|
+
URLContextDependency,
|
|
60
|
+
"webpack/lib/dependencies/URLContextDependency"
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
URLContextDependency.Template = ContextDependencyTemplateAsRequireCall;
|
|
64
|
+
|
|
65
|
+
module.exports = URLContextDependency;
|