webpack 5.108.1 → 5.108.2
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/lib/CleanPlugin.js +8 -25
- package/lib/Compilation.js +0 -1
- package/lib/DefinePlugin.js +8 -19
- package/lib/ExternalModule.js +64 -19
- package/lib/ExternalModuleFactoryPlugin.js +37 -1
- package/lib/LazyBarrel.js +4 -3
- package/lib/NormalModule.js +49 -59
- package/lib/bun/BunTargetPlugin.js +1 -7
- package/lib/container/ModuleFederationPlugin.js +9 -25
- package/lib/css/CssInjectStyleRuntimeModule.js +9 -24
- package/lib/css/CssLoadingRuntimeModule.js +12 -27
- package/lib/css/CssModulesPlugin.js +15 -31
- package/lib/deno/DenoTargetPlugin.js +1 -7
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +22 -0
- package/lib/dependencies/HarmonyImportDependency.js +2 -0
- package/lib/dependencies/ImportMetaPlugin.js +9 -25
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +10 -26
- package/lib/javascript/JavascriptModulesPlugin.js +38 -54
- package/lib/node/NodeTargetPlugin.js +1 -62
- package/lib/node/nodeBuiltins.js +80 -0
- package/lib/optimize/ConcatenatedModule.js +17 -27
- package/lib/optimize/RealContentHashPlugin.js +8 -24
- package/lib/runtime/LoadScriptRuntimeModule.js +9 -24
- package/lib/util/createHooksRegistry.js +35 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +12 -29
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +10 -25
- package/package.json +1 -1
- package/types.d.ts +84 -71
|
@@ -13,7 +13,7 @@ const {
|
|
|
13
13
|
RawSource,
|
|
14
14
|
ReplaceSource
|
|
15
15
|
} = require("webpack-sources");
|
|
16
|
-
|
|
16
|
+
/** @typedef {import("../Compilation")} Compilation */
|
|
17
17
|
const HotUpdateChunk = require("../HotUpdateChunk");
|
|
18
18
|
const { CSS_IMPORT_TYPE, CSS_TYPE } = require("../ModuleSourceTypeConstants");
|
|
19
19
|
const {
|
|
@@ -37,6 +37,7 @@ const JavascriptModulesPlugin = require("../javascript/JavascriptModulesPlugin")
|
|
|
37
37
|
const ConcatenatedModule = require("../optimize/ConcatenatedModule");
|
|
38
38
|
const { compareModulesByFullName } = require("../util/comparators");
|
|
39
39
|
const createHash = require("../util/createHash");
|
|
40
|
+
const createHooksRegistry = require("../util/createHooksRegistry");
|
|
40
41
|
const { getUndoPath } = require("../util/identifier");
|
|
41
42
|
const memoize = require("../util/memoize");
|
|
42
43
|
const { digestNonNumericOnlyWithFull } = require("../util/nonNumericOnlyHash");
|
|
@@ -180,39 +181,9 @@ const generatorValidationOptions = {
|
|
|
180
181
|
baseDataPath: "generator"
|
|
181
182
|
};
|
|
182
183
|
|
|
183
|
-
/** @type {WeakMap<Compilation, CompilationHooks>} */
|
|
184
|
-
const compilationHooksMap = new WeakMap();
|
|
185
|
-
|
|
186
184
|
const PLUGIN_NAME = "CssModulesPlugin";
|
|
187
185
|
|
|
188
186
|
class CssModulesPlugin {
|
|
189
|
-
/**
|
|
190
|
-
* Returns the attached hooks.
|
|
191
|
-
* @param {Compilation} compilation the compilation
|
|
192
|
-
* @returns {CompilationHooks} the attached hooks
|
|
193
|
-
*/
|
|
194
|
-
static getCompilationHooks(compilation) {
|
|
195
|
-
if (!(compilation instanceof Compilation)) {
|
|
196
|
-
throw new TypeError(
|
|
197
|
-
"The 'compilation' argument must be an instance of Compilation"
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
let hooks = compilationHooksMap.get(compilation);
|
|
201
|
-
if (hooks === undefined) {
|
|
202
|
-
hooks = {
|
|
203
|
-
renderModulePackage: new SyncWaterfallHook([
|
|
204
|
-
"source",
|
|
205
|
-
"module",
|
|
206
|
-
"renderContext"
|
|
207
|
-
]),
|
|
208
|
-
chunkHash: new SyncHook(["chunk", "hash", "context"]),
|
|
209
|
-
orderModules: new SyncBailHook(["chunk", "modules", "compilation"])
|
|
210
|
-
};
|
|
211
|
-
compilationHooksMap.set(compilation, hooks);
|
|
212
|
-
}
|
|
213
|
-
return hooks;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
187
|
constructor() {
|
|
217
188
|
/** @type {WeakMap<Source, ModuleFactoryCacheEntry>} */
|
|
218
189
|
this._moduleFactoryCache = new WeakMap();
|
|
@@ -1164,4 +1135,17 @@ class CssModulesPlugin {
|
|
|
1164
1135
|
}
|
|
1165
1136
|
}
|
|
1166
1137
|
|
|
1138
|
+
CssModulesPlugin.getCompilationHooks = createHooksRegistry(
|
|
1139
|
+
() =>
|
|
1140
|
+
/** @type {CompilationHooks} */ ({
|
|
1141
|
+
renderModulePackage: new SyncWaterfallHook([
|
|
1142
|
+
"source",
|
|
1143
|
+
"module",
|
|
1144
|
+
"renderContext"
|
|
1145
|
+
]),
|
|
1146
|
+
chunkHash: new SyncHook(["chunk", "hash", "context"]),
|
|
1147
|
+
orderModules: new SyncBailHook(["chunk", "modules", "compilation"])
|
|
1148
|
+
})
|
|
1149
|
+
);
|
|
1150
|
+
|
|
1167
1151
|
module.exports = CssModulesPlugin;
|
|
@@ -6,18 +6,12 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const ExternalsPlugin = require("../ExternalsPlugin");
|
|
9
|
-
const
|
|
9
|
+
const { coreModules } = require("../node/nodeBuiltins");
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("../Compiler")} Compiler */
|
|
12
12
|
|
|
13
13
|
// Deno only resolves node.js core modules through the `node:` specifier, so the
|
|
14
14
|
// prefix is baked into the external request for both `import` and `require`.
|
|
15
|
-
// cspell:word pnpapi
|
|
16
|
-
const coreModules = new Set(
|
|
17
|
-
NodeTargetPlugin.builtins.filter(
|
|
18
|
-
(builtin) => typeof builtin === "string" && builtin !== "pnpapi"
|
|
19
|
-
)
|
|
20
|
-
);
|
|
21
15
|
|
|
22
16
|
// Deno's own import protocols are resolved by the runtime, never bundled.
|
|
23
17
|
const DENO_PROTOCOLS = /^(?:npm|jsr|https?):/;
|
|
@@ -108,6 +108,11 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
|
108
108
|
/** @type {DependencyLocation} */ (statement.loc),
|
|
109
109
|
-1
|
|
110
110
|
);
|
|
111
|
+
// lazy barrel: defer at parse time when the importing module is side-effect-free
|
|
112
|
+
const moduleFactoryMeta = parser.state.module.factoryMeta;
|
|
113
|
+
if (moduleFactoryMeta !== undefined && moduleFactoryMeta.sideEffectFree) {
|
|
114
|
+
sideEffectDep.setLazy(true);
|
|
115
|
+
}
|
|
111
116
|
parser.state.current.addDependency(sideEffectDep);
|
|
112
117
|
return true;
|
|
113
118
|
});
|
|
@@ -226,6 +231,15 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
|
226
231
|
name,
|
|
227
232
|
tagData ? tagData.value || null : undefined
|
|
228
233
|
);
|
|
234
|
+
// lazy barrel: defer the re-export at parse time when the importing module is side-effect-free
|
|
235
|
+
const moduleFactoryMeta = parser.state.module.factoryMeta;
|
|
236
|
+
if (
|
|
237
|
+
settings &&
|
|
238
|
+
moduleFactoryMeta !== undefined &&
|
|
239
|
+
moduleFactoryMeta.sideEffectFree
|
|
240
|
+
) {
|
|
241
|
+
dep.setLazy(true);
|
|
242
|
+
}
|
|
229
243
|
dep.setLocWithIndex(
|
|
230
244
|
/** @type {DependencyLocation} */ (statement.loc),
|
|
231
245
|
/** @type {number} */ (idx)
|
|
@@ -273,6 +287,14 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
|
273
287
|
if (harmonyStarExports) {
|
|
274
288
|
harmonyStarExports.push(dep);
|
|
275
289
|
}
|
|
290
|
+
// lazy barrel: defer the re-export at parse time when the importing module is side-effect-free
|
|
291
|
+
const moduleFactoryMeta = parser.state.module.factoryMeta;
|
|
292
|
+
if (
|
|
293
|
+
moduleFactoryMeta !== undefined &&
|
|
294
|
+
moduleFactoryMeta.sideEffectFree
|
|
295
|
+
) {
|
|
296
|
+
dep.setLazy(true);
|
|
297
|
+
}
|
|
276
298
|
dep.setLocWithIndex(
|
|
277
299
|
/** @type {DependencyLocation} */ (statement.loc),
|
|
278
300
|
/** @type {number} */ (idx)
|
|
@@ -366,6 +366,7 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
|
366
366
|
const { write } = context;
|
|
367
367
|
write(this.attributes);
|
|
368
368
|
write(this.phase);
|
|
369
|
+
write(this._lazyMake);
|
|
369
370
|
super.serialize(context);
|
|
370
371
|
}
|
|
371
372
|
|
|
@@ -377,6 +378,7 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
|
377
378
|
const { read } = context;
|
|
378
379
|
this.attributes = read();
|
|
379
380
|
this.phase = read();
|
|
381
|
+
this._lazyMake = read();
|
|
380
382
|
super.deserialize(context);
|
|
381
383
|
}
|
|
382
384
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const { pathToFileURL } = require("url");
|
|
9
9
|
const { SyncBailHook } = require("tapable");
|
|
10
|
-
|
|
10
|
+
/** @typedef {import("../Compilation")} Compilation */
|
|
11
11
|
const DefinePlugin = require("../DefinePlugin");
|
|
12
12
|
const {
|
|
13
13
|
JAVASCRIPT_MODULE_TYPE_AUTO,
|
|
@@ -22,6 +22,7 @@ const {
|
|
|
22
22
|
evaluateToString,
|
|
23
23
|
toConstantDependency
|
|
24
24
|
} = require("../javascript/JavascriptParserHelpers");
|
|
25
|
+
const createHooksRegistry = require("../util/createHooksRegistry");
|
|
25
26
|
const { propertyAccess } = require("../util/property");
|
|
26
27
|
const ConstDependency = require("./ConstDependency");
|
|
27
28
|
const ModuleInitFragmentDependency = require("./ModuleInitFragmentDependency");
|
|
@@ -109,31 +110,7 @@ const collectImportMetaEnvDefinitions = (compilation) => {
|
|
|
109
110
|
* @property {SyncBailHook<[DestructuringAssignmentProperty], string | void>} propertyInDestructuring
|
|
110
111
|
*/
|
|
111
112
|
|
|
112
|
-
/** @type {WeakMap<Compilation, ImportMetaPluginHooks>} */
|
|
113
|
-
const compilationHooksMap = new WeakMap();
|
|
114
|
-
|
|
115
113
|
class ImportMetaPlugin {
|
|
116
|
-
/**
|
|
117
|
-
* Returns the attached hooks.
|
|
118
|
-
* @param {Compilation} compilation the compilation
|
|
119
|
-
* @returns {ImportMetaPluginHooks} the attached hooks
|
|
120
|
-
*/
|
|
121
|
-
static getCompilationHooks(compilation) {
|
|
122
|
-
if (!(compilation instanceof Compilation)) {
|
|
123
|
-
throw new TypeError(
|
|
124
|
-
"The 'compilation' argument must be an instance of Compilation"
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
let hooks = compilationHooksMap.get(compilation);
|
|
128
|
-
if (hooks === undefined) {
|
|
129
|
-
hooks = {
|
|
130
|
-
propertyInDestructuring: new SyncBailHook(["property"])
|
|
131
|
-
};
|
|
132
|
-
compilationHooksMap.set(compilation, hooks);
|
|
133
|
-
}
|
|
134
|
-
return hooks;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
114
|
/**
|
|
138
115
|
* Applies the plugin by registering its hooks on the compiler.
|
|
139
116
|
* @param {Compiler} compiler compiler
|
|
@@ -501,6 +478,13 @@ class ImportMetaPlugin {
|
|
|
501
478
|
}
|
|
502
479
|
}
|
|
503
480
|
|
|
481
|
+
ImportMetaPlugin.getCompilationHooks = createHooksRegistry(
|
|
482
|
+
() =>
|
|
483
|
+
/** @type {ImportMetaPluginHooks} */ ({
|
|
484
|
+
propertyInDestructuring: new SyncBailHook(["property"])
|
|
485
|
+
})
|
|
486
|
+
);
|
|
487
|
+
|
|
504
488
|
module.exports = ImportMetaPlugin;
|
|
505
489
|
module.exports.IMPORT_META_DIRNAME = IMPORT_META_DIRNAME;
|
|
506
490
|
module.exports.IMPORT_META_FILENAME = IMPORT_META_FILENAME;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
7
|
const { SyncWaterfallHook } = require("tapable");
|
|
8
|
-
|
|
8
|
+
/** @typedef {import("../Compilation")} Compilation */
|
|
9
9
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
10
10
|
const RuntimeModule = require("../RuntimeModule");
|
|
11
11
|
const Template = require("../Template");
|
|
@@ -18,6 +18,7 @@ const {
|
|
|
18
18
|
} = require("../javascript/JavascriptModulesPlugin");
|
|
19
19
|
const { getInitialChunkIds } = require("../javascript/StartupHelpers");
|
|
20
20
|
const compileBooleanMatcher = require("../util/compileBooleanMatcher");
|
|
21
|
+
const createHooksRegistry = require("../util/createHooksRegistry");
|
|
21
22
|
const { getUndoPath } = require("../util/identifier");
|
|
22
23
|
|
|
23
24
|
/** @typedef {import("../Chunk")} Chunk */
|
|
@@ -31,32 +32,7 @@ const { getUndoPath } = require("../util/identifier");
|
|
|
31
32
|
* @property {SyncWaterfallHook<[string, Chunk]>} linkPrefetch
|
|
32
33
|
*/
|
|
33
34
|
|
|
34
|
-
/** @type {WeakMap<Compilation, JsonpCompilationPluginHooks>} */
|
|
35
|
-
const compilationHooksMap = new WeakMap();
|
|
36
|
-
|
|
37
35
|
class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
38
|
-
/**
|
|
39
|
-
* Returns hooks.
|
|
40
|
-
* @param {Compilation} compilation the compilation
|
|
41
|
-
* @returns {JsonpCompilationPluginHooks} hooks
|
|
42
|
-
*/
|
|
43
|
-
static getCompilationHooks(compilation) {
|
|
44
|
-
if (!(compilation instanceof Compilation)) {
|
|
45
|
-
throw new TypeError(
|
|
46
|
-
"The 'compilation' argument must be an instance of Compilation"
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
let hooks = compilationHooksMap.get(compilation);
|
|
50
|
-
if (hooks === undefined) {
|
|
51
|
-
hooks = {
|
|
52
|
-
linkPreload: new SyncWaterfallHook(["source", "chunk"]),
|
|
53
|
-
linkPrefetch: new SyncWaterfallHook(["source", "chunk"])
|
|
54
|
-
};
|
|
55
|
-
compilationHooksMap.set(compilation, hooks);
|
|
56
|
-
}
|
|
57
|
-
return hooks;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
36
|
/**
|
|
61
37
|
* Creates an instance of ModuleChunkLoadingRuntimeModule.
|
|
62
38
|
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
|
|
@@ -433,4 +409,12 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
433
409
|
}
|
|
434
410
|
}
|
|
435
411
|
|
|
412
|
+
ModuleChunkLoadingRuntimeModule.getCompilationHooks = createHooksRegistry(
|
|
413
|
+
() =>
|
|
414
|
+
/** @type {JsonpCompilationPluginHooks} */ ({
|
|
415
|
+
linkPreload: new SyncWaterfallHook(["source", "chunk"]),
|
|
416
|
+
linkPrefetch: new SyncWaterfallHook(["source", "chunk"])
|
|
417
|
+
})
|
|
418
|
+
);
|
|
419
|
+
|
|
436
420
|
module.exports = ModuleChunkLoadingRuntimeModule;
|
|
@@ -16,7 +16,7 @@ const {
|
|
|
16
16
|
RawSource,
|
|
17
17
|
ReplaceSource
|
|
18
18
|
} = require("webpack-sources");
|
|
19
|
-
|
|
19
|
+
/** @typedef {import("../Compilation")} Compilation */
|
|
20
20
|
const HotUpdateChunk = require("../HotUpdateChunk");
|
|
21
21
|
const InitFragment = require("../InitFragment");
|
|
22
22
|
const { JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants");
|
|
@@ -42,6 +42,7 @@ const {
|
|
|
42
42
|
getUsedNamesInScopeInfo
|
|
43
43
|
} = require("../util/concatenate");
|
|
44
44
|
const createHash = require("../util/createHash");
|
|
45
|
+
const createHooksRegistry = require("../util/createHooksRegistry");
|
|
45
46
|
const { digestNonNumericOnlyWithFull } = require("../util/nonNumericOnlyHash");
|
|
46
47
|
const removeBOM = require("../util/removeBOM");
|
|
47
48
|
const { intersectRuntime } = require("../util/runtime");
|
|
@@ -345,9 +346,6 @@ const printGeneratedCodeForStack = (module, code) => {
|
|
|
345
346
|
* @property {SyncBailHook<[Chunk, RenderContext], boolean | void>} useSourceMap
|
|
346
347
|
*/
|
|
347
348
|
|
|
348
|
-
/** @type {WeakMap<Compilation, CompilationHooks>} */
|
|
349
|
-
const compilationHooksMap = new WeakMap();
|
|
350
|
-
|
|
351
349
|
/**
|
|
352
350
|
* Renames an inlined module's top-level declaration (and all its references) when
|
|
353
351
|
* its name is already taken in the shared startup scope, recording the chosen name
|
|
@@ -422,56 +420,6 @@ const PLUGIN_NAME = "JavascriptModulesPlugin";
|
|
|
422
420
|
/** @typedef {{ header: string[], beforeStartup: string[], startup: string[], afterStartup: string[], allowInlineStartup: boolean }} Bootstrap */
|
|
423
421
|
|
|
424
422
|
class JavascriptModulesPlugin {
|
|
425
|
-
/**
|
|
426
|
-
* Returns the attached hooks.
|
|
427
|
-
* @param {Compilation} compilation the compilation
|
|
428
|
-
* @returns {CompilationHooks} the attached hooks
|
|
429
|
-
*/
|
|
430
|
-
static getCompilationHooks(compilation) {
|
|
431
|
-
if (!(compilation instanceof Compilation)) {
|
|
432
|
-
throw new TypeError(
|
|
433
|
-
"The 'compilation' argument must be an instance of Compilation"
|
|
434
|
-
);
|
|
435
|
-
}
|
|
436
|
-
let hooks = compilationHooksMap.get(compilation);
|
|
437
|
-
if (hooks === undefined) {
|
|
438
|
-
hooks = {
|
|
439
|
-
renderModuleContent: new SyncWaterfallHook([
|
|
440
|
-
"source",
|
|
441
|
-
"module",
|
|
442
|
-
"moduleRenderContext"
|
|
443
|
-
]),
|
|
444
|
-
renderModuleContainer: new SyncWaterfallHook([
|
|
445
|
-
"source",
|
|
446
|
-
"module",
|
|
447
|
-
"moduleRenderContext"
|
|
448
|
-
]),
|
|
449
|
-
renderModulePackage: new SyncWaterfallHook([
|
|
450
|
-
"source",
|
|
451
|
-
"module",
|
|
452
|
-
"moduleRenderContext"
|
|
453
|
-
]),
|
|
454
|
-
render: new SyncWaterfallHook(["source", "renderContext"]),
|
|
455
|
-
renderContent: new SyncWaterfallHook(["source", "renderContext"]),
|
|
456
|
-
renderStartup: new SyncWaterfallHook([
|
|
457
|
-
"source",
|
|
458
|
-
"module",
|
|
459
|
-
"startupRenderContext"
|
|
460
|
-
]),
|
|
461
|
-
renderChunk: new SyncWaterfallHook(["source", "renderContext"]),
|
|
462
|
-
renderMain: new SyncWaterfallHook(["source", "renderContext"]),
|
|
463
|
-
renderRequire: new SyncWaterfallHook(["code", "renderContext"]),
|
|
464
|
-
inlineInRuntimeBailout: new SyncBailHook(["module", "renderContext"]),
|
|
465
|
-
embedInRuntimeBailout: new SyncBailHook(["module", "renderContext"]),
|
|
466
|
-
strictRuntimeBailout: new SyncBailHook(["renderContext"]),
|
|
467
|
-
chunkHash: new SyncHook(["chunk", "hash", "context"]),
|
|
468
|
-
useSourceMap: new SyncBailHook(["chunk", "renderContext"])
|
|
469
|
-
};
|
|
470
|
-
compilationHooksMap.set(compilation, hooks);
|
|
471
|
-
}
|
|
472
|
-
return hooks;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
423
|
constructor(options = {}) {
|
|
476
424
|
this.options = options;
|
|
477
425
|
/** @type {WeakMap<Source, { source: Source, needModule: boolean, needExports: boolean, needRequire: boolean, needThisAsExports: boolean, needStrict: boolean | undefined, renderShorthand: boolean }>} */
|
|
@@ -2185,5 +2133,41 @@ class JavascriptModulesPlugin {
|
|
|
2185
2133
|
}
|
|
2186
2134
|
}
|
|
2187
2135
|
|
|
2136
|
+
JavascriptModulesPlugin.getCompilationHooks = createHooksRegistry(
|
|
2137
|
+
() =>
|
|
2138
|
+
/** @type {CompilationHooks} */ ({
|
|
2139
|
+
renderModuleContent: new SyncWaterfallHook([
|
|
2140
|
+
"source",
|
|
2141
|
+
"module",
|
|
2142
|
+
"moduleRenderContext"
|
|
2143
|
+
]),
|
|
2144
|
+
renderModuleContainer: new SyncWaterfallHook([
|
|
2145
|
+
"source",
|
|
2146
|
+
"module",
|
|
2147
|
+
"moduleRenderContext"
|
|
2148
|
+
]),
|
|
2149
|
+
renderModulePackage: new SyncWaterfallHook([
|
|
2150
|
+
"source",
|
|
2151
|
+
"module",
|
|
2152
|
+
"moduleRenderContext"
|
|
2153
|
+
]),
|
|
2154
|
+
render: new SyncWaterfallHook(["source", "renderContext"]),
|
|
2155
|
+
renderContent: new SyncWaterfallHook(["source", "renderContext"]),
|
|
2156
|
+
renderStartup: new SyncWaterfallHook([
|
|
2157
|
+
"source",
|
|
2158
|
+
"module",
|
|
2159
|
+
"startupRenderContext"
|
|
2160
|
+
]),
|
|
2161
|
+
renderChunk: new SyncWaterfallHook(["source", "renderContext"]),
|
|
2162
|
+
renderMain: new SyncWaterfallHook(["source", "renderContext"]),
|
|
2163
|
+
renderRequire: new SyncWaterfallHook(["code", "renderContext"]),
|
|
2164
|
+
inlineInRuntimeBailout: new SyncBailHook(["module", "renderContext"]),
|
|
2165
|
+
embedInRuntimeBailout: new SyncBailHook(["module", "renderContext"]),
|
|
2166
|
+
strictRuntimeBailout: new SyncBailHook(["renderContext"]),
|
|
2167
|
+
chunkHash: new SyncHook(["chunk", "hash", "context"]),
|
|
2168
|
+
useSourceMap: new SyncBailHook(["chunk", "renderContext"])
|
|
2169
|
+
})
|
|
2170
|
+
);
|
|
2171
|
+
|
|
2188
2172
|
module.exports = JavascriptModulesPlugin;
|
|
2189
2173
|
module.exports.chunkHasJs = chunkHasJs;
|
|
@@ -6,72 +6,11 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const ExternalsPlugin = require("../ExternalsPlugin");
|
|
9
|
+
const { builtins } = require("./nodeBuiltins");
|
|
9
10
|
|
|
10
11
|
/** @typedef {import("../../declarations/WebpackOptions").ExternalsType} ExternalsType */
|
|
11
12
|
/** @typedef {import("../Compiler")} Compiler */
|
|
12
13
|
|
|
13
|
-
const builtins = [
|
|
14
|
-
"assert",
|
|
15
|
-
"assert/strict",
|
|
16
|
-
"async_hooks",
|
|
17
|
-
"buffer",
|
|
18
|
-
"child_process",
|
|
19
|
-
"cluster",
|
|
20
|
-
"console",
|
|
21
|
-
"constants",
|
|
22
|
-
"crypto",
|
|
23
|
-
"dgram",
|
|
24
|
-
"diagnostics_channel",
|
|
25
|
-
"dns",
|
|
26
|
-
"dns/promises",
|
|
27
|
-
"domain",
|
|
28
|
-
"events",
|
|
29
|
-
"fs",
|
|
30
|
-
"fs/promises",
|
|
31
|
-
"http",
|
|
32
|
-
"http2",
|
|
33
|
-
"https",
|
|
34
|
-
"inspector",
|
|
35
|
-
"inspector/promises",
|
|
36
|
-
"module",
|
|
37
|
-
"net",
|
|
38
|
-
"os",
|
|
39
|
-
"path",
|
|
40
|
-
"path/posix",
|
|
41
|
-
"path/win32",
|
|
42
|
-
"perf_hooks",
|
|
43
|
-
"process",
|
|
44
|
-
"punycode",
|
|
45
|
-
"querystring",
|
|
46
|
-
"readline",
|
|
47
|
-
"readline/promises",
|
|
48
|
-
"repl",
|
|
49
|
-
"stream",
|
|
50
|
-
"stream/consumers",
|
|
51
|
-
"stream/promises",
|
|
52
|
-
"stream/web",
|
|
53
|
-
"string_decoder",
|
|
54
|
-
"sys",
|
|
55
|
-
"timers",
|
|
56
|
-
"timers/promises",
|
|
57
|
-
"tls",
|
|
58
|
-
"trace_events",
|
|
59
|
-
"tty",
|
|
60
|
-
"url",
|
|
61
|
-
"util",
|
|
62
|
-
"util/types",
|
|
63
|
-
"v8",
|
|
64
|
-
"vm",
|
|
65
|
-
"wasi",
|
|
66
|
-
"worker_threads",
|
|
67
|
-
"zlib",
|
|
68
|
-
/^node:/,
|
|
69
|
-
|
|
70
|
-
// cspell:word pnpapi
|
|
71
|
-
// Yarn PnP adds pnpapi as "builtin"
|
|
72
|
-
"pnpapi"
|
|
73
|
-
];
|
|
74
|
-
|
|
75
14
|
class NodeTargetPlugin {
|
|
76
15
|
/**
|
|
77
16
|
* Creates an instance of NodeTargetPlugin.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author sheo13666q @sheo13666q
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
// node.js built-in modules externalized by the node/deno/bun target presets.
|
|
9
|
+
const builtins = [
|
|
10
|
+
"assert",
|
|
11
|
+
"assert/strict",
|
|
12
|
+
"async_hooks",
|
|
13
|
+
"buffer",
|
|
14
|
+
"child_process",
|
|
15
|
+
"cluster",
|
|
16
|
+
"console",
|
|
17
|
+
"constants",
|
|
18
|
+
"crypto",
|
|
19
|
+
"dgram",
|
|
20
|
+
"diagnostics_channel",
|
|
21
|
+
"dns",
|
|
22
|
+
"dns/promises",
|
|
23
|
+
"domain",
|
|
24
|
+
"events",
|
|
25
|
+
"fs",
|
|
26
|
+
"fs/promises",
|
|
27
|
+
"http",
|
|
28
|
+
"http2",
|
|
29
|
+
"https",
|
|
30
|
+
"inspector",
|
|
31
|
+
"inspector/promises",
|
|
32
|
+
"module",
|
|
33
|
+
"net",
|
|
34
|
+
"os",
|
|
35
|
+
"path",
|
|
36
|
+
"path/posix",
|
|
37
|
+
"path/win32",
|
|
38
|
+
"perf_hooks",
|
|
39
|
+
"process",
|
|
40
|
+
"punycode",
|
|
41
|
+
"querystring",
|
|
42
|
+
"readline",
|
|
43
|
+
"readline/promises",
|
|
44
|
+
"repl",
|
|
45
|
+
"stream",
|
|
46
|
+
"stream/consumers",
|
|
47
|
+
"stream/promises",
|
|
48
|
+
"stream/web",
|
|
49
|
+
"string_decoder",
|
|
50
|
+
"sys",
|
|
51
|
+
"timers",
|
|
52
|
+
"timers/promises",
|
|
53
|
+
"tls",
|
|
54
|
+
"trace_events",
|
|
55
|
+
"tty",
|
|
56
|
+
"url",
|
|
57
|
+
"util",
|
|
58
|
+
"util/types",
|
|
59
|
+
"v8",
|
|
60
|
+
"vm",
|
|
61
|
+
"wasi",
|
|
62
|
+
"worker_threads",
|
|
63
|
+
"zlib",
|
|
64
|
+
/^node:/,
|
|
65
|
+
|
|
66
|
+
// cspell:word pnpapi
|
|
67
|
+
// Yarn PnP adds pnpapi as "builtin"
|
|
68
|
+
"pnpapi"
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
// Bare core module names (no `node:` prefix, no regex, no pnpapi), used to
|
|
72
|
+
// recognize a request that has a `node:`-prefixed equivalent.
|
|
73
|
+
const coreModules = new Set(
|
|
74
|
+
builtins.filter(
|
|
75
|
+
(builtin) => typeof builtin === "string" && builtin !== "pnpapi"
|
|
76
|
+
)
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
module.exports.builtins = builtins;
|
|
80
|
+
module.exports.coreModules = coreModules;
|
|
@@ -43,6 +43,7 @@ const {
|
|
|
43
43
|
getUsedNamesInScopeInfo
|
|
44
44
|
} = require("../util/concatenate");
|
|
45
45
|
const createHash = require("../util/createHash");
|
|
46
|
+
const createHooksRegistry = require("../util/createHooksRegistry");
|
|
46
47
|
const { makePathsRelative } = require("../util/identifier");
|
|
47
48
|
const makeSerializable = require("../util/makeSerializable");
|
|
48
49
|
const { propertyAccess, propertyName } = require("../util/property");
|
|
@@ -817,9 +818,6 @@ const getFinalName = (
|
|
|
817
818
|
|
|
818
819
|
/** @typedef {BuildInfo & KnownConcatenatedModuleBuildInfo} ConcatenatedModuleBuildInfo */
|
|
819
820
|
|
|
820
|
-
/** @type {WeakMap<Compilation, ConcatenateModuleHooks>} */
|
|
821
|
-
const compilationHooksMap = new WeakMap();
|
|
822
|
-
|
|
823
821
|
class ConcatenatedModule extends Module {
|
|
824
822
|
/**
|
|
825
823
|
* @param {Module} rootModule the root module of the concatenation
|
|
@@ -853,30 +851,6 @@ class ConcatenatedModule extends Module {
|
|
|
853
851
|
});
|
|
854
852
|
}
|
|
855
853
|
|
|
856
|
-
/**
|
|
857
|
-
* @param {Compilation} compilation the compilation
|
|
858
|
-
* @returns {ConcatenateModuleHooks} the attached hooks
|
|
859
|
-
*/
|
|
860
|
-
static getCompilationHooks(compilation) {
|
|
861
|
-
let hooks = compilationHooksMap.get(compilation);
|
|
862
|
-
if (hooks === undefined) {
|
|
863
|
-
hooks = {
|
|
864
|
-
onDemandExportsGeneration: new SyncBailHook([
|
|
865
|
-
"module",
|
|
866
|
-
"runtimes",
|
|
867
|
-
"exportsFinalName",
|
|
868
|
-
"exportsSource"
|
|
869
|
-
]),
|
|
870
|
-
concatenatedModuleInfo: new SyncBailHook([
|
|
871
|
-
"updatedInfo",
|
|
872
|
-
"concatenatedModuleInfo"
|
|
873
|
-
])
|
|
874
|
-
};
|
|
875
|
-
compilationHooksMap.set(compilation, hooks);
|
|
876
|
-
}
|
|
877
|
-
return hooks;
|
|
878
|
-
}
|
|
879
|
-
|
|
880
854
|
/**
|
|
881
855
|
* @param {object} options options
|
|
882
856
|
* @param {string} options.identifier the identifier of the module
|
|
@@ -2661,6 +2635,22 @@ ${defineGetters}`
|
|
|
2661
2635
|
}
|
|
2662
2636
|
}
|
|
2663
2637
|
|
|
2638
|
+
ConcatenatedModule.getCompilationHooks = createHooksRegistry(
|
|
2639
|
+
() =>
|
|
2640
|
+
/** @type {ConcatenateModuleHooks} */ ({
|
|
2641
|
+
onDemandExportsGeneration: new SyncBailHook([
|
|
2642
|
+
"module",
|
|
2643
|
+
"runtimes",
|
|
2644
|
+
"exportsFinalName",
|
|
2645
|
+
"exportsSource"
|
|
2646
|
+
]),
|
|
2647
|
+
concatenatedModuleInfo: new SyncBailHook([
|
|
2648
|
+
"updatedInfo",
|
|
2649
|
+
"concatenatedModuleInfo"
|
|
2650
|
+
])
|
|
2651
|
+
})
|
|
2652
|
+
);
|
|
2653
|
+
|
|
2664
2654
|
makeSerializable(ConcatenatedModule, "webpack/lib/optimize/ConcatenatedModule");
|
|
2665
2655
|
|
|
2666
2656
|
module.exports = ConcatenatedModule;
|
|
@@ -11,6 +11,7 @@ const Compilation = require("../Compilation");
|
|
|
11
11
|
const WebpackError = require("../errors/WebpackError");
|
|
12
12
|
const { compareSelect, compareStrings } = require("../util/comparators");
|
|
13
13
|
const createHash = require("../util/createHash");
|
|
14
|
+
const createHooksRegistry = require("../util/createHooksRegistry");
|
|
14
15
|
|
|
15
16
|
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
|
|
16
17
|
/** @typedef {import("../../declarations/WebpackOptions").HashDigest} HashDigest */
|
|
@@ -171,9 +172,6 @@ const toCachedSource = (source) => {
|
|
|
171
172
|
* @property {SyncBailHook<[Buffer[], string], string | void>} updateHash
|
|
172
173
|
*/
|
|
173
174
|
|
|
174
|
-
/** @type {WeakMap<Compilation, CompilationHooks>} */
|
|
175
|
-
const compilationHooksMap = new WeakMap();
|
|
176
|
-
|
|
177
175
|
/**
|
|
178
176
|
* Defines the real content hash plugin options type used by this module.
|
|
179
177
|
* @typedef {object} RealContentHashPluginOptions
|
|
@@ -184,27 +182,6 @@ const compilationHooksMap = new WeakMap();
|
|
|
184
182
|
const PLUGIN_NAME = "RealContentHashPlugin";
|
|
185
183
|
|
|
186
184
|
class RealContentHashPlugin {
|
|
187
|
-
/**
|
|
188
|
-
* Returns the attached hooks.
|
|
189
|
-
* @param {Compilation} compilation the compilation
|
|
190
|
-
* @returns {CompilationHooks} the attached hooks
|
|
191
|
-
*/
|
|
192
|
-
static getCompilationHooks(compilation) {
|
|
193
|
-
if (!(compilation instanceof Compilation)) {
|
|
194
|
-
throw new TypeError(
|
|
195
|
-
"The 'compilation' argument must be an instance of Compilation"
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
let hooks = compilationHooksMap.get(compilation);
|
|
199
|
-
if (hooks === undefined) {
|
|
200
|
-
hooks = {
|
|
201
|
-
updateHash: new SyncBailHook(["content", "oldHash"])
|
|
202
|
-
};
|
|
203
|
-
compilationHooksMap.set(compilation, hooks);
|
|
204
|
-
}
|
|
205
|
-
return hooks;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
185
|
/**
|
|
209
186
|
* Creates an instance of RealContentHashPlugin.
|
|
210
187
|
* @param {RealContentHashPluginOptions} options options
|
|
@@ -576,4 +553,11 @@ ${referencingAssets
|
|
|
576
553
|
}
|
|
577
554
|
}
|
|
578
555
|
|
|
556
|
+
RealContentHashPlugin.getCompilationHooks = createHooksRegistry(
|
|
557
|
+
() =>
|
|
558
|
+
/** @type {CompilationHooks} */ ({
|
|
559
|
+
updateHash: new SyncBailHook(["content", "oldHash"])
|
|
560
|
+
})
|
|
561
|
+
);
|
|
562
|
+
|
|
579
563
|
module.exports = RealContentHashPlugin;
|