webpack 5.101.3 → 5.102.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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 +37 -27
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +3 -2
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +209 -196
- 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 +25 -21
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +5 -9
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +2 -4
- 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 +105 -90
- 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 +42 -25
- 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 +146 -89
- package/lib/NormalModuleFactory.js +132 -42
- 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 +22 -12
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +11 -18
- 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 +167 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +22 -37
- 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/cache/getLazyHashedEtag.js +1 -1
- package/lib/config/browserslistTargetHandler.js +77 -76
- package/lib/config/defaults.js +162 -23
- package/lib/config/normalization.js +18 -3
- package/lib/config/target.js +1 -1
- 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 +13 -19
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +2 -2
- 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 +4 -7
- 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 +33 -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/ImportContextDependency.js +13 -0
- 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 +3 -2
- 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 +4 -12
- 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/HashedModuleIdsPlugin.js +5 -7
- package/lib/ids/IdHelpers.js +1 -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 +46 -24
- package/lib/javascript/JavascriptParser.js +120 -55
- 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 +15 -6
- 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/RealContentHashPlugin.js +5 -3
- 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/FileMiddleware.js +1 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +31 -20
- 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 +179 -95
- 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/Hash.js +35 -5
- 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 +1 -2
- package/lib/util/createHash.js +85 -15
- 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/hash/BatchedHash.js +47 -8
- package/lib/util/hash/wasm-hash.js +53 -13
- 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 -10
- 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 -13
- 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 +21 -21
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +93 -96
- 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/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
- package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1699 -706
- package/SECURITY.md +0 -9
- package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +0 -7
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
package/lib/IgnorePlugin.js
CHANGED
|
@@ -12,6 +12,7 @@ const createSchemaValidation = require("./util/create-schema-validation");
|
|
|
12
12
|
/** @typedef {import("../declarations/plugins/IgnorePlugin").IgnorePluginOptions} IgnorePluginOptions */
|
|
13
13
|
/** @typedef {import("./Compiler")} Compiler */
|
|
14
14
|
/** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */
|
|
15
|
+
/** @typedef {import("./ContextModuleFactory").BeforeContextResolveData} BeforeContextResolveData */
|
|
15
16
|
|
|
16
17
|
const validate = createSchemaValidation(
|
|
17
18
|
require("../schemas/plugins/IgnorePlugin.check"),
|
|
@@ -22,6 +23,8 @@ const validate = createSchemaValidation(
|
|
|
22
23
|
}
|
|
23
24
|
);
|
|
24
25
|
|
|
26
|
+
/** @typedef {(resource: string, context: string) => boolean} CheckResourceFn */
|
|
27
|
+
|
|
25
28
|
const PLUGIN_NAME = "IgnorePlugin";
|
|
26
29
|
|
|
27
30
|
class IgnorePlugin {
|
|
@@ -36,8 +39,8 @@ class IgnorePlugin {
|
|
|
36
39
|
|
|
37
40
|
/**
|
|
38
41
|
* Note that if "contextRegExp" is given, both the "resourceRegExp" and "contextRegExp" have to match.
|
|
39
|
-
* @param {ResolveData} resolveData resolve data
|
|
40
|
-
* @returns {false|undefined} returns false when the request should be ignored, otherwise undefined
|
|
42
|
+
* @param {ResolveData | BeforeContextResolveData} resolveData resolve data
|
|
43
|
+
* @returns {false | undefined} returns false when the request should be ignored, otherwise undefined
|
|
41
44
|
*/
|
|
42
45
|
checkIgnore(resolveData) {
|
|
43
46
|
if (
|
package/lib/InitFragment.js
CHANGED
|
@@ -13,18 +13,32 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
13
13
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
14
14
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
15
15
|
|
|
16
|
+
/** @typedef {string} InitFragmentKey */
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @template GenerateContext
|
|
20
|
+
* @typedef {object} MaybeMergeableInitFragment
|
|
21
|
+
* @property {InitFragmentKey=} key
|
|
22
|
+
* @property {number} stage
|
|
23
|
+
* @property {number} position
|
|
24
|
+
* @property {(context: GenerateContext) => string | Source | undefined} getContent
|
|
25
|
+
* @property {(context: GenerateContext) => string | Source | undefined} getEndContent
|
|
26
|
+
* @property {(fragments: MaybeMergeableInitFragment<GenerateContext>) => MaybeMergeableInitFragment<GenerateContext>=} merge
|
|
27
|
+
* @property {(fragments: MaybeMergeableInitFragment<GenerateContext>[]) => MaybeMergeableInitFragment<GenerateContext>[]=} mergeAll
|
|
28
|
+
*/
|
|
29
|
+
|
|
16
30
|
/**
|
|
17
31
|
* @template T
|
|
18
|
-
* @param {
|
|
32
|
+
* @param {T} fragment the init fragment
|
|
19
33
|
* @param {number} index index
|
|
20
|
-
* @returns {[
|
|
34
|
+
* @returns {[T, number]} tuple with both
|
|
21
35
|
*/
|
|
22
36
|
const extractFragmentIndex = (fragment, index) => [fragment, index];
|
|
23
37
|
|
|
24
38
|
/**
|
|
25
39
|
* @template T
|
|
26
|
-
* @param {[
|
|
27
|
-
* @param {[
|
|
40
|
+
* @param {[MaybeMergeableInitFragment<T>, number]} a first pair
|
|
41
|
+
* @param {[MaybeMergeableInitFragment<T>, number]} b second pair
|
|
28
42
|
* @returns {number} sort value
|
|
29
43
|
*/
|
|
30
44
|
const sortFragmentWithIndex = ([a, i], [b, j]) => {
|
|
@@ -37,13 +51,14 @@ const sortFragmentWithIndex = ([a, i], [b, j]) => {
|
|
|
37
51
|
|
|
38
52
|
/**
|
|
39
53
|
* @template GenerateContext
|
|
54
|
+
* @implements {MaybeMergeableInitFragment<GenerateContext>}
|
|
40
55
|
*/
|
|
41
56
|
class InitFragment {
|
|
42
57
|
/**
|
|
43
58
|
* @param {string | Source | undefined} content the source code that will be included as initialization code
|
|
44
59
|
* @param {number} stage category of initialization code (contribute to order)
|
|
45
60
|
* @param {number} position position in the category (contribute to order)
|
|
46
|
-
* @param {
|
|
61
|
+
* @param {InitFragmentKey=} key unique key to avoid emitting the same initialization code twice
|
|
47
62
|
* @param {string | Source=} endContent the source code that will be included at the end of the module
|
|
48
63
|
*/
|
|
49
64
|
constructor(content, stage, position, key, endContent) {
|
|
@@ -64,7 +79,7 @@ class InitFragment {
|
|
|
64
79
|
|
|
65
80
|
/**
|
|
66
81
|
* @param {GenerateContext} context context
|
|
67
|
-
* @returns {string | Source
|
|
82
|
+
* @returns {string | Source | undefined} the source code that will be included at the end of the module
|
|
68
83
|
*/
|
|
69
84
|
getEndContent(context) {
|
|
70
85
|
return this.endContent;
|
|
@@ -72,9 +87,8 @@ class InitFragment {
|
|
|
72
87
|
|
|
73
88
|
/**
|
|
74
89
|
* @template Context
|
|
75
|
-
* @template T
|
|
76
90
|
* @param {Source} source sources
|
|
77
|
-
* @param {
|
|
91
|
+
* @param {MaybeMergeableInitFragment<Context>[]} initFragments init fragments
|
|
78
92
|
* @param {Context} context context
|
|
79
93
|
* @returns {Source} source
|
|
80
94
|
*/
|
|
@@ -87,14 +101,10 @@ class InitFragment {
|
|
|
87
101
|
.sort(sortFragmentWithIndex);
|
|
88
102
|
|
|
89
103
|
// Deduplicate fragments. If a fragment has no key, it is always included.
|
|
104
|
+
/** @type {Map<InitFragmentKey | symbol, MaybeMergeableInitFragment<Context> | MaybeMergeableInitFragment<Context>[]>} */
|
|
90
105
|
const keyedFragments = new Map();
|
|
91
106
|
for (const [fragment] of sortedFragments) {
|
|
92
|
-
if (
|
|
93
|
-
typeof (
|
|
94
|
-
/** @type {InitFragment<T> & { mergeAll?: (fragments: InitFragment<Context>[]) => InitFragment<Context>[] }} */
|
|
95
|
-
(fragment).mergeAll
|
|
96
|
-
) === "function"
|
|
97
|
-
) {
|
|
107
|
+
if (typeof fragment.mergeAll === "function") {
|
|
98
108
|
if (!fragment.key) {
|
|
99
109
|
throw new Error(
|
|
100
110
|
`InitFragment with mergeAll function must have a valid key: ${fragment.constructor.name}`
|
|
@@ -110,9 +120,12 @@ class InitFragment {
|
|
|
110
120
|
}
|
|
111
121
|
continue;
|
|
112
122
|
} else if (typeof fragment.merge === "function") {
|
|
113
|
-
const
|
|
123
|
+
const key = /** @type {InitFragmentKey} */ (fragment.key);
|
|
124
|
+
const oldValue =
|
|
125
|
+
/** @type {MaybeMergeableInitFragment<Context>} */
|
|
126
|
+
(keyedFragments.get(key));
|
|
114
127
|
if (oldValue !== undefined) {
|
|
115
|
-
keyedFragments.set(
|
|
128
|
+
keyedFragments.set(key, fragment.merge(oldValue));
|
|
116
129
|
continue;
|
|
117
130
|
}
|
|
118
131
|
}
|
|
@@ -123,10 +136,19 @@ class InitFragment {
|
|
|
123
136
|
const endContents = [];
|
|
124
137
|
for (let fragment of keyedFragments.values()) {
|
|
125
138
|
if (Array.isArray(fragment)) {
|
|
126
|
-
fragment =
|
|
139
|
+
fragment =
|
|
140
|
+
/** @type {[MaybeMergeableInitFragment<Context> & { mergeAll: (fragments: MaybeMergeableInitFragment<Context>[]) => MaybeMergeableInitFragment<Context>[] }, ...MaybeMergeableInitFragment<Context>[]]} */
|
|
141
|
+
(fragment)[0].mergeAll(fragment);
|
|
127
142
|
}
|
|
128
|
-
|
|
129
|
-
|
|
143
|
+
const content =
|
|
144
|
+
/** @type {MaybeMergeableInitFragment<Context>} */
|
|
145
|
+
(fragment).getContent(context);
|
|
146
|
+
if (content) {
|
|
147
|
+
concatSource.add(content);
|
|
148
|
+
}
|
|
149
|
+
const endContent =
|
|
150
|
+
/** @type {MaybeMergeableInitFragment<Context>} */
|
|
151
|
+
(fragment).getEndContent(context);
|
|
130
152
|
if (endContent) {
|
|
131
153
|
endContents.push(endContent);
|
|
132
154
|
}
|
|
@@ -170,16 +192,6 @@ class InitFragment {
|
|
|
170
192
|
|
|
171
193
|
makeSerializable(InitFragment, "webpack/lib/InitFragment");
|
|
172
194
|
|
|
173
|
-
InitFragment.prototype.merge =
|
|
174
|
-
/** @type {TODO} */
|
|
175
|
-
(undefined);
|
|
176
|
-
InitFragment.prototype.getImported =
|
|
177
|
-
/** @type {TODO} */
|
|
178
|
-
(undefined);
|
|
179
|
-
InitFragment.prototype.setImported =
|
|
180
|
-
/** @type {TODO} */
|
|
181
|
-
(undefined);
|
|
182
|
-
|
|
183
195
|
InitFragment.STAGE_CONSTANTS = 10;
|
|
184
196
|
InitFragment.STAGE_ASYNC_BOUNDARY = 20;
|
|
185
197
|
InitFragment.STAGE_HARMONY_EXPORTS = 30;
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
const WebpackError = require("./WebpackError");
|
|
9
9
|
const makeSerializable = require("./util/makeSerializable");
|
|
10
10
|
|
|
11
|
-
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
|
12
11
|
/** @typedef {import("./Module")} Module */
|
|
13
12
|
|
|
14
13
|
class InvalidDependenciesModuleWarning extends WebpackError {
|
package/lib/LibManifestPlugin.js
CHANGED
|
@@ -15,12 +15,13 @@ const { dirname, mkdirp } = require("./util/fs");
|
|
|
15
15
|
/** @typedef {import("./Compiler")} Compiler */
|
|
16
16
|
/** @typedef {import("./Compiler").IntermediateFileSystem} IntermediateFileSystem */
|
|
17
17
|
/** @typedef {import("./Module").BuildMeta} BuildMeta */
|
|
18
|
+
/** @typedef {import("./ExportsInfo").ExportInfoName} ExportInfoName */
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* @typedef {object} ManifestModuleData
|
|
21
|
-
* @property {
|
|
22
|
+
* @property {ModuleId} id
|
|
22
23
|
* @property {BuildMeta=} buildMeta
|
|
23
|
-
* @property {
|
|
24
|
+
* @property {ExportInfoName[]=} exports
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -92,10 +93,7 @@ class LibManifestPlugin {
|
|
|
92
93
|
continue;
|
|
93
94
|
}
|
|
94
95
|
const ident = module.libIdent({
|
|
95
|
-
context:
|
|
96
|
-
this.options.context ||
|
|
97
|
-
/** @type {string} */
|
|
98
|
-
(compiler.options.context),
|
|
96
|
+
context: this.options.context || compiler.context,
|
|
99
97
|
associatedObjectForCache: compiler.root
|
|
100
98
|
});
|
|
101
99
|
if (ident) {
|
|
@@ -11,7 +11,6 @@ const createSchemaValidation = require("./util/create-schema-validation");
|
|
|
11
11
|
|
|
12
12
|
/** @typedef {import("../declarations/plugins/LoaderOptionsPlugin").LoaderOptionsPluginOptions} LoaderOptionsPluginOptions */
|
|
13
13
|
/** @typedef {import("./Compiler")} Compiler */
|
|
14
|
-
/** @typedef {import("./ModuleFilenameHelpers").Matcher} Matcher */
|
|
15
14
|
/** @typedef {import("./ModuleFilenameHelpers").MatchObject} MatchObject */
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -39,15 +38,7 @@ class LoaderOptionsPlugin {
|
|
|
39
38
|
// If no options are set then generate empty options object
|
|
40
39
|
if (typeof options !== "object") options = {};
|
|
41
40
|
if (!options.test) {
|
|
42
|
-
|
|
43
|
-
const defaultTrueMockRegExp = {
|
|
44
|
-
test: () => true
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/** @type {RegExp} */
|
|
48
|
-
options.test =
|
|
49
|
-
/** @type {RegExp} */
|
|
50
|
-
(defaultTrueMockRegExp);
|
|
41
|
+
options.test = () => true;
|
|
51
42
|
}
|
|
52
43
|
this.options = options;
|
|
53
44
|
}
|
package/lib/MainTemplate.js
CHANGED
|
@@ -11,7 +11,6 @@ const RuntimeGlobals = require("./RuntimeGlobals");
|
|
|
11
11
|
const memoize = require("./util/memoize");
|
|
12
12
|
|
|
13
13
|
/** @typedef {import("tapable").Tap} Tap */
|
|
14
|
-
/** @typedef {import("webpack-sources").ConcatSource} ConcatSource */
|
|
15
14
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
16
15
|
/** @typedef {import("../declarations/WebpackOptions").Output} OutputOptions */
|
|
17
16
|
/** @typedef {import("./ModuleTemplate")} ModuleTemplate */
|
|
@@ -19,19 +18,13 @@ const memoize = require("./util/memoize");
|
|
|
19
18
|
/** @typedef {import("./Compilation")} Compilation */
|
|
20
19
|
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
|
21
20
|
/** @typedef {import("./Compilation").InterpolatedPathAndAssetInfo} InterpolatedPathAndAssetInfo */
|
|
22
|
-
/** @typedef {import("./
|
|
23
|
-
/** @typedef {import("./
|
|
24
|
-
/** @typedef {import("./
|
|
25
|
-
/** @typedef {import("./
|
|
26
|
-
/** @typedef {import("./
|
|
27
|
-
/** @typedef {import("./
|
|
28
|
-
/** @typedef {import("./
|
|
29
|
-
/** @typedef {import("./ModuleGraph")} ModuleGraph} */
|
|
30
|
-
/** @typedef {import("./ChunkGraph")} ChunkGraph} */
|
|
31
|
-
/** @typedef {import("./Template").RenderManifestOptions} RenderManifestOptions} */
|
|
32
|
-
/** @typedef {import("./Template").RenderManifestEntry} RenderManifestEntry} */
|
|
33
|
-
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath} */
|
|
34
|
-
/** @typedef {import("./TemplatedPathPlugin").PathData} PathData} */
|
|
21
|
+
/** @typedef {import("./util/Hash")} Hash */
|
|
22
|
+
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
|
23
|
+
/** @typedef {import("./javascript/JavascriptModulesPlugin").RenderBootstrapContext} RenderBootstrapContext */
|
|
24
|
+
/** @typedef {import("./Template").RenderManifestOptions} RenderManifestOptions */
|
|
25
|
+
/** @typedef {import("./Template").RenderManifestEntry} RenderManifestEntry */
|
|
26
|
+
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
|
27
|
+
/** @typedef {import("./TemplatedPathPlugin").PathData} PathData */
|
|
35
28
|
/**
|
|
36
29
|
* @template T
|
|
37
30
|
* @typedef {import("tapable").IfSet<T>} IfSet
|
|
@@ -324,11 +317,7 @@ class MainTemplate {
|
|
|
324
317
|
* @param {PathData} options context data
|
|
325
318
|
* @returns {string} interpolated path
|
|
326
319
|
*/ (options) =>
|
|
327
|
-
compilation.getAssetPath(
|
|
328
|
-
/** @type {string} */
|
|
329
|
-
(compilation.outputOptions.publicPath),
|
|
330
|
-
options
|
|
331
|
-
),
|
|
320
|
+
compilation.getAssetPath(compilation.outputOptions.publicPath, options),
|
|
332
321
|
"MainTemplate.getPublicPath is deprecated (use Compilation.getAssetPath(compilation.outputOptions.publicPath, options) instead)",
|
|
333
322
|
"DEP_WEBPACK_MAIN_TEMPLATE_GET_PUBLIC_PATH"
|
|
334
323
|
);
|
package/lib/Module.js
CHANGED
|
@@ -17,7 +17,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
17
17
|
|
|
18
18
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
19
19
|
/** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
|
|
20
|
-
/** @typedef {import("
|
|
20
|
+
/** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
21
21
|
/** @typedef {import("./Chunk")} Chunk */
|
|
22
22
|
/** @typedef {import("./ChunkGraph").ModuleId} ModuleId */
|
|
23
23
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
@@ -30,15 +30,19 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
30
30
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
|
31
31
|
/** @typedef {import("./DependencyTemplate").CssData} CssData */
|
|
32
32
|
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
|
33
|
-
/** @typedef {import("./ExportsInfo").UsageStateType} UsageStateType */
|
|
34
33
|
/** @typedef {import("./FileSystemInfo")} FileSystemInfo */
|
|
35
34
|
/** @typedef {import("./FileSystemInfo").Snapshot} Snapshot */
|
|
36
35
|
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
37
36
|
/** @typedef {import("./ModuleTypeConstants").ModuleTypes} ModuleTypes */
|
|
37
|
+
/** @typedef {import("./ModuleGraph").OptimizationBailouts} OptimizationBailouts */
|
|
38
38
|
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
|
|
39
39
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
|
40
40
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
41
41
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
|
42
|
+
/**
|
|
43
|
+
* @template T
|
|
44
|
+
* @typedef {import("./InitFragment")<T>} InitFragment
|
|
45
|
+
*/
|
|
42
46
|
/** @typedef {import("./WebpackError")} WebpackError */
|
|
43
47
|
/** @typedef {import("./json/JsonData")} JsonData */
|
|
44
48
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
@@ -54,11 +58,6 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
54
58
|
* @typedef {import("./util/LazySet")<T>} LazySet<T>
|
|
55
59
|
*/
|
|
56
60
|
|
|
57
|
-
/**
|
|
58
|
-
* @template T
|
|
59
|
-
* @typedef {import("./util/SortableSet")<T>} SortableSet<T>
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
61
|
/**
|
|
63
62
|
* @typedef {object} SourceContext
|
|
64
63
|
* @property {DependencyTemplates} dependencyTemplates the dependency templates
|
|
@@ -94,10 +93,16 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
94
93
|
/** @typedef {Set<string>} RuntimeRequirements */
|
|
95
94
|
/** @typedef {ReadonlySet<string>} ReadOnlyRuntimeRequirements */
|
|
96
95
|
|
|
96
|
+
/** @typedef {Map<"topLevelDeclarations", Set<string>> & Map<"chunkInitFragments", InitFragment<EXPECTED_ANY>[]>} KnownCodeGenerationResultDataForJavascriptModules */
|
|
97
|
+
/** @typedef {Map<"url", { ["css-url"]: string }>} KnownCodeGenerationResultDataForCssModules */
|
|
98
|
+
/** @typedef {Map<"filename", string> & Map<"assetInfo", AssetInfo> & Map<"fullContentHash", string>} KnownCodeGenerationResultDataForAssetModules */
|
|
99
|
+
/** @typedef {Map<"share-init", [{ shareScope: string, initStage: number, init: string }]>} KnownCodeGenerationResultForSharing */
|
|
100
|
+
/** @typedef {KnownCodeGenerationResultDataForJavascriptModules & KnownCodeGenerationResultDataForCssModules & KnownCodeGenerationResultDataForAssetModules & KnownCodeGenerationResultForSharing & Map<string, EXPECTED_ANY>} CodeGenerationResultData */
|
|
101
|
+
|
|
97
102
|
/**
|
|
98
103
|
* @typedef {object} CodeGenerationResult
|
|
99
104
|
* @property {Map<string, Source>} sources the resulting sources for all source types
|
|
100
|
-
* @property {
|
|
105
|
+
* @property {CodeGenerationResultData=} data the resulting data for all source types
|
|
101
106
|
* @property {ReadOnlyRuntimeRequirements | null} runtimeRequirements the runtime requirements
|
|
102
107
|
* @property {string=} hash a hash of the code generation result (will be automatically calculated from sources and runtimeRequirements if not provided)
|
|
103
108
|
*/
|
|
@@ -113,6 +118,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
113
118
|
* @property {("default" | "namespace" | "flagged" | "dynamic")=} exportsType
|
|
114
119
|
* @property {(false | "redirect" | "redirect-warn")=} defaultObject
|
|
115
120
|
* @property {boolean=} strictHarmonyModule
|
|
121
|
+
* @property {boolean=} treatAsCommonJs
|
|
116
122
|
* @property {boolean=} async
|
|
117
123
|
* @property {boolean=} sideEffectFree
|
|
118
124
|
* @property {boolean=} isCSSModule
|
|
@@ -121,6 +127,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
121
127
|
* @property {string=} factoryExportsBinding
|
|
122
128
|
*/
|
|
123
129
|
|
|
130
|
+
/** @typedef {LazySet<string>} FileSystemDependencies */
|
|
131
|
+
|
|
124
132
|
/**
|
|
125
133
|
* @typedef {object} KnownBuildInfo
|
|
126
134
|
* @property {boolean=} cacheable
|
|
@@ -131,10 +139,10 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
131
139
|
* @property {string=} moduleConcatenationBailout using in CommonJs
|
|
132
140
|
* @property {boolean=} needCreateRequire using in APIPlugin
|
|
133
141
|
* @property {string=} resourceIntegrity using in HttpUriPlugin
|
|
134
|
-
* @property {
|
|
135
|
-
* @property {
|
|
136
|
-
* @property {
|
|
137
|
-
* @property {
|
|
142
|
+
* @property {FileSystemDependencies=} fileDependencies using in NormalModule
|
|
143
|
+
* @property {FileSystemDependencies=} contextDependencies using in NormalModule
|
|
144
|
+
* @property {FileSystemDependencies=} missingDependencies using in NormalModule
|
|
145
|
+
* @property {FileSystemDependencies=} buildDependencies using in NormalModule
|
|
138
146
|
* @property {ValueCacheVersions=} valueDependencies using in NormalModule
|
|
139
147
|
* @property {Record<string, Source>=} assets using in NormalModule
|
|
140
148
|
* @property {Map<string, AssetInfo | undefined>=} assetsInfo using in NormalModule
|
|
@@ -151,7 +159,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
151
159
|
* @property {Set<string>=} topLevelDeclarations top level declaration names
|
|
152
160
|
*/
|
|
153
161
|
|
|
154
|
-
/** @typedef {
|
|
162
|
+
/** @typedef {string | Set<string>} ValueCacheVersion */
|
|
163
|
+
/** @typedef {Map<string, ValueCacheVersion>} ValueCacheVersions */
|
|
155
164
|
|
|
156
165
|
/**
|
|
157
166
|
* @typedef {object} NeedBuildContext
|
|
@@ -193,6 +202,9 @@ const deprecatedNeedRebuild = util.deprecate(
|
|
|
193
202
|
"DEP_WEBPACK_MODULE_NEED_REBUILD"
|
|
194
203
|
);
|
|
195
204
|
|
|
205
|
+
/** @typedef {string} LibIdent */
|
|
206
|
+
/** @typedef {string} NameForCondition */
|
|
207
|
+
|
|
196
208
|
/** @typedef {(requestShortener: RequestShortener) => string} OptimizationBailoutFunction */
|
|
197
209
|
|
|
198
210
|
class Module extends DependenciesBlock {
|
|
@@ -412,7 +424,7 @@ class Module extends DependenciesBlock {
|
|
|
412
424
|
|
|
413
425
|
/**
|
|
414
426
|
* @deprecated
|
|
415
|
-
* @returns {
|
|
427
|
+
* @returns {OptimizationBailouts} list
|
|
416
428
|
*/
|
|
417
429
|
get optimizationBailout() {
|
|
418
430
|
return ModuleGraph.getModuleGraphForModule(
|
|
@@ -967,14 +979,14 @@ class Module extends DependenciesBlock {
|
|
|
967
979
|
|
|
968
980
|
/**
|
|
969
981
|
* @param {LibIdentOptions} options options
|
|
970
|
-
* @returns {
|
|
982
|
+
* @returns {LibIdent | null} an identifier for library inclusion
|
|
971
983
|
*/
|
|
972
984
|
libIdent(options) {
|
|
973
985
|
return null;
|
|
974
986
|
}
|
|
975
987
|
|
|
976
988
|
/**
|
|
977
|
-
* @returns {
|
|
989
|
+
* @returns {NameForCondition | null} absolute path which should be used for condition matching (usually the resource path)
|
|
978
990
|
*/
|
|
979
991
|
nameForCondition() {
|
|
980
992
|
return null;
|
|
@@ -1091,10 +1103,10 @@ class Module extends DependenciesBlock {
|
|
|
1091
1103
|
}
|
|
1092
1104
|
|
|
1093
1105
|
/**
|
|
1094
|
-
* @param {
|
|
1095
|
-
* @param {
|
|
1096
|
-
* @param {
|
|
1097
|
-
* @param {
|
|
1106
|
+
* @param {FileSystemDependencies} fileDependencies set where file dependencies are added to
|
|
1107
|
+
* @param {FileSystemDependencies} contextDependencies set where context dependencies are added to
|
|
1108
|
+
* @param {FileSystemDependencies} missingDependencies set where missing dependencies are added to
|
|
1109
|
+
* @param {FileSystemDependencies} buildDependencies set where build dependencies are added to
|
|
1098
1110
|
*/
|
|
1099
1111
|
addCacheDependencies(
|
|
1100
1112
|
fileDependencies,
|
package/lib/ModuleFactory.js
CHANGED
|
@@ -10,13 +10,12 @@ const { DEFAULTS } = require("./config/defaults");
|
|
|
10
10
|
const createHash = require("./util/createHash");
|
|
11
11
|
const memoize = require("./util/memoize");
|
|
12
12
|
|
|
13
|
-
/** @typedef {import("../declarations/WebpackOptions").DevtoolModuleFilenameTemplate} DevtoolModuleFilenameTemplate */
|
|
14
13
|
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
|
15
14
|
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
|
16
15
|
/** @typedef {import("./Module")} Module */
|
|
17
16
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
|
18
17
|
|
|
19
|
-
/** @typedef {string | RegExp | (string | RegExp)[]} Matcher */
|
|
18
|
+
/** @typedef {string | RegExp | ((str: string) => boolean) | (string | RegExp | ((str: string) => boolean))[]} Matcher */
|
|
20
19
|
/** @typedef {{ test?: Matcher, include?: Matcher, exclude?: Matcher }} MatchObject */
|
|
21
20
|
|
|
22
21
|
const ModuleFilenameHelpers = module.exports;
|
|
@@ -85,7 +84,7 @@ const getHash =
|
|
|
85
84
|
() => {
|
|
86
85
|
const hash = createHash(hashFunction);
|
|
87
86
|
hash.update(strFn());
|
|
88
|
-
const digest =
|
|
87
|
+
const digest = hash.digest("hex");
|
|
89
88
|
return digest.slice(0, 4);
|
|
90
89
|
};
|
|
91
90
|
|
|
@@ -94,10 +93,10 @@ const getHash =
|
|
|
94
93
|
* Returns a lazy object. The object is lazy in the sense that the properties are
|
|
95
94
|
* only evaluated when they are accessed. This is only obtained by setting a function as the value for each key.
|
|
96
95
|
* @param {Record<string, () => T>} obj the object to convert to a lazy access object
|
|
97
|
-
* @returns {T} the lazy access object
|
|
96
|
+
* @returns {Record<string, T>} the lazy access object
|
|
98
97
|
*/
|
|
99
98
|
const lazyObject = (obj) => {
|
|
100
|
-
const newObj = /** @type {T} */ ({});
|
|
99
|
+
const newObj = /** @type {Record<string, T>} */ ({});
|
|
101
100
|
for (const key of Object.keys(obj)) {
|
|
102
101
|
const fn = obj[key];
|
|
103
102
|
Object.defineProperty(newObj, key, {
|
|
@@ -117,8 +116,21 @@ const lazyObject = (obj) => {
|
|
|
117
116
|
};
|
|
118
117
|
|
|
119
118
|
const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/gi;
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
/**
|
|
120
|
+
* @typedef {object} ModuleFilenameTemplateContext
|
|
121
|
+
* @property {string} identifier the identifier of the module
|
|
122
|
+
* @property {string} shortIdentifier the shortened identifier of the module
|
|
123
|
+
* @property {string} resource the resource of the module request
|
|
124
|
+
* @property {string} resourcePath the resource path of the module request
|
|
125
|
+
* @property {string} absoluteResourcePath the absolute resource path of the module request
|
|
126
|
+
* @property {string} loaders the loaders of the module request
|
|
127
|
+
* @property {string} allLoaders the all loaders of the module request
|
|
128
|
+
* @property {string} query the query of the module identifier
|
|
129
|
+
* @property {string} moduleId the module id of the module
|
|
130
|
+
* @property {string} hash the hash of the module identifier
|
|
131
|
+
* @property {string} namespace the module namespace
|
|
132
|
+
*/
|
|
133
|
+
/** @typedef {((context: ModuleFilenameTemplateContext) => string)} ModuleFilenameTemplateFunction */
|
|
122
134
|
/** @typedef {string | ModuleFilenameTemplateFunction} ModuleFilenameTemplate */
|
|
123
135
|
|
|
124
136
|
/**
|
|
@@ -190,19 +202,22 @@ ModuleFilenameHelpers.createFilename = (
|
|
|
190
202
|
};
|
|
191
203
|
if (typeof opts.moduleFilenameTemplate === "function") {
|
|
192
204
|
return opts.moduleFilenameTemplate(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
/** @type {ModuleFilenameTemplateContext} */
|
|
206
|
+
(
|
|
207
|
+
lazyObject({
|
|
208
|
+
identifier,
|
|
209
|
+
shortIdentifier,
|
|
210
|
+
resource,
|
|
211
|
+
resourcePath: memoize(resourcePath),
|
|
212
|
+
absoluteResourcePath: memoize(absoluteResourcePath),
|
|
213
|
+
loaders: memoize(loaders),
|
|
214
|
+
allLoaders: memoize(allLoaders),
|
|
215
|
+
query: memoize(query),
|
|
216
|
+
moduleId: memoize(moduleId),
|
|
217
|
+
hash: memoize(hash),
|
|
218
|
+
namespace: () => opts.namespace
|
|
219
|
+
})
|
|
220
|
+
)
|
|
206
221
|
);
|
|
207
222
|
}
|
|
208
223
|
|
|
@@ -319,13 +334,15 @@ ModuleFilenameHelpers.replaceDuplicates = (array, fn, comparator) => {
|
|
|
319
334
|
*/
|
|
320
335
|
const matchPart = (str, test) => {
|
|
321
336
|
if (!test) return true;
|
|
322
|
-
if (
|
|
323
|
-
return test.
|
|
324
|
-
}
|
|
325
|
-
if (typeof test === "string") {
|
|
337
|
+
if (test instanceof RegExp) {
|
|
338
|
+
return test.test(str);
|
|
339
|
+
} else if (typeof test === "string") {
|
|
326
340
|
return str.startsWith(test);
|
|
341
|
+
} else if (typeof test === "function") {
|
|
342
|
+
return test(str);
|
|
327
343
|
}
|
|
328
|
-
|
|
344
|
+
|
|
345
|
+
return test.some((test) => matchPart(str, test));
|
|
329
346
|
};
|
|
330
347
|
|
|
331
348
|
ModuleFilenameHelpers.matchPart = matchPart;
|