webpack 5.102.1 → 5.104.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 +121 -134
- package/hot/dev-server.js +18 -3
- package/hot/emitter-event-target.js +7 -0
- package/hot/lazy-compilation-node.js +45 -29
- package/hot/lazy-compilation-universal.js +18 -0
- package/hot/lazy-compilation-web.js +15 -5
- package/hot/load-http.js +7 -0
- package/hot/only-dev-server.js +19 -4
- package/lib/APIPlugin.js +6 -0
- package/lib/Chunk.js +1 -1
- package/lib/ChunkGraph.js +9 -7
- package/lib/ChunkGroup.js +8 -5
- package/lib/CleanPlugin.js +6 -3
- package/lib/CodeGenerationResults.js +2 -1
- package/lib/CompatibilityPlugin.js +28 -2
- package/lib/Compilation.js +58 -21
- package/lib/Compiler.js +3 -3
- package/lib/ConcatenationScope.js +0 -15
- package/lib/ContextModule.js +6 -3
- package/lib/ContextModuleFactory.js +6 -4
- package/lib/CssModule.js +6 -1
- package/lib/DefinePlugin.js +45 -14
- package/lib/DelegatedModule.js +7 -4
- package/lib/Dependency.js +8 -1
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DllModule.js +6 -3
- package/lib/DotenvPlugin.js +462 -0
- package/lib/EnvironmentPlugin.js +19 -16
- package/lib/EvalSourceMapDevToolPlugin.js +16 -0
- package/lib/ExportsInfo.js +6 -2
- package/lib/ExternalModule.js +28 -35
- package/lib/ExternalModuleFactoryPlugin.js +11 -9
- package/lib/ExternalsPlugin.js +2 -1
- package/lib/FileSystemInfo.js +1 -1
- package/lib/Generator.js +10 -7
- package/lib/HookWebpackError.js +33 -4
- package/lib/HotModuleReplacementPlugin.js +22 -0
- package/lib/ManifestPlugin.js +235 -0
- package/lib/Module.js +27 -15
- package/lib/ModuleBuildError.js +1 -1
- package/lib/ModuleError.js +1 -1
- package/lib/ModuleFilenameHelpers.js +1 -1
- package/lib/ModuleGraph.js +29 -13
- package/lib/ModuleGraphConnection.js +2 -2
- package/lib/ModuleSourceTypeConstants.js +189 -0
- package/lib/ModuleTypeConstants.js +1 -4
- package/lib/ModuleWarning.js +1 -1
- package/lib/MultiCompiler.js +1 -1
- package/lib/NodeStuffPlugin.js +424 -116
- package/lib/NormalModule.js +23 -20
- package/lib/NormalModuleFactory.js +7 -10
- package/lib/Parser.js +1 -1
- package/lib/RawModule.js +7 -4
- package/lib/RuntimeGlobals.js +22 -4
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +27 -6
- package/lib/RuntimeTemplate.js +120 -57
- package/lib/SourceMapDevToolPlugin.js +26 -1
- package/lib/Template.js +17 -6
- package/lib/TemplatedPathPlugin.js +5 -6
- package/lib/WebpackError.js +0 -1
- package/lib/WebpackOptionsApply.js +67 -15
- package/lib/asset/AssetBytesGenerator.js +16 -12
- package/lib/asset/AssetGenerator.js +31 -26
- package/lib/asset/AssetSourceGenerator.js +16 -12
- package/lib/asset/RawDataUrlModule.js +6 -3
- package/lib/buildChunkGraph.js +4 -2
- package/lib/cache/PackFileCacheStrategy.js +6 -5
- package/lib/cli.js +2 -43
- package/lib/config/browserslistTargetHandler.js +24 -0
- package/lib/config/defaults.js +226 -61
- package/lib/config/normalization.js +4 -3
- package/lib/config/target.js +11 -0
- package/lib/container/ContainerEntryModule.js +6 -3
- package/lib/container/FallbackModule.js +6 -3
- package/lib/container/RemoteModule.js +1 -3
- package/lib/css/CssGenerator.js +304 -76
- package/lib/css/CssLoadingRuntimeModule.js +14 -4
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +56 -0
- package/lib/css/CssModulesPlugin.js +72 -67
- package/lib/css/CssParser.js +1726 -732
- package/lib/css/walkCssTokens.js +128 -11
- package/lib/dependencies/CachedConstDependency.js +24 -10
- package/lib/dependencies/CommonJsImportsParserPlugin.js +0 -9
- package/lib/dependencies/CommonJsPlugin.js +12 -0
- package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +2 -2
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +3 -1
- package/lib/dependencies/CssIcssExportDependency.js +389 -12
- package/lib/dependencies/CssIcssImportDependency.js +114 -51
- package/lib/dependencies/CssIcssSymbolDependency.js +31 -33
- package/lib/dependencies/CssImportDependency.js +17 -6
- package/lib/dependencies/CssUrlDependency.js +3 -2
- package/lib/dependencies/DynamicExports.js +7 -7
- package/lib/dependencies/ExternalModuleDependency.js +7 -4
- package/lib/dependencies/ExternalModuleInitFragment.js +3 -2
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +96 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +6 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +2 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +12 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +35 -23
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +13 -9
- package/lib/dependencies/HarmonyExports.js +4 -4
- package/lib/dependencies/HarmonyImportDependency.js +28 -27
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +28 -69
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -3
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -8
- package/lib/dependencies/ImportDependency.js +8 -2
- package/lib/dependencies/ImportEagerDependency.js +6 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportMetaPlugin.js +154 -9
- package/lib/dependencies/ImportParserPlugin.js +21 -23
- package/lib/dependencies/ImportPhase.js +121 -0
- package/lib/dependencies/ImportWeakDependency.js +6 -3
- package/lib/dependencies/LocalModulesHelpers.js +3 -3
- package/lib/dependencies/ModuleDependency.js +5 -1
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/dependencies/getFunctionExpression.js +1 -1
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +1 -8
- package/lib/esm/ModuleChunkFormatPlugin.js +5 -4
- package/lib/hmr/HotModuleReplacement.runtime.js +2 -1
- package/lib/hmr/LazyCompilationPlugin.js +5 -3
- package/lib/ids/IdHelpers.js +20 -8
- package/lib/index.js +6 -0
- package/lib/javascript/ChunkHelpers.js +16 -5
- package/lib/javascript/JavascriptGenerator.js +105 -104
- package/lib/javascript/JavascriptModulesPlugin.js +80 -37
- package/lib/javascript/JavascriptParser.js +161 -44
- package/lib/json/JsonGenerator.js +5 -4
- package/lib/json/JsonParser.js +9 -2
- package/lib/library/AbstractLibraryPlugin.js +1 -1
- package/lib/library/AmdLibraryPlugin.js +4 -1
- package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
- package/lib/library/ModuleLibraryPlugin.js +41 -23
- package/lib/library/SystemLibraryPlugin.js +8 -1
- package/lib/library/UmdLibraryPlugin.js +2 -2
- package/lib/logging/Logger.js +5 -4
- package/lib/logging/createConsoleLogger.js +2 -2
- package/lib/node/NodeTargetPlugin.js +9 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +0 -2
- package/lib/optimize/ConcatenatedModule.js +208 -167
- package/lib/optimize/ModuleConcatenationPlugin.js +5 -4
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
- package/lib/optimize/SplitChunksPlugin.js +60 -46
- package/lib/rules/RuleSetCompiler.js +1 -1
- package/lib/runtime/AsyncModuleRuntimeModule.js +28 -18
- package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +3 -2
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +89 -55
- package/lib/schemes/HttpUriPlugin.js +78 -7
- package/lib/serialization/AggregateErrorSerializer.js +1 -2
- package/lib/serialization/ObjectMiddleware.js +0 -2
- package/lib/serialization/SingleItemMiddleware.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ConsumeSharedPlugin.js +5 -3
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/resolveMatchedConfigs.js +15 -9
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +8 -5
- package/lib/stats/DefaultStatsPresetPlugin.js +1 -1
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/util/StringXor.js +1 -1
- package/lib/util/URLAbsoluteSpecifier.js +2 -2
- package/lib/util/binarySearchBounds.js +2 -2
- package/lib/util/comparators.js +54 -76
- package/lib/util/compileBooleanMatcher.js +78 -6
- package/lib/util/createHash.js +20 -199
- package/lib/util/deprecation.js +1 -1
- package/lib/util/deterministicGrouping.js +6 -3
- package/lib/util/fs.js +75 -75
- package/lib/util/hash/BatchedHash.js +10 -9
- package/lib/util/hash/BulkUpdateHash.js +138 -0
- package/lib/util/hash/DebugHash.js +75 -0
- package/lib/util/hash/hash-digest.js +216 -0
- package/lib/util/identifier.js +82 -17
- package/lib/util/internalSerializables.js +2 -6
- package/lib/util/runtime.js +3 -3
- package/lib/util/source.js +2 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +10 -4
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +3 -2
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +11 -7
- package/lib/wasm-sync/WebAssemblyGenerator.js +9 -6
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +11 -6
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +6 -2
- package/lib/web/FetchCompileWasmPlugin.js +0 -2
- package/lib/webpack.js +85 -82
- package/module.d.ts +5 -0
- package/package.json +34 -28
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +160 -101
- package/schemas/plugins/{css/CssAutoParserOptions.check.d.ts → ManifestPlugin.check.d.ts} +1 -1
- package/schemas/plugins/ManifestPlugin.check.js +6 -0
- package/schemas/plugins/ManifestPlugin.json +98 -0
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +16 -3
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +4 -1
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +4 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/schemas/plugins/json/JsonModulesPluginParser.check.js +1 -1
- package/types.d.ts +771 -436
- package/lib/ModuleSourceTypesConstants.js +0 -123
- package/lib/dependencies/CssLocalIdentifierDependency.js +0 -250
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +0 -112
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +0 -6
- package/schemas/plugins/css/CssAutoGeneratorOptions.json +0 -3
- package/schemas/plugins/css/CssAutoParserOptions.check.js +0 -6
- package/schemas/plugins/css/CssAutoParserOptions.json +0 -3
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +0 -6
- package/schemas/plugins/css/CssGlobalGeneratorOptions.json +0 -3
- package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssGlobalParserOptions.check.js +0 -6
- package/schemas/plugins/css/CssGlobalParserOptions.json +0 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* global __resourceQuery */
|
|
4
|
+
|
|
5
|
+
var isNodeLikeEnv =
|
|
6
|
+
typeof global !== "undefined" && typeof global.process !== "undefined";
|
|
7
|
+
|
|
8
|
+
var handler = isNodeLikeEnv
|
|
9
|
+
? require("./lazy-compilation-node")
|
|
10
|
+
: require("./lazy-compilation-web");
|
|
11
|
+
|
|
12
|
+
handler.setUrl(decodeURIComponent(__resourceQuery.slice(1)));
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {{ data: string, onError: (err: Error) => void, active: boolean, module: module }} options options
|
|
16
|
+
* @returns {() => void} function to destroy response
|
|
17
|
+
*/
|
|
18
|
+
module.exports = handler;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* global __resourceQuery */
|
|
2
|
-
|
|
3
1
|
"use strict";
|
|
4
2
|
|
|
3
|
+
/* global __resourceQuery */
|
|
4
|
+
|
|
5
5
|
if (typeof EventSource !== "function") {
|
|
6
6
|
throw new Error(
|
|
7
7
|
"Environment doesn't support lazy compilation (requires EventSource)"
|
|
@@ -54,15 +54,18 @@ var updateEventSource = function updateEventSource() {
|
|
|
54
54
|
exports.keepAlive = function (options) {
|
|
55
55
|
var data = options.data;
|
|
56
56
|
var onError = options.onError;
|
|
57
|
-
|
|
58
|
-
var module = options.module;
|
|
57
|
+
|
|
59
58
|
errorHandlers.add(onError);
|
|
59
|
+
|
|
60
60
|
var value = activeKeys.get(data) || 0;
|
|
61
|
+
|
|
61
62
|
activeKeys.set(data, value + 1);
|
|
63
|
+
|
|
62
64
|
if (value === 0) {
|
|
63
65
|
updateEventSource();
|
|
64
66
|
}
|
|
65
|
-
|
|
67
|
+
|
|
68
|
+
if (!options.active && !options.module.hot) {
|
|
66
69
|
console.log(
|
|
67
70
|
"Hot Module Replacement is not enabled. Waiting for process restart..."
|
|
68
71
|
);
|
|
@@ -81,3 +84,10 @@ exports.keepAlive = function (options) {
|
|
|
81
84
|
}, 1000);
|
|
82
85
|
};
|
|
83
86
|
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @param {string} value new url value
|
|
90
|
+
*/
|
|
91
|
+
exports.setUrl = function (value) {
|
|
92
|
+
urlBase = value;
|
|
93
|
+
};
|
package/hot/load-http.js
ADDED
package/hot/only-dev-server.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/* globals __webpack_hash__ */
|
|
6
6
|
if (module.hot) {
|
|
7
|
-
/** @type {undefined|string} */
|
|
7
|
+
/** @type {undefined | string} */
|
|
8
8
|
var lastHash;
|
|
9
9
|
var upToDate = function upToDate() {
|
|
10
10
|
return /** @type {string} */ (lastHash).indexOf(__webpack_hash__) >= 0;
|
|
@@ -79,9 +79,13 @@ if (module.hot) {
|
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
};
|
|
82
|
+
/** @type {EventTarget | NodeJS.EventEmitter} */
|
|
82
83
|
var hotEmitter = require("./emitter");
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
/**
|
|
85
|
+
* @param {CustomEvent<{ currentHash: string }>} event event or hash
|
|
86
|
+
*/
|
|
87
|
+
var handler = function (event) {
|
|
88
|
+
lastHash = typeof event === "string" ? event : event.detail.currentHash;
|
|
85
89
|
if (!upToDate()) {
|
|
86
90
|
var status = module.hot.status();
|
|
87
91
|
if (status === "idle") {
|
|
@@ -96,7 +100,18 @@ if (module.hot) {
|
|
|
96
100
|
);
|
|
97
101
|
}
|
|
98
102
|
}
|
|
99
|
-
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
if (typeof EventTarget !== "undefined" && hotEmitter instanceof EventTarget) {
|
|
106
|
+
hotEmitter.addEventListener(
|
|
107
|
+
"webpackHotUpdate",
|
|
108
|
+
/** @type {EventListener} */
|
|
109
|
+
(handler)
|
|
110
|
+
);
|
|
111
|
+
} else {
|
|
112
|
+
hotEmitter.on("webpackHotUpdate", handler);
|
|
113
|
+
}
|
|
114
|
+
|
|
100
115
|
log("info", "[HMR] Waiting for update signal from WDS...");
|
|
101
116
|
} else {
|
|
102
117
|
throw new Error("[HMR] Hot Module Replacement is disabled.");
|
package/lib/APIPlugin.js
CHANGED
|
@@ -42,6 +42,12 @@ function getReplacements() {
|
|
|
42
42
|
type: "function",
|
|
43
43
|
assign: false
|
|
44
44
|
},
|
|
45
|
+
__webpack_global__: {
|
|
46
|
+
expr: RuntimeGlobals.require,
|
|
47
|
+
req: [RuntimeGlobals.require],
|
|
48
|
+
type: "function",
|
|
49
|
+
assign: false
|
|
50
|
+
},
|
|
45
51
|
__webpack_public_path__: {
|
|
46
52
|
expr: RuntimeGlobals.publicPath,
|
|
47
53
|
req: [RuntimeGlobals.publicPath],
|
package/lib/Chunk.js
CHANGED
|
@@ -207,7 +207,7 @@ class Chunk {
|
|
|
207
207
|
|
|
208
208
|
/**
|
|
209
209
|
* @param {Chunk} otherChunk the chunk to compare with
|
|
210
|
-
* @returns {-1|0|1} the comparison result
|
|
210
|
+
* @returns {-1 | 0 | 1} the comparison result
|
|
211
211
|
*/
|
|
212
212
|
compareTo(otherChunk) {
|
|
213
213
|
const chunkGraph = ChunkGraph.getChunkGraphForChunk(
|
package/lib/ChunkGraph.js
CHANGED
|
@@ -35,8 +35,9 @@ const {
|
|
|
35
35
|
/** @typedef {import("./Chunk").Entrypoints} Entrypoints */
|
|
36
36
|
/** @typedef {import("./Chunk").ChunkId} ChunkId */
|
|
37
37
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
38
|
-
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
|
|
39
38
|
/** @typedef {import("./Module")} Module */
|
|
39
|
+
/** @typedef {import("./Module").SourceType} SourceType */
|
|
40
|
+
/** @typedef {import("./Module").SourceTypes} SourceTypes */
|
|
40
41
|
/** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
|
41
42
|
/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
|
|
42
43
|
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
|
@@ -97,7 +98,7 @@ const getModuleRuntimes = (chunks) => {
|
|
|
97
98
|
* @returns {(set: SortableSet<Module>) => Map<string, SortableSet<Module>>} modules by source type
|
|
98
99
|
*/
|
|
99
100
|
const modulesBySourceType = (sourceTypesByModule) => (set) => {
|
|
100
|
-
/** @type {Map<
|
|
101
|
+
/** @type {Map<SourceType, SortableSet<Module>>} */
|
|
101
102
|
const map = new Map();
|
|
102
103
|
for (const module of set) {
|
|
103
104
|
const sourceTypes =
|
|
@@ -220,7 +221,7 @@ class ChunkGraphModule {
|
|
|
220
221
|
}
|
|
221
222
|
}
|
|
222
223
|
|
|
223
|
-
/** @typedef {WeakMap<Module,
|
|
224
|
+
/** @typedef {WeakMap<Module, SourceTypes>} SourceTypesByModule */
|
|
224
225
|
/** @typedef {Map<Module, Entrypoint>} EntryModules */
|
|
225
226
|
|
|
226
227
|
class ChunkGraphChunk {
|
|
@@ -631,7 +632,7 @@ class ChunkGraph {
|
|
|
631
632
|
/**
|
|
632
633
|
* @param {Chunk} chunk chunk
|
|
633
634
|
* @param {Module} module chunk module
|
|
634
|
-
* @param {
|
|
635
|
+
* @param {SourceTypes} sourceTypes source types
|
|
635
636
|
*/
|
|
636
637
|
setChunkModuleSourceTypes(chunk, module, sourceTypes) {
|
|
637
638
|
const cgc = this._getChunkGraphChunk(chunk);
|
|
@@ -668,10 +669,11 @@ class ChunkGraph {
|
|
|
668
669
|
|
|
669
670
|
/**
|
|
670
671
|
* @param {Module} module module
|
|
671
|
-
* @returns {
|
|
672
|
+
* @returns {SourceTypes | undefined} source types
|
|
672
673
|
*/
|
|
673
674
|
_getOverwrittenModuleSourceTypes(module) {
|
|
674
675
|
let newSet = false;
|
|
676
|
+
/** @type {Set<SourceType> | undefined} */
|
|
675
677
|
let sourceTypes;
|
|
676
678
|
for (const chunk of this.getModuleChunksIterable(module)) {
|
|
677
679
|
const cgc = this._getChunkGraphChunk(chunk);
|
|
@@ -679,7 +681,7 @@ class ChunkGraph {
|
|
|
679
681
|
const st = cgc.sourceTypesByModule.get(module);
|
|
680
682
|
if (st === undefined) return;
|
|
681
683
|
if (!sourceTypes) {
|
|
682
|
-
sourceTypes = st;
|
|
684
|
+
sourceTypes = /** @type {Set<SourceType>} */ (st);
|
|
683
685
|
} else if (!newSet) {
|
|
684
686
|
for (const type of st) {
|
|
685
687
|
if (!newSet) {
|
|
@@ -871,7 +873,7 @@ class ChunkGraph {
|
|
|
871
873
|
/**
|
|
872
874
|
* @param {Chunk} chunkA first chunk
|
|
873
875
|
* @param {Chunk} chunkB second chunk
|
|
874
|
-
* @returns {-1|0|1} this is a comparator function like sort and returns -1, 0, or 1 based on sort order
|
|
876
|
+
* @returns {-1 | 0 | 1} this is a comparator function like sort and returns -1, 0, or 1 based on sort order
|
|
875
877
|
*/
|
|
876
878
|
compareChunks(chunkA, chunkB) {
|
|
877
879
|
const cgcA = this._getChunkGraphChunk(chunkA);
|
package/lib/ChunkGroup.js
CHANGED
|
@@ -45,7 +45,7 @@ const getArray = (set) => [...set];
|
|
|
45
45
|
* A convenience method used to sort chunks based on their id's
|
|
46
46
|
* @param {ChunkGroup} a first sorting comparator
|
|
47
47
|
* @param {ChunkGroup} b second sorting comparator
|
|
48
|
-
* @returns {1|0
|
|
48
|
+
* @returns {1 | 0 | -1} a sorting index to determine order
|
|
49
49
|
*/
|
|
50
50
|
const sortById = (a, b) => {
|
|
51
51
|
if (a.id < b.id) return -1;
|
|
@@ -56,7 +56,7 @@ const sortById = (a, b) => {
|
|
|
56
56
|
/**
|
|
57
57
|
* @param {OriginRecord} a the first comparator in sort
|
|
58
58
|
* @param {OriginRecord} b the second comparator in sort
|
|
59
|
-
* @returns {1
|
|
59
|
+
* @returns {1 | -1| 0} returns sorting order as index
|
|
60
60
|
*/
|
|
61
61
|
const sortOrigin = (a, b) => {
|
|
62
62
|
const aIdent = a.module ? a.module.identifier() : "";
|
|
@@ -91,16 +91,19 @@ class ChunkGroup {
|
|
|
91
91
|
this.chunks = [];
|
|
92
92
|
/** @type {OriginRecord[]} */
|
|
93
93
|
this.origins = [];
|
|
94
|
+
|
|
95
|
+
/** @typedef {Map<Module, number>} OrderIndices */
|
|
96
|
+
|
|
94
97
|
/** Indices in top-down order */
|
|
95
98
|
/**
|
|
96
99
|
* @private
|
|
97
|
-
* @type {
|
|
100
|
+
* @type {OrderIndices}
|
|
98
101
|
*/
|
|
99
102
|
this._modulePreOrderIndices = new Map();
|
|
100
103
|
/** Indices in bottom-up order */
|
|
101
104
|
/**
|
|
102
105
|
* @private
|
|
103
|
-
* @type {
|
|
106
|
+
* @type {OrderIndices}
|
|
104
107
|
*/
|
|
105
108
|
this._modulePostOrderIndices = new Map();
|
|
106
109
|
/** @type {number | undefined} */
|
|
@@ -485,7 +488,7 @@ class ChunkGroup {
|
|
|
485
488
|
* Sorting values are based off of number of chunks in ChunkGroup.
|
|
486
489
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
487
490
|
* @param {ChunkGroup} otherGroup the chunkGroup to compare this against
|
|
488
|
-
* @returns {-1|0|1} sort position for comparison
|
|
491
|
+
* @returns {-1 | 0 | 1} sort position for comparison
|
|
489
492
|
*/
|
|
490
493
|
compareTo(chunkGraph, otherGroup) {
|
|
491
494
|
if (this.chunks.length > otherGroup.chunks.length) return -1;
|
package/lib/CleanPlugin.js
CHANGED
|
@@ -63,8 +63,10 @@ const mergeAssets = (as1, as2) => {
|
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
/** @typedef {Map<string, number>} CurrentAssets */
|
|
67
|
+
|
|
66
68
|
/**
|
|
67
|
-
* @param {
|
|
69
|
+
* @param {CurrentAssets} assets current assets
|
|
68
70
|
* @returns {Set<string>} Set of directory paths
|
|
69
71
|
*/
|
|
70
72
|
function getDirectories(assets) {
|
|
@@ -92,12 +94,13 @@ function getDirectories(assets) {
|
|
|
92
94
|
/**
|
|
93
95
|
* @param {OutputFileSystem} fs filesystem
|
|
94
96
|
* @param {string} outputPath output path
|
|
95
|
-
* @param {
|
|
97
|
+
* @param {CurrentAssets} currentAssets filename of the current assets (must not start with .. or ., must only use / as path separator)
|
|
96
98
|
* @param {(err?: Error | null, set?: Diff) => void} callback returns the filenames of the assets that shouldn't be there
|
|
97
99
|
* @returns {void}
|
|
98
100
|
*/
|
|
99
101
|
const getDiffToFs = (fs, outputPath, currentAssets, callback) => {
|
|
100
102
|
const directories = getDirectories(currentAssets);
|
|
103
|
+
/** @type {Diff} */
|
|
101
104
|
const diff = new Set();
|
|
102
105
|
asyncLib.forEachLimit(
|
|
103
106
|
directories,
|
|
@@ -388,7 +391,7 @@ class CleanPlugin {
|
|
|
388
391
|
// We assume that no external modification happens while the compiler is active
|
|
389
392
|
// So we can store the old assets and only diff to them to avoid fs access on
|
|
390
393
|
// incremental builds
|
|
391
|
-
/** @type {undefined|Assets} */
|
|
394
|
+
/** @type {undefined | Assets} */
|
|
392
395
|
let oldAssets;
|
|
393
396
|
|
|
394
397
|
compiler.hooks.emit.tapAsync(
|
|
@@ -13,6 +13,7 @@ const { RuntimeSpecMap, runtimeToString } = require("./util/runtime");
|
|
|
13
13
|
|
|
14
14
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
15
15
|
/** @typedef {import("./Module")} Module */
|
|
16
|
+
/** @typedef {import("./Module").SourceType} SourceType */
|
|
16
17
|
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
|
17
18
|
/** @typedef {import("./Module").CodeGenerationResultData} CodeGenerationResultData */
|
|
18
19
|
/** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
|
@@ -96,7 +97,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
96
97
|
/**
|
|
97
98
|
* @param {Module} module the module
|
|
98
99
|
* @param {RuntimeSpec} runtime runtime(s)
|
|
99
|
-
* @param {
|
|
100
|
+
* @param {SourceType} sourceType the source type
|
|
100
101
|
* @returns {Source} a source
|
|
101
102
|
*/
|
|
102
103
|
getSource(module, runtime, sourceType) {
|
|
@@ -147,13 +147,16 @@ class CompatibilityPlugin {
|
|
|
147
147
|
range: /** @type {Range} */ (pattern.range)
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
|
-
|
|
150
|
+
if (!parser.scope.topLevelScope) {
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
151
153
|
});
|
|
152
154
|
parser.hooks.pattern
|
|
153
155
|
.for(RuntimeGlobals.exports)
|
|
154
156
|
.tap(PLUGIN_NAME, (pattern) => {
|
|
157
|
+
const newName = "__nested_webpack_exports__";
|
|
155
158
|
parser.tagVariable(pattern.name, nestedWebpackIdentifierTag, {
|
|
156
|
-
name:
|
|
159
|
+
name: newName,
|
|
157
160
|
declaration: {
|
|
158
161
|
updated: false,
|
|
159
162
|
loc: /** @type {DependencyLocation} */ (pattern.loc),
|
|
@@ -162,6 +165,28 @@ class CompatibilityPlugin {
|
|
|
162
165
|
});
|
|
163
166
|
return true;
|
|
164
167
|
});
|
|
168
|
+
// Update single `var __webpack_require__ = {};` and `var __webpack_exports__ = {};` without expression
|
|
169
|
+
parser.hooks.declarator.tap(PLUGIN_NAME, (declarator) => {
|
|
170
|
+
if (
|
|
171
|
+
declarator.id.type === "Identifier" &&
|
|
172
|
+
(declarator.id.name === RuntimeGlobals.exports ||
|
|
173
|
+
declarator.id.name === RuntimeGlobals.require)
|
|
174
|
+
) {
|
|
175
|
+
const { name, declaration } =
|
|
176
|
+
/** @type {CompatibilitySettings} */ (
|
|
177
|
+
parser.getTagData(
|
|
178
|
+
declarator.id.name,
|
|
179
|
+
nestedWebpackIdentifierTag
|
|
180
|
+
)
|
|
181
|
+
);
|
|
182
|
+
if (!declaration.updated) {
|
|
183
|
+
const dep = new ConstDependency(name, declaration.range);
|
|
184
|
+
dep.loc = declaration.loc;
|
|
185
|
+
parser.state.module.addPresentationalDependency(dep);
|
|
186
|
+
declaration.updated = true;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
165
190
|
parser.hooks.expression
|
|
166
191
|
.for(nestedWebpackIdentifierTag)
|
|
167
192
|
.tap(PLUGIN_NAME, (expr) => {
|
|
@@ -212,3 +237,4 @@ class CompatibilityPlugin {
|
|
|
212
237
|
}
|
|
213
238
|
|
|
214
239
|
module.exports = CompatibilityPlugin;
|
|
240
|
+
module.exports.nestedWebpackIdentifierTag = nestedWebpackIdentifierTag;
|
package/lib/Compilation.js
CHANGED
|
@@ -84,7 +84,6 @@ const processAsyncTree = require("./util/processAsyncTree");
|
|
|
84
84
|
const { getRuntimeKey } = require("./util/runtime");
|
|
85
85
|
const { isSourceEqual } = require("./util/source");
|
|
86
86
|
|
|
87
|
-
/** @template T @typedef {import("tapable").AsArray<T>} AsArray<T> */
|
|
88
87
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
89
88
|
/** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputOptions */
|
|
90
89
|
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
|
@@ -134,6 +133,12 @@ const { isSourceEqual } = require("./util/source");
|
|
|
134
133
|
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsModule} StatsModule */
|
|
135
134
|
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
|
136
135
|
/** @typedef {import("./util/Hash")} Hash */
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @template T
|
|
139
|
+
* @typedef {import("tapable").AsArray<T>} AsArray<T>
|
|
140
|
+
*/
|
|
141
|
+
|
|
137
142
|
/**
|
|
138
143
|
* @template T
|
|
139
144
|
* @typedef {import("./util/deprecation").FakeHook<T>} FakeHook<T>
|
|
@@ -199,9 +204,9 @@ const { isSourceEqual } = require("./util/source");
|
|
|
199
204
|
* @property {string | number} id
|
|
200
205
|
* @property {string=} name
|
|
201
206
|
* @property {string} hash
|
|
202
|
-
* @property {
|
|
207
|
+
* @property {HashWithLengthFunction=} hashWithLength
|
|
203
208
|
* @property {(Record<string, string>)=} contentHash
|
|
204
|
-
* @property {(Record<string,
|
|
209
|
+
* @property {(Record<string, HashWithLengthFunction>)=} contentHashWithLength
|
|
205
210
|
*/
|
|
206
211
|
|
|
207
212
|
/**
|
|
@@ -223,17 +228,19 @@ const { isSourceEqual } = require("./util/source");
|
|
|
223
228
|
* @property {EntryOptions=} entryOptions
|
|
224
229
|
*/
|
|
225
230
|
|
|
231
|
+
/** @typedef {LazySet<string>} FileSystemDependencies */
|
|
232
|
+
|
|
226
233
|
/** @typedef {EXPECTED_ANY} ExecuteModuleExports */
|
|
227
234
|
|
|
228
235
|
/**
|
|
229
236
|
* @typedef {object} ExecuteModuleResult
|
|
230
237
|
* @property {ExecuteModuleExports} exports
|
|
231
238
|
* @property {boolean} cacheable
|
|
232
|
-
* @property {
|
|
233
|
-
* @property {
|
|
234
|
-
* @property {
|
|
235
|
-
* @property {
|
|
236
|
-
* @property {
|
|
239
|
+
* @property {ExecuteModuleAssets} assets
|
|
240
|
+
* @property {FileSystemDependencies} fileDependencies
|
|
241
|
+
* @property {FileSystemDependencies} contextDependencies
|
|
242
|
+
* @property {FileSystemDependencies} missingDependencies
|
|
243
|
+
* @property {FileSystemDependencies} buildDependencies
|
|
237
244
|
*/
|
|
238
245
|
|
|
239
246
|
/**
|
|
@@ -260,9 +267,11 @@ const { isSourceEqual } = require("./util/source");
|
|
|
260
267
|
* @property {WebpackRequire} require require function
|
|
261
268
|
*/
|
|
262
269
|
|
|
270
|
+
/** @typedef {Map<string, { source: Source, info: AssetInfo | undefined }>} ExecuteModuleAssets */
|
|
271
|
+
|
|
263
272
|
/**
|
|
264
273
|
* @typedef {object} ExecuteModuleContext
|
|
265
|
-
* @property {
|
|
274
|
+
* @property {ExecuteModuleAssets} assets
|
|
266
275
|
* @property {Chunk} chunk
|
|
267
276
|
* @property {ChunkGraph} chunkGraph
|
|
268
277
|
* @property {WebpackRequire=} __webpack_require__
|
|
@@ -296,6 +305,7 @@ const { isSourceEqual } = require("./util/source");
|
|
|
296
305
|
* @property {boolean=} development true, when asset is only used for development and doesn't count towards user-facing assets
|
|
297
306
|
* @property {boolean=} hotModuleReplacement true, when asset ships data for updating an existing application (HMR)
|
|
298
307
|
* @property {boolean=} javascriptModule true, when asset is javascript and an ESM
|
|
308
|
+
* @property {boolean=} manifest true, when file is a manifest
|
|
299
309
|
* @property {Record<string, null | string | string[]>=} related object of pointers to other assets, keyed by type of relation (only points from parent to child)
|
|
300
310
|
*/
|
|
301
311
|
|
|
@@ -310,18 +320,22 @@ const { isSourceEqual } = require("./util/source");
|
|
|
310
320
|
* @property {AssetInfo} info info about the asset
|
|
311
321
|
*/
|
|
312
322
|
|
|
323
|
+
/** @typedef {(length: number) => string} HashWithLengthFunction */
|
|
324
|
+
|
|
313
325
|
/**
|
|
314
326
|
* @typedef {object} ModulePathData
|
|
315
327
|
* @property {string | number} id
|
|
316
328
|
* @property {string} hash
|
|
317
|
-
* @property {
|
|
329
|
+
* @property {HashWithLengthFunction=} hashWithLength
|
|
318
330
|
*/
|
|
319
331
|
|
|
332
|
+
/** @typedef {(id: string | number) => string | number} PrepareIdFunction */
|
|
333
|
+
|
|
320
334
|
/**
|
|
321
335
|
* @typedef {object} PathData
|
|
322
336
|
* @property {ChunkGraph=} chunkGraph
|
|
323
337
|
* @property {string=} hash
|
|
324
|
-
* @property {
|
|
338
|
+
* @property {HashWithLengthFunction=} hashWithLength
|
|
325
339
|
* @property {(Chunk | ChunkPathData)=} chunk
|
|
326
340
|
* @property {(Module | ModulePathData)=} module
|
|
327
341
|
* @property {RuntimeSpec=} runtime
|
|
@@ -330,9 +344,10 @@ const { isSourceEqual } = require("./util/source");
|
|
|
330
344
|
* @property {string=} query
|
|
331
345
|
* @property {string=} contentHashType
|
|
332
346
|
* @property {string=} contentHash
|
|
333
|
-
* @property {
|
|
347
|
+
* @property {HashWithLengthFunction=} contentHashWithLength
|
|
334
348
|
* @property {boolean=} noChunkHash
|
|
335
349
|
* @property {string=} url
|
|
350
|
+
* @property {PrepareIdFunction=} prepareId
|
|
336
351
|
*/
|
|
337
352
|
|
|
338
353
|
/** @typedef {"module" | "chunk" | "root-of-chunk" | "nested"} ExcludeModulesType */
|
|
@@ -695,8 +710,8 @@ class Compilation {
|
|
|
695
710
|
) => `Can't automatically convert plugin using Compilation.hooks.${name} to Compilation.hooks.processAssets because ${reason}.
|
|
696
711
|
BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a single Compilation.hooks.processAssets hook.`;
|
|
697
712
|
/**
|
|
698
|
-
* @param {string | (import("tapable").TapOptions & { name: string
|
|
699
|
-
* @returns {import("tapable").TapOptions & { name: string
|
|
713
|
+
* @param {string | (import("tapable").TapOptions & { name: string } & ProcessAssetsAdditionalOptions)} options hook options
|
|
714
|
+
* @returns {import("tapable").TapOptions & { name: string } & ProcessAssetsAdditionalOptions} modified options
|
|
700
715
|
*/
|
|
701
716
|
const getOptions = (options) => {
|
|
702
717
|
if (typeof options === "string") options = { name: options };
|
|
@@ -1216,20 +1231,20 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1216
1231
|
this.emittedAssets = new Set();
|
|
1217
1232
|
/** @type {Set<string>} */
|
|
1218
1233
|
this.comparedForEmitAssets = new Set();
|
|
1219
|
-
/** @type {
|
|
1234
|
+
/** @type {FileSystemDependencies} */
|
|
1220
1235
|
this.fileDependencies = new LazySet();
|
|
1221
|
-
/** @type {
|
|
1236
|
+
/** @type {FileSystemDependencies} */
|
|
1222
1237
|
this.contextDependencies = new LazySet();
|
|
1223
|
-
/** @type {
|
|
1238
|
+
/** @type {FileSystemDependencies} */
|
|
1224
1239
|
this.missingDependencies = new LazySet();
|
|
1225
|
-
/** @type {
|
|
1240
|
+
/** @type {FileSystemDependencies} */
|
|
1226
1241
|
this.buildDependencies = new LazySet();
|
|
1227
1242
|
// TODO webpack 6 remove
|
|
1228
1243
|
this.compilationDependencies = {
|
|
1229
1244
|
add: util.deprecate(
|
|
1230
1245
|
/**
|
|
1231
1246
|
* @param {string} item item
|
|
1232
|
-
* @returns {
|
|
1247
|
+
* @returns {FileSystemDependencies} file dependencies
|
|
1233
1248
|
*/
|
|
1234
1249
|
(item) => this.fileDependencies.add(item),
|
|
1235
1250
|
"Compilation.compilationDependencies is deprecated (used Compilation.fileDependencies instead)",
|
|
@@ -1635,6 +1650,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1635
1650
|
_processModuleDependencies(module, callback) {
|
|
1636
1651
|
/** @type {{ factory: ModuleFactory, dependencies: Dependency[], context: string | undefined, originModule: Module | null }[]} */
|
|
1637
1652
|
const sortedDependencies = [];
|
|
1653
|
+
/** @type {boolean} */
|
|
1654
|
+
const hasLowPriorityDependencies = module.dependencies.some(
|
|
1655
|
+
Dependency.isLowPriorityDependency
|
|
1656
|
+
);
|
|
1638
1657
|
|
|
1639
1658
|
/** @type {DependenciesBlock} */
|
|
1640
1659
|
let currentBlock;
|
|
@@ -1882,12 +1901,29 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
1882
1901
|
if (list === undefined) {
|
|
1883
1902
|
/** @type {FactoryCacheValue} */
|
|
1884
1903
|
(factoryCacheValue).set(cacheKey, (list = []));
|
|
1885
|
-
|
|
1904
|
+
const newItem = {
|
|
1886
1905
|
factory: factoryCacheKey2,
|
|
1887
1906
|
dependencies: list,
|
|
1888
1907
|
context: dep.getContext(),
|
|
1889
1908
|
originModule: module
|
|
1890
|
-
}
|
|
1909
|
+
};
|
|
1910
|
+
if (hasLowPriorityDependencies) {
|
|
1911
|
+
let insertIndex = sortedDependencies.length;
|
|
1912
|
+
while (insertIndex > 0) {
|
|
1913
|
+
const item = sortedDependencies[insertIndex - 1];
|
|
1914
|
+
const isAllLowPriorityDependencies = item.dependencies.every(
|
|
1915
|
+
Dependency.isLowPriorityDependency
|
|
1916
|
+
);
|
|
1917
|
+
if (isAllLowPriorityDependencies) {
|
|
1918
|
+
insertIndex--;
|
|
1919
|
+
} else {
|
|
1920
|
+
break;
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
sortedDependencies.splice(insertIndex, 0, newItem);
|
|
1924
|
+
} else {
|
|
1925
|
+
sortedDependencies.push(newItem);
|
|
1926
|
+
}
|
|
1891
1927
|
}
|
|
1892
1928
|
list.push(dep);
|
|
1893
1929
|
listCacheKey1 = category;
|
|
@@ -3721,6 +3757,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
3721
3757
|
dependencyTemplates,
|
|
3722
3758
|
runtimeTemplate,
|
|
3723
3759
|
runtime,
|
|
3760
|
+
runtimes,
|
|
3724
3761
|
codeGenerationResults: results,
|
|
3725
3762
|
compilation: this
|
|
3726
3763
|
});
|
package/lib/Compiler.js
CHANGED
|
@@ -719,9 +719,9 @@ class Compiler {
|
|
|
719
719
|
({ name: file, source, info }, callback) => {
|
|
720
720
|
let targetFile = file;
|
|
721
721
|
let immutable = info.immutable;
|
|
722
|
-
const
|
|
723
|
-
if (
|
|
724
|
-
targetFile = targetFile.slice(0,
|
|
722
|
+
const queryOrHashStringIdx = targetFile.search(/[?#]/);
|
|
723
|
+
if (queryOrHashStringIdx >= 0) {
|
|
724
|
+
targetFile = targetFile.slice(0, queryOrHashStringIdx);
|
|
725
725
|
// We may remove the hash, which is in the query string
|
|
726
726
|
// So we recheck if the file is immutable
|
|
727
727
|
// This doesn't cover all cases, but immutable is only a performance optimization anyway
|
|
@@ -112,18 +112,6 @@ class ConcatenationScope {
|
|
|
112
112
|
this._currentModule.namespaceExportSymbol = symbol;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
/**
|
|
116
|
-
* @param {string} symbol identifier of the export in source code
|
|
117
|
-
* @returns {boolean} registered success
|
|
118
|
-
*/
|
|
119
|
-
registerUsedName(symbol) {
|
|
120
|
-
if (this.usedNames.has(symbol)) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
this.usedNames.add(symbol);
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
115
|
/**
|
|
128
116
|
* @param {Module} module the referenced module
|
|
129
117
|
* @param {Partial<ModuleReferenceOptions>} options options
|
|
@@ -189,7 +177,4 @@ class ConcatenationScope {
|
|
|
189
177
|
ConcatenationScope.DEFAULT_EXPORT = DEFAULT_EXPORT;
|
|
190
178
|
ConcatenationScope.NAMESPACE_OBJECT_EXPORT = NAMESPACE_OBJECT_EXPORT;
|
|
191
179
|
|
|
192
|
-
/** @type {WeakMap<Chunk, Set<string>>} */
|
|
193
|
-
ConcatenationScope.chunkUsedNames = new WeakMap();
|
|
194
|
-
|
|
195
180
|
module.exports = ConcatenationScope;
|
package/lib/ContextModule.js
CHANGED
|
@@ -9,7 +9,10 @@ const { OriginalSource, RawSource } = require("webpack-sources");
|
|
|
9
9
|
const AsyncDependenciesBlock = require("./AsyncDependenciesBlock");
|
|
10
10
|
const { makeWebpackError } = require("./HookWebpackError");
|
|
11
11
|
const Module = require("./Module");
|
|
12
|
-
const {
|
|
12
|
+
const {
|
|
13
|
+
JAVASCRIPT_TYPE,
|
|
14
|
+
JAVASCRIPT_TYPES
|
|
15
|
+
} = require("./ModuleSourceTypeConstants");
|
|
13
16
|
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
|
|
14
17
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
|
15
18
|
const Template = require("./Template");
|
|
@@ -162,7 +165,7 @@ class ContextModule extends Module {
|
|
|
162
165
|
* @returns {SourceTypes} types available (do not mutate)
|
|
163
166
|
*/
|
|
164
167
|
getSourceTypes() {
|
|
165
|
-
return
|
|
168
|
+
return JAVASCRIPT_TYPES;
|
|
166
169
|
}
|
|
167
170
|
|
|
168
171
|
/**
|
|
@@ -1184,7 +1187,7 @@ module.exports = webpackEmptyAsyncContext;`;
|
|
|
1184
1187
|
const { chunkGraph, compilation } = context;
|
|
1185
1188
|
const sources = new Map();
|
|
1186
1189
|
sources.set(
|
|
1187
|
-
|
|
1190
|
+
JAVASCRIPT_TYPE,
|
|
1188
1191
|
this.getSource(
|
|
1189
1192
|
this.getSourceString(this.options.mode, context),
|
|
1190
1193
|
compilation
|
|
@@ -15,6 +15,8 @@ const { cachedSetProperty } = require("./util/cleverMerge");
|
|
|
15
15
|
const { createFakeHook } = require("./util/deprecation");
|
|
16
16
|
const { join } = require("./util/fs");
|
|
17
17
|
|
|
18
|
+
/** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
|
|
19
|
+
/** @typedef {import("./Compilation").FileSystemDependencies} FileSystemDependencies */
|
|
18
20
|
/** @typedef {import("./ContextModule").ContextModuleOptions} ContextModuleOptions */
|
|
19
21
|
/** @typedef {import("./ContextModule").ResolveDependenciesCallback} ResolveDependenciesCallback */
|
|
20
22
|
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
|
|
@@ -22,7 +24,7 @@ const { join } = require("./util/fs");
|
|
|
22
24
|
/** @typedef {import("./ResolverFactory")} ResolverFactory */
|
|
23
25
|
/** @typedef {import("./dependencies/ContextDependency")} ContextDependency */
|
|
24
26
|
/** @typedef {import("./dependencies/ContextDependency").ContextOptions} ContextOptions */
|
|
25
|
-
|
|
27
|
+
|
|
26
28
|
/**
|
|
27
29
|
* @template T
|
|
28
30
|
* @typedef {import("./util/deprecation").FakeHook<T>} FakeHook<T>
|
|
@@ -36,9 +38,9 @@ const { join } = require("./util/fs");
|
|
|
36
38
|
* @property {string} context
|
|
37
39
|
* @property {string} request
|
|
38
40
|
* @property {ModuleFactoryCreateData["resolveOptions"]} resolveOptions
|
|
39
|
-
* @property {
|
|
40
|
-
* @property {
|
|
41
|
-
* @property {
|
|
41
|
+
* @property {FileSystemDependencies} fileDependencies
|
|
42
|
+
* @property {FileSystemDependencies} missingDependencies
|
|
43
|
+
* @property {FileSystemDependencies} contextDependencies
|
|
42
44
|
* @property {ContextDependency[]} dependencies
|
|
43
45
|
*/
|
|
44
46
|
|