webpack 5.101.3 → 5.102.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 +21 -26
- package/lib/APIPlugin.js +30 -36
- package/lib/AsyncDependenciesBlock.js +1 -4
- package/lib/BannerPlugin.js +0 -1
- package/lib/Cache.js +7 -6
- package/lib/CacheFacade.js +0 -1
- package/lib/Chunk.js +49 -31
- package/lib/ChunkGraph.js +35 -25
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +2 -1
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +204 -185
- package/lib/Compiler.js +36 -35
- package/lib/ConcatenationScope.js +6 -1
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +6 -5
- package/lib/ContextExclusionPlugin.js +0 -1
- package/lib/ContextModule.js +22 -20
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +4 -8
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +1 -3
- package/lib/DllModule.js +1 -7
- package/lib/DllReferencePlugin.js +2 -4
- package/lib/DynamicEntryPlugin.js +0 -2
- package/lib/EntryOptionPlugin.js +0 -5
- package/lib/EnvironmentNotSupportAsyncWarning.js +0 -3
- package/lib/EvalDevToolModulePlugin.js +4 -3
- package/lib/EvalSourceMapDevToolPlugin.js +3 -4
- package/lib/ExportsInfo.js +50 -49
- package/lib/ExternalModule.js +84 -52
- package/lib/ExternalModuleFactoryPlugin.js +27 -7
- package/lib/ExternalsPlugin.js +24 -17
- package/lib/FileSystemInfo.js +96 -78
- package/lib/FlagDependencyUsagePlugin.js +3 -4
- package/lib/Generator.js +2 -13
- package/lib/GraphHelpers.js +0 -3
- package/lib/HookWebpackError.js +0 -2
- package/lib/HotModuleReplacementPlugin.js +22 -24
- package/lib/HotUpdateChunk.js +0 -3
- package/lib/IgnorePlugin.js +5 -2
- package/lib/InitFragment.js +41 -29
- package/lib/InvalidDependenciesModuleWarning.js +0 -1
- package/lib/LibManifestPlugin.js +4 -6
- package/lib/LoaderOptionsPlugin.js +1 -10
- package/lib/MainTemplate.js +8 -19
- package/lib/Module.js +32 -20
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleFilenameHelpers.js +41 -24
- package/lib/ModuleGraph.js +30 -16
- package/lib/ModuleInfoHeaderPlugin.js +0 -1
- package/lib/ModuleTemplate.js +0 -2
- package/lib/ModuleTypeConstants.js +11 -1
- package/lib/MultiCompiler.js +23 -15
- package/lib/MultiWatching.js +6 -10
- package/lib/NodeStuffPlugin.js +2 -10
- package/lib/NormalModule.js +145 -88
- package/lib/NormalModuleFactory.js +59 -40
- package/lib/OptionsApply.js +1 -1
- package/lib/Parser.js +1 -1
- package/lib/ProgressPlugin.js +6 -10
- package/lib/ProvidePlugin.js +5 -7
- package/lib/RawModule.js +1 -6
- package/lib/RecordIdsPlugin.js +10 -6
- package/lib/ResolverFactory.js +0 -2
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimeModule.js +1 -3
- package/lib/RuntimePlugin.js +26 -22
- package/lib/RuntimeTemplate.js +12 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +6 -11
- package/lib/Stats.js +0 -1
- package/lib/Template.js +6 -11
- package/lib/TemplatedPathPlugin.js +2 -1
- package/lib/WatchIgnorePlugin.js +2 -3
- package/lib/Watching.js +15 -15
- package/lib/WebpackIsIncludedPlugin.js +0 -2
- package/lib/WebpackOptionsApply.js +74 -107
- package/lib/asset/AssetBytesGenerator.js +166 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +20 -34
- package/lib/asset/AssetModulesPlugin.js +34 -16
- package/lib/asset/AssetParser.js +7 -3
- package/lib/asset/AssetSourceGenerator.js +1 -1
- package/lib/asset/RawDataUrlModule.js +3 -2
- package/lib/async-modules/AsyncModuleHelpers.js +6 -4
- package/lib/buildChunkGraph.js +0 -1
- package/lib/cache/MemoryCachePlugin.js +0 -2
- package/lib/cache/MemoryWithGcCachePlugin.js +0 -2
- package/lib/cache/PackFileCacheStrategy.js +14 -1
- package/lib/cache/ResolverCachePlugin.js +9 -15
- package/lib/config/defaults.js +155 -21
- package/lib/config/normalization.js +18 -3
- package/lib/container/ContainerEntryDependency.js +0 -1
- package/lib/container/ContainerEntryModule.js +3 -7
- package/lib/container/ContainerPlugin.js +1 -2
- package/lib/container/ContainerReferencePlugin.js +0 -1
- package/lib/container/FallbackDependency.js +2 -1
- package/lib/container/FallbackModule.js +6 -7
- package/lib/container/ModuleFederationPlugin.js +0 -1
- package/lib/container/RemoteModule.js +8 -8
- package/lib/container/RemoteRuntimeModule.js +2 -2
- package/lib/css/CssGenerator.js +3 -6
- package/lib/css/CssLoadingRuntimeModule.js +6 -9
- package/lib/css/CssModulesPlugin.js +11 -13
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +1 -1
- package/lib/debug/ProfilingPlugin.js +35 -8
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
- package/lib/dependencies/AMDPlugin.js +2 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/CachedConstDependency.js +0 -4
- package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
- package/lib/dependencies/CommonJsExportsDependency.js +2 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
- package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +9 -4
- package/lib/dependencies/ContextDependencyHelpers.js +2 -2
- package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
- package/lib/dependencies/ContextElementDependency.js +22 -11
- package/lib/dependencies/CssIcssImportDependency.js +0 -2
- package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
- package/lib/dependencies/CssImportDependency.js +0 -8
- package/lib/dependencies/CssLocalIdentifierDependency.js +3 -4
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssUrlDependency.js +0 -6
- package/lib/dependencies/ExportsInfoDependency.js +7 -9
- package/lib/dependencies/ExternalModuleDependency.js +0 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
- package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
- package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
- package/lib/dependencies/HarmonyImportDependency.js +30 -14
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
- package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
- package/lib/dependencies/ImportDependency.js +18 -6
- package/lib/dependencies/ImportEagerDependency.js +2 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
- package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
- package/lib/dependencies/ImportMetaPlugin.js +2 -1
- package/lib/dependencies/ImportParserPlugin.js +288 -45
- package/lib/dependencies/ImportWeakDependency.js +2 -3
- package/lib/dependencies/JsonExportsDependency.js +0 -1
- package/lib/dependencies/LoaderDependency.js +0 -3
- package/lib/dependencies/LoaderImportDependency.js +0 -3
- package/lib/dependencies/LoaderPlugin.js +11 -5
- package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
- package/lib/dependencies/ModuleDependency.js +3 -9
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/ProvidedDependency.js +6 -8
- package/lib/dependencies/PureExpressionDependency.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/RequireIncludeDependency.js +2 -2
- package/lib/dependencies/RequireResolveDependency.js +2 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
- package/lib/dependencies/StaticExportsDependency.js +3 -5
- package/lib/dependencies/URLDependency.js +2 -7
- package/lib/dependencies/URLPlugin.js +1 -2
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
- package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
- package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
- package/lib/dependencies/WorkerDependency.js +2 -3
- package/lib/dependencies/WorkerPlugin.js +3 -9
- package/lib/dependencies/processExportInfo.js +2 -3
- package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
- package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
- package/lib/hmr/LazyCompilationPlugin.js +6 -4
- package/lib/hmr/lazyCompilationBackend.js +13 -10
- package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
- package/lib/ids/NamedChunkIdsPlugin.js +1 -6
- package/lib/ids/NamedModuleIdsPlugin.js +1 -5
- package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
- package/lib/ids/SyncModuleIdsPlugin.js +4 -3
- package/lib/index.js +8 -7
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
- package/lib/javascript/BasicEvaluatedExpression.js +13 -6
- package/lib/javascript/ChunkFormatHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
- package/lib/javascript/JavascriptGenerator.js +2 -3
- package/lib/javascript/JavascriptModulesPlugin.js +44 -21
- package/lib/javascript/JavascriptParser.js +119 -54
- package/lib/javascript/JavascriptParserHelpers.js +2 -2
- package/lib/javascript/StartupHelpers.js +2 -4
- package/lib/json/JsonData.js +1 -1
- package/lib/json/JsonGenerator.js +4 -5
- package/lib/json/JsonModulesPlugin.js +0 -3
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +0 -1
- package/lib/library/AssignLibraryPlugin.js +23 -12
- package/lib/library/EnableLibraryPlugin.js +7 -11
- package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
- package/lib/library/JsonpLibraryPlugin.js +5 -2
- package/lib/library/ModuleLibraryPlugin.js +88 -43
- package/lib/library/SystemLibraryPlugin.js +0 -1
- package/lib/library/UmdLibraryPlugin.js +12 -18
- package/lib/logging/Logger.js +12 -10
- package/lib/logging/createConsoleLogger.js +15 -14
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeWatchFileSystem.js +4 -4
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
- package/lib/node/nodeConsole.js +2 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
- package/lib/optimize/ConcatenatedModule.js +142 -100
- package/lib/optimize/InnerGraph.js +17 -11
- package/lib/optimize/InnerGraphPlugin.js +0 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
- package/lib/optimize/RuntimeChunkPlugin.js +0 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
- package/lib/optimize/SplitChunksPlugin.js +46 -40
- package/lib/performance/SizeLimitsPlugin.js +2 -1
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
- package/lib/rules/BasicMatcherRulePlugin.js +0 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
- package/lib/rules/RuleSetCompiler.js +8 -6
- package/lib/runtime/BaseUriRuntimeModule.js +2 -2
- package/lib/runtime/CompatRuntimeModule.js +0 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
- package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
- package/lib/runtime/PublicPathRuntimeModule.js +2 -2
- package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
- package/lib/runtime/SystemContextRuntimeModule.js +0 -2
- package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
- package/lib/schemes/DataUriPlugin.js +2 -28
- package/lib/schemes/FileUriPlugin.js +5 -2
- package/lib/schemes/HttpUriPlugin.js +4 -2
- package/lib/schemes/VirtualUrlPlugin.js +11 -11
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +30 -19
- package/lib/serialization/SerializerMiddleware.js +1 -3
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +3 -5
- package/lib/sharing/ConsumeSharedPlugin.js +2 -4
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
- package/lib/sharing/ProvideSharedModule.js +3 -7
- package/lib/sharing/SharePlugin.js +0 -2
- package/lib/sharing/ShareRuntimeModule.js +4 -1
- package/lib/sharing/resolveMatchedConfigs.js +14 -6
- package/lib/sharing/utils.js +0 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +178 -94
- package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
- package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
- package/lib/stats/StatsFactory.js +14 -11
- package/lib/url/URLParserPlugin.js +2 -4
- package/lib/util/ArrayHelpers.js +4 -4
- package/lib/util/AsyncQueue.js +1 -0
- package/lib/util/LazySet.js +2 -2
- package/lib/util/StackedCacheMap.js +0 -2
- package/lib/util/TupleSet.js +9 -4
- package/lib/util/URLAbsoluteSpecifier.js +0 -1
- package/lib/util/WeakTupleMap.js +1 -1
- package/lib/util/chainedImports.js +3 -1
- package/lib/util/cleverMerge.js +15 -18
- package/lib/util/comparators.js +2 -4
- package/lib/util/compileBooleanMatcher.js +11 -9
- package/lib/util/concatenate.js +1 -2
- package/lib/util/create-schema-validation.js +0 -1
- package/lib/util/dataURL.js +39 -0
- package/lib/util/deprecation.js +29 -31
- package/lib/util/deterministicGrouping.js +34 -30
- package/lib/util/extractSourceMap.js +319 -0
- package/lib/util/findGraphRoots.js +15 -5
- package/lib/util/fs.js +29 -8
- package/lib/util/semver.js +9 -8
- package/lib/util/smartGrouping.js +41 -26
- package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
- package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
- package/lib/wasm-sync/WebAssemblyParser.js +1 -4
- package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/web/JsonpTemplatePlugin.js +0 -1
- package/lib/webpack.js +21 -8
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +12 -12
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +77 -93
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +4 -0
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +5 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1129 -530
- package/SECURITY.md +0 -9
|
@@ -11,7 +11,7 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
11
11
|
const ModuleDependency = require("./ModuleDependency");
|
|
12
12
|
|
|
13
13
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
14
|
-
/** @typedef {import("../Dependency").
|
|
14
|
+
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
|
15
15
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
16
16
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
17
17
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
@@ -32,7 +32,7 @@ class RequireIncludeDependency extends ModuleDependency {
|
|
|
32
32
|
* Returns list of exports referenced by this dependency
|
|
33
33
|
* @param {ModuleGraph} moduleGraph module graph
|
|
34
34
|
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
|
35
|
-
* @returns {
|
|
35
|
+
* @returns {ReferencedExports} referenced exports
|
|
36
36
|
*/
|
|
37
37
|
getReferencedExports(moduleGraph, runtime) {
|
|
38
38
|
// This doesn't use any export
|
|
@@ -10,7 +10,7 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
10
10
|
const ModuleDependency = require("./ModuleDependency");
|
|
11
11
|
const ModuleDependencyAsId = require("./ModuleDependencyTemplateAsId");
|
|
12
12
|
|
|
13
|
-
/** @typedef {import("../Dependency").
|
|
13
|
+
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
|
14
14
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
15
15
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
16
16
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
@@ -40,7 +40,7 @@ class RequireResolveDependency extends ModuleDependency {
|
|
|
40
40
|
* Returns list of exports referenced by this dependency
|
|
41
41
|
* @param {ModuleGraph} moduleGraph module graph
|
|
42
42
|
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
|
43
|
-
* @returns {
|
|
43
|
+
* @returns {ReferencedExports} referenced exports
|
|
44
44
|
*/
|
|
45
45
|
getReferencedExports(moduleGraph, runtime) {
|
|
46
46
|
// This doesn't use any export
|
|
@@ -9,18 +9,17 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
9
9
|
const NullDependency = require("./NullDependency");
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
12
|
-
/** @typedef {import("
|
|
12
|
+
/** @typedef {import("./NullDependency").RawRuntimeRequirements} RawRuntimeRequirements */
|
|
13
13
|
/** @typedef {import("../Dependency")} Dependency */
|
|
14
14
|
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
|
15
15
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
16
|
-
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
17
16
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
18
17
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
19
18
|
/** @typedef {import("../util/Hash")} Hash */
|
|
20
19
|
|
|
21
20
|
class RuntimeRequirementsDependency extends NullDependency {
|
|
22
21
|
/**
|
|
23
|
-
* @param {
|
|
22
|
+
* @param {RawRuntimeRequirements} runtimeRequirements runtime requirements
|
|
24
23
|
*/
|
|
25
24
|
constructor(runtimeRequirements) {
|
|
26
25
|
super();
|
|
@@ -8,18 +8,16 @@
|
|
|
8
8
|
const makeSerializable = require("../util/makeSerializable");
|
|
9
9
|
const NullDependency = require("./NullDependency");
|
|
10
10
|
|
|
11
|
-
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
12
|
-
/** @typedef {import("../Dependency").ExportSpec} ExportSpec */
|
|
13
11
|
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
|
14
|
-
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
|
15
12
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
16
13
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
17
14
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
18
|
-
|
|
15
|
+
|
|
16
|
+
/** @typedef {string[] | true} Exports */
|
|
19
17
|
|
|
20
18
|
class StaticExportsDependency extends NullDependency {
|
|
21
19
|
/**
|
|
22
|
-
* @param {
|
|
20
|
+
* @param {Exports} exports export names
|
|
23
21
|
* @param {boolean} canMangle true, if mangling exports names is allowed
|
|
24
22
|
*/
|
|
25
23
|
constructor(exports, canMangle) {
|
|
@@ -15,20 +15,15 @@ const memoize = require("../util/memoize");
|
|
|
15
15
|
const ModuleDependency = require("./ModuleDependency");
|
|
16
16
|
|
|
17
17
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
18
|
-
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
19
18
|
/** @typedef {import("../Dependency")} Dependency */
|
|
20
19
|
/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
|
|
21
|
-
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
|
22
20
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
23
21
|
/** @typedef {import("../Module")} Module */
|
|
24
22
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
25
|
-
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
|
26
|
-
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
27
23
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
24
|
+
/** @typedef {import("../optimize/InnerGraph").UsedByExports} UsedByExports */
|
|
28
25
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
29
26
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
30
|
-
/** @typedef {import("../util/Hash")} Hash */
|
|
31
|
-
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
32
27
|
|
|
33
28
|
const getIgnoredRawDataUrlModule = memoize(
|
|
34
29
|
() => new RawDataUrlModule("data:,", "ignored-asset", "(ignored asset)")
|
|
@@ -46,7 +41,7 @@ class URLDependency extends ModuleDependency {
|
|
|
46
41
|
this.range = range;
|
|
47
42
|
this.outerRange = outerRange;
|
|
48
43
|
this.relative = relative || false;
|
|
49
|
-
/** @type {
|
|
44
|
+
/** @type {UsedByExports | undefined} */
|
|
50
45
|
this.usedByExports = undefined;
|
|
51
46
|
}
|
|
52
47
|
|
|
@@ -17,7 +17,6 @@ const URLParserPlugin = require("../url/URLParserPlugin");
|
|
|
17
17
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
18
18
|
/** @typedef {import("../Compiler")} Compiler */
|
|
19
19
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|
20
|
-
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
|
21
20
|
|
|
22
21
|
const PLUGIN_NAME = "URLPlugin";
|
|
23
22
|
|
|
@@ -44,7 +43,7 @@ class URLPlugin {
|
|
|
44
43
|
);
|
|
45
44
|
|
|
46
45
|
/**
|
|
47
|
-
* @param {
|
|
46
|
+
* @param {JavascriptParser} parser parser parser
|
|
48
47
|
* @param {JavascriptParserOptions} parserOptions parserOptions
|
|
49
48
|
* @returns {void}
|
|
50
49
|
*/
|
|
@@ -9,7 +9,7 @@ const Dependency = require("../Dependency");
|
|
|
9
9
|
const makeSerializable = require("../util/makeSerializable");
|
|
10
10
|
const ModuleDependency = require("./ModuleDependency");
|
|
11
11
|
|
|
12
|
-
/** @typedef {import("../Dependency").
|
|
12
|
+
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
|
13
13
|
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
|
|
14
14
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
15
15
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
@@ -44,7 +44,7 @@ class WebAssemblyExportImportedDependency extends ModuleDependency {
|
|
|
44
44
|
* Returns list of exports referenced by this dependency
|
|
45
45
|
* @param {ModuleGraph} moduleGraph module graph
|
|
46
46
|
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
|
47
|
-
* @returns {
|
|
47
|
+
* @returns {ReferencedExports} referenced exports
|
|
48
48
|
*/
|
|
49
49
|
getReferencedExports(moduleGraph, runtime) {
|
|
50
50
|
return [[this.name]];
|
|
@@ -10,7 +10,7 @@ const UnsupportedWebAssemblyFeatureError = require("../wasm-sync/UnsupportedWebA
|
|
|
10
10
|
const ModuleDependency = require("./ModuleDependency");
|
|
11
11
|
|
|
12
12
|
/** @typedef {import("@webassemblyjs/ast").ModuleImportDescription} ModuleImportDescription */
|
|
13
|
-
/** @typedef {import("../Dependency").
|
|
13
|
+
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
|
14
14
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
15
15
|
/** @typedef {import("../WebpackError")} WebpackError */
|
|
16
16
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
@@ -46,7 +46,7 @@ class WebAssemblyImportDependency extends ModuleDependency {
|
|
|
46
46
|
* Returns list of exports referenced by this dependency
|
|
47
47
|
* @param {ModuleGraph} moduleGraph module graph
|
|
48
48
|
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
|
49
|
-
* @returns {
|
|
49
|
+
* @returns {ReferencedExports} referenced exports
|
|
50
50
|
*/
|
|
51
51
|
getReferencedExports(moduleGraph, runtime) {
|
|
52
52
|
return [[this.name]];
|
|
@@ -11,8 +11,7 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
11
11
|
const ModuleDependency = require("./ModuleDependency");
|
|
12
12
|
|
|
13
13
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
14
|
-
/** @typedef {import("../
|
|
15
|
-
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
|
14
|
+
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
|
16
15
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
17
16
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
18
17
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
@@ -34,7 +33,7 @@ class WebpackIsIncludedDependency extends ModuleDependency {
|
|
|
34
33
|
* Returns list of exports referenced by this dependency
|
|
35
34
|
* @param {ModuleGraph} moduleGraph module graph
|
|
36
35
|
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
|
37
|
-
* @returns {
|
|
36
|
+
* @returns {ReferencedExports} referenced exports
|
|
38
37
|
*/
|
|
39
38
|
getReferencedExports(moduleGraph, runtime) {
|
|
40
39
|
// This doesn't use any export
|
|
@@ -12,8 +12,7 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
12
12
|
|
|
13
13
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
14
14
|
/** @typedef {import("../AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
|
15
|
-
/** @typedef {import("../
|
|
16
|
-
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
|
15
|
+
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
|
17
16
|
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
|
18
17
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
19
18
|
/** @typedef {import("../Entrypoint")} Entrypoint */
|
|
@@ -45,7 +44,7 @@ class WorkerDependency extends ModuleDependency {
|
|
|
45
44
|
* Returns list of exports referenced by this dependency
|
|
46
45
|
* @param {ModuleGraph} moduleGraph module graph
|
|
47
46
|
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
|
48
|
-
* @returns {
|
|
47
|
+
* @returns {ReferencedExports} referenced exports
|
|
49
48
|
*/
|
|
50
49
|
getReferencedExports(moduleGraph, runtime) {
|
|
51
50
|
return Dependency.NO_EXPORTS_REFERENCED;
|
|
@@ -27,14 +27,12 @@ const WorkerDependency = require("./WorkerDependency");
|
|
|
27
27
|
|
|
28
28
|
/** @typedef {import("estree").CallExpression} CallExpression */
|
|
29
29
|
/** @typedef {import("estree").Expression} Expression */
|
|
30
|
-
/** @typedef {import("estree").Identifier} Identifier */
|
|
31
30
|
/** @typedef {import("estree").MemberExpression} MemberExpression */
|
|
32
31
|
/** @typedef {import("estree").ObjectExpression} ObjectExpression */
|
|
33
32
|
/** @typedef {import("estree").Pattern} Pattern */
|
|
34
33
|
/** @typedef {import("estree").Property} Property */
|
|
35
34
|
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
|
36
35
|
/** @typedef {import("../../declarations/WebpackOptions").ChunkLoading} ChunkLoading */
|
|
37
|
-
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
|
|
38
36
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
39
37
|
/** @typedef {import("../../declarations/WebpackOptions").OutputModule} OutputModule */
|
|
40
38
|
/** @typedef {import("../../declarations/WebpackOptions").WasmLoading} WasmLoading */
|
|
@@ -44,7 +42,6 @@ const WorkerDependency = require("./WorkerDependency");
|
|
|
44
42
|
/** @typedef {import("../Entrypoint").EntryOptions} EntryOptions */
|
|
45
43
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
46
44
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
|
47
|
-
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
|
48
45
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|
49
46
|
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
|
50
47
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
@@ -291,8 +288,8 @@ class WorkerPlugin {
|
|
|
291
288
|
} = arg2 && arg2.type === "ObjectExpression"
|
|
292
289
|
? parseObjectExpression(parser, arg2)
|
|
293
290
|
: {
|
|
294
|
-
|
|
295
|
-
|
|
291
|
+
expressions:
|
|
292
|
+
/** @type {Record<string, Expression | Pattern>} */ ({}),
|
|
296
293
|
otherElements: [],
|
|
297
294
|
/** @type {Values} */
|
|
298
295
|
values: {},
|
|
@@ -379,10 +376,7 @@ class WorkerPlugin {
|
|
|
379
376
|
const name = `${cachedContextify(
|
|
380
377
|
parser.state.module.identifier()
|
|
381
378
|
)}|${i}`;
|
|
382
|
-
const hash = createHash(
|
|
383
|
-
/** @type {HashFunction} */
|
|
384
|
-
(compilation.outputOptions.hashFunction)
|
|
385
|
-
);
|
|
379
|
+
const hash = createHash(compilation.outputOptions.hashFunction);
|
|
386
380
|
hash.update(name);
|
|
387
381
|
const digest =
|
|
388
382
|
/** @type {string} */
|
|
@@ -7,14 +7,13 @@
|
|
|
7
7
|
|
|
8
8
|
const { UsageState } = require("../ExportsInfo");
|
|
9
9
|
|
|
10
|
+
/** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */
|
|
10
11
|
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
|
|
11
12
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
12
13
|
|
|
13
|
-
/** @typedef {string[][]} ReferencedExports */
|
|
14
|
-
|
|
15
14
|
/**
|
|
16
15
|
* @param {RuntimeSpec} runtime the runtime
|
|
17
|
-
* @param {
|
|
16
|
+
* @param {RawReferencedExports} referencedExports list of referenced exports, will be added to
|
|
18
17
|
* @param {string[]} prefix export prefix
|
|
19
18
|
* @param {ExportInfo=} exportInfo the export info
|
|
20
19
|
* @param {boolean} defaultPointsToSelf when true, using default will reference itself
|
|
@@ -23,12 +23,9 @@ const { getUndoPath } = require("../util/identifier");
|
|
|
23
23
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
24
24
|
/** @typedef {import("../Chunk")} Chunk */
|
|
25
25
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
26
|
-
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
|
27
26
|
/** @typedef {import("../Compilation")} Compilation */
|
|
28
27
|
/** @typedef {import("../Compiler")} Compiler */
|
|
29
28
|
/** @typedef {import("../Entrypoint")} Entrypoint */
|
|
30
|
-
/** @typedef {import("../Module")} Module */
|
|
31
|
-
/** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */
|
|
32
29
|
|
|
33
30
|
/**
|
|
34
31
|
* @param {Compilation} compilation the compilation instance
|
|
@@ -11,6 +11,7 @@ const ModuleChunkLoadingRuntimeModule = require("./ModuleChunkLoadingRuntimeModu
|
|
|
11
11
|
|
|
12
12
|
/** @typedef {import("../Chunk")} Chunk */
|
|
13
13
|
/** @typedef {import("../Compiler")} Compiler */
|
|
14
|
+
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
|
14
15
|
|
|
15
16
|
const PLUGIN_NAME = "ModuleChunkLoadingPlugin";
|
|
16
17
|
|
|
@@ -38,7 +39,7 @@ class ModuleChunkLoadingPlugin {
|
|
|
38
39
|
const onceForChunkSet = new WeakSet();
|
|
39
40
|
/**
|
|
40
41
|
* @param {Chunk} chunk chunk to check
|
|
41
|
-
* @param {
|
|
42
|
+
* @param {RuntimeRequirements} set runtime requirements
|
|
42
43
|
*/
|
|
43
44
|
const handler = (chunk, set) => {
|
|
44
45
|
if (onceForChunkSet.has(chunk)) return;
|
|
@@ -20,7 +20,6 @@ const { getInitialChunkIds } = require("../javascript/StartupHelpers");
|
|
|
20
20
|
const compileBooleanMatcher = require("../util/compileBooleanMatcher");
|
|
21
21
|
const { getUndoPath } = require("../util/identifier");
|
|
22
22
|
|
|
23
|
-
/** @typedef {import("../../declarations/WebpackOptions").Environment} Environment */
|
|
24
23
|
/** @typedef {import("../Chunk")} Chunk */
|
|
25
24
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
26
25
|
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
|
@@ -91,9 +90,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
91
90
|
const compilation = /** @type {Compilation} */ (this.compilation);
|
|
92
91
|
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
|
93
92
|
const chunk = /** @type {Chunk} */ (this.chunk);
|
|
94
|
-
const environment =
|
|
95
|
-
/** @type {Environment} */
|
|
96
|
-
(compilation.outputOptions.environment);
|
|
93
|
+
const environment = compilation.outputOptions.environment;
|
|
97
94
|
const {
|
|
98
95
|
runtimeTemplate,
|
|
99
96
|
outputOptions: { importFunctionName, crossOriginLoading, charset }
|
|
@@ -139,7 +136,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
139
136
|
);
|
|
140
137
|
const rootOutputDir = getUndoPath(
|
|
141
138
|
outputName,
|
|
142
|
-
|
|
139
|
+
compilation.outputOptions.path,
|
|
143
140
|
true
|
|
144
141
|
);
|
|
145
142
|
|
|
@@ -395,8 +392,8 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
395
392
|
[
|
|
396
393
|
`return ${importFunctionName}(/* webpackIgnore: true */ url).then(onResolve).catch(onReject)`
|
|
397
394
|
]
|
|
398
|
-
)}
|
|
399
|
-
loadScript(url, onResolve, onReject)
|
|
395
|
+
)}`,
|
|
396
|
+
"loadScript(url, onResolve, onReject);"
|
|
400
397
|
]
|
|
401
398
|
)});`
|
|
402
399
|
]),
|
|
@@ -414,6 +411,9 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
414
411
|
RuntimeGlobals.getUpdateManifestFilename
|
|
415
412
|
}()).then(${runtimeTemplate.basicFunction("obj", [
|
|
416
413
|
"return obj.default;"
|
|
414
|
+
])}, ${runtimeTemplate.basicFunction("error", [
|
|
415
|
+
"if(['MODULE_NOT_FOUND', 'ENOENT'].includes(error.code)) return;",
|
|
416
|
+
"throw error;"
|
|
417
417
|
])});`
|
|
418
418
|
])};`
|
|
419
419
|
])
|
|
@@ -19,7 +19,7 @@ const Template = require("../Template");
|
|
|
19
19
|
const CommonJsRequireDependency = require("../dependencies/CommonJsRequireDependency");
|
|
20
20
|
const { registerNotSerializable } = require("../util/serialization");
|
|
21
21
|
|
|
22
|
-
/** @typedef {import("
|
|
22
|
+
/** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
23
23
|
/** @typedef {import("../Compilation")} Compilation */
|
|
24
24
|
/** @typedef {import("../Compiler")} Compiler */
|
|
25
25
|
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
|
@@ -28,6 +28,7 @@ const { registerNotSerializable } = require("../util/serialization");
|
|
|
28
28
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
|
29
29
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
|
30
30
|
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
|
31
|
+
/** @typedef {import("../Module").LibIdent} LibIdent */
|
|
31
32
|
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
|
|
32
33
|
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
|
|
33
34
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
@@ -35,7 +36,6 @@ const { registerNotSerializable } = require("../util/serialization");
|
|
|
35
36
|
/** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
|
|
36
37
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
37
38
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
38
|
-
/** @typedef {import("../WebpackError")} WebpackError */
|
|
39
39
|
/** @typedef {import("../dependencies/HarmonyImportDependency")} HarmonyImportDependency */
|
|
40
40
|
/** @typedef {import("../util/Hash")} Hash */
|
|
41
41
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
@@ -161,7 +161,7 @@ class LazyCompilationProxyModule extends Module {
|
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
163
|
* @param {LibIdentOptions} options options
|
|
164
|
-
* @returns {
|
|
164
|
+
* @returns {LibIdent | null} an identifier for library inclusion
|
|
165
165
|
*/
|
|
166
166
|
libIdent(options) {
|
|
167
167
|
return `${this.originalModule.libIdent(
|
|
@@ -345,12 +345,14 @@ class LazyCompilationDependencyFactory extends ModuleFactory {
|
|
|
345
345
|
|
|
346
346
|
/** @typedef {BackendHandler | PromiseBackendHandler} BackEnd */
|
|
347
347
|
|
|
348
|
+
/** @typedef {(module: Module) => boolean} TestFn */
|
|
349
|
+
|
|
348
350
|
/**
|
|
349
351
|
* @typedef {object} Options options
|
|
350
352
|
* @property {BackEnd} backend the backend
|
|
351
353
|
* @property {boolean=} entries
|
|
352
354
|
* @property {boolean=} imports
|
|
353
|
-
* @property {
|
|
355
|
+
* @property {RegExp | string | TestFn=} test additional filter for lazy compiled entrypoint modules
|
|
354
356
|
*/
|
|
355
357
|
|
|
356
358
|
const PLUGIN_NAME = "LazyCompilationPlugin";
|
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
/** @typedef {import("http").IncomingMessage} IncomingMessage */
|
|
9
8
|
/** @typedef {import("http").RequestListener} RequestListener */
|
|
10
9
|
/** @typedef {import("http").ServerOptions} HttpServerOptions */
|
|
11
|
-
/** @typedef {import("http").
|
|
10
|
+
/** @typedef {import("http").Server} HttpServer */
|
|
12
11
|
/** @typedef {import("https").ServerOptions} HttpsServerOptions */
|
|
12
|
+
/** @typedef {import("https").Server} HttpsServer */
|
|
13
13
|
/** @typedef {import("net").AddressInfo} AddressInfo */
|
|
14
|
-
/** @typedef {import("net").Server} Server */
|
|
15
|
-
/** @typedef {import("../../declarations/WebpackOptions").LazyCompilationDefaultBackendOptions} LazyCompilationDefaultBackendOptions */
|
|
16
|
-
/** @typedef {import("../Compiler")} Compiler */
|
|
17
|
-
/** @typedef {import("../Module")} Module */
|
|
18
|
-
/** @typedef {import("./LazyCompilationPlugin").BackendApi} BackendApi */
|
|
19
14
|
/** @typedef {import("./LazyCompilationPlugin").BackendHandler} BackendHandler */
|
|
15
|
+
/** @typedef {import("../../declarations/WebpackOptions").LazyCompilationDefaultBackendOptions} LazyCompilationDefaultBackendOptions */
|
|
16
|
+
|
|
17
|
+
/** @typedef {HttpServer | HttpsServer} Server */
|
|
18
|
+
/** @typedef {(server: Server) => void} Listen */
|
|
19
|
+
/** @typedef {() => Server} CreateServerFunction */
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* @param {Omit<LazyCompilationDefaultBackendOptions, "client"> & { client: NonNullable<LazyCompilationDefaultBackendOptions["client"]>}} options additional options for the backend
|
|
@@ -32,18 +32,21 @@ module.exports = (options) => (compiler, callback) => {
|
|
|
32
32
|
(typeof options.server === "object" &&
|
|
33
33
|
("key" in options.server || "pfx" in options.server));
|
|
34
34
|
|
|
35
|
+
/** @type {CreateServerFunction} */
|
|
35
36
|
const createServer =
|
|
36
37
|
typeof options.server === "function"
|
|
37
38
|
? options.server
|
|
38
39
|
: (() => {
|
|
39
40
|
const http = isHttps ? require("https") : require("http");
|
|
40
|
-
return http
|
|
41
|
+
return /** @type {(this: import("http") | import("https"), options: HttpServerOptions | HttpsServerOptions) => Server} */ (
|
|
42
|
+
http.createServer
|
|
43
|
+
).bind(
|
|
41
44
|
http,
|
|
42
45
|
/** @type {HttpServerOptions | HttpsServerOptions} */
|
|
43
46
|
(options.server)
|
|
44
47
|
);
|
|
45
48
|
})();
|
|
46
|
-
/** @type {
|
|
49
|
+
/** @type {Listen} */
|
|
47
50
|
const listen =
|
|
48
51
|
typeof options.listen === "function"
|
|
49
52
|
? options.listen
|
|
@@ -94,7 +97,7 @@ module.exports = (options) => (compiler, callback) => {
|
|
|
94
97
|
if (moduleActivated && compiler.watching) compiler.watching.invalidate();
|
|
95
98
|
};
|
|
96
99
|
|
|
97
|
-
const server =
|
|
100
|
+
const server = createServer();
|
|
98
101
|
server.on("request", requestListener);
|
|
99
102
|
|
|
100
103
|
let isClosing = false;
|
|
@@ -14,10 +14,7 @@ const {
|
|
|
14
14
|
getUsedChunkIds
|
|
15
15
|
} = require("./IdHelpers");
|
|
16
16
|
|
|
17
|
-
/** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} Output */
|
|
18
|
-
/** @typedef {import("../Chunk")} Chunk */
|
|
19
17
|
/** @typedef {import("../Compiler")} Compiler */
|
|
20
|
-
/** @typedef {import("../Module")} Module */
|
|
21
18
|
|
|
22
19
|
/**
|
|
23
20
|
* @typedef {object} NamedChunkIdsPluginOptions
|
|
@@ -43,9 +40,7 @@ class NamedChunkIdsPlugin {
|
|
|
43
40
|
*/
|
|
44
41
|
apply(compiler) {
|
|
45
42
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
46
|
-
const hashFunction =
|
|
47
|
-
/** @type {NonNullable<Output["hashFunction"]>} */
|
|
48
|
-
(compilation.outputOptions.hashFunction);
|
|
43
|
+
const hashFunction = compilation.outputOptions.hashFunction;
|
|
49
44
|
compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => {
|
|
50
45
|
const chunkGraph = compilation.chunkGraph;
|
|
51
46
|
const context = this.context ? this.context : compiler.context;
|
|
@@ -14,9 +14,7 @@ const {
|
|
|
14
14
|
getUsedModuleIdsAndModules
|
|
15
15
|
} = require("./IdHelpers");
|
|
16
16
|
|
|
17
|
-
/** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} Output */
|
|
18
17
|
/** @typedef {import("../Compiler")} Compiler */
|
|
19
|
-
/** @typedef {import("../Module")} Module */
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
20
|
* @typedef {object} NamedModuleIdsPluginOptions
|
|
@@ -41,9 +39,7 @@ class NamedModuleIdsPlugin {
|
|
|
41
39
|
apply(compiler) {
|
|
42
40
|
const { root } = compiler;
|
|
43
41
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
44
|
-
const hashFunction =
|
|
45
|
-
/** @type {NonNullable<Output["hashFunction"]>} */
|
|
46
|
-
(compilation.outputOptions.hashFunction);
|
|
42
|
+
const hashFunction = compilation.outputOptions.hashFunction;
|
|
47
43
|
compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => {
|
|
48
44
|
const chunkGraph = compilation.chunkGraph;
|
|
49
45
|
const context = this.options.context
|
|
@@ -10,7 +10,6 @@ const { assignAscendingChunkIds } = require("./IdHelpers");
|
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("../Chunk")} Chunk */
|
|
12
12
|
/** @typedef {import("../Compiler")} Compiler */
|
|
13
|
-
/** @typedef {import("../Module")} Module */
|
|
14
13
|
|
|
15
14
|
const PLUGIN_NAME = "NaturalChunkIdsPlugin";
|
|
16
15
|
|
|
@@ -12,7 +12,6 @@ const { assignAscendingChunkIds } = require("./IdHelpers");
|
|
|
12
12
|
/** @typedef {import("../../declarations/plugins/ids/OccurrenceChunkIdsPlugin").OccurrenceChunkIdsPluginOptions} OccurrenceChunkIdsPluginOptions */
|
|
13
13
|
/** @typedef {import("../Chunk")} Chunk */
|
|
14
14
|
/** @typedef {import("../Compiler")} Compiler */
|
|
15
|
-
/** @typedef {import("../Module")} Module */
|
|
16
15
|
|
|
17
16
|
const validate = createSchemaValidation(
|
|
18
17
|
require("../../schemas/plugins/ids/OccurrenceChunkIdsPlugin.check"),
|
|
@@ -17,7 +17,6 @@ const {
|
|
|
17
17
|
/** @typedef {import("../../declarations/plugins/ids/OccurrenceModuleIdsPlugin").OccurrenceModuleIdsPluginOptions} OccurrenceModuleIdsPluginOptions */
|
|
18
18
|
/** @typedef {import("../Compiler")} Compiler */
|
|
19
19
|
/** @typedef {import("../Module")} Module */
|
|
20
|
-
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
|
21
20
|
|
|
22
21
|
const validate = createSchemaValidation(
|
|
23
22
|
require("../../schemas/plugins/ids/OccurrenceModuleIdsPlugin.check"),
|
|
@@ -10,6 +10,7 @@ const { getUsedModuleIdsAndModules } = require("./IdHelpers");
|
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("../Compiler")} Compiler */
|
|
12
12
|
/** @typedef {import("../Module")} Module */
|
|
13
|
+
/** @typedef {import("../Module").ModuleId} ModuleId */
|
|
13
14
|
/** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
|
|
14
15
|
|
|
15
16
|
const plugin = "SyncModuleIdsPlugin";
|
|
@@ -42,7 +43,7 @@ class SyncModuleIdsPlugin {
|
|
|
42
43
|
* @returns {void}
|
|
43
44
|
*/
|
|
44
45
|
apply(compiler) {
|
|
45
|
-
/** @type {Map<string,
|
|
46
|
+
/** @type {Map<string, ModuleId>} */
|
|
46
47
|
let data;
|
|
47
48
|
let dataChanged = false;
|
|
48
49
|
if (this._read) {
|
|
@@ -70,7 +71,7 @@ class SyncModuleIdsPlugin {
|
|
|
70
71
|
if (this._write) {
|
|
71
72
|
compiler.hooks.emitRecords.tapAsync(plugin, (callback) => {
|
|
72
73
|
if (!data || !dataChanged) return callback();
|
|
73
|
-
/** @type {{[key: string]:
|
|
74
|
+
/** @type {{[key: string]: ModuleId}} */
|
|
74
75
|
const json = {};
|
|
75
76
|
const sorted = [...data].sort(([a], [b]) => (a < b ? -1 : 1));
|
|
76
77
|
for (const [key, value] of sorted) {
|
|
@@ -108,7 +109,7 @@ class SyncModuleIdsPlugin {
|
|
|
108
109
|
err.module = module;
|
|
109
110
|
compilation.errors.push(err);
|
|
110
111
|
}
|
|
111
|
-
chunkGraph.setModuleId(module, /** @type {
|
|
112
|
+
chunkGraph.setModuleId(module, /** @type {ModuleId} */ (id));
|
|
112
113
|
usedIds.add(idAsString);
|
|
113
114
|
}
|
|
114
115
|
});
|
package/lib/index.js
CHANGED
|
@@ -13,12 +13,6 @@ const memoize = require("./util/memoize");
|
|
|
13
13
|
/** @typedef {import("../declarations/WebpackOptions").EntryObject} EntryObject */
|
|
14
14
|
/** @typedef {import("../declarations/WebpackOptions").ExternalItem} ExternalItem */
|
|
15
15
|
/** @typedef {import("../declarations/WebpackOptions").ExternalItemFunction} ExternalItemFunction */
|
|
16
|
-
/** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionCallback} ExternalItemFunctionCallback */
|
|
17
|
-
/** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionData} ExternalItemFunctionData */
|
|
18
|
-
/** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionDataGetResolve} ExternalItemFunctionDataGetResolve */
|
|
19
|
-
/** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionDataGetResolveCallbackResult} ExternalItemFunctionDataGetResolveCallbackResult */
|
|
20
|
-
/** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionDataGetResolveResult} ExternalItemFunctionDataGetResolveResult */
|
|
21
|
-
/** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionPromise} ExternalItemFunctionPromise */
|
|
22
16
|
/** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectKnown} ExternalItemObjectKnown */
|
|
23
17
|
/** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectUnknown} ExternalItemObjectUnknown */
|
|
24
18
|
/** @typedef {import("../declarations/WebpackOptions").ExternalItemValue} ExternalItemValue */
|
|
@@ -42,12 +36,19 @@ const memoize = require("./util/memoize");
|
|
|
42
36
|
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
|
|
43
37
|
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginInstance} WebpackPluginInstance */
|
|
44
38
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
39
|
+
/** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
|
|
45
40
|
/** @typedef {import("./Compilation").Asset} Asset */
|
|
46
41
|
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
|
47
42
|
/** @typedef {import("./Compilation").EntryOptions} EntryOptions */
|
|
48
43
|
/** @typedef {import("./Compilation").PathData} PathData */
|
|
49
|
-
/** @typedef {import("./
|
|
44
|
+
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
|
|
50
45
|
/** @typedef {import("./Entrypoint")} Entrypoint */
|
|
46
|
+
/** @typedef {import("./ExternalModuleFactoryPlugin").ExternalItemFunctionCallback} ExternalItemFunctionCallback */
|
|
47
|
+
/** @typedef {import("./ExternalModuleFactoryPlugin").ExternalItemFunctionData} ExternalItemFunctionData */
|
|
48
|
+
/** @typedef {import("./ExternalModuleFactoryPlugin").ExternalItemFunctionDataGetResolve} ExternalItemFunctionDataGetResolve */
|
|
49
|
+
/** @typedef {import("./ExternalModuleFactoryPlugin").ExternalItemFunctionDataGetResolveCallbackResult} ExternalItemFunctionDataGetResolveCallbackResult */
|
|
50
|
+
/** @typedef {import("./ExternalModuleFactoryPlugin").ExternalItemFunctionDataGetResolveResult} ExternalItemFunctionDataGetResolveResult */
|
|
51
|
+
/** @typedef {import("./ExternalModuleFactoryPlugin").ExternalItemFunctionPromise} ExternalItemFunctionPromise */
|
|
51
52
|
/** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */
|
|
52
53
|
/** @typedef {import("./MultiCompiler").MultiWebpackOptions} MultiConfiguration */
|
|
53
54
|
/** @typedef {import("./MultiStats")} MultiStats */
|