webpack 5.93.0 → 5.94.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 +8 -5
- package/bin/webpack.js +6 -7
- package/hot/log.js +1 -2
- package/hot/only-dev-server.js +1 -1
- package/hot/poll.js +1 -1
- package/hot/signal.js +1 -1
- package/lib/APIPlugin.js +4 -3
- package/lib/AbstractMethodError.js +10 -5
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +12 -6
- package/lib/Cache.js +8 -10
- package/lib/CacheFacade.js +3 -3
- package/lib/CaseSensitiveModulesWarning.js +5 -7
- package/lib/Chunk.js +14 -11
- package/lib/ChunkGraph.js +58 -36
- package/lib/ChunkGroup.js +2 -3
- package/lib/ChunkTemplate.js +43 -0
- package/lib/CleanPlugin.js +10 -11
- package/lib/CodeGenerationResults.js +6 -5
- package/lib/CommentCompilationWarning.js +0 -1
- package/lib/Compilation.js +223 -191
- package/lib/Compiler.js +81 -82
- package/lib/ConcatenationScope.js +3 -6
- package/lib/ConditionalInitFragment.js +6 -7
- package/lib/ConstPlugin.js +7 -15
- package/lib/ContextExclusionPlugin.js +3 -3
- package/lib/ContextModule.js +33 -20
- package/lib/ContextModuleFactory.js +89 -44
- package/lib/ContextReplacementPlugin.js +10 -9
- package/lib/DefinePlugin.js +75 -68
- package/lib/DelegatedModule.js +7 -3
- package/lib/DelegatedModuleFactoryPlugin.js +36 -22
- package/lib/DelegatedPlugin.js +4 -0
- package/lib/DependenciesBlock.js +0 -1
- package/lib/Dependency.js +10 -14
- package/lib/DllEntryPlugin.js +4 -2
- package/lib/DllModuleFactory.js +1 -0
- package/lib/DllPlugin.js +9 -7
- package/lib/DllReferencePlugin.js +30 -15
- package/lib/EntryPlugin.js +1 -3
- package/lib/EnvironmentPlugin.js +5 -2
- package/lib/ErrorHelpers.js +11 -12
- package/lib/EvalDevToolModulePlugin.js +10 -12
- package/lib/EvalSourceMapDevToolPlugin.js +15 -13
- package/lib/ExportsInfo.js +185 -120
- package/lib/ExternalModule.js +104 -64
- package/lib/ExternalModuleFactoryPlugin.js +23 -10
- package/lib/FileSystemInfo.js +791 -422
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -1
- package/lib/FlagDependencyExportsPlugin.js +12 -11
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +2 -5
- package/lib/GraphHelpers.js +3 -2
- package/lib/HookWebpackError.js +8 -10
- package/lib/HotModuleReplacementPlugin.js +78 -64
- package/lib/IgnoreErrorModuleFactory.js +3 -3
- package/lib/IgnorePlugin.js +1 -3
- package/lib/IgnoreWarningsPlugin.js +6 -9
- package/lib/InitFragment.js +2 -3
- package/lib/LibManifestPlugin.js +4 -3
- package/lib/MainTemplate.js +72 -19
- package/lib/Module.js +25 -9
- package/lib/ModuleBuildError.js +4 -11
- package/lib/ModuleDependencyError.js +5 -5
- package/lib/ModuleDependencyWarning.js +5 -5
- package/lib/ModuleError.js +1 -5
- package/lib/ModuleFilenameHelpers.js +29 -46
- package/lib/ModuleGraph.js +7 -6
- package/lib/ModuleGraphConnection.js +6 -6
- package/lib/ModuleInfoHeaderPlugin.js +82 -30
- package/lib/ModuleParseError.js +8 -9
- package/lib/ModuleRestoreError.js +1 -1
- package/lib/ModuleStoreError.js +1 -1
- package/lib/ModuleTemplate.js +33 -1
- package/lib/ModuleTypeConstants.js +21 -22
- package/lib/ModuleWarning.js +1 -5
- package/lib/MultiCompiler.js +24 -26
- package/lib/MultiStats.js +73 -31
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +126 -69
- package/lib/NormalModuleFactory.js +53 -49
- package/lib/OptimizationStages.js +3 -3
- package/lib/ProgressPlugin.js +9 -9
- package/lib/ProvidePlugin.js +4 -4
- package/lib/RuntimeGlobals.js +71 -70
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +24 -12
- package/lib/RuntimeTemplate.js +40 -44
- package/lib/SizeFormatHelpers.js +2 -4
- package/lib/SourceMapDevToolPlugin.js +42 -34
- package/lib/Stats.js +5 -11
- package/lib/Template.js +18 -24
- package/lib/TemplatedPathPlugin.js +12 -10
- package/lib/WarnDeprecatedOptionPlugin.js +0 -1
- package/lib/WatchIgnorePlugin.js +26 -9
- package/lib/Watching.js +10 -5
- package/lib/WebpackOptionsApply.js +84 -62
- package/lib/asset/AssetGenerator.js +107 -42
- package/lib/asset/AssetModulesPlugin.js +29 -23
- package/lib/asset/AssetSourceGenerator.js +2 -7
- package/lib/async-modules/AwaitDependenciesInitFragment.js +6 -7
- package/lib/buildChunkGraph.js +14 -19
- package/lib/cache/IdleFileCachePlugin.js +4 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +5 -5
- package/lib/cache/PackFileCacheStrategy.js +51 -50
- package/lib/cache/ResolverCachePlugin.js +6 -6
- package/lib/cache/mergeEtags.js +16 -21
- package/lib/cli.js +148 -104
- package/lib/config/browserslistTargetHandler.js +16 -13
- package/lib/config/defaults.js +31 -28
- package/lib/config/normalization.js +335 -344
- package/lib/config/target.js +42 -52
- package/lib/container/ContainerEntryModule.js +2 -2
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/RemoteRuntimeModule.js +11 -8
- package/lib/container/options.js +18 -4
- package/lib/css/CssExportsGenerator.js +26 -24
- package/lib/css/CssGenerator.js +9 -4
- package/lib/css/CssLoadingRuntimeModule.js +10 -10
- package/lib/css/CssModulesPlugin.js +127 -47
- package/lib/css/CssParser.js +20 -18
- package/lib/css/walkCssTokens.js +80 -95
- package/lib/debug/ProfilingPlugin.js +19 -20
- package/lib/dependencies/AMDDefineDependency.js +1 -1
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +83 -47
- package/lib/dependencies/AMDRequireArrayDependency.js +9 -10
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +22 -16
- package/lib/dependencies/AMDRuntimeModules.js +2 -2
- package/lib/dependencies/CommonJsDependencyHelpers.js +6 -2
- package/lib/dependencies/CommonJsExportRequireDependency.js +37 -41
- package/lib/dependencies/CommonJsExportsDependency.js +0 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +19 -23
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +52 -61
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +6 -8
- package/lib/dependencies/ConstDependency.js +1 -1
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +31 -34
- package/lib/dependencies/ContextElementDependency.js +2 -2
- package/lib/dependencies/CriticalDependencyWarning.js +1 -1
- package/lib/dependencies/CssExportDependency.js +7 -7
- package/lib/dependencies/CssImportDependency.js +0 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +3 -3
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +4 -5
- package/lib/dependencies/DynamicExports.js +5 -5
- package/lib/dependencies/ExportsInfoDependency.js +1 -2
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +27 -16
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +107 -64
- package/lib/dependencies/HarmonyExports.js +2 -2
- package/lib/dependencies/HarmonyImportDependency.js +2 -4
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -15
- package/lib/dependencies/ImportDependency.js +1 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +5 -5
- package/lib/dependencies/ImportMetaPlugin.js +11 -13
- package/lib/dependencies/ImportParserPlugin.js +39 -44
- package/lib/dependencies/JsonExportsDependency.js +22 -18
- package/lib/dependencies/LoaderPlugin.js +47 -36
- package/lib/dependencies/LocalModule.js +1 -1
- package/lib/dependencies/LocalModulesHelpers.js +4 -4
- package/lib/dependencies/ModuleDecoratorDependency.js +1 -1
- package/lib/dependencies/ProvidedDependency.js +1 -1
- package/lib/dependencies/PureExpressionDependency.js +6 -6
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLDependency.js +3 -3
- package/lib/dependencies/URLPlugin.js +66 -12
- package/lib/dependencies/WorkerPlugin.js +25 -24
- package/lib/dependencies/processExportInfo.js +3 -1
- package/lib/electron/ElectronTargetPlugin.js +1 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +3 -3
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -3
- package/lib/formatLocation.js +1 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +4 -5
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +9 -12
- package/lib/hmr/LazyCompilationPlugin.js +27 -12
- package/lib/hmr/lazyCompilationBackend.js +64 -40
- package/lib/ids/ChunkModuleIdRangePlugin.js +1 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +2 -4
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +5 -1
- package/lib/ids/IdHelpers.js +29 -39
- package/lib/ids/SyncModuleIdsPlugin.js +7 -2
- package/lib/index.js +1 -5
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +5 -4
- package/lib/javascript/BasicEvaluatedExpression.js +4 -19
- package/lib/javascript/ChunkHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +3 -2
- package/lib/javascript/EnableChunkLoadingPlugin.js +7 -6
- package/lib/javascript/JavascriptGenerator.js +23 -7
- package/lib/javascript/JavascriptModulesPlugin.js +91 -69
- package/lib/javascript/JavascriptParser.js +179 -200
- package/lib/javascript/JavascriptParserHelpers.js +20 -21
- package/lib/javascript/StartupHelpers.js +41 -13
- package/lib/json/JsonGenerator.js +7 -13
- package/lib/json/JsonModulesPlugin.js +1 -4
- package/lib/json/JsonParser.js +5 -3
- package/lib/library/AmdLibraryPlugin.js +12 -16
- package/lib/library/AssignLibraryPlugin.js +8 -10
- package/lib/library/EnableLibraryPlugin.js +15 -14
- package/lib/library/JsonpLibraryPlugin.js +2 -1
- package/lib/library/ModernModuleLibraryPlugin.js +8 -6
- package/lib/library/ModuleLibraryPlugin.js +2 -1
- package/lib/library/SystemLibraryPlugin.js +2 -1
- package/lib/library/UmdLibraryPlugin.js +66 -92
- package/lib/logging/Logger.js +32 -4
- package/lib/logging/createConsoleLogger.js +12 -13
- package/lib/logging/runtime.js +7 -8
- package/lib/logging/truncateArgs.js +5 -8
- package/lib/node/NodeWatchFileSystem.js +3 -18
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/nodeConsole.js +22 -22
- package/lib/optimize/AggressiveMergingPlugin.js +2 -4
- package/lib/optimize/AggressiveSplittingPlugin.js +16 -19
- package/lib/optimize/ConcatenatedModule.js +80 -48
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -3
- package/lib/optimize/InnerGraph.js +17 -17
- package/lib/optimize/InnerGraphPlugin.js +8 -7
- package/lib/optimize/LimitChunkCountPlugin.js +2 -3
- package/lib/optimize/MangleExportsPlugin.js +1 -0
- package/lib/optimize/MinMaxSizeWarning.js +1 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +54 -78
- package/lib/optimize/RealContentHashPlugin.js +7 -10
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -2
- package/lib/optimize/SplitChunksPlugin.js +34 -30
- package/lib/performance/SizeLimitsPlugin.js +2 -2
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -1
- package/lib/rules/BasicEffectRulePlugin.js +3 -1
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +4 -1
- package/lib/rules/RuleSetCompiler.js +41 -22
- package/lib/rules/UseEffectRulePlugin.js +36 -32
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -1
- package/lib/runtime/EnsureChunkRuntimeModule.js +10 -11
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +11 -17
- package/lib/runtime/LoadScriptRuntimeModule.js +17 -18
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -3
- package/lib/schemes/DataUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +241 -126
- package/lib/serialization/BinaryMiddleware.js +44 -28
- package/lib/serialization/DateObjectSerializer.js +1 -0
- package/lib/serialization/ErrorObjectSerializer.js +2 -0
- package/lib/serialization/FileMiddleware.js +154 -106
- package/lib/serialization/MapObjectSerializer.js +2 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +3 -2
- package/lib/serialization/ObjectMiddleware.js +52 -56
- package/lib/serialization/PlainObjectSerializer.js +32 -6
- package/lib/serialization/RegExpObjectSerializer.js +1 -0
- package/lib/serialization/Serializer.js +4 -5
- package/lib/serialization/SerializerMiddleware.js +6 -6
- package/lib/serialization/SetObjectSerializer.js +2 -1
- package/lib/sharing/ConsumeSharedPlugin.js +116 -97
- package/lib/sharing/ConsumeSharedRuntimeModule.js +4 -4
- package/lib/sharing/ProvideForSharedDependency.js +0 -1
- package/lib/sharing/ProvideSharedPlugin.js +2 -2
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +15 -27
- package/lib/stats/DefaultStatsFactoryPlugin.js +424 -281
- package/lib/stats/DefaultStatsPresetPlugin.js +73 -18
- package/lib/stats/DefaultStatsPrinterPlugin.js +370 -101
- package/lib/stats/StatsFactory.js +127 -56
- package/lib/stats/StatsPrinter.js +75 -44
- package/lib/util/ArrayHelpers.js +8 -4
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +31 -12
- package/lib/util/IterableHelpers.js +3 -4
- package/lib/util/LazyBucketSortedSet.js +60 -44
- package/lib/util/LazySet.js +1 -0
- package/lib/util/MapHelpers.js +1 -3
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/Queue.js +1 -1
- package/lib/util/Semaphore.js +4 -7
- package/lib/util/SetHelpers.js +5 -5
- package/lib/util/SortableSet.js +4 -3
- package/lib/util/StackedCacheMap.js +4 -6
- package/lib/util/StackedMap.js +1 -3
- package/lib/util/StringXor.js +0 -5
- package/lib/util/TupleQueue.js +1 -1
- package/lib/util/TupleSet.js +15 -5
- package/lib/util/URLAbsoluteSpecifier.js +7 -7
- package/lib/util/WeakTupleMap.js +19 -21
- package/lib/util/binarySearchBounds.js +5 -12
- package/lib/util/chainedImports.js +1 -1
- package/lib/util/cleverMerge.js +21 -19
- package/lib/util/comparators.js +57 -52
- package/lib/util/compileBooleanMatcher.js +3 -6
- package/lib/util/conventions.js +8 -11
- package/lib/util/createHash.js +9 -6
- package/lib/util/deprecation.js +22 -12
- package/lib/util/deterministicGrouping.js +19 -26
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +31 -31
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +7 -7
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +81 -59
- package/lib/util/memoize.js +8 -10
- package/lib/util/mergeScope.js +6 -9
- package/lib/util/nonNumericOnlyHash.js +2 -2
- package/lib/util/numberHash.js +1 -6
- package/lib/util/objectToMap.js +0 -1
- package/lib/util/propertyAccess.js +2 -5
- package/lib/util/propertyName.js +1 -3
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/util/runtime.js +103 -113
- package/lib/util/semver.js +29 -27
- package/lib/util/serialization.js +16 -1
- package/lib/util/smartGrouping.js +5 -5
- package/lib/util/source.js +1 -1
- package/lib/wasm/EnableWasmLoadingPlugin.js +5 -4
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -6
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +20 -19
- package/lib/wasm-sync/WebAssemblyGenerator.js +14 -29
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +15 -14
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +1 -0
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
- package/types.d.ts +667 -347
package/lib/DefinePlugin.js
CHANGED
@@ -22,6 +22,7 @@ const {
|
|
22
22
|
const createHash = require("./util/createHash");
|
23
23
|
|
24
24
|
/** @typedef {import("estree").Expression} Expression */
|
25
|
+
/** @typedef {import("./Compilation").ValueCacheVersion} ValueCacheVersion */
|
25
26
|
/** @typedef {import("./Compiler")} Compiler */
|
26
27
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
27
28
|
/** @typedef {import("./NormalModule")} NormalModule */
|
@@ -30,6 +31,7 @@ const createHash = require("./util/createHash");
|
|
30
31
|
/** @typedef {import("./javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */
|
31
32
|
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
|
32
33
|
/** @typedef {import("./logging/Logger").Logger} Logger */
|
34
|
+
/** @typedef {import("./util/createHash").Algorithm} Algorithm */
|
33
35
|
|
34
36
|
/** @typedef {null|undefined|RegExp|Function|string|number|boolean|bigint|undefined} CodeValuePrimitive */
|
35
37
|
/** @typedef {RecursiveArrayOrRecord<CodeValuePrimitive|RuntimeValue>} CodeValue */
|
@@ -43,9 +45,11 @@ const createHash = require("./util/createHash");
|
|
43
45
|
* @property {string|function(): string=} version
|
44
46
|
*/
|
45
47
|
|
48
|
+
/** @typedef {function({ module: NormalModule, key: string, readonly version: ValueCacheVersion }): CodeValuePrimitive} GeneratorFn */
|
49
|
+
|
46
50
|
class RuntimeValue {
|
47
51
|
/**
|
48
|
-
* @param {
|
52
|
+
* @param {GeneratorFn} fn generator function
|
49
53
|
* @param {true | string[] | RuntimeValueOptions=} options options
|
50
54
|
*/
|
51
55
|
constructor(fn, options) {
|
@@ -64,7 +68,7 @@ class RuntimeValue {
|
|
64
68
|
|
65
69
|
/**
|
66
70
|
* @param {JavascriptParser} parser the parser
|
67
|
-
* @param {Map<string,
|
71
|
+
* @param {Map<string, ValueCacheVersion>} valueCacheVersions valueCacheVersions
|
68
72
|
* @param {string} key the defined key
|
69
73
|
* @returns {CodeValuePrimitive} code
|
70
74
|
*/
|
@@ -75,22 +79,26 @@ class RuntimeValue {
|
|
75
79
|
} else {
|
76
80
|
if (this.options.fileDependencies) {
|
77
81
|
for (const dep of this.options.fileDependencies) {
|
78
|
-
|
82
|
+
/** @type {NonNullable<BuildInfo["fileDependencies"]>} */
|
83
|
+
(buildInfo.fileDependencies).add(dep);
|
79
84
|
}
|
80
85
|
}
|
81
86
|
if (this.options.contextDependencies) {
|
82
87
|
for (const dep of this.options.contextDependencies) {
|
83
|
-
|
88
|
+
/** @type {NonNullable<BuildInfo["contextDependencies"]>} */
|
89
|
+
(buildInfo.contextDependencies).add(dep);
|
84
90
|
}
|
85
91
|
}
|
86
92
|
if (this.options.missingDependencies) {
|
87
93
|
for (const dep of this.options.missingDependencies) {
|
88
|
-
|
94
|
+
/** @type {NonNullable<BuildInfo["missingDependencies"]>} */
|
95
|
+
(buildInfo.missingDependencies).add(dep);
|
89
96
|
}
|
90
97
|
}
|
91
98
|
if (this.options.buildDependencies) {
|
92
99
|
for (const dep of this.options.buildDependencies) {
|
93
|
-
|
100
|
+
/** @type {NonNullable<BuildInfo["buildDependencies"]>} */
|
101
|
+
(buildInfo.buildDependencies).add(dep);
|
94
102
|
}
|
95
103
|
}
|
96
104
|
}
|
@@ -99,9 +107,7 @@ class RuntimeValue {
|
|
99
107
|
module: parser.state.module,
|
100
108
|
key,
|
101
109
|
get version() {
|
102
|
-
return
|
103
|
-
valueCacheVersions.get(VALUE_DEP_PREFIX + key)
|
104
|
-
);
|
110
|
+
return valueCacheVersions.get(VALUE_DEP_PREFIX + key);
|
105
111
|
}
|
106
112
|
});
|
107
113
|
}
|
@@ -120,19 +126,22 @@ class RuntimeValue {
|
|
120
126
|
* @returns {Set<string> | undefined} used keys
|
121
127
|
*/
|
122
128
|
function getObjKeys(properties) {
|
123
|
-
if (!properties) return
|
129
|
+
if (!properties) return;
|
124
130
|
return new Set([...properties].map(p => p.id));
|
125
131
|
}
|
126
132
|
|
133
|
+
/** @typedef {Set<string> | null} ObjKeys */
|
134
|
+
/** @typedef {boolean | undefined | null} AsiSafe */
|
135
|
+
|
127
136
|
/**
|
128
137
|
* @param {any[]|{[k: string]: any}} obj obj
|
129
138
|
* @param {JavascriptParser} parser Parser
|
130
|
-
* @param {Map<string,
|
139
|
+
* @param {Map<string, ValueCacheVersion>} valueCacheVersions valueCacheVersions
|
131
140
|
* @param {string} key the defined key
|
132
141
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
133
142
|
* @param {Logger} logger the logger object
|
134
|
-
* @param {
|
135
|
-
* @param {
|
143
|
+
* @param {AsiSafe=} asiSafe asi safe (undefined: unknown, null: unneeded)
|
144
|
+
* @param {ObjKeys=} objKeys used keys
|
136
145
|
* @returns {string} code converted to string that evaluates
|
137
146
|
*/
|
138
147
|
const stringifyObj = (
|
@@ -146,7 +155,7 @@ const stringifyObj = (
|
|
146
155
|
objKeys
|
147
156
|
) => {
|
148
157
|
let code;
|
149
|
-
|
158
|
+
const arr = Array.isArray(obj);
|
150
159
|
if (arr) {
|
151
160
|
code = `[${
|
152
161
|
/** @type {any[]} */ (obj)
|
@@ -166,25 +175,20 @@ const stringifyObj = (
|
|
166
175
|
} else {
|
167
176
|
let keys = Object.keys(obj);
|
168
177
|
if (objKeys) {
|
169
|
-
|
170
|
-
else keys = keys.filter(k => objKeys.has(k));
|
178
|
+
keys = objKeys.size === 0 ? [] : keys.filter(k => objKeys.has(k));
|
171
179
|
}
|
172
180
|
code = `{${keys
|
173
181
|
.map(key => {
|
174
182
|
const code = /** @type {{[k: string]: any}} */ (obj)[key];
|
175
|
-
return (
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
logger,
|
185
|
-
null
|
186
|
-
)
|
187
|
-
);
|
183
|
+
return `${JSON.stringify(key)}:${toCode(
|
184
|
+
code,
|
185
|
+
parser,
|
186
|
+
valueCacheVersions,
|
187
|
+
key,
|
188
|
+
runtimeTemplate,
|
189
|
+
logger,
|
190
|
+
null
|
191
|
+
)}`;
|
188
192
|
})
|
189
193
|
.join(",")}}`;
|
190
194
|
}
|
@@ -205,12 +209,12 @@ const stringifyObj = (
|
|
205
209
|
* Convert code to a string that evaluates
|
206
210
|
* @param {CodeValue} code Code to evaluate
|
207
211
|
* @param {JavascriptParser} parser Parser
|
208
|
-
* @param {Map<string,
|
212
|
+
* @param {Map<string, ValueCacheVersion>} valueCacheVersions valueCacheVersions
|
209
213
|
* @param {string} key the defined key
|
210
214
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
211
215
|
* @param {Logger} logger the logger object
|
212
|
-
* @param {boolean|undefined|null=} asiSafe asi safe (undefined: unknown, null: unneeded)
|
213
|
-
* @param {
|
216
|
+
* @param {boolean | undefined | null=} asiSafe asi safe (undefined: unknown, null: unneeded)
|
217
|
+
* @param {ObjKeys=} objKeys used keys
|
214
218
|
* @returns {string} code converted to string that evaluates
|
215
219
|
*/
|
216
220
|
const toCode = (
|
@@ -248,7 +252,7 @@ const toCode = (
|
|
248
252
|
return code.toString();
|
249
253
|
}
|
250
254
|
if (typeof code === "function" && code.toString) {
|
251
|
-
return
|
255
|
+
return `(${code.toString()})`;
|
252
256
|
}
|
253
257
|
if (typeof code === "object") {
|
254
258
|
return stringifyObj(
|
@@ -267,7 +271,7 @@ const toCode = (
|
|
267
271
|
? `${code}n`
|
268
272
|
: `BigInt("${code}")`;
|
269
273
|
}
|
270
|
-
return code
|
274
|
+
return `${code}`;
|
271
275
|
};
|
272
276
|
|
273
277
|
const strCode = transformToCode();
|
@@ -298,20 +302,20 @@ const toCacheVersion = code => {
|
|
298
302
|
return code.toString();
|
299
303
|
}
|
300
304
|
if (typeof code === "function" && code.toString) {
|
301
|
-
return
|
305
|
+
return `(${code.toString()})`;
|
302
306
|
}
|
303
307
|
if (typeof code === "object") {
|
304
308
|
const items = Object.keys(code).map(key => ({
|
305
309
|
key,
|
306
310
|
value: toCacheVersion(/** @type {Record<string, any>} */ (code)[key])
|
307
311
|
}));
|
308
|
-
if (items.some(({ value }) => value === undefined)) return
|
312
|
+
if (items.some(({ value }) => value === undefined)) return;
|
309
313
|
return `{${items.map(({ key, value }) => `${key}: ${value}`).join(", ")}}`;
|
310
314
|
}
|
311
315
|
if (typeof code === "bigint") {
|
312
316
|
return `${code}n`;
|
313
317
|
}
|
314
|
-
return code
|
318
|
+
return `${code}`;
|
315
319
|
};
|
316
320
|
|
317
321
|
const PLUGIN_NAME = "DefinePlugin";
|
@@ -333,7 +337,7 @@ class DefinePlugin {
|
|
333
337
|
}
|
334
338
|
|
335
339
|
/**
|
336
|
-
* @param {
|
340
|
+
* @param {GeneratorFn} fn generator function
|
337
341
|
* @param {true | string[] | RuntimeValueOptions=} options options
|
338
342
|
* @returns {RuntimeValue} runtime value
|
339
343
|
*/
|
@@ -358,11 +362,13 @@ class DefinePlugin {
|
|
358
362
|
);
|
359
363
|
const { runtimeTemplate } = compilation;
|
360
364
|
|
361
|
-
const mainHash = createHash(
|
365
|
+
const mainHash = createHash(
|
366
|
+
/** @type {Algorithm} */
|
367
|
+
(compilation.outputOptions.hashFunction)
|
368
|
+
);
|
362
369
|
mainHash.update(
|
363
|
-
/** @type {string} */
|
364
|
-
|
365
|
-
) || ""
|
370
|
+
/** @type {string} */
|
371
|
+
(compilation.valueCacheVersions.get(VALUE_DEP_MAIN)) || ""
|
366
372
|
);
|
367
373
|
|
368
374
|
/**
|
@@ -385,15 +391,22 @@ class DefinePlugin {
|
|
385
391
|
* @param {string} key key
|
386
392
|
*/
|
387
393
|
const addValueDependency = key => {
|
388
|
-
const buildInfo =
|
389
|
-
|
390
|
-
|
391
|
-
|
394
|
+
const buildInfo =
|
395
|
+
/** @type {BuildInfo} */
|
396
|
+
(parser.state.module.buildInfo);
|
397
|
+
/** @type {NonNullable<BuildInfo["valueDependencies"]>} */
|
398
|
+
(buildInfo.valueDependencies).set(
|
392
399
|
VALUE_DEP_PREFIX + key,
|
393
400
|
compilation.valueCacheVersions.get(VALUE_DEP_PREFIX + key)
|
394
401
|
);
|
395
402
|
};
|
396
403
|
|
404
|
+
/**
|
405
|
+
* @template {Function} T
|
406
|
+
* @param {string} key key
|
407
|
+
* @param {T} fn fn
|
408
|
+
* @returns {function(TODO): TODO} result
|
409
|
+
*/
|
397
410
|
const withValueDependency =
|
398
411
|
(key, fn) =>
|
399
412
|
(...args) => {
|
@@ -408,7 +421,7 @@ class DefinePlugin {
|
|
408
421
|
* @returns {void}
|
409
422
|
*/
|
410
423
|
const walkDefinitions = (definitions, prefix) => {
|
411
|
-
Object.keys(definitions)
|
424
|
+
for (const key of Object.keys(definitions)) {
|
412
425
|
const code = definitions[key];
|
413
426
|
if (
|
414
427
|
code &&
|
@@ -418,14 +431,14 @@ class DefinePlugin {
|
|
418
431
|
) {
|
419
432
|
walkDefinitions(
|
420
433
|
/** @type {Record<string, CodeValue>} */ (code),
|
421
|
-
prefix + key
|
434
|
+
`${prefix + key}.`
|
422
435
|
);
|
423
436
|
applyObjectDefine(prefix + key, code);
|
424
|
-
|
437
|
+
continue;
|
425
438
|
}
|
426
439
|
applyDefineKey(prefix, key);
|
427
440
|
applyDefine(prefix + key, code);
|
428
|
-
}
|
441
|
+
}
|
429
442
|
};
|
430
443
|
|
431
444
|
/**
|
@@ -436,13 +449,13 @@ class DefinePlugin {
|
|
436
449
|
*/
|
437
450
|
const applyDefineKey = (prefix, key) => {
|
438
451
|
const splittedKey = key.split(".");
|
439
|
-
splittedKey.slice(1).
|
452
|
+
for (const [i, _] of splittedKey.slice(1).entries()) {
|
440
453
|
const fullKey = prefix + splittedKey.slice(0, i + 1).join(".");
|
441
454
|
parser.hooks.canRename.for(fullKey).tap(PLUGIN_NAME, () => {
|
442
455
|
addValueDependency(key);
|
443
456
|
return true;
|
444
457
|
});
|
445
|
-
}
|
458
|
+
}
|
446
459
|
};
|
447
460
|
|
448
461
|
/**
|
@@ -505,7 +518,7 @@ class DefinePlugin {
|
|
505
518
|
);
|
506
519
|
|
507
520
|
if (parser.scope.inShorthand) {
|
508
|
-
strCode = parser.scope.inShorthand
|
521
|
+
strCode = `${parser.scope.inShorthand}:${strCode}`;
|
509
522
|
}
|
510
523
|
|
511
524
|
if (WEBPACK_REQUIRE_FUNCTION_REGEXP.test(strCode)) {
|
@@ -516,9 +529,8 @@ class DefinePlugin {
|
|
516
529
|
return toConstantDependency(parser, strCode, [
|
517
530
|
RuntimeGlobals.requireScope
|
518
531
|
])(expr);
|
519
|
-
} else {
|
520
|
-
return toConstantDependency(parser, strCode)(expr);
|
521
532
|
}
|
533
|
+
return toConstantDependency(parser, strCode)(expr);
|
522
534
|
});
|
523
535
|
}
|
524
536
|
parser.hooks.evaluateTypeof.for(key).tap(PLUGIN_NAME, expr => {
|
@@ -542,9 +554,7 @@ class DefinePlugin {
|
|
542
554
|
logger,
|
543
555
|
null
|
544
556
|
);
|
545
|
-
const typeofCode = isTypeof
|
546
|
-
? codeCode
|
547
|
-
: "typeof (" + codeCode + ")";
|
557
|
+
const typeofCode = isTypeof ? codeCode : `typeof (${codeCode})`;
|
548
558
|
const res = parser.evaluate(typeofCode);
|
549
559
|
recurseTypeof = false;
|
550
560
|
res.setRange(/** @type {Range} */ (expr.range));
|
@@ -561,9 +571,7 @@ class DefinePlugin {
|
|
561
571
|
logger,
|
562
572
|
null
|
563
573
|
);
|
564
|
-
const typeofCode = isTypeof
|
565
|
-
? codeCode
|
566
|
-
: "typeof (" + codeCode + ")";
|
574
|
+
const typeofCode = isTypeof ? codeCode : `typeof (${codeCode})`;
|
567
575
|
const res = parser.evaluate(typeofCode);
|
568
576
|
if (!res.isString()) return;
|
569
577
|
return toConstantDependency(
|
@@ -611,7 +619,7 @@ class DefinePlugin {
|
|
611
619
|
);
|
612
620
|
|
613
621
|
if (parser.scope.inShorthand) {
|
614
|
-
strCode = parser.scope.inShorthand
|
622
|
+
strCode = `${parser.scope.inShorthand}:${strCode}`;
|
615
623
|
}
|
616
624
|
|
617
625
|
if (WEBPACK_REQUIRE_FUNCTION_REGEXP.test(strCode)) {
|
@@ -622,9 +630,8 @@ class DefinePlugin {
|
|
622
630
|
return toConstantDependency(parser, strCode, [
|
623
631
|
RuntimeGlobals.requireScope
|
624
632
|
])(expr);
|
625
|
-
} else {
|
626
|
-
return toConstantDependency(parser, strCode)(expr);
|
627
633
|
}
|
634
|
+
return toConstantDependency(parser, strCode)(expr);
|
628
635
|
});
|
629
636
|
parser.hooks.typeof
|
630
637
|
.for(key)
|
@@ -657,11 +664,11 @@ class DefinePlugin {
|
|
657
664
|
* @returns {void}
|
658
665
|
*/
|
659
666
|
const walkDefinitionsForValues = (definitions, prefix) => {
|
660
|
-
Object.keys(definitions)
|
667
|
+
for (const key of Object.keys(definitions)) {
|
661
668
|
const code = definitions[key];
|
662
669
|
const version = toCacheVersion(code);
|
663
670
|
const name = VALUE_DEP_PREFIX + prefix + key;
|
664
|
-
mainHash.update(
|
671
|
+
mainHash.update(`|${prefix}${key}`);
|
665
672
|
const oldVersion = compilation.valueCacheVersions.get(name);
|
666
673
|
if (oldVersion === undefined) {
|
667
674
|
compilation.valueCacheVersions.set(name, version);
|
@@ -681,10 +688,10 @@ class DefinePlugin {
|
|
681
688
|
) {
|
682
689
|
walkDefinitionsForValues(
|
683
690
|
/** @type {Record<string, CodeValue>} */ (code),
|
684
|
-
prefix + key
|
691
|
+
`${prefix + key}.`
|
685
692
|
);
|
686
693
|
}
|
687
|
-
}
|
694
|
+
}
|
688
695
|
};
|
689
696
|
|
690
697
|
walkDefinitionsForValues(definitions, "");
|
package/lib/DelegatedModule.js
CHANGED
@@ -36,6 +36,10 @@ const makeSerializable = require("./util/makeSerializable");
|
|
36
36
|
/** @typedef {import("./util/Hash")} Hash */
|
37
37
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
38
38
|
|
39
|
+
/** @typedef {string} SourceRequest */
|
40
|
+
/** @typedef {"require" | "object"} Type */
|
41
|
+
/** @typedef {TODO} Data */
|
42
|
+
|
39
43
|
const TYPES = new Set(["javascript"]);
|
40
44
|
const RUNTIME_REQUIREMENTS = new Set([
|
41
45
|
RuntimeGlobals.module,
|
@@ -44,9 +48,9 @@ const RUNTIME_REQUIREMENTS = new Set([
|
|
44
48
|
|
45
49
|
class DelegatedModule extends Module {
|
46
50
|
/**
|
47
|
-
* @param {
|
48
|
-
* @param {
|
49
|
-
* @param {
|
51
|
+
* @param {SourceRequest} sourceRequest source request
|
52
|
+
* @param {Data} data data
|
53
|
+
* @param {Type} type type
|
50
54
|
* @param {string} userRequest user request
|
51
55
|
* @param {string | Module} originalRequest original request
|
52
56
|
*/
|
@@ -7,15 +7,28 @@
|
|
7
7
|
|
8
8
|
const DelegatedModule = require("./DelegatedModule");
|
9
9
|
|
10
|
+
/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */
|
11
|
+
/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptionsContent} DllReferencePluginOptionsContent */
|
12
|
+
/** @typedef {import("./DelegatedModule").Data} Data */
|
13
|
+
/** @typedef {import("./DelegatedModule").SourceRequest} SourceRequest */
|
14
|
+
/** @typedef {import("./DelegatedModule").Type} Type */
|
10
15
|
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
|
11
16
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
/**
|
18
|
+
* @typedef {object} Options
|
19
|
+
* @property {SourceRequest} source source
|
20
|
+
* @property {NonNullable<DllReferencePluginOptions["context"]>} context absolute context path to which lib ident is relative to
|
21
|
+
* @property {DllReferencePluginOptionsContent} content content
|
22
|
+
* @property {DllReferencePluginOptions["type"]} type type
|
23
|
+
* @property {DllReferencePluginOptions["extensions"]} extensions extensions
|
24
|
+
* @property {DllReferencePluginOptions["scope"]} scope scope
|
25
|
+
* @property {object=} associatedObjectForCache object for caching
|
26
|
+
*/
|
27
|
+
|
18
28
|
class DelegatedModuleFactoryPlugin {
|
29
|
+
/**
|
30
|
+
* @param {Options} options options
|
31
|
+
*/
|
19
32
|
constructor(options) {
|
20
33
|
this.options = options;
|
21
34
|
options.type = options.type || "require";
|
@@ -35,7 +48,7 @@ class DelegatedModuleFactoryPlugin {
|
|
35
48
|
const [dependency] = data.dependencies;
|
36
49
|
const { request } = dependency;
|
37
50
|
if (request && request.startsWith(`${scope}/`)) {
|
38
|
-
const innerRequest =
|
51
|
+
const innerRequest = `.${request.slice(scope.length)}`;
|
39
52
|
let resolved;
|
40
53
|
if (innerRequest in this.options.content) {
|
41
54
|
resolved = this.options.content[innerRequest];
|
@@ -44,14 +57,17 @@ class DelegatedModuleFactoryPlugin {
|
|
44
57
|
new DelegatedModule(
|
45
58
|
this.options.source,
|
46
59
|
resolved,
|
47
|
-
this.options.type,
|
60
|
+
/** @type {Type} */ (this.options.type),
|
48
61
|
innerRequest,
|
49
62
|
request
|
50
63
|
)
|
51
64
|
);
|
52
65
|
}
|
53
|
-
|
54
|
-
|
66
|
+
const extensions =
|
67
|
+
/** @type {string[]} */
|
68
|
+
(this.options.extensions);
|
69
|
+
for (let i = 0; i < extensions.length; i++) {
|
70
|
+
const extension = extensions[i];
|
55
71
|
const requestPlusExt = innerRequest + extension;
|
56
72
|
if (requestPlusExt in this.options.content) {
|
57
73
|
resolved = this.options.content[requestPlusExt];
|
@@ -60,7 +76,7 @@ class DelegatedModuleFactoryPlugin {
|
|
60
76
|
new DelegatedModule(
|
61
77
|
this.options.source,
|
62
78
|
resolved,
|
63
|
-
this.options.type,
|
79
|
+
/** @type {Type} */ (this.options.type),
|
64
80
|
requestPlusExt,
|
65
81
|
request + extension
|
66
82
|
)
|
@@ -76,17 +92,15 @@ class DelegatedModuleFactoryPlugin {
|
|
76
92
|
"DelegatedModuleFactoryPlugin",
|
77
93
|
module => {
|
78
94
|
const request = module.libIdent(this.options);
|
79
|
-
if (request) {
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
);
|
89
|
-
}
|
95
|
+
if (request && request in this.options.content) {
|
96
|
+
const resolved = this.options.content[request];
|
97
|
+
return new DelegatedModule(
|
98
|
+
this.options.source,
|
99
|
+
resolved,
|
100
|
+
/** @type {Type} */ (this.options.type),
|
101
|
+
request,
|
102
|
+
module
|
103
|
+
);
|
90
104
|
}
|
91
105
|
return module;
|
92
106
|
}
|
package/lib/DelegatedPlugin.js
CHANGED
@@ -9,8 +9,12 @@ const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
|
|
9
9
|
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
|
10
10
|
|
11
11
|
/** @typedef {import("./Compiler")} Compiler */
|
12
|
+
/** @typedef {import("./DelegatedModuleFactoryPlugin").Options} Options */
|
12
13
|
|
13
14
|
class DelegatedPlugin {
|
15
|
+
/**
|
16
|
+
* @param {Options} options options
|
17
|
+
*/
|
14
18
|
constructor(options) {
|
15
19
|
this.options = options;
|
16
20
|
}
|
package/lib/DependenciesBlock.js
CHANGED
@@ -46,7 +46,6 @@ class DependenciesBlock {
|
|
46
46
|
/**
|
47
47
|
* Adds a DependencyBlock to DependencyBlock relationship.
|
48
48
|
* This is used for when a Module has a AsyncDependencyBlock tie (for code-splitting)
|
49
|
-
*
|
50
49
|
* @param {AsyncDependenciesBlock} block block being added
|
51
50
|
* @returns {void}
|
52
51
|
*/
|
package/lib/Dependency.js
CHANGED
@@ -67,7 +67,7 @@ const memoize = require("./util/memoize");
|
|
67
67
|
* @typedef {object} ExportsSpec
|
68
68
|
* @property {(string | ExportSpec)[] | true | null} exports exported names, true for unknown exports or null for no exports
|
69
69
|
* @property {Set<string>=} excludeExports when exports = true, list of unaffected exports
|
70
|
-
* @property {Set<string
|
70
|
+
* @property {(Set<string> | null)=} hideExports list of maybe prior exposed, but now hidden exports
|
71
71
|
* @property {ModuleGraphConnection=} from when reexported: from which module
|
72
72
|
* @property {number=} priority when reexported: with which priority
|
73
73
|
* @property {boolean=} canMangle can the export be renamed (defaults to true)
|
@@ -85,9 +85,9 @@ const memoize = require("./util/memoize");
|
|
85
85
|
|
86
86
|
const TRANSITIVE = Symbol("transitive");
|
87
87
|
|
88
|
-
const getIgnoredModule = memoize(
|
89
|
-
|
90
|
-
|
88
|
+
const getIgnoredModule = memoize(
|
89
|
+
() => new RawModule("/* (ignored) */", "ignored", "(ignored)")
|
90
|
+
);
|
91
91
|
|
92
92
|
class Dependency {
|
93
93
|
constructor() {
|
@@ -163,16 +163,8 @@ class Dependency {
|
|
163
163
|
this._locEL = 0;
|
164
164
|
this._locEC = 0;
|
165
165
|
}
|
166
|
-
|
167
|
-
|
168
|
-
} else {
|
169
|
-
this._locI = undefined;
|
170
|
-
}
|
171
|
-
if ("name" in loc) {
|
172
|
-
this._locN = loc.name;
|
173
|
-
} else {
|
174
|
-
this._locN = undefined;
|
175
|
-
}
|
166
|
+
this._locI = "index" in loc ? loc.index : undefined;
|
167
|
+
this._locN = "name" in loc ? loc.name : undefined;
|
176
168
|
this._loc = loc;
|
177
169
|
}
|
178
170
|
|
@@ -336,6 +328,8 @@ Dependency.NO_EXPORTS_REFERENCED = [];
|
|
336
328
|
/** @type {string[][]} */
|
337
329
|
Dependency.EXPORTS_OBJECT_REFERENCED = [[]];
|
338
330
|
|
331
|
+
// eslint-disable-next-line no-warning-comments
|
332
|
+
// @ts-ignore https://github.com/microsoft/TypeScript/issues/42919
|
339
333
|
Object.defineProperty(Dependency.prototype, "module", {
|
340
334
|
/**
|
341
335
|
* @deprecated
|
@@ -358,6 +352,8 @@ Object.defineProperty(Dependency.prototype, "module", {
|
|
358
352
|
}
|
359
353
|
});
|
360
354
|
|
355
|
+
// eslint-disable-next-line no-warning-comments
|
356
|
+
// @ts-ignore https://github.com/microsoft/TypeScript/issues/42919
|
361
357
|
Object.defineProperty(Dependency.prototype, "disconnect", {
|
362
358
|
get() {
|
363
359
|
throw new Error(
|
package/lib/DllEntryPlugin.js
CHANGED
@@ -10,12 +10,14 @@ const DllEntryDependency = require("./dependencies/DllEntryDependency");
|
|
10
10
|
const EntryDependency = require("./dependencies/EntryDependency");
|
11
11
|
|
12
12
|
/** @typedef {import("./Compiler")} Compiler */
|
13
|
+
/** @typedef {string[]} Entries */
|
14
|
+
/** @typedef {{ name: string, filename: TODO }} Options */
|
13
15
|
|
14
16
|
class DllEntryPlugin {
|
15
17
|
/**
|
16
18
|
* @param {string} context context
|
17
|
-
* @param {
|
18
|
-
* @param {
|
19
|
+
* @param {Entries} entries entry names
|
20
|
+
* @param {Options} options options
|
19
21
|
*/
|
20
22
|
constructor(context, entries, options) {
|
21
23
|
this.context = context;
|
package/lib/DllModuleFactory.js
CHANGED
package/lib/DllPlugin.js
CHANGED
@@ -12,6 +12,8 @@ const createSchemaValidation = require("./util/create-schema-validation");
|
|
12
12
|
|
13
13
|
/** @typedef {import("../declarations/plugins/DllPlugin").DllPluginOptions} DllPluginOptions */
|
14
14
|
/** @typedef {import("./Compiler")} Compiler */
|
15
|
+
/** @typedef {import("./DllEntryPlugin").Entries} Entries */
|
16
|
+
/** @typedef {import("./DllEntryPlugin").Options} Options */
|
15
17
|
|
16
18
|
const validate = createSchemaValidation(
|
17
19
|
require("../schemas/plugins/DllPlugin.check.js"),
|
@@ -43,13 +45,13 @@ class DllPlugin {
|
|
43
45
|
compiler.hooks.entryOption.tap("DllPlugin", (context, entry) => {
|
44
46
|
if (typeof entry !== "function") {
|
45
47
|
for (const name of Object.keys(entry)) {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
);
|
48
|
+
/** @type {Options} */
|
49
|
+
const options = { name, filename: entry.filename };
|
50
|
+
new DllEntryPlugin(
|
51
|
+
context,
|
52
|
+
/** @type {Entries} */ (entry[name].import),
|
53
|
+
options
|
54
|
+
).apply(compiler);
|
53
55
|
}
|
54
56
|
} else {
|
55
57
|
throw new Error(
|