rollup 4.34.9 → 4.36.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/dist/bin/rollup CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  /*
3
3
  @license
4
- Rollup.js v4.34.9
5
- Sat, 01 Mar 2025 07:32:06 GMT - commit 0ab9b9772e24dfe9ef08bfce3132e99a15b793f6
4
+ Rollup.js v4.36.0
5
+ Mon, 17 Mar 2025 08:35:11 GMT - commit ab7bfa8fe9c25e41cc62058fa2dcde6b321fd51d
6
6
 
7
7
  https://github.com/rollup/rollup
8
8
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.34.9
4
- Sat, 01 Mar 2025 07:32:06 GMT - commit 0ab9b9772e24dfe9ef08bfce3132e99a15b793f6
3
+ Rollup.js v4.36.0
4
+ Mon, 17 Mar 2025 08:35:11 GMT - commit ab7bfa8fe9c25e41cc62058fa2dcde6b321fd51d
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.34.9
4
- Sat, 01 Mar 2025 07:32:06 GMT - commit 0ab9b9772e24dfe9ef08bfce3132e99a15b793f6
3
+ Rollup.js v4.36.0
4
+ Mon, 17 Mar 2025 08:35:11 GMT - commit ab7bfa8fe9c25e41cc62058fa2dcde6b321fd51d
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/es/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.34.9
4
- Sat, 01 Mar 2025 07:32:06 GMT - commit 0ab9b9772e24dfe9ef08bfce3132e99a15b793f6
3
+ Rollup.js v4.36.0
4
+ Mon, 17 Mar 2025 08:35:11 GMT - commit ab7bfa8fe9c25e41cc62058fa2dcde6b321fd51d
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.34.9
4
- Sat, 01 Mar 2025 07:32:06 GMT - commit 0ab9b9772e24dfe9ef08bfce3132e99a15b793f6
3
+ Rollup.js v4.36.0
4
+ Mon, 17 Mar 2025 08:35:11 GMT - commit ab7bfa8fe9c25e41cc62058fa2dcde6b321fd51d
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -15,7 +15,7 @@ import process$1, { env } from 'node:process';
15
15
  import { performance } from 'node:perf_hooks';
16
16
  import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
17
17
 
18
- var version = "4.34.9";
18
+ var version = "4.36.0";
19
19
 
20
20
  const comma = ','.charCodeAt(0);
21
21
  const semicolon = ';'.charCodeAt(0);
@@ -8297,58 +8297,114 @@ function updateExtensionForRelativeAmdId(id, forceJsExtensionForImports) {
8297
8297
  }
8298
8298
 
8299
8299
  const builtinModules = [
8300
+ "node:assert",
8300
8301
  "assert",
8302
+ "node:assert/strict",
8301
8303
  "assert/strict",
8304
+ "node:async_hooks",
8302
8305
  "async_hooks",
8306
+ "node:buffer",
8303
8307
  "buffer",
8308
+ "node:child_process",
8304
8309
  "child_process",
8310
+ "node:cluster",
8305
8311
  "cluster",
8312
+ "node:console",
8306
8313
  "console",
8314
+ "node:constants",
8307
8315
  "constants",
8316
+ "node:crypto",
8308
8317
  "crypto",
8318
+ "node:dgram",
8309
8319
  "dgram",
8320
+ "node:diagnostics_channel",
8310
8321
  "diagnostics_channel",
8322
+ "node:dns",
8311
8323
  "dns",
8324
+ "node:dns/promises",
8312
8325
  "dns/promises",
8326
+ "node:domain",
8313
8327
  "domain",
8328
+ "node:events",
8314
8329
  "events",
8330
+ "node:fs",
8315
8331
  "fs",
8332
+ "node:fs/promises",
8316
8333
  "fs/promises",
8334
+ "node:http",
8317
8335
  "http",
8336
+ "node:http2",
8318
8337
  "http2",
8338
+ "node:https",
8319
8339
  "https",
8340
+ "node:inspector",
8320
8341
  "inspector",
8342
+ "node:inspector/promises",
8321
8343
  "inspector/promises",
8344
+ "node:module",
8322
8345
  "module",
8346
+ "node:net",
8323
8347
  "net",
8348
+ "node:os",
8324
8349
  "os",
8350
+ "node:path",
8325
8351
  "path",
8352
+ "node:path/posix",
8326
8353
  "path/posix",
8354
+ "node:path/win32",
8327
8355
  "path/win32",
8356
+ "node:perf_hooks",
8328
8357
  "perf_hooks",
8358
+ "node:process",
8329
8359
  "process",
8330
- "punycode",
8360
+ "node:querystring",
8331
8361
  "querystring",
8362
+ "node:quic",
8363
+ "node:readline",
8332
8364
  "readline",
8365
+ "node:readline/promises",
8333
8366
  "readline/promises",
8367
+ "node:repl",
8334
8368
  "repl",
8369
+ "node:sea",
8370
+ "node:sqlite",
8371
+ "node:stream",
8335
8372
  "stream",
8373
+ "node:stream/consumers",
8336
8374
  "stream/consumers",
8375
+ "node:stream/promises",
8337
8376
  "stream/promises",
8377
+ "node:stream/web",
8338
8378
  "stream/web",
8379
+ "node:string_decoder",
8339
8380
  "string_decoder",
8381
+ "node:test",
8382
+ "node:test/reporters",
8383
+ "node:timers",
8340
8384
  "timers",
8385
+ "node:timers/promises",
8341
8386
  "timers/promises",
8387
+ "node:tls",
8342
8388
  "tls",
8389
+ "node:trace_events",
8343
8390
  "trace_events",
8391
+ "node:tty",
8344
8392
  "tty",
8393
+ "node:url",
8345
8394
  "url",
8395
+ "node:util",
8346
8396
  "util",
8397
+ "node:util/types",
8347
8398
  "util/types",
8399
+ "node:v8",
8348
8400
  "v8",
8401
+ "node:vm",
8349
8402
  "vm",
8403
+ "node:wasi",
8350
8404
  "wasi",
8405
+ "node:worker_threads",
8351
8406
  "worker_threads",
8407
+ "node:zlib",
8352
8408
  "zlib"
8353
8409
  ];
8354
8410
 
@@ -8933,7 +8989,7 @@ function getDefaultExportFromCjs (x) {
8933
8989
  }
8934
8990
 
8935
8991
  function getAugmentedNamespace(n) {
8936
- if (n.__esModule) return n;
8992
+ if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
8937
8993
  var f = n.default;
8938
8994
  if (typeof f == "function") {
8939
8995
  var a = function a () {
@@ -11601,6 +11657,12 @@ class AssignmentPattern extends NodeBase {
11601
11657
  }
11602
11658
 
11603
11659
  class AwaitExpression extends NodeBase {
11660
+ get isTopLevelAwait() {
11661
+ return isFlagSet(this.flags, 134217728 /* Flag.isTopLevelAwait */);
11662
+ }
11663
+ set isTopLevelAwait(value) {
11664
+ this.flags = setFlag(this.flags, 134217728 /* Flag.isTopLevelAwait */, value);
11665
+ }
11604
11666
  hasEffects() {
11605
11667
  if (!this.deoptimized)
11606
11668
  this.applyDeoptimizations();
@@ -11615,13 +11677,14 @@ class AwaitExpression extends NodeBase {
11615
11677
  this.included = true;
11616
11678
  if (!this.deoptimized)
11617
11679
  this.applyDeoptimizations();
11618
- checkTopLevelAwait: if (!this.scope.context.usesTopLevelAwait) {
11680
+ checkTopLevelAwait: {
11619
11681
  let parent = this.parent;
11620
11682
  do {
11621
11683
  if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression)
11622
11684
  break checkTopLevelAwait;
11623
11685
  } while ((parent = parent.parent));
11624
11686
  this.scope.context.usesTopLevelAwait = true;
11687
+ this.isTopLevelAwait = true;
11625
11688
  }
11626
11689
  // Thenables need to be included
11627
11690
  this.argument.includePath(THEN_PATH, context);
@@ -12831,6 +12894,9 @@ class VariableDeclarator extends NodeBase {
12831
12894
  }
12832
12895
  VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
12833
12896
 
12897
+ function getChunkInfoWithPath(chunk) {
12898
+ return { fileName: chunk.getFileName(), ...chunk.getPreRenderedChunkInfo() };
12899
+ }
12834
12900
  class ImportExpression extends NodeBase {
12835
12901
  constructor() {
12836
12902
  super(...arguments);
@@ -12847,6 +12913,9 @@ class ImportExpression extends NodeBase {
12847
12913
  bind() {
12848
12914
  this.source.bind();
12849
12915
  }
12916
+ get isFollowingTopLevelAwait() {
12917
+ return this.parent instanceof AwaitExpression && this.parent.isTopLevelAwait;
12918
+ }
12850
12919
  /**
12851
12920
  * Get imported variables for deterministic usage, valid cases are:
12852
12921
  *
@@ -12999,7 +13068,7 @@ class ImportExpression extends NodeBase {
12999
13068
  }
13000
13069
  }
13001
13070
  }
13002
- setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, attributes) {
13071
+ setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, attributes, ownChunk, targetChunk) {
13003
13072
  const { format } = options;
13004
13073
  this.inlineNamespace = null;
13005
13074
  this.resolution = resolution;
@@ -13008,7 +13077,7 @@ class ImportExpression extends NodeBase {
13008
13077
  this.attributes = attributes;
13009
13078
  const accessedGlobals = [...(accessedImportGlobals[format] || [])];
13010
13079
  let helper;
13011
- ({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver));
13080
+ ({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver, ownChunk, targetChunk));
13012
13081
  if (helper) {
13013
13082
  accessedGlobals.push(helper);
13014
13083
  }
@@ -13019,12 +13088,39 @@ class ImportExpression extends NodeBase {
13019
13088
  setInternalResolution(inlineNamespace) {
13020
13089
  this.inlineNamespace = inlineNamespace;
13021
13090
  }
13022
- getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
13091
+ getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver, ownChunk, targetChunk) {
13023
13092
  const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
13024
13093
  {
13094
+ chunk: getChunkInfoWithPath(ownChunk),
13025
13095
  customResolution: typeof this.resolution === 'string' ? this.resolution : null,
13026
13096
  format,
13097
+ getTargetChunkImports() {
13098
+ if (targetChunk === null)
13099
+ return null;
13100
+ const chunkInfos = [];
13101
+ const importerPath = ownChunk.getFileName();
13102
+ for (const dep of targetChunk.dependencies) {
13103
+ const resolvedImportPath = `'${dep.getImportPath(importerPath)}'`;
13104
+ if (dep instanceof ExternalChunk) {
13105
+ chunkInfos.push({
13106
+ fileName: dep.getFileName(),
13107
+ resolvedImportPath,
13108
+ type: 'external'
13109
+ });
13110
+ }
13111
+ else {
13112
+ chunkInfos.push({
13113
+ chunk: dep.getPreRenderedChunkInfo(),
13114
+ fileName: dep.getFileName(),
13115
+ resolvedImportPath,
13116
+ type: 'internal'
13117
+ });
13118
+ }
13119
+ }
13120
+ return chunkInfos;
13121
+ },
13027
13122
  moduleId: this.scope.context.module.id,
13123
+ targetChunk: targetChunk ? getChunkInfoWithPath(targetChunk) : null,
13028
13124
  targetModuleId: this.resolution && typeof this.resolution !== 'string' ? this.resolution.id : null
13029
13125
  }
13030
13126
  ]);
@@ -16474,6 +16570,7 @@ class Module {
16474
16570
  this.importedFromNotTreeshaken = false;
16475
16571
  this.importers = [];
16476
16572
  this.includedDynamicImporters = [];
16573
+ this.includedDirectTopLevelAwaitingDynamicImporters = new Set();
16477
16574
  this.includedImports = new Set();
16478
16575
  this.isExecuted = false;
16479
16576
  this.isUserDefinedEntryPoint = false;
@@ -17330,6 +17427,9 @@ class Module {
17330
17427
  if (resolution instanceof Module) {
17331
17428
  if (!resolution.includedDynamicImporters.includes(this)) {
17332
17429
  resolution.includedDynamicImporters.push(this);
17430
+ if (node.isFollowingTopLevelAwait) {
17431
+ resolution.includedDirectTopLevelAwaitingDynamicImporters.add(this);
17432
+ }
17333
17433
  }
17334
17434
  const importedNames = this.options.treeshake
17335
17435
  ? node.getDeterministicImportedNames()
@@ -17823,13 +17923,13 @@ class Chunk {
17823
17923
  this.bundle = bundle;
17824
17924
  this.inputBase = inputBase;
17825
17925
  this.snippets = snippets;
17926
+ this.dependencies = new Set();
17826
17927
  this.entryModules = [];
17827
17928
  this.exportMode = 'named';
17828
17929
  this.facadeModule = null;
17829
17930
  this.namespaceVariableName = '';
17830
17931
  this.variableName = '';
17831
17932
  this.accessedGlobalsByScope = new Map();
17832
- this.dependencies = new Set();
17833
17933
  this.dynamicEntryModules = [];
17834
17934
  this.dynamicName = null;
17835
17935
  this.exportNamesByVariable = new Map();
@@ -18134,9 +18234,9 @@ class Chunk {
18134
18234
  this.setUpChunkImportsAndExportsForModule(module);
18135
18235
  }
18136
18236
  }
18137
- async render() {
18138
- const { dependencies, exportMode, facadeModule, inputOptions: { onLog }, outputOptions, pluginDriver, snippets } = this;
18139
- const { format, hoistTransitiveImports, preserveModules } = outputOptions;
18237
+ inlineTransitiveImports() {
18238
+ const { facadeModule, dependencies, outputOptions } = this;
18239
+ const { hoistTransitiveImports, preserveModules } = outputOptions;
18140
18240
  // for static and dynamic entry points, add transitive dependencies to this
18141
18241
  // chunk's dependencies to avoid loading latency
18142
18242
  if (hoistTransitiveImports && !preserveModules && facadeModule !== null) {
@@ -18145,6 +18245,10 @@ class Chunk {
18145
18245
  this.inlineChunkDependencies(dep);
18146
18246
  }
18147
18247
  }
18248
+ }
18249
+ async render() {
18250
+ const { exportMode, facadeModule, inputOptions: { onLog }, outputOptions, pluginDriver, snippets } = this;
18251
+ const { format, preserveModules } = outputOptions;
18148
18252
  const preliminaryFileName = this.getPreliminaryFileName();
18149
18253
  const preliminarySourcemapFileName = this.getPreliminarySourcemapFileName();
18150
18254
  const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = this.renderModules(preliminaryFileName.fileName);
@@ -18727,13 +18831,13 @@ class Chunk {
18727
18831
  node.setInternalResolution(resolution.namespace);
18728
18832
  }
18729
18833
  else {
18730
- node.setExternalResolution((facadeChunk || chunk).exportMode, resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, `'${(facadeChunk || chunk).getImportPath(fileName)}'`, !facadeChunk?.strictFacade && chunk.exportNamesByVariable.get(resolution.namespace)[0], null);
18834
+ node.setExternalResolution((facadeChunk || chunk).exportMode, resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, `'${(facadeChunk || chunk).getImportPath(fileName)}'`, !facadeChunk?.strictFacade && chunk.exportNamesByVariable.get(resolution.namespace)[0], null, this, facadeChunk || chunk);
18731
18835
  }
18732
18836
  }
18733
18837
  else {
18734
18838
  const { node, resolution } = resolvedDynamicImport;
18735
18839
  const [resolutionString, attributes] = this.getDynamicImportStringAndAttributes(resolution, fileName, node);
18736
- node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes);
18840
+ node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes, this, null);
18737
18841
  }
18738
18842
  }
18739
18843
  }
@@ -18999,15 +19103,16 @@ function* concatLazy(iterables) {
18999
19103
  */
19000
19104
  function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log) {
19001
19105
  const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry);
19002
- const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry } = analyzeModuleGraph(entries);
19106
+ const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry } = analyzeModuleGraph(entries);
19003
19107
  // Each chunk is identified by its position in this array
19004
19108
  const chunkAtoms = getChunksWithSameDependentEntries(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks));
19005
19109
  const staticDependencyAtomsByEntry = getStaticDependencyAtomsByEntry(allEntries, chunkAtoms);
19006
19110
  // Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
19007
19111
  // If we no longer want this, we should make a copy here.
19008
19112
  const alreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
19113
+ const awaitedAlreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry, allEntries);
19009
19114
  // This mutates the dependentEntries in chunkAtoms
