webpack 5.101.0 → 5.101.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.
@@ -272,6 +272,7 @@ const deserialize = async (middleware, name, readFile) => {
272
272
  while (contentItemLength - contentPosition < n) {
273
273
  const remaining = contentItem.slice(contentPosition);
274
274
  let lengthFromNext = n - remaining.length;
275
+ /** @type {Buffer[]} */
275
276
  const buffers = [remaining];
276
277
  for (let i = contentsIndex + 1; i < contents.length; i++) {
277
278
  const l = contents[i].length;
package/lib/util/fs.js CHANGED
@@ -65,7 +65,7 @@ const path = require("path");
65
65
 
66
66
  /** @typedef {string | number | boolean | null} JsonPrimitive */
67
67
  /** @typedef {JsonValue[]} JsonArray */
68
- /** @typedef {{[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined}} JsonObject */
68
+ /** @typedef {{ [Key in string]?: JsonValue }} JsonObject */
69
69
  /** @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue */
70
70
 
71
71
  /** @typedef {(err: NodeJS.ErrnoException | null) => void} NoParamCallback */
@@ -43,7 +43,7 @@ const WebAssemblyUtils = require("./WebAssemblyUtils");
43
43
  /**
44
44
  * @template T
45
45
  * @param {((prev: ArrayBuffer) => ArrayBuffer)[]} fns transforms
46
- * @returns {ArrayBufferTransform} composed transform
46
+ * @returns {(buf: ArrayBuffer) => ArrayBuffer} composed transform
47
47
  */
48
48
  const compose = (...fns) =>
49
49
  fns.reduce(
@@ -514,8 +514,7 @@ class WebAssemblyGenerator extends Generator {
514
514
  })
515
515
  );
516
516
 
517
- const newBin = transform(bin);
518
-
517
+ const newBin = transform(/** @type {ArrayBuffer} */ (bin.buffer));
519
518
  const newBuf = Buffer.from(newBin);
520
519
 
521
520
  return new RawSource(newBuf);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.101.0",
3
+ "version": "5.101.2",
4
4
  "description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
5
5
  "homepage": "https://github.com/webpack/webpack",
6
6
  "bugs": "https://github.com/webpack/webpack/issues",
@@ -91,7 +91,7 @@
91
91
  "acorn-import-phases": "^1.0.3",
92
92
  "browserslist": "^4.24.0",
93
93
  "chrome-trace-event": "^1.0.2",
94
- "enhanced-resolve": "^5.17.2",
94
+ "enhanced-resolve": "^5.17.3",
95
95
  "es-module-lexer": "^1.2.1",
96
96
  "eslint-scope": "5.1.1",
97
97
  "events": "^3.2.0",
@@ -179,12 +179,12 @@
179
179
  "strip-ansi": "^6.0.0",
180
180
  "style-loader": "^4.0.0",
181
181
  "terser": "^5.43.1",
182
- "three": "^0.178.0",
182
+ "three": "^0.179.1",
183
183
  "tinybench": "^4.0.1",
184
184
  "toml": "^3.0.0",
185
185
  "tooling": "webpack/tooling#v1.24.3",
186
186
  "ts-loader": "^9.5.1",
187
- "typescript": "^5.8.2",
187
+ "typescript": "^5.9.2",
188
188
  "url-loader": "^4.1.0",
189
189
  "wast-loader": "^1.12.1",
190
190
  "webassembly-feature": "1.3.0",
package/types.d.ts CHANGED
@@ -160,6 +160,12 @@ declare class AbstractLibraryPlugin<T> {
160
160
  renderContext: StartupRenderContext,
161
161
  libraryContext: LibraryContext<T>
162
162
  ): Source;
163
+ renderModuleContent(
164
+ source: Source,
165
+ module: Module,
166
+ renderContext: ModuleRenderContext,
167
+ libraryContext: Omit<LibraryContext<T>, "options">
168
+ ): Source;
163
169
  chunkHash(
164
170
  chunk: Chunk,
165
171
  hash: Hash,
@@ -1367,6 +1373,7 @@ declare class ChunkGraph {
1367
1373
  getNumberOfRuntimeModules(chunk: Chunk): number;
1368
1374
  getChunkEntryModulesIterable(chunk: Chunk): Iterable<Module>;
1369
1375
  getChunkEntryDependentChunksIterable(chunk: Chunk): Iterable<Chunk>;
1376
+ getRuntimeChunkDependentChunksIterable(chunk: Chunk): Iterable<Chunk>;
1370
1377
  hasChunkEntryDependentChunks(chunk: Chunk): boolean;
1371
1378
  getChunkRuntimeModulesIterable(chunk: Chunk): Iterable<RuntimeModule>;
1372
1379
  getChunkRuntimeModulesInOrder(chunk: Chunk): RuntimeModule[];
@@ -2549,15 +2556,11 @@ declare interface CompilationHooksCssModulesPlugin {
2549
2556
  chunkHash: SyncHook<[Chunk, Hash, ChunkHashContext]>;
2550
2557
  }
2551
2558
  declare interface CompilationHooksJavascriptModulesPlugin {
2552
- renderModuleContent: SyncWaterfallHook<
2553
- [Source, Module, ChunkRenderContextJavascriptModulesPlugin]
2554
- >;
2559
+ renderModuleContent: SyncWaterfallHook<[Source, Module, ModuleRenderContext]>;
2555
2560
  renderModuleContainer: SyncWaterfallHook<
2556
- [Source, Module, ChunkRenderContextJavascriptModulesPlugin]
2557
- >;
2558
- renderModulePackage: SyncWaterfallHook<
2559
- [Source, Module, ChunkRenderContextJavascriptModulesPlugin]
2561
+ [Source, Module, ModuleRenderContext]
2560
2562
  >;
2563
+ renderModulePackage: SyncWaterfallHook<[Source, Module, ModuleRenderContext]>;
2561
2564
  renderChunk: SyncWaterfallHook<
2562
2565
  [Source, RenderContextJavascriptModulesPlugin]
2563
2566
  >;
@@ -4531,6 +4534,8 @@ declare abstract class Entrypoint extends ChunkGroup {
4531
4534
  * (or at least the execution of them)
4532
4535
  */
4533
4536
  getEntrypointChunk(): Chunk;
4537
+ addDependOn(entrypoint: Entrypoint): void;
4538
+ dependOn(entrypoint: Entrypoint): boolean;
4534
4539
  }
4535
4540
  type EnumValue =
4536
4541
  | null
@@ -6461,9 +6466,8 @@ declare class JavascriptModulesPlugin {
6461
6466
  apply(compiler: Compiler): void;
6462
6467
  renderModule(
6463
6468
  module: Module,
6464
- renderContext: ChunkRenderContextJavascriptModulesPlugin,
6465
- hooks: CompilationHooksJavascriptModulesPlugin,
6466
- factory: boolean
6469
+ renderContext: ModuleRenderContext,
6470
+ hooks: CompilationHooksJavascriptModulesPlugin
6467
6471
  ): null | Source;
6468
6472
  renderChunk(
6469
6473
  renderContext: RenderContextJavascriptModulesPlugin,
@@ -7052,6 +7056,40 @@ declare class JavascriptParser extends ParserClass {
7052
7056
  classy: ClassExpression | ClassDeclaration | MaybeNamedClassDeclaration
7053
7057
  ): void;
7054
7058
 
7059
+ /**
7060
+ * Module pre walking iterates the scope for import entries
7061
+ */
7062
+ modulePreWalkStatements(
7063
+ statements: (
7064
+ | ImportDeclarationJavascriptParser
7065
+ | ExportNamedDeclarationJavascriptParser
7066
+ | ExportAllDeclarationJavascriptParser
7067
+ | FunctionDeclaration
7068
+ | VariableDeclaration
7069
+ | ClassDeclaration
7070
+ | ExpressionStatement
7071
+ | BlockStatement
7072
+ | StaticBlock
7073
+ | EmptyStatement
7074
+ | DebuggerStatement
7075
+ | WithStatement
7076
+ | ReturnStatement
7077
+ | LabeledStatement
7078
+ | BreakStatement
7079
+ | ContinueStatement
7080
+ | IfStatement
7081
+ | SwitchStatement
7082
+ | ThrowStatement
7083
+ | TryStatement
7084
+ | WhileStatement
7085
+ | DoWhileStatement
7086
+ | ForStatement
7087
+ | ForInStatement
7088
+ | ForOfStatement
7089
+ | ExportDefaultDeclaration
7090
+ )[]
7091
+ ): void;
7092
+
7055
7093
  /**
7056
7094
  * Pre walking iterates the scope for variable declarations
7057
7095
  */
@@ -7291,13 +7329,16 @@ declare class JavascriptParser extends ParserClass {
7291
7329
  ): void;
7292
7330
  blockPreWalkExpressionStatement(statement: ExpressionStatement): void;
7293
7331
  preWalkAssignmentExpression(expression: AssignmentExpression): void;
7294
- blockPreWalkImportDeclaration(
7332
+ modulePreWalkImportDeclaration(
7295
7333
  statement: ImportDeclarationJavascriptParser
7296
7334
  ): void;
7297
7335
  enterDeclaration(
7298
7336
  declaration: Declaration,
7299
7337
  onIdent: (ident: string, identifier: Identifier) => void
7300
7338
  ): void;
7339
+ modulePreWalkExportNamedDeclaration(
7340
+ statement: ExportNamedDeclarationJavascriptParser
7341
+ ): void;
7301
7342
  blockPreWalkExportNamedDeclaration(
7302
7343
  statement: ExportNamedDeclarationJavascriptParser
7303
7344
  ): void;
@@ -7308,7 +7349,7 @@ declare class JavascriptParser extends ParserClass {
7308
7349
  statement: ExportDefaultDeclaration
7309
7350
  ): void;
7310
7351
  walkExportDefaultDeclaration(statement: ExportDefaultDeclaration): void;
7311
- blockPreWalkExportAllDeclaration(
7352
+ modulePreWalkExportAllDeclaration(
7312
7353
  statement: ExportAllDeclarationJavascriptParser
7313
7354
  ): void;
7314
7355
  preWalkVariableDeclaration(statement: VariableDeclaration): void;
@@ -7714,7 +7755,12 @@ declare class JavascriptParser extends ParserClass {
7714
7755
  unsetAsiPosition(pos: number): void;
7715
7756
  isStatementLevelExpression(expr: Expression): boolean;
7716
7757
  getTagData(name: string, tag: symbol): undefined | TagData;
7717
- tagVariable(name: string, tag: symbol, data?: TagData): void;
7758
+ tagVariable(
7759
+ name: string,
7760
+ tag: symbol,
7761
+ data?: TagData,
7762
+ flags?: 0 | 1 | 2 | 4
7763
+ ): void;
7718
7764
  defineVariable(name: string): void;
7719
7765
  undefineVariable(name: string): void;
7720
7766
  isVariableDefined(name: string): boolean;
@@ -7792,6 +7838,9 @@ declare class JavascriptParser extends ParserClass {
7792
7838
  getFreeInfoFromVariable(
7793
7839
  varName: string
7794
7840
  ): undefined | { name: string; info: string | VariableInfo };
7841
+ getNameInfoFromVariable(
7842
+ varName: string
7843
+ ): undefined | { name: string; info: string | VariableInfo };
7795
7844
  getMemberExpressionInfo(
7796
7845
  expression:
7797
7846
  | ImportExpressionImport
@@ -7840,6 +7889,12 @@ declare class JavascriptParser extends ParserClass {
7840
7889
  static ALLOWED_MEMBER_TYPES_CALL_EXPRESSION: 1;
7841
7890
  static ALLOWED_MEMBER_TYPES_EXPRESSION: 2;
7842
7891
  static VariableInfo: typeof VariableInfo;
7892
+ static VariableInfoFlags: Readonly<{
7893
+ Evaluated: 0;
7894
+ Free: 1;
7895
+ Normal: 2;
7896
+ Tagged: 4;
7897
+ }>;
7843
7898
  static getImportAttributes: (
7844
7899
  node:
7845
7900
  | ImportDeclarationJavascriptParser
@@ -8076,7 +8131,7 @@ declare interface JsonGeneratorOptions {
8076
8131
  */
8077
8132
  JSONParse?: boolean;
8078
8133
  }
8079
- type JsonObjectFs = { [index: string]: JsonValueFs } & {
8134
+ declare interface JsonObjectFs {
8080
8135
  [index: string]:
8081
8136
  | undefined
8082
8137
  | null
@@ -8085,8 +8140,8 @@ type JsonObjectFs = { [index: string]: JsonValueFs } & {
8085
8140
  | boolean
8086
8141
  | JsonObjectFs
8087
8142
  | JsonValueFs[];
8088
- };
8089
- type JsonObjectTypes = { [index: string]: JsonValueTypes } & {
8143
+ }
8144
+ declare interface JsonObjectTypes {
8090
8145
  [index: string]:
8091
8146
  | undefined
8092
8147
  | null
@@ -8095,7 +8150,7 @@ type JsonObjectTypes = { [index: string]: JsonValueTypes } & {
8095
8150
  | boolean
8096
8151
  | JsonObjectTypes
8097
8152
  | JsonValueTypes[];
8098
- };
8153
+ }
8099
8154
 
8100
8155
  /**
8101
8156
  * Parser options for JSON modules.
@@ -8355,9 +8410,10 @@ declare interface KnownBuildMeta {
8355
8410
  strictHarmonyModule?: boolean;
8356
8411
  async?: boolean;
8357
8412
  sideEffectFree?: boolean;
8358
- exportsFinalName?: Record<string, string>;
8359
8413
  isCSSModule?: boolean;
8360
8414
  jsIncompatibleExports?: Record<string, string>;
8415
+ exportsFinalName?: Record<string, string>;
8416
+ factoryExportsBinding?: string;
8361
8417
  }
8362
8418
  declare interface KnownCreateStatsOptionsContext {
8363
8419
  forToString?: boolean;
@@ -9848,7 +9904,8 @@ declare class ModuleExternalInitFragment extends InitFragment<GenerateContext> {
9848
9904
  static STAGE_ASYNC_DEPENDENCIES: number;
9849
9905
  static STAGE_ASYNC_HARMONY_IMPORTS: number;
9850
9906
  }
9851
- declare abstract class ModuleFactory {
9907
+ declare class ModuleFactory {
9908
+ constructor();
9852
9909
  create(
9853
9910
  data: ModuleFactoryCreateData,
9854
9911
  callback: (err?: null | Error, result?: ModuleFactoryResult) => void
@@ -10355,6 +10412,57 @@ declare interface ModuleReferenceOptions {
10355
10412
  */
10356
10413
  asiSafe?: boolean;
10357
10414
  }
10415
+ declare interface ModuleRenderContext {
10416
+ /**
10417
+ * the chunk
10418
+ */
10419
+ chunk: Chunk;
10420
+
10421
+ /**
10422
+ * the dependency templates
10423
+ */
10424
+ dependencyTemplates: DependencyTemplates;
10425
+
10426
+ /**
10427
+ * the runtime template
10428
+ */
10429
+ runtimeTemplate: RuntimeTemplate;
10430
+
10431
+ /**
10432
+ * the module graph
10433
+ */
10434
+ moduleGraph: ModuleGraph;
10435
+
10436
+ /**
10437
+ * the chunk graph
10438
+ */
10439
+ chunkGraph: ChunkGraph;
10440
+
10441
+ /**
10442
+ * results of code generation
10443
+ */
10444
+ codeGenerationResults: CodeGenerationResults;
10445
+
10446
+ /**
10447
+ * init fragments for the chunk
10448
+ */
10449
+ chunkInitFragments: InitFragment<ChunkRenderContextJavascriptModulesPlugin>[];
10450
+
10451
+ /**
10452
+ * rendering in strict context
10453
+ */
10454
+ strictMode?: boolean;
10455
+
10456
+ /**
10457
+ * true: renders as factory method, false: pure module content
10458
+ */
10459
+ factory: boolean;
10460
+
10461
+ /**
10462
+ * the inlined entry module is wrapped in an IIFE, existing only when `factory` is set to false
10463
+ */
10464
+ inlinedInIIFE?: boolean;
10465
+ }
10358
10466
  declare interface ModuleResult {
10359
10467
  client: string;
10360
10468
  data: string;
@@ -10402,7 +10510,7 @@ declare abstract class ModuleTemplate {
10402
10510
  fn: (
10403
10511
  source: Source,
10404
10512
  module: Module,
10405
- chunkRenderContext: ChunkRenderContextJavascriptModulesPlugin,
10513
+ moduleRenderContext: ModuleRenderContext,
10406
10514
  dependencyTemplates: DependencyTemplates
10407
10515
  ) => Source
10408
10516
  ) => void;
@@ -10415,7 +10523,7 @@ declare abstract class ModuleTemplate {
10415
10523
  fn: (
10416
10524
  source: Source,
10417
10525
  module: Module,
10418
- chunkRenderContext: ChunkRenderContextJavascriptModulesPlugin,
10526
+ moduleRenderContext: ModuleRenderContext,
10419
10527
  dependencyTemplates: DependencyTemplates
10420
10528
  ) => Source
10421
10529
  ) => void;
@@ -15976,9 +16084,52 @@ declare abstract class StackedMap<K, V> {
15976
16084
  get size(): number;
15977
16085
  createChild(): StackedMap<K, V>;
15978
16086
  }
15979
- type StartupRenderContext = RenderContextJavascriptModulesPlugin & {
16087
+ declare interface StartupRenderContext {
16088
+ /**
16089
+ * the chunk
16090
+ */
16091
+ chunk: Chunk;
16092
+
16093
+ /**
16094
+ * the dependency templates
16095
+ */
16096
+ dependencyTemplates: DependencyTemplates;
16097
+
16098
+ /**
16099
+ * the runtime template
16100
+ */
16101
+ runtimeTemplate: RuntimeTemplate;
16102
+
16103
+ /**
16104
+ * the module graph
16105
+ */
16106
+ moduleGraph: ModuleGraph;
16107
+
16108
+ /**
16109
+ * the chunk graph
16110
+ */
16111
+ chunkGraph: ChunkGraph;
16112
+
16113
+ /**
16114
+ * results of code generation
16115
+ */
16116
+ codeGenerationResults: CodeGenerationResults;
16117
+
16118
+ /**
16119
+ * rendering in strict context
16120
+ */
16121
+ strictMode?: boolean;
16122
+
16123
+ /**
16124
+ * inlined
16125
+ */
15980
16126
  inlined: boolean;
15981
- };
16127
+
16128
+ /**
16129
+ * the inlined entry module is wrapped in an IIFE
16130
+ */
16131
+ inlinedInIIFE?: boolean;
16132
+ }
15982
16133
  declare interface StatFs {
15983
16134
  (
15984
16135
  path: PathLikeFs,
@@ -16851,13 +17002,18 @@ declare interface Values {
16851
17002
  declare class VariableInfo {
16852
17003
  constructor(
16853
17004
  declaredScope: ScopeInfo,
16854
- freeName?: string | true,
17005
+ name: undefined | string,
17006
+ flags: VariableInfoFlagsType,
16855
17007
  tagInfo?: TagInfo
16856
17008
  );
16857
17009
  declaredScope: ScopeInfo;
16858
- freeName?: string | true;
17010
+ name?: string;
17011
+ flags: VariableInfoFlagsType;
16859
17012
  tagInfo?: TagInfo;
17013
+ isFree(): boolean;
17014
+ isTagged(): boolean;
16860
17015
  }
17016
+ type VariableInfoFlagsType = 0 | 1 | 2 | 4;
16861
17017
  declare interface VirtualModuleConfig {
16862
17018
  /**
16863
17019
  * - The module type
@@ -18147,6 +18303,7 @@ declare namespace exports {
18147
18303
  LoaderOptionsPlugin,
18148
18304
  LoaderTargetPlugin,
18149
18305
  Module,
18306
+ ModuleFactory,
18150
18307
  ModuleGraph,
18151
18308
  ModuleGraphConnection,
18152
18309
  NoEmitOnErrorsPlugin,
@@ -18210,6 +18367,9 @@ declare namespace exports {
18210
18367
  ParserState,
18211
18368
  ResolvePluginInstance,
18212
18369
  Resolver,
18370
+ RenderManifestEntry,
18371
+ RenderManifestOptions,
18372
+ TemplatePath,
18213
18373
  Watching,
18214
18374
  Argument,
18215
18375
  Problem,
@@ -18229,6 +18389,8 @@ declare namespace exports {
18229
18389
  StatsModuleTraceDependency,
18230
18390
  StatsModuleTraceItem,
18231
18391
  StatsProfile,
18392
+ ObjectSerializerContext,
18393
+ ObjectDeserializerContext,
18232
18394
  InputFileSystem,
18233
18395
  OutputFileSystem,
18234
18396
  LoaderModule,