webpack 5.91.0 → 5.92.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/bin/webpack.js +1 -2
- package/lib/APIPlugin.js +6 -2
- package/lib/Cache.js +1 -1
- package/lib/Chunk.js +7 -4
- package/lib/ChunkGraph.js +20 -7
- package/lib/ChunkGroup.js +9 -3
- package/lib/CleanPlugin.js +1 -1
- package/lib/Compilation.js +33 -27
- package/lib/Compiler.js +28 -8
- package/lib/ConcatenationScope.js +3 -3
- package/lib/ContextModule.js +95 -43
- package/lib/DefinePlugin.js +14 -4
- package/lib/Dependency.js +8 -8
- package/lib/DependencyTemplate.js +10 -5
- package/lib/DllReferencePlugin.js +1 -1
- package/lib/EvalDevToolModulePlugin.js +11 -0
- package/lib/ExportsInfo.js +22 -4
- package/lib/ExternalModule.js +49 -18
- package/lib/FileSystemInfo.js +68 -41
- package/lib/FlagDependencyExportsPlugin.js +21 -7
- package/lib/Generator.js +2 -3
- package/lib/HotModuleReplacementPlugin.js +108 -45
- package/lib/IgnorePlugin.js +4 -1
- package/lib/LibManifestPlugin.js +2 -2
- package/lib/Module.js +11 -12
- package/lib/ModuleFactory.js +3 -3
- package/lib/ModuleFilenameHelpers.js +29 -16
- package/lib/ModuleGraph.js +5 -5
- package/lib/MultiCompiler.js +36 -1
- package/lib/NormalModule.js +10 -12
- package/lib/NormalModuleFactory.js +17 -8
- package/lib/Parser.js +1 -1
- package/lib/PlatformPlugin.js +39 -0
- package/lib/ProgressPlugin.js +1 -1
- package/lib/RecordIdsPlugin.js +4 -4
- package/lib/ResolverFactory.js +3 -3
- package/lib/RuntimeTemplate.js +22 -18
- package/lib/Stats.js +1 -1
- package/lib/Template.js +5 -5
- package/lib/TemplatedPathPlugin.js +16 -1
- package/lib/asset/AssetGenerator.js +15 -0
- package/lib/buildChunkGraph.js +3 -3
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -1
- package/lib/cache/PackFileCacheStrategy.js +2 -2
- package/lib/cache/ResolverCachePlugin.js +8 -8
- package/lib/cache/getLazyHashedEtag.js +1 -1
- package/lib/cli.js +5 -5
- package/lib/config/browserslistTargetHandler.js +7 -1
- package/lib/config/defaults.js +85 -34
- package/lib/config/target.js +18 -11
- package/lib/container/ContainerEntryModule.js +1 -1
- package/lib/css/CssExportsGenerator.js +43 -17
- package/lib/css/CssGenerator.js +22 -12
- package/lib/css/CssLoadingRuntimeModule.js +8 -5
- package/lib/css/CssModulesPlugin.js +197 -100
- package/lib/css/CssParser.js +24 -15
- package/lib/css/walkCssTokens.js +1 -1
- package/lib/debug/ProfilingPlugin.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +2 -2
- package/lib/dependencies/CssExportDependency.js +2 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +9 -2
- package/lib/dependencies/CssUrlDependency.js +5 -4
- package/lib/dependencies/ExportsInfoDependency.js +1 -1
- package/lib/dependencies/ExternalModuleDependency.js +4 -2
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +2 -2
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -2
- package/lib/dependencies/HarmonyImportDependency.js +2 -2
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +41 -18
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +2 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +43 -32
- package/lib/dependencies/ImportDependency.js +2 -2
- package/lib/dependencies/ImportEagerDependency.js +2 -2
- package/lib/dependencies/ImportMetaPlugin.js +1 -1
- package/lib/dependencies/ImportParserPlugin.js +3 -1
- package/lib/dependencies/ImportWeakDependency.js +2 -2
- package/lib/dependencies/LoaderPlugin.js +2 -2
- package/lib/dependencies/ModuleDependency.js +2 -2
- package/lib/dependencies/PureExpressionDependency.js +63 -49
- package/lib/dependencies/WorkerDependency.js +1 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +90 -2
- package/lib/hmr/LazyCompilationPlugin.js +2 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +1 -1
- package/lib/ids/DeterministicChunkIdsPlugin.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/IdHelpers.js +6 -6
- package/lib/ids/NamedChunkIdsPlugin.js +1 -1
- package/lib/ids/NamedModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +2 -2
- package/lib/index.js +11 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +0 -1
- package/lib/javascript/JavascriptModulesPlugin.js +174 -17
- package/lib/javascript/JavascriptParser.js +37 -16
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +2 -2
- package/lib/library/AssignLibraryPlugin.js +3 -3
- package/lib/library/ExportPropertyLibraryPlugin.js +2 -2
- package/lib/library/JsonpLibraryPlugin.js +2 -2
- package/lib/library/ModuleLibraryPlugin.js +2 -2
- package/lib/library/SystemLibraryPlugin.js +2 -2
- package/lib/library/UmdLibraryPlugin.js +33 -12
- package/lib/logging/createConsoleLogger.js +2 -2
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeEnvironmentPlugin.js +1 -1
- package/lib/node/NodeTemplatePlugin.js +1 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -1
- package/lib/node/nodeConsole.js +1 -1
- package/lib/optimize/AggressiveMergingPlugin.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +11 -76
- package/lib/optimize/InnerGraph.js +1 -1
- package/lib/optimize/LimitChunkCountPlugin.js +1 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +1 -1
- package/lib/optimize/RealContentHashPlugin.js +3 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +2 -2
- package/lib/optimize/SplitChunksPlugin.js +8 -8
- package/lib/performance/SizeLimitsPlugin.js +2 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +11 -1
- package/lib/rules/RuleSetCompiler.js +9 -7
- package/lib/runtime/LoadScriptRuntimeModule.js +1 -1
- package/lib/runtime/StartupChunkDependenciesPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +4 -4
- package/lib/serialization/FileMiddleware.js +3 -3
- package/lib/serialization/NullPrototypeObjectSerializer.js +2 -2
- package/lib/serialization/ObjectMiddleware.js +6 -5
- package/lib/serialization/PlainObjectSerializer.js +2 -2
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/serialization/SingleItemMiddleware.js +2 -2
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +1 -1
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +20 -20
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/stats/StatsFactory.js +2 -2
- package/lib/stats/StatsPrinter.js +6 -6
- package/lib/util/ArrayQueue.js +14 -21
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Queue.js +8 -2
- package/lib/util/SortableSet.js +16 -4
- package/lib/util/TupleQueue.js +8 -2
- package/lib/util/WeakTupleMap.js +3 -3
- package/lib/util/binarySearchBounds.js +1 -1
- package/lib/util/cleverMerge.js +2 -2
- package/lib/util/comparators.js +4 -2
- package/lib/util/conventions.js +1 -1
- package/lib/util/createHash.js +3 -5
- package/lib/util/deprecation.js +3 -3
- package/lib/util/deterministicGrouping.js +2 -2
- package/lib/util/findGraphRoots.js +1 -1
- package/lib/util/fs.js +15 -15
- package/lib/util/identifier.js +5 -5
- package/lib/util/mergeScope.js +79 -0
- package/lib/util/runtime.js +2 -17
- package/lib/util/semver.js +3 -0
- package/lib/util/smartGrouping.js +3 -3
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +4 -2
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +1 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +17 -17
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -1
- package/lib/web/FetchCompileWasmPlugin.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/webpack.js +12 -3
- package/package.json +20 -18
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +30 -2
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/types.d.ts +213 -81
package/bin/webpack.js
CHANGED
@@ -79,7 +79,6 @@ const runCli = cli => {
|
|
79
79
|
const pkg = require(pkgPath);
|
80
80
|
|
81
81
|
if (pkg.type === "module" || /\.mjs/i.test(pkg.bin[cli.binName])) {
|
82
|
-
// eslint-disable-next-line n/no-unsupported-features/es-syntax
|
83
82
|
import(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName])).catch(
|
84
83
|
error => {
|
85
84
|
console.error(error);
|
@@ -92,7 +91,7 @@ const runCli = cli => {
|
|
92
91
|
};
|
93
92
|
|
94
93
|
/**
|
95
|
-
* @typedef {
|
94
|
+
* @typedef {object} CliOption
|
96
95
|
* @property {string} name display name
|
97
96
|
* @property {string} package npm package name
|
98
97
|
* @property {string} binName name of the executable file
|
package/lib/APIPlugin.js
CHANGED
@@ -133,7 +133,7 @@ function getReplacements(module, importMetaName) {
|
|
133
133
|
const PLUGIN_NAME = "APIPlugin";
|
134
134
|
|
135
135
|
/**
|
136
|
-
* @typedef {
|
136
|
+
* @typedef {object} APIPluginOptions
|
137
137
|
* @property {boolean} [module] the output filename
|
138
138
|
*/
|
139
139
|
|
@@ -189,9 +189,13 @@ class APIPlugin {
|
|
189
189
|
PLUGIN_NAME,
|
190
190
|
(source, module, renderContext) => {
|
191
191
|
if (/** @type {BuildInfo} */ (module.buildInfo).needCreateRequire) {
|
192
|
+
const needPrefix =
|
193
|
+
renderContext.runtimeTemplate.supportNodePrefixForCoreModules();
|
192
194
|
const chunkInitFragments = [
|
193
195
|
new InitFragment(
|
194
|
-
|
196
|
+
`import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "${
|
197
|
+
needPrefix ? "node:" : ""
|
198
|
+
}module";\n`,
|
195
199
|
InitFragment.STAGE_HARMONY_IMPORTS,
|
196
200
|
0,
|
197
201
|
"external module node-commonjs"
|
package/lib/Cache.js
CHANGED
package/lib/Chunk.js
CHANGED
@@ -38,13 +38,13 @@ const { mergeRuntime } = require("./util/runtime");
|
|
38
38
|
const ChunkFilesSet = createArrayToSetDeprecationSet("chunk.files");
|
39
39
|
|
40
40
|
/**
|
41
|
-
* @typedef {
|
41
|
+
* @typedef {object} WithId an object who has an id property *
|
42
42
|
* @property {string | number} id the id of the object
|
43
43
|
*/
|
44
44
|
|
45
45
|
/**
|
46
46
|
* @deprecated
|
47
|
-
* @typedef {
|
47
|
+
* @typedef {object} ChunkMaps
|
48
48
|
* @property {Record<string|number, string>} hash
|
49
49
|
* @property {Record<string|number, Record<string, string>>} contentHash
|
50
50
|
* @property {Record<string|number, string>} name
|
@@ -52,7 +52,7 @@ const ChunkFilesSet = createArrayToSetDeprecationSet("chunk.files");
|
|
52
52
|
|
53
53
|
/**
|
54
54
|
* @deprecated
|
55
|
-
* @typedef {
|
55
|
+
* @typedef {object} ChunkModuleMaps
|
56
56
|
* @property {Record<string|number, (string|number)[]>} id
|
57
57
|
* @property {Record<string|number, string>} hash
|
58
58
|
*/
|
@@ -85,7 +85,10 @@ class Chunk {
|
|
85
85
|
this.filenameTemplate = undefined;
|
86
86
|
/** @type {(string | function(PathData, AssetInfo=): string) | undefined} */
|
87
87
|
this.cssFilenameTemplate = undefined;
|
88
|
-
/**
|
88
|
+
/**
|
89
|
+
* @private
|
90
|
+
* @type {SortableSet<ChunkGroup>}
|
91
|
+
*/
|
89
92
|
this._groups = new SortableSet(undefined, compareChunkGroupsByIndex);
|
90
93
|
/** @type {RuntimeSpec} */
|
91
94
|
this.runtime = undefined;
|
package/lib/ChunkGraph.js
CHANGED
@@ -50,7 +50,7 @@ const compareModuleIterables = compareIterables(compareModulesByIdentifier);
|
|
50
50
|
/** @typedef {[Module, Entrypoint | undefined]} EntryModuleWithChunkGroup */
|
51
51
|
|
52
52
|
/**
|
53
|
-
* @typedef {
|
53
|
+
* @typedef {object} ChunkSizeOptions
|
54
54
|
* @property {number=} chunkOverhead constant overhead for a chunk
|
55
55
|
* @property {number=} entryChunkMultiplicator multiplicator for initial chunks
|
56
56
|
*/
|
@@ -187,6 +187,7 @@ const isAvailableChunk = (a, b) => {
|
|
187
187
|
|
188
188
|
/** @typedef {Set<Chunk>} EntryInChunks */
|
189
189
|
/** @typedef {Set<Chunk>} RuntimeInChunks */
|
190
|
+
/** @typedef {string | number} ModuleId */
|
190
191
|
|
191
192
|
class ChunkGraphModule {
|
192
193
|
constructor() {
|
@@ -238,13 +239,25 @@ class ChunkGraph {
|
|
238
239
|
* @param {string | Hash} hashFunction the hash function to use
|
239
240
|
*/
|
240
241
|
constructor(moduleGraph, hashFunction = "md4") {
|
241
|
-
/**
|
242
|
+
/**
|
243
|
+
* @private
|
244
|
+
* @type {WeakMap<Module, ChunkGraphModule>}
|
245
|
+
*/
|
242
246
|
this._modules = new WeakMap();
|
243
|
-
/**
|
247
|
+
/**
|
248
|
+
* @private
|
249
|
+
* @type {WeakMap<Chunk, ChunkGraphChunk>}
|
250
|
+
*/
|
244
251
|
this._chunks = new WeakMap();
|
245
|
-
/**
|
252
|
+
/**
|
253
|
+
* @private
|
254
|
+
* @type {WeakMap<AsyncDependenciesBlock, ChunkGroup>}
|
255
|
+
*/
|
246
256
|
this._blockChunkGroups = new WeakMap();
|
247
|
-
/**
|
257
|
+
/**
|
258
|
+
* @private
|
259
|
+
* @type {Map<string, string | number>}
|
260
|
+
*/
|
248
261
|
this._runtimeIds = new Map();
|
249
262
|
/** @type {ModuleGraph} */
|
250
263
|
this.moduleGraph = moduleGraph;
|
@@ -1309,7 +1322,7 @@ class ChunkGraph {
|
|
1309
1322
|
|
1310
1323
|
/**
|
1311
1324
|
* @param {Module} module the module
|
1312
|
-
* @returns {
|
1325
|
+
* @returns {ModuleId} the id of the module
|
1313
1326
|
*/
|
1314
1327
|
getModuleId(module) {
|
1315
1328
|
const cgm = this._getChunkGraphModule(module);
|
@@ -1318,7 +1331,7 @@ class ChunkGraph {
|
|
1318
1331
|
|
1319
1332
|
/**
|
1320
1333
|
* @param {Module} module the module
|
1321
|
-
* @param {
|
1334
|
+
* @param {ModuleId} id the id of the module
|
1322
1335
|
* @returns {void}
|
1323
1336
|
*/
|
1324
1337
|
setModuleId(module, id) {
|
package/lib/ChunkGroup.js
CHANGED
@@ -25,7 +25,7 @@ const {
|
|
25
25
|
/** @typedef {{module: Module, loc: DependencyLocation, request: string}} OriginRecord */
|
26
26
|
|
27
27
|
/**
|
28
|
-
* @typedef {
|
28
|
+
* @typedef {object} RawChunkGroupOptions
|
29
29
|
* @property {number=} preloadOrder
|
30
30
|
* @property {number=} prefetchOrder
|
31
31
|
* @property {("low" | "high" | "auto")=} fetchPriority
|
@@ -93,10 +93,16 @@ class ChunkGroup {
|
|
93
93
|
/** @type {OriginRecord[]} */
|
94
94
|
this.origins = [];
|
95
95
|
/** Indices in top-down order */
|
96
|
-
/**
|
96
|
+
/**
|
97
|
+
* @private
|
98
|
+
* @type {Map<Module, number>}
|
99
|
+
*/
|
97
100
|
this._modulePreOrderIndices = new Map();
|
98
101
|
/** Indices in bottom-up order */
|
99
|
-
/**
|
102
|
+
/**
|
103
|
+
* @private
|
104
|
+
* @type {Map<Module, number>}
|
105
|
+
*/
|
100
106
|
this._modulePostOrderIndices = new Map();
|
101
107
|
/** @type {number | undefined} */
|
102
108
|
this.index = undefined;
|
package/lib/CleanPlugin.js
CHANGED
@@ -24,7 +24,7 @@ const processAsyncTree = require("./util/processAsyncTree");
|
|
24
24
|
/** @typedef {function(IgnoreItem): void} AddToIgnoreCallback */
|
25
25
|
|
26
26
|
/**
|
27
|
-
* @typedef {
|
27
|
+
* @typedef {object} CleanPluginCompilationHooks
|
28
28
|
* @property {SyncBailHook<[string], boolean>} keep when returning true the file/directory will be kept during cleaning, returning false will clean it and ignore the following plugins and config
|
29
29
|
*/
|
30
30
|
|
package/lib/Compilation.js
CHANGED
@@ -168,20 +168,20 @@ const { isSourceEqual } = require("./util/source");
|
|
168
168
|
/** @typedef {Record<string, Source>} CompilationAssets */
|
169
169
|
|
170
170
|
/**
|
171
|
-
* @typedef {
|
171
|
+
* @typedef {object} AvailableModulesChunkGroupMapping
|
172
172
|
* @property {ChunkGroup} chunkGroup
|
173
173
|
* @property {Set<Module>} availableModules
|
174
174
|
* @property {boolean} needCopy
|
175
175
|
*/
|
176
176
|
|
177
177
|
/**
|
178
|
-
* @typedef {
|
178
|
+
* @typedef {object} DependenciesBlockLike
|
179
179
|
* @property {Dependency[]} dependencies
|
180
180
|
* @property {AsyncDependenciesBlock[]} blocks
|
181
181
|
*/
|
182
182
|
|
183
183
|
/**
|
184
|
-
* @typedef {
|
184
|
+
* @typedef {object} ChunkPathData
|
185
185
|
* @property {string|number} id
|
186
186
|
* @property {string=} name
|
187
187
|
* @property {string} hash
|
@@ -191,7 +191,7 @@ const { isSourceEqual } = require("./util/source");
|
|
191
191
|
*/
|
192
192
|
|
193
193
|
/**
|
194
|
-
* @typedef {
|
194
|
+
* @typedef {object} ChunkHashContext
|
195
195
|
* @property {CodeGenerationResults} codeGenerationResults results of code generation
|
196
196
|
* @property {RuntimeTemplate} runtimeTemplate the runtime template
|
197
197
|
* @property {ModuleGraph} moduleGraph the module graph
|
@@ -199,18 +199,18 @@ const { isSourceEqual } = require("./util/source");
|
|
199
199
|
*/
|
200
200
|
|
201
201
|
/**
|
202
|
-
* @typedef {
|
202
|
+
* @typedef {object} RuntimeRequirementsContext
|
203
203
|
* @property {ChunkGraph} chunkGraph the chunk graph
|
204
204
|
* @property {CodeGenerationResults} codeGenerationResults the code generation results
|
205
205
|
*/
|
206
206
|
|
207
207
|
/**
|
208
|
-
* @typedef {
|
208
|
+
* @typedef {object} ExecuteModuleOptions
|
209
209
|
* @property {EntryOptions=} entryOptions
|
210
210
|
*/
|
211
211
|
|
212
212
|
/**
|
213
|
-
* @typedef {
|
213
|
+
* @typedef {object} ExecuteModuleResult
|
214
214
|
* @property {any} exports
|
215
215
|
* @property {boolean} cacheable
|
216
216
|
* @property {Map<string, { source: Source, info: AssetInfo }>} assets
|
@@ -221,7 +221,7 @@ const { isSourceEqual } = require("./util/source");
|
|
221
221
|
*/
|
222
222
|
|
223
223
|
/**
|
224
|
-
* @typedef {
|
224
|
+
* @typedef {object} ExecuteModuleArgument
|
225
225
|
* @property {Module} module
|
226
226
|
* @property {{ id: string, exports: any, loaded: boolean }=} moduleObject
|
227
227
|
* @property {any} preparedInfo
|
@@ -229,7 +229,7 @@ const { isSourceEqual } = require("./util/source");
|
|
229
229
|
*/
|
230
230
|
|
231
231
|
/**
|
232
|
-
* @typedef {
|
232
|
+
* @typedef {object} ExecuteModuleContext
|
233
233
|
* @property {Map<string, { source: Source, info: AssetInfo }>} assets
|
234
234
|
* @property {Chunk} chunk
|
235
235
|
* @property {ChunkGraph} chunkGraph
|
@@ -237,14 +237,14 @@ const { isSourceEqual } = require("./util/source");
|
|
237
237
|
*/
|
238
238
|
|
239
239
|
/**
|
240
|
-
* @typedef {
|
240
|
+
* @typedef {object} EntryData
|
241
241
|
* @property {Dependency[]} dependencies dependencies of the entrypoint that should be evaluated at startup
|
242
242
|
* @property {Dependency[]} includeDependencies dependencies of the entrypoint that should be included but not evaluated
|
243
243
|
* @property {EntryOptions} options options of the entrypoint
|
244
244
|
*/
|
245
245
|
|
246
246
|
/**
|
247
|
-
* @typedef {
|
247
|
+
* @typedef {object} LogEntry
|
248
248
|
* @property {string} type
|
249
249
|
* @property {any[]} args
|
250
250
|
* @property {number} time
|
@@ -252,7 +252,7 @@ const { isSourceEqual } = require("./util/source");
|
|
252
252
|
*/
|
253
253
|
|
254
254
|
/**
|
255
|
-
* @typedef {
|
255
|
+
* @typedef {object} KnownAssetInfo
|
256
256
|
* @property {boolean=} immutable true, if the asset can be long term cached forever (contains a hash)
|
257
257
|
* @property {boolean=} minimized whether the asset is minimized
|
258
258
|
* @property {string | string[]=} fullhash the value(s) of the full hash used for this asset
|
@@ -270,21 +270,21 @@ const { isSourceEqual } = require("./util/source");
|
|
270
270
|
/** @typedef {KnownAssetInfo & Record<string, any>} AssetInfo */
|
271
271
|
|
272
272
|
/**
|
273
|
-
* @typedef {
|
273
|
+
* @typedef {object} Asset
|
274
274
|
* @property {string} name the filename of the asset
|
275
275
|
* @property {Source} source source of the asset
|
276
276
|
* @property {AssetInfo} info info about the asset
|
277
277
|
*/
|
278
278
|
|
279
279
|
/**
|
280
|
-
* @typedef {
|
280
|
+
* @typedef {object} ModulePathData
|
281
281
|
* @property {string|number} id
|
282
282
|
* @property {string} hash
|
283
283
|
* @property {function(number): string=} hashWithLength
|
284
284
|
*/
|
285
285
|
|
286
286
|
/**
|
287
|
-
* @typedef {
|
287
|
+
* @typedef {object} PathData
|
288
288
|
* @property {ChunkGraph=} chunkGraph
|
289
289
|
* @property {string=} hash
|
290
290
|
* @property {function(number): string=} hashWithLength
|
@@ -302,7 +302,7 @@ const { isSourceEqual } = require("./util/source");
|
|
302
302
|
*/
|
303
303
|
|
304
304
|
/**
|
305
|
-
* @typedef {
|
305
|
+
* @typedef {object} KnownNormalizedStatsOptions
|
306
306
|
* @property {string} context
|
307
307
|
* @property {RequestShortener} requestShortener
|
308
308
|
* @property {string} chunksSort
|
@@ -346,7 +346,7 @@ const { isSourceEqual } = require("./util/source");
|
|
346
346
|
/** @typedef {KnownNormalizedStatsOptions & Omit<StatsOptions, keyof KnownNormalizedStatsOptions> & Record<string, any>} NormalizedStatsOptions */
|
347
347
|
|
348
348
|
/**
|
349
|
-
* @typedef {
|
349
|
+
* @typedef {object} KnownCreateStatsOptionsContext
|
350
350
|
* @property {boolean=} forToString
|
351
351
|
*/
|
352
352
|
|
@@ -849,7 +849,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
849
849
|
/** @type {SyncHook<[Chunk, string]>} */
|
850
850
|
chunkAsset: new SyncHook(["chunk", "filename"]),
|
851
851
|
|
852
|
-
/** @type {SyncWaterfallHook<[string, object, AssetInfo]>} */
|
852
|
+
/** @type {SyncWaterfallHook<[string, object, AssetInfo | undefined]>} */
|
853
853
|
assetPath: new SyncWaterfallHook(["path", "options", "assetInfo"]),
|
854
854
|
|
855
855
|
/** @type {SyncBailHook<[], boolean>} */
|
@@ -1019,7 +1019,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1019
1019
|
arrayToSetDeprecation(this.chunks, "Compilation.chunks");
|
1020
1020
|
arrayToSetDeprecation(this.modules, "Compilation.modules");
|
1021
1021
|
}
|
1022
|
-
/**
|
1022
|
+
/**
|
1023
|
+
* @private
|
1024
|
+
* @type {Map<string, Module>}
|
1025
|
+
*/
|
1023
1026
|
this._modules = new Map();
|
1024
1027
|
this.records = null;
|
1025
1028
|
/** @type {string[]} */
|
@@ -1061,7 +1064,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1061
1064
|
this.codeGeneratedModules = new WeakSet();
|
1062
1065
|
/** @type {WeakSet<Module>} */
|
1063
1066
|
this.buildTimeExecutedModules = new WeakSet();
|
1064
|
-
/**
|
1067
|
+
/**
|
1068
|
+
* @private
|
1069
|
+
* @type {Map<Module, Callback[]>}
|
1070
|
+
*/
|
1065
1071
|
this._rebuildingModules = new Map();
|
1066
1072
|
/** @type {Set<string>} */
|
1067
1073
|
this.emittedAssets = new Set();
|
@@ -1787,7 +1793,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1787
1793
|
}
|
1788
1794
|
|
1789
1795
|
/**
|
1790
|
-
* @typedef {
|
1796
|
+
* @typedef {object} HandleModuleCreationOptions
|
1791
1797
|
* @property {ModuleFactory} factory
|
1792
1798
|
* @property {Dependency[]} dependencies
|
1793
1799
|
* @property {Module | null} originModule
|
@@ -2122,7 +2128,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2122
2128
|
}
|
2123
2129
|
|
2124
2130
|
/**
|
2125
|
-
* @param {
|
2131
|
+
* @param {object} options options
|
2126
2132
|
* @param {string} options.context context string path
|
2127
2133
|
* @param {Dependency} options.dependency dependency used to create Module chain
|
2128
2134
|
* @param {Partial<ModuleFactoryCreateDataContextInfo>=} options.contextInfo additional context info for the root module
|
@@ -2561,7 +2567,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2561
2567
|
};
|
2562
2568
|
/**
|
2563
2569
|
* @param {Module} module module
|
2564
|
-
* @param {
|
2570
|
+
* @param {object} references references
|
2565
2571
|
* @param {string | number} references.id id
|
2566
2572
|
* @param {Map<Module, string | number | undefined>=} references.modules modules
|
2567
2573
|
* @param {(string | number | null)[]=} references.blocks blocks
|
@@ -3466,7 +3472,6 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3466
3472
|
dependencyTemplates,
|
3467
3473
|
runtimeTemplate,
|
3468
3474
|
runtime,
|
3469
|
-
runtimes,
|
3470
3475
|
codeGenerationResults: results,
|
3471
3476
|
compilation: this
|
3472
3477
|
});
|
@@ -3510,7 +3515,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3510
3515
|
}
|
3511
3516
|
|
3512
3517
|
/**
|
3513
|
-
* @param {
|
3518
|
+
* @param {object} options options
|
3514
3519
|
* @param {ChunkGraph=} options.chunkGraph the chunk graph
|
3515
3520
|
* @param {Iterable<Module>=} options.modules modules
|
3516
3521
|
* @param {Iterable<Chunk>=} options.chunks chunks
|
@@ -5338,7 +5343,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
5338
5343
|
}
|
5339
5344
|
|
5340
5345
|
/**
|
5341
|
-
* @typedef {
|
5346
|
+
* @typedef {object} FactorizeModuleOptions
|
5342
5347
|
* @property {ModuleProfile} currentProfile
|
5343
5348
|
* @property {ModuleFactory} factory
|
5344
5349
|
* @property {Dependency[]} dependencies
|
@@ -5355,7 +5360,8 @@ This prevents using hashes of each other and should be avoided.`);
|
|
5355
5360
|
*/
|
5356
5361
|
|
5357
5362
|
// Workaround for typescript as it doesn't support function overloading in jsdoc within a class
|
5358
|
-
Compilation.prototype.factorizeModule = /**
|
5363
|
+
Compilation.prototype.factorizeModule = /**
|
5364
|
+
@type {{
|
5359
5365
|
(options: FactorizeModuleOptions & { factoryResult?: false }, callback: ModuleCallback): void;
|
5360
5366
|
(options: FactorizeModuleOptions & { factoryResult: true }, callback: ModuleFactoryResultCallback): void;
|
5361
5367
|
}} */ (
|
package/lib/Compiler.js
CHANGED
@@ -45,6 +45,7 @@ const { isSourceEqual } = require("./util/source");
|
|
45
45
|
/** @typedef {import("./FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */
|
46
46
|
/** @typedef {import("./Module")} Module */
|
47
47
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
48
|
+
/** @typedef {import("./config/target").PlatformTargetProperties} PlatformTargetProperties */
|
48
49
|
/** @typedef {import("./logging/createConsoleLogger").LoggingFunction} LoggingFunction */
|
49
50
|
/** @typedef {import("./util/WeakTupleMap")} WeakTupleMap */
|
50
51
|
/** @typedef {import("./util/fs").IStats} IStats */
|
@@ -54,7 +55,7 @@ const { isSourceEqual } = require("./util/source");
|
|
54
55
|
/** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */
|
55
56
|
|
56
57
|
/**
|
57
|
-
* @typedef {
|
58
|
+
* @typedef {object} CompilationParams
|
58
59
|
* @property {NormalModuleFactory} normalModuleFactory
|
59
60
|
* @property {ContextModuleFactory} contextModuleFactory
|
60
61
|
*/
|
@@ -81,7 +82,7 @@ const { isSourceEqual } = require("./util/source");
|
|
81
82
|
*/
|
82
83
|
|
83
84
|
/**
|
84
|
-
* @typedef {
|
85
|
+
* @typedef {object} AssetEmittedInfo
|
85
86
|
* @property {Buffer} content
|
86
87
|
* @property {Source} source
|
87
88
|
* @property {Compilation} compilation
|
@@ -104,12 +105,12 @@ const isSorted = array => {
|
|
104
105
|
};
|
105
106
|
|
106
107
|
/**
|
107
|
-
* @param {
|
108
|
+
* @param {{[key: string]: any}} obj an object
|
108
109
|
* @param {string[]} keys the keys of the object
|
109
|
-
* @returns {
|
110
|
+
* @returns {{[key: string]: any}} the object with properties sorted by property name
|
110
111
|
*/
|
111
112
|
const sortObject = (obj, keys) => {
|
112
|
-
/** @type {
|
113
|
+
/** @type {{[key: string]: any}} */
|
113
114
|
const o = {};
|
114
115
|
for (const k of keys.sort()) {
|
115
116
|
o[k] = obj[k];
|
@@ -265,6 +266,16 @@ class Compiler {
|
|
265
266
|
/** @type {LoggingFunction | undefined} */
|
266
267
|
this.infrastructureLogger = undefined;
|
267
268
|
|
269
|
+
/** @type {Readonly<PlatformTargetProperties>} */
|
270
|
+
this.platform = {
|
271
|
+
web: null,
|
272
|
+
browser: null,
|
273
|
+
webworker: null,
|
274
|
+
node: null,
|
275
|
+
nwjs: null,
|
276
|
+
electron: null
|
277
|
+
};
|
278
|
+
|
268
279
|
this.options = options;
|
269
280
|
|
270
281
|
this.context = context;
|
@@ -294,11 +305,20 @@ class Compiler {
|
|
294
305
|
/** @type {NormalModuleFactory | undefined} */
|
295
306
|
this._lastNormalModuleFactory = undefined;
|
296
307
|
|
297
|
-
/**
|
308
|
+
/**
|
309
|
+
* @private
|
310
|
+
* @type {WeakMap<Source, CacheEntry>}
|
311
|
+
*/
|
298
312
|
this._assetEmittingSourceCache = new WeakMap();
|
299
|
-
/**
|
313
|
+
/**
|
314
|
+
* @private
|
315
|
+
* @type {Map<string, number>}
|
316
|
+
*/
|
300
317
|
this._assetEmittingWrittenFiles = new Map();
|
301
|
-
/**
|
318
|
+
/**
|
319
|
+
* @private
|
320
|
+
* @type {Set<string>}
|
321
|
+
*/
|
302
322
|
this._assetEmittingPreviousFiles = new Set();
|
303
323
|
}
|
304
324
|
|
@@ -14,13 +14,13 @@ const DEFAULT_EXPORT = "__WEBPACK_DEFAULT_EXPORT__";
|
|
14
14
|
const NAMESPACE_OBJECT_EXPORT = "__WEBPACK_NAMESPACE_OBJECT__";
|
15
15
|
|
16
16
|
/**
|
17
|
-
* @typedef {
|
17
|
+
* @typedef {object} ExternalModuleInfo
|
18
18
|
* @property {number} index
|
19
19
|
* @property {Module} module
|
20
20
|
*/
|
21
21
|
|
22
22
|
/**
|
23
|
-
* @typedef {
|
23
|
+
* @typedef {object} ConcatenatedModuleInfo
|
24
24
|
* @property {number} index
|
25
25
|
* @property {Module} module
|
26
26
|
* @property {Map<string, string>} exportMap mapping from export name to symbol
|
@@ -31,7 +31,7 @@ const NAMESPACE_OBJECT_EXPORT = "__WEBPACK_NAMESPACE_OBJECT__";
|
|
31
31
|
/** @typedef {ConcatenatedModuleInfo | ExternalModuleInfo} ModuleInfo */
|
32
32
|
|
33
33
|
/**
|
34
|
-
* @typedef {
|
34
|
+
* @typedef {object} ModuleReferenceOptions
|
35
35
|
* @property {string[]} ids the properties/exports of the module
|
36
36
|
* @property {boolean} call true, when this referenced export is called
|
37
37
|
* @property {boolean} directImport true, when this referenced export is directly imported (not via property access)
|