19010
- removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry);
19115
+ removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry, awaitedAlreadyLoadedAtomsByEntry);
19011
19116
  const { chunks, sideEffectAtoms, sizeByAtom } = getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize);
19012
19117
  chunkDefinitions.push(...getOptimizedChunks(chunks, minChunkSize, sideEffectAtoms, sizeByAtom, log).map(({ modules }) => ({
19013
19118
  alias: null,
@@ -19043,13 +19148,17 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
19043
19148
  }
19044
19149
  function analyzeModuleGraph(entries) {
19045
19150
  const dynamicEntryModules = new Set();
19151
+ const awaitedDynamicEntryModules = new Set();
19046
19152
  const dependentEntriesByModule = new Map();
19047
19153
  const allEntriesSet = new Set(entries);
19048
19154
  const dynamicImportModulesByEntry = new Array(allEntriesSet.size);
19155
+ const awaitedDynamicImportModulesByEntry = new Array(allEntriesSet.size);
19049
19156
  let entryIndex = 0;
19050
19157
  for (const currentEntry of allEntriesSet) {
19051
19158
  const dynamicImportsForCurrentEntry = new Set();
19159
+ const awaitedDynamicImportsForCurrentEntry = new Set();
19052
19160
  dynamicImportModulesByEntry[entryIndex] = dynamicImportsForCurrentEntry;
19161
+ awaitedDynamicImportModulesByEntry[entryIndex] = awaitedDynamicImportsForCurrentEntry;
19053
19162
  const modulesToHandle = new Set([currentEntry]);
19054
19163
  for (const module of modulesToHandle) {
19055
19164
  getOrCreate(dependentEntriesByModule, module, (getNewSet)).add(entryIndex);
@@ -19065,6 +19174,10 @@ function analyzeModuleGraph(entries) {
19065
19174
  dynamicEntryModules.add(resolution);
19066
19175
  allEntriesSet.add(resolution);
19067
19176
  dynamicImportsForCurrentEntry.add(resolution);
19177
+ if (resolution.includedDirectTopLevelAwaitingDynamicImporters.has(currentEntry)) {
19178
+ awaitedDynamicEntryModules.add(resolution);
19179
+ awaitedDynamicImportsForCurrentEntry.add(resolution);
19180
+ }
19068
19181
  }
19069
19182
  }
19070
19183
  for (const dependency of module.implicitlyLoadedBefore) {
@@ -19077,23 +19190,39 @@ function analyzeModuleGraph(entries) {
19077
19190
  entryIndex++;
19078
19191
  }
19079
19192
  const allEntries = [...allEntriesSet];
19080
- const { dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry);
19193
+ const { awaitedDynamicEntries, awaitedDynamicImportsByEntry, dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry, awaitedDynamicEntryModules, awaitedDynamicImportModulesByEntry);
19081
19194
  return {
19082
19195
  allEntries,
19196
+ awaitedDynamicImportsByEntry,
19083
19197
  dependentEntriesByModule,
19084
- dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries),
19198
+ dynamicallyDependentEntriesByAwaitedDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, awaitedDynamicEntries, allEntries, dynamicEntry => dynamicEntry.includedDirectTopLevelAwaitingDynamicImporters),
19199
+ dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries, dynamicEntry => dynamicEntry.includedDynamicImporters),
19085
19200
  dynamicImportsByEntry
19086
19201
  };
19087
19202
  }
19088
- function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry) {
19203
+ function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry, awaitedDynamicEntryModules, awaitedDynamicImportModulesByEntry) {
19089
19204
  const entryIndexByModule = new Map();
19090
19205
  const dynamicEntries = new Set();
19206
+ const awaitedDynamicEntries = new Set();
19091
19207
  for (const [entryIndex, entry] of allEntries.entries()) {
19092
19208
  entryIndexByModule.set(entry, entryIndex);
19093
19209
  if (dynamicEntryModules.has(entry)) {
19094
19210
  dynamicEntries.add(entryIndex);
19095
19211
  }
19212
+ if (awaitedDynamicEntryModules.has(entry)) {
19213
+ awaitedDynamicEntries.add(entryIndex);
19214
+ }
19096
19215
  }
19216
+ const dynamicImportsByEntry = getDynamicImportsByEntry(dynamicImportModulesByEntry, entryIndexByModule);
19217
+ const awaitedDynamicImportsByEntry = getDynamicImportsByEntry(awaitedDynamicImportModulesByEntry, entryIndexByModule);
19218
+ return {
19219
+ awaitedDynamicEntries,
19220
+ awaitedDynamicImportsByEntry,
19221
+ dynamicEntries,
19222
+ dynamicImportsByEntry
19223
+ };
19224
+ }
19225
+ function getDynamicImportsByEntry(dynamicImportModulesByEntry, entryIndexByModule) {
19097
19226
  const dynamicImportsByEntry = new Array(dynamicImportModulesByEntry.length);
19098
19227
  let index = 0;
19099
19228
  for (const dynamicImportModules of dynamicImportModulesByEntry) {
@@ -19103,15 +19232,15 @@ function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModules
19103
19232
  }
19104
19233
  dynamicImportsByEntry[index++] = dynamicImports;
19105
19234
  }
19106
- return { dynamicEntries, dynamicImportsByEntry };
19235
+ return dynamicImportsByEntry;
19107
19236
  }
19108
- function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries) {
19237
+ function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries, getDynamicImporters) {
19109
19238
  const dynamicallyDependentEntriesByDynamicEntry = new Map();
19110
19239
  for (const dynamicEntryIndex of dynamicEntries) {
19111
19240
  const dynamicallyDependentEntries = getOrCreate(dynamicallyDependentEntriesByDynamicEntry, dynamicEntryIndex, (getNewSet));
19112
19241
  const dynamicEntry = allEntries[dynamicEntryIndex];
19113
19242
  for (const importer of concatLazy([
19114
- dynamicEntry.includedDynamicImporters,
19243
+ getDynamicImporters(dynamicEntry),
19115
19244
  dynamicEntry.implicitlyLoadedAfter
19116
19245
  ])) {
19117
19246
  for (const entry of dependentEntriesByModule.get(importer)) {
@@ -19190,13 +19319,15 @@ function getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyD
19190
19319
  * This removes all unnecessary dynamic entries from the dependentEntries in its
19191
19320
  * first argument if a chunk is already loaded without that entry.
19192
19321
  */
19193
- function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry) {
19322
+ function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry, awaitedAlreadyLoadedAtomsByEntry) {
19194
19323
  // Remove entries from dependent entries if a chunk is already loaded without
19195
- // that entry.
19324
+ // that entry. Do not remove already loaded atoms where all dynamic imports
19325
+ // are awaited to avoid cycles in the output.
19196
19326
  let chunkMask = 1n;
19197
19327
  for (const { dependentEntries } of chunkAtoms) {
19198
19328
  for (const entryIndex of dependentEntries) {
19199
- if ((alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask) {
19329
+ if ((alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask &&
19330
+ (awaitedAlreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === 0n) {
19200
19331
  dependentEntries.delete(entryIndex);
19201
19332
  }
19202
19333
  }
@@ -20103,6 +20234,7 @@ class Bundle {
20103
20234
  this.pluginDriver.setChunkInformation(this.facadeChunkByModule);
20104
20235
  for (const chunk of chunks) {
20105
20236
  chunk.generateExports();
20237
+ chunk.inlineTransitiveImports();
20106
20238
  }
20107
20239
  timeEnd('generate chunks', 2);
20108
20240
  await renderChunks(chunks, outputBundle, this.pluginDriver, this.outputOptions, this.inputOptions.onLog);
@@ -22725,11 +22857,28 @@ async function rollupInternal(rawInputOptions, watcher) {
22725
22857
  if (watchFiles.length > 0) {
22726
22858
  error_.watchFiles = watchFiles;
22727
22859
  }
22728
- await graph.pluginDriver.hookParallel('buildEnd', [error_]);
22729
- await graph.pluginDriver.hookParallel('closeBundle', []);
22860
+ try {
22861
+ await graph.pluginDriver.hookParallel('buildEnd', [error_]);
22862
+ }
22863
+ catch (buildEndError) {
22864
+ // Create a compound error object to include both errors, based on the original error
22865
+ const compoundError = getRollupError({
22866
+ ...error_,
22867
+ message: `There was an error during the build:\n ${error_.message}\nAdditionally, handling the error in the 'buildEnd' hook caused the following error:\n ${buildEndError.message}`
22868
+ });
22869
+ await graph.pluginDriver.hookParallel('closeBundle', [compoundError]);
22870
+ throw compoundError;
22871
+ }
22872
+ await graph.pluginDriver.hookParallel('closeBundle', [error_]);
22730
22873
  throw error_;
22731
22874
  }
22732
- await graph.pluginDriver.hookParallel('buildEnd', []);
22875
+ try {
22876
+ await graph.pluginDriver.hookParallel('buildEnd', []);
22877
+ }
22878
+ catch (buildEndError) {
22879
+ await graph.pluginDriver.hookParallel('closeBundle', [buildEndError]);
22880
+ throw buildEndError;
22881
+ }
22733
22882
  });
22734
22883
  timeEnd('BUILD', 1);
22735
22884
  const result = {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.34.9
4
- Sat, 01 Mar 2025 07:32:06 GMT - commit 0ab9b9772e24dfe9ef08bfce3132e99a15b793f6
3
+ Rollup.js v4.36.0
4
+ Mon, 17 Mar 2025 08:35:11 GMT - commit ab7bfa8fe9c25e41cc62058fa2dcde6b321fd51d
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.34.9
4
- Sat, 01 Mar 2025 07:32:06 GMT - commit 0ab9b9772e24dfe9ef08bfce3132e99a15b793f6
3
+ Rollup.js v4.36.0
4
+ Mon, 17 Mar 2025 08:35:11 GMT - commit ab7bfa8fe9c25e41cc62058fa2dcde6b321fd51d
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.34.9
4
- Sat, 01 Mar 2025 07:32:06 GMT - commit 0ab9b9772e24dfe9ef08bfce3132e99a15b793f6
3
+ Rollup.js v4.36.0
4
+ Mon, 17 Mar 2025 08:35:11 GMT - commit ab7bfa8fe9c25e41cc62058fa2dcde6b321fd51d
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.34.9
4
- Sat, 01 Mar 2025 07:32:06 GMT - commit 0ab9b9772e24dfe9ef08bfce3132e99a15b793f6
3
+ Rollup.js v4.36.0
4
+ Mon, 17 Mar 2025 08:35:11 GMT - commit ab7bfa8fe9c25e41cc62058fa2dcde6b321fd51d
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/parseAst.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.34.9
4
- Sat, 01 Mar 2025 07:32:06 GMT - commit 0ab9b9772e24dfe9ef08bfce3132e99a15b793f6
3
+ Rollup.js v4.36.0
4
+ Mon, 17 Mar 2025 08:35:11 GMT - commit ab7bfa8fe9c25e41cc62058fa2dcde6b321fd51d
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/rollup.d.ts CHANGED
@@ -190,7 +190,7 @@ export type EmittedFile = EmittedAsset | EmittedChunk | EmittedPrebuiltChunk;
190
190
 
191
191
  export type EmitFile = (emittedFile: EmittedFile) => string;
192
192
 
193
- interface ModuleInfo extends ModuleOptions {
193
+ export interface ModuleInfo extends ModuleOptions {
194
194
  ast: ProgramNode | null;
195
195
  code: string | null;
196
196
  dynamicImporters: readonly string[];
@@ -280,7 +280,7 @@ export interface ResolvedId extends ModuleOptions {
280
280
 
281
281
  export type ResolvedIdMap = Record<string, ResolvedId>;
282
282
 
283
- interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
283
+ export interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
284
284
  external?: boolean | 'absolute' | 'relative';
285
285
  id: string;
286
286
  resolvedBy?: string;
@@ -400,11 +400,28 @@ export type PluginImpl<O extends object = object, A = any> = (options?: O) => Pl
400
400
 
401
401
  export type OutputBundle = Record<string, OutputAsset | OutputChunk>;
402
402
 
403
+ export type PreRenderedChunkWithFileName = PreRenderedChunk & { fileName: string };
404
+
405
+ export interface ImportedInternalChunk {
406
+ type: 'internal';
407
+ fileName: string;
408
+ resolvedImportPath: string;
409
+ chunk: PreRenderedChunk;
410
+ }
411
+
412
+ export interface ImportedExternalChunk {
413
+ type: 'external';
414
+ fileName: string;
415
+ resolvedImportPath: string;
416
+ }
417
+
418
+ export type DynamicImportTargetChunk = ImportedInternalChunk | ImportedExternalChunk;
419
+
403
420
  export interface FunctionPluginHooks {
404
421
  augmentChunkHash: (this: PluginContext, chunk: RenderedChunk) => string | void;
405
422
  buildEnd: (this: PluginContext, error?: Error) => void;
406
423
  buildStart: (this: PluginContext, options: NormalizedInputOptions) => void;
407
- closeBundle: (this: PluginContext) => void;
424
+ closeBundle: (this: PluginContext, error?: Error) => void;
408
425
  closeWatcher: (this: PluginContext) => void;
409
426
  generateBundle: (
410
427
  this: PluginContext,
@@ -425,6 +442,9 @@ export interface FunctionPluginHooks {
425
442
  format: InternalModuleFormat;
426
443
  moduleId: string;
427
444
  targetModuleId: string | null;
445
+ chunk: PreRenderedChunkWithFileName;
446
+ targetChunk: PreRenderedChunkWithFileName | null;
447
+ getTargetChunkImports: () => DynamicImportTargetChunk[] | null;
428
448
  }
429
449
  ) => { left: string; right: string } | NullValue;
430
450
  renderError: (this: PluginContext, error?: Error) => void;
@@ -504,7 +524,7 @@ type MakeAsync<Function_> = Function_ extends (
504
524
  : never;
505
525
 
506
526
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
507
- type ObjectHook<T, O = {}> = T | ({ handler: T; order?: 'pre' | 'post' | null } & O);
527
+ export type ObjectHook<T, O = {}> = T | ({ handler: T; order?: 'pre' | 'post' | null } & O);
508
528
 
509
529
  export type PluginHooks = {
510
530
  [K in keyof FunctionPluginHooks]: ObjectHook<
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.34.9
4
- Sat, 01 Mar 2025 07:32:06 GMT - commit 0ab9b9772e24dfe9ef08bfce3132e99a15b793f6
3
+ Rollup.js v4.36.0
4
+ Mon, 17 Mar 2025 08:35:11 GMT - commit ab7bfa8fe9c25e41cc62058fa2dcde6b321fd51d
5
5
 
6
6
  https://github.com/rollup/rollup
7
7