rollup 4.35.0 → 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.35.0
5
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0";
18
+ var version = "4.36.0";
19
19
 
20
20
  const comma = ','.charCodeAt(0);
21
21
  const semicolon = ';'.charCodeAt(0);
@@ -11657,6 +11657,12 @@ class AssignmentPattern extends NodeBase {
11657
11657
  }
11658
11658
 
11659
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
+ }
11660
11666
  hasEffects() {
11661
11667
  if (!this.deoptimized)
11662
11668
  this.applyDeoptimizations();
@@ -11671,13 +11677,14 @@ class AwaitExpression extends NodeBase {
11671
11677
  this.included = true;
11672
11678
  if (!this.deoptimized)
11673
11679
  this.applyDeoptimizations();
11674
- checkTopLevelAwait: if (!this.scope.context.usesTopLevelAwait) {
11680
+ checkTopLevelAwait: {
11675
11681
  let parent = this.parent;
11676
11682
  do {
11677
11683
  if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression)
11678
11684
  break checkTopLevelAwait;
11679
11685
  } while ((parent = parent.parent));
11680
11686
  this.scope.context.usesTopLevelAwait = true;
11687
+ this.isTopLevelAwait = true;
11681
11688
  }
11682
11689
  // Thenables need to be included
11683
11690
  this.argument.includePath(THEN_PATH, context);
@@ -12887,6 +12894,9 @@ class VariableDeclarator extends NodeBase {
12887
12894
  }
12888
12895
  VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
12889
12896
 
12897
+ function getChunkInfoWithPath(chunk) {
12898
+ return { fileName: chunk.getFileName(), ...chunk.getPreRenderedChunkInfo() };
12899
+ }
12890
12900
  class ImportExpression extends NodeBase {
12891
12901
  constructor() {
12892
12902
  super(...arguments);
@@ -12903,6 +12913,9 @@ class ImportExpression extends NodeBase {
12903
12913
  bind() {
12904
12914
  this.source.bind();
12905
12915
  }
12916
+ get isFollowingTopLevelAwait() {
12917
+ return this.parent instanceof AwaitExpression && this.parent.isTopLevelAwait;
12918
+ }
12906
12919
  /**
12907
12920
  * Get imported variables for deterministic usage, valid cases are:
12908
12921
  *
@@ -13055,7 +13068,7 @@ class ImportExpression extends NodeBase {
13055
13068
  }
13056
13069
  }
13057
13070
  }
13058
- setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, attributes) {
13071
+ setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, attributes, ownChunk, targetChunk) {
13059
13072
  const { format } = options;
13060
13073
  this.inlineNamespace = null;
13061
13074
  this.resolution = resolution;
@@ -13064,7 +13077,7 @@ class ImportExpression extends NodeBase {
13064
13077
  this.attributes = attributes;
13065
13078
  const accessedGlobals = [...(accessedImportGlobals[format] || [])];
13066
13079
  let helper;
13067
- ({ 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));
13068
13081
  if (helper) {
13069
13082
  accessedGlobals.push(helper);
13070
13083
  }
@@ -13075,12 +13088,39 @@ class ImportExpression extends NodeBase {
13075
13088
  setInternalResolution(inlineNamespace) {
13076
13089
  this.inlineNamespace = inlineNamespace;
13077
13090
  }
13078
- 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) {
13079
13092
  const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
13080
13093
  {
13094
+ chunk: getChunkInfoWithPath(ownChunk),
13081
13095
  customResolution: typeof this.resolution === 'string' ? this.resolution : null,
13082
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
+ },
13083
13122
  moduleId: this.scope.context.module.id,
13123
+ targetChunk: targetChunk ? getChunkInfoWithPath(targetChunk) : null,
13084
13124
  targetModuleId: this.resolution && typeof this.resolution !== 'string' ? this.resolution.id : null
13085
13125
  }
13086
13126
  ]);
@@ -16530,6 +16570,7 @@ class Module {
16530
16570
  this.importedFromNotTreeshaken = false;
16531
16571
  this.importers = [];
16532
16572
  this.includedDynamicImporters = [];
16573
+ this.includedDirectTopLevelAwaitingDynamicImporters = new Set();
16533
16574
  this.includedImports = new Set();
16534
16575
  this.isExecuted = false;
16535
16576
  this.isUserDefinedEntryPoint = false;
@@ -17386,6 +17427,9 @@ class Module {
17386
17427
  if (resolution instanceof Module) {
17387
17428
  if (!resolution.includedDynamicImporters.includes(this)) {
17388
17429
  resolution.includedDynamicImporters.push(this);
17430
+ if (node.isFollowingTopLevelAwait) {
17431
+ resolution.includedDirectTopLevelAwaitingDynamicImporters.add(this);
17432
+ }
17389
17433
  }
17390
17434
  const importedNames = this.options.treeshake
17391
17435
  ? node.getDeterministicImportedNames()
@@ -17879,13 +17923,13 @@ class Chunk {
17879
17923
  this.bundle = bundle;
17880
17924
  this.inputBase = inputBase;
17881
17925
  this.snippets = snippets;
17926
+ this.dependencies = new Set();
17882
17927
  this.entryModules = [];
17883
17928
  this.exportMode = 'named';
17884
17929
  this.facadeModule = null;
17885
17930
  this.namespaceVariableName = '';
17886
17931
  this.variableName = '';
17887
17932
  this.accessedGlobalsByScope = new Map();
17888
- this.dependencies = new Set();
17889
17933
  this.dynamicEntryModules = [];
17890
17934
  this.dynamicName = null;
17891
17935
  this.exportNamesByVariable = new Map();
@@ -18190,9 +18234,9 @@ class Chunk {
18190
18234
  this.setUpChunkImportsAndExportsForModule(module);
18191
18235
  }
18192
18236
  }
18193
- async render() {
18194
- const { dependencies, exportMode, facadeModule, inputOptions: { onLog }, outputOptions, pluginDriver, snippets } = this;
18195
- const { format, hoistTransitiveImports, preserveModules } = outputOptions;
18237
+ inlineTransitiveImports() {
18238
+ const { facadeModule, dependencies, outputOptions } = this;
18239
+ const { hoistTransitiveImports, preserveModules } = outputOptions;
18196
18240
  // for static and dynamic entry points, add transitive dependencies to this
18197
18241
  // chunk's dependencies to avoid loading latency
18198
18242
  if (hoistTransitiveImports && !preserveModules && facadeModule !== null) {
@@ -18201,6 +18245,10 @@ class Chunk {
18201
18245
  this.inlineChunkDependencies(dep);
18202
18246
  }
18203
18247
  }
18248
+ }
18249
+ async render() {
18250
+ const { exportMode, facadeModule, inputOptions: { onLog }, outputOptions, pluginDriver, snippets } = this;
18251
+ const { format, preserveModules } = outputOptions;
18204
18252
  const preliminaryFileName = this.getPreliminaryFileName();
18205
18253
  const preliminarySourcemapFileName = this.getPreliminarySourcemapFileName();
18206
18254
  const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = this.renderModules(preliminaryFileName.fileName);
@@ -18783,13 +18831,13 @@ class Chunk {
18783
18831
  node.setInternalResolution(resolution.namespace);
18784
18832
  }
18785
18833
  else {
18786
- 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);
18787
18835
  }
18788
18836
  }
18789
18837
  else {
18790
18838
  const { node, resolution } = resolvedDynamicImport;
18791
18839
  const [resolutionString, attributes] = this.getDynamicImportStringAndAttributes(resolution, fileName, node);
18792
- 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);
18793
18841
  }
18794
18842
  }
18795
18843
  }
@@ -19055,15 +19103,16 @@ function* concatLazy(iterables) {
19055
19103
  */
19056
19104
  function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log) {
19057
19105
  const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry);
19058
- const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry } = analyzeModuleGraph(entries);
19106
+ const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry } = analyzeModuleGraph(entries);
19059
19107
  // Each chunk is identified by its position in this array
19060
19108
  const chunkAtoms = getChunksWithSameDependentEntries(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks));
19061
19109
  const staticDependencyAtomsByEntry = getStaticDependencyAtomsByEntry(allEntries, chunkAtoms);
19062
19110
  // Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
19063
19111
  // If we no longer want this, we should make a copy here.
19064
19112
  const alreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
19113
+ const awaitedAlreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry, allEntries);
19065
19114
  // This mutates the dependentEntries in chunkAtoms
19066
- removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry);
19115
+ removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry, awaitedAlreadyLoadedAtomsByEntry);
19067
19116
  const { chunks, sideEffectAtoms, sizeByAtom } = getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize);
19068
19117
  chunkDefinitions.push(...getOptimizedChunks(chunks, minChunkSize, sideEffectAtoms, sizeByAtom, log).map(({ modules }) => ({
19069
19118
  alias: null,
@@ -19099,13 +19148,17 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
19099
19148
  }
19100
19149
  function analyzeModuleGraph(entries) {
19101
19150
  const dynamicEntryModules = new Set();
19151
+ const awaitedDynamicEntryModules = new Set();
19102
19152
  const dependentEntriesByModule = new Map();
19103
19153
  const allEntriesSet = new Set(entries);
19104
19154
  const dynamicImportModulesByEntry = new Array(allEntriesSet.size);
19155
+ const awaitedDynamicImportModulesByEntry = new Array(allEntriesSet.size);
19105
19156
  let entryIndex = 0;
19106
19157
  for (const currentEntry of allEntriesSet) {
19107
19158
  const dynamicImportsForCurrentEntry = new Set();
19159
+ const awaitedDynamicImportsForCurrentEntry = new Set();
19108
19160
  dynamicImportModulesByEntry[entryIndex] = dynamicImportsForCurrentEntry;
19161
+ awaitedDynamicImportModulesByEntry[entryIndex] = awaitedDynamicImportsForCurrentEntry;
19109
19162
  const modulesToHandle = new Set([currentEntry]);
19110
19163
  for (const module of modulesToHandle) {
19111
19164
  getOrCreate(dependentEntriesByModule, module, (getNewSet)).add(entryIndex);
@@ -19121,6 +19174,10 @@ function analyzeModuleGraph(entries) {
19121
19174
  dynamicEntryModules.add(resolution);
19122
19175
  allEntriesSet.add(resolution);
19123
19176
  dynamicImportsForCurrentEntry.add(resolution);
19177
+ if (resolution.includedDirectTopLevelAwaitingDynamicImporters.has(currentEntry)) {
19178
+ awaitedDynamicEntryModules.add(resolution);
19179
+ awaitedDynamicImportsForCurrentEntry.add(resolution);
19180
+ }
19124
19181
  }
19125
19182
  }
19126
19183
  for (const dependency of module.implicitlyLoadedBefore) {
@@ -19133,23 +19190,39 @@ function analyzeModuleGraph(entries) {
19133
19190
  entryIndex++;
19134
19191
  }
19135
19192
  const allEntries = [...allEntriesSet];
19136
- const { dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry);
19193
+ const { awaitedDynamicEntries, awaitedDynamicImportsByEntry, dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry, awaitedDynamicEntryModules, awaitedDynamicImportModulesByEntry);
19137
19194
  return {
19138
19195
  allEntries,
19196
+ awaitedDynamicImportsByEntry,
19139
19197
  dependentEntriesByModule,
19140
- dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries),
19198
+ dynamicallyDependentEntriesByAwaitedDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, awaitedDynamicEntries, allEntries, dynamicEntry => dynamicEntry.includedDirectTopLevelAwaitingDynamicImporters),
19199
+ dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries, dynamicEntry => dynamicEntry.includedDynamicImporters),
19141
19200
  dynamicImportsByEntry
19142
19201
  };
19143
19202
  }
19144
- function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry) {
19203
+ function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry, awaitedDynamicEntryModules, awaitedDynamicImportModulesByEntry) {
19145
19204
  const entryIndexByModule = new Map();
19146
19205
  const dynamicEntries = new Set();
19206
+ const awaitedDynamicEntries = new Set();
19147
19207
  for (const [entryIndex, entry] of allEntries.entries()) {
19148
19208
  entryIndexByModule.set(entry, entryIndex);
19149
19209
  if (dynamicEntryModules.has(entry)) {
19150
19210
  dynamicEntries.add(entryIndex);
19151
19211
  }
19212
+ if (awaitedDynamicEntryModules.has(entry)) {
19213
+ awaitedDynamicEntries.add(entryIndex);
19214
+ }
19152
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) {
19153
19226
  const dynamicImportsByEntry = new Array(dynamicImportModulesByEntry.length);
19154
19227
  let index = 0;
19155
19228
  for (const dynamicImportModules of dynamicImportModulesByEntry) {
@@ -19159,15 +19232,15 @@ function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModules
19159
19232
  }
19160
19233
  dynamicImportsByEntry[index++] = dynamicImports;
19161
19234
  }
19162
- return { dynamicEntries, dynamicImportsByEntry };
19235
+ return dynamicImportsByEntry;
19163
19236
  }
19164
- function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries) {
19237
+ function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries, getDynamicImporters) {
19165
19238
  const dynamicallyDependentEntriesByDynamicEntry = new Map();
19166
19239
  for (const dynamicEntryIndex of dynamicEntries) {
19167
19240
  const dynamicallyDependentEntries = getOrCreate(dynamicallyDependentEntriesByDynamicEntry, dynamicEntryIndex, (getNewSet));
19168
19241
  const dynamicEntry = allEntries[dynamicEntryIndex];
19169
19242
  for (const importer of concatLazy([
19170
- dynamicEntry.includedDynamicImporters,
19243
+ getDynamicImporters(dynamicEntry),
19171
19244
  dynamicEntry.implicitlyLoadedAfter
19172
19245
  ])) {
19173
19246
  for (const entry of dependentEntriesByModule.get(importer)) {
@@ -19246,13 +19319,15 @@ function getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyD
19246
19319
  * This removes all unnecessary dynamic entries from the dependentEntries in its
19247
19320
  * first argument if a chunk is already loaded without that entry.
19248
19321
  */
19249
- function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry) {
19322
+ function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry, awaitedAlreadyLoadedAtomsByEntry) {
19250
19323
  // Remove entries from dependent entries if a chunk is already loaded without
19251
- // that entry.
19324
+ // that entry. Do not remove already loaded atoms where all dynamic imports
19325
+ // are awaited to avoid cycles in the output.
19252
19326
  let chunkMask = 1n;
19253
19327
  for (const { dependentEntries } of chunkAtoms) {
19254
19328
  for (const entryIndex of dependentEntries) {
19255
- if ((alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask) {
19329
+ if ((alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask &&
19330
+ (awaitedAlreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === 0n) {
19256
19331
  dependentEntries.delete(entryIndex);
19257
19332
  }
19258
19333
  }
@@ -20159,6 +20234,7 @@ class Bundle {
20159
20234
  this.pluginDriver.setChunkInformation(this.facadeChunkByModule);
20160
20235
  for (const chunk of chunks) {
20161
20236
  chunk.generateExports();
20237
+ chunk.inlineTransitiveImports();
20162
20238
  }
20163
20239
  timeEnd('generate chunks', 2);
20164
20240
  await renderChunks(chunks, outputBundle, this.pluginDriver, this.outputOptions, this.inputOptions.onLog);
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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,6 +400,23 @@ 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;
@@ -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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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
 
@@ -17,7 +17,7 @@ const native_js = require('../native.js');
17
17
  const node_perf_hooks = require('node:perf_hooks');
18
18
  const promises = require('node:fs/promises');
19
19
 
20
- var version = "4.35.0";
20
+ var version = "4.36.0";
21
21
 
22
22
  function ensureArray$1(items) {
23
23
  if (Array.isArray(items)) {
@@ -13125,6 +13125,12 @@ class AssignmentPattern extends NodeBase {
13125
13125
  }
13126
13126
 
13127
13127
  class AwaitExpression extends NodeBase {
13128
+ get isTopLevelAwait() {
13129
+ return isFlagSet(this.flags, 134217728 /* Flag.isTopLevelAwait */);
13130
+ }
13131
+ set isTopLevelAwait(value) {
13132
+ this.flags = setFlag(this.flags, 134217728 /* Flag.isTopLevelAwait */, value);
13133
+ }
13128
13134
  hasEffects() {
13129
13135
  if (!this.deoptimized)
13130
13136
  this.applyDeoptimizations();
@@ -13139,13 +13145,14 @@ class AwaitExpression extends NodeBase {
13139
13145
  this.included = true;
13140
13146
  if (!this.deoptimized)
13141
13147
  this.applyDeoptimizations();
13142
- checkTopLevelAwait: if (!this.scope.context.usesTopLevelAwait) {
13148
+ checkTopLevelAwait: {
13143
13149
  let parent = this.parent;
13144
13150
  do {
13145
13151
  if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression)
13146
13152
  break checkTopLevelAwait;
13147
13153
  } while ((parent = parent.parent));
13148
13154
  this.scope.context.usesTopLevelAwait = true;
13155
+ this.isTopLevelAwait = true;
13149
13156
  }
13150
13157
  // Thenables need to be included
13151
13158
  this.argument.includePath(THEN_PATH, context);
@@ -14355,6 +14362,9 @@ class VariableDeclarator extends NodeBase {
14355
14362
  }
14356
14363
  VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
14357
14364
 
14365
+ function getChunkInfoWithPath(chunk) {
14366
+ return { fileName: chunk.getFileName(), ...chunk.getPreRenderedChunkInfo() };
14367
+ }
14358
14368
  class ImportExpression extends NodeBase {
14359
14369
  constructor() {
14360
14370
  super(...arguments);
@@ -14371,6 +14381,9 @@ class ImportExpression extends NodeBase {
14371
14381
  bind() {
14372
14382
  this.source.bind();
14373
14383
  }
14384
+ get isFollowingTopLevelAwait() {
14385
+ return this.parent instanceof AwaitExpression && this.parent.isTopLevelAwait;
14386
+ }
14374
14387
  /**
14375
14388
  * Get imported variables for deterministic usage, valid cases are:
14376
14389
  *
@@ -14523,7 +14536,7 @@ class ImportExpression extends NodeBase {
14523
14536
  }
14524
14537
  }
14525
14538
  }
14526
- setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, attributes) {
14539
+ setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, attributes, ownChunk, targetChunk) {
14527
14540
  const { format } = options;
14528
14541
  this.inlineNamespace = null;
14529
14542
  this.resolution = resolution;
@@ -14532,7 +14545,7 @@ class ImportExpression extends NodeBase {
14532
14545
  this.attributes = attributes;
14533
14546
  const accessedGlobals = [...(accessedImportGlobals[format] || [])];
14534
14547
  let helper;
14535
- ({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver));
14548
+ ({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver, ownChunk, targetChunk));
14536
14549
  if (helper) {
14537
14550
  accessedGlobals.push(helper);
14538
14551
  }
@@ -14543,12 +14556,39 @@ class ImportExpression extends NodeBase {
14543
14556
  setInternalResolution(inlineNamespace) {
14544
14557
  this.inlineNamespace = inlineNamespace;
14545
14558
  }
14546
- getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
14559
+ getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver, ownChunk, targetChunk) {
14547
14560
  const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
14548
14561
  {
14562
+ chunk: getChunkInfoWithPath(ownChunk),
14549
14563
  customResolution: typeof this.resolution === 'string' ? this.resolution : null,
14550
14564
  format,
14565
+ getTargetChunkImports() {
14566
+ if (targetChunk === null)
14567
+ return null;
14568
+ const chunkInfos = [];
14569
+ const importerPath = ownChunk.getFileName();
14570
+ for (const dep of targetChunk.dependencies) {
14571
+ const resolvedImportPath = `'${dep.getImportPath(importerPath)}'`;
14572
+ if (dep instanceof ExternalChunk) {
14573
+ chunkInfos.push({
14574
+ fileName: dep.getFileName(),
14575
+ resolvedImportPath,
14576
+ type: 'external'
14577
+ });
14578
+ }
14579
+ else {
14580
+ chunkInfos.push({
14581
+ chunk: dep.getPreRenderedChunkInfo(),
14582
+ fileName: dep.getFileName(),
14583
+ resolvedImportPath,
14584
+ type: 'internal'
14585
+ });
14586
+ }
14587
+ }
14588
+ return chunkInfos;
14589
+ },
14551
14590
  moduleId: this.scope.context.module.id,
14591
+ targetChunk: targetChunk ? getChunkInfoWithPath(targetChunk) : null,
14552
14592
  targetModuleId: this.resolution && typeof this.resolution !== 'string' ? this.resolution.id : null
14553
14593
  }
14554
14594
  ]);
@@ -17991,6 +18031,7 @@ class Module {
17991
18031
  this.importedFromNotTreeshaken = false;
17992
18032
  this.importers = [];
17993
18033
  this.includedDynamicImporters = [];
18034
+ this.includedDirectTopLevelAwaitingDynamicImporters = new Set();
17994
18035
  this.includedImports = new Set();
17995
18036
  this.isExecuted = false;
17996
18037
  this.isUserDefinedEntryPoint = false;
@@ -18847,6 +18888,9 @@ class Module {
18847
18888
  if (resolution instanceof Module) {
18848
18889
  if (!resolution.includedDynamicImporters.includes(this)) {
18849
18890
  resolution.includedDynamicImporters.push(this);
18891
+ if (node.isFollowingTopLevelAwait) {
18892
+ resolution.includedDirectTopLevelAwaitingDynamicImporters.add(this);
18893
+ }
18850
18894
  }
18851
18895
  const importedNames = this.options.treeshake
18852
18896
  ? node.getDeterministicImportedNames()
@@ -19231,13 +19275,13 @@ class Chunk {
19231
19275
  this.bundle = bundle;
19232
19276
  this.inputBase = inputBase;
19233
19277
  this.snippets = snippets;
19278
+ this.dependencies = new Set();
19234
19279
  this.entryModules = [];
19235
19280
  this.exportMode = 'named';
19236
19281
  this.facadeModule = null;
19237
19282
  this.namespaceVariableName = '';
19238
19283
  this.variableName = '';
19239
19284
  this.accessedGlobalsByScope = new Map();
19240
- this.dependencies = new Set();
19241
19285
  this.dynamicEntryModules = [];
19242
19286
  this.dynamicName = null;
19243
19287
  this.exportNamesByVariable = new Map();
@@ -19542,9 +19586,9 @@ class Chunk {
19542
19586
  this.setUpChunkImportsAndExportsForModule(module);
19543
19587
  }
19544
19588
  }
19545
- async render() {
19546
- const { dependencies, exportMode, facadeModule, inputOptions: { onLog }, outputOptions, pluginDriver, snippets } = this;
19547
- const { format, hoistTransitiveImports, preserveModules } = outputOptions;
19589
+ inlineTransitiveImports() {
19590
+ const { facadeModule, dependencies, outputOptions } = this;
19591
+ const { hoistTransitiveImports, preserveModules } = outputOptions;
19548
19592
  // for static and dynamic entry points, add transitive dependencies to this
19549
19593
  // chunk's dependencies to avoid loading latency
19550
19594
  if (hoistTransitiveImports && !preserveModules && facadeModule !== null) {
@@ -19553,6 +19597,10 @@ class Chunk {
19553
19597
  this.inlineChunkDependencies(dep);
19554
19598
  }
19555
19599
  }
19600
+ }
19601
+ async render() {
19602
+ const { exportMode, facadeModule, inputOptions: { onLog }, outputOptions, pluginDriver, snippets } = this;
19603
+ const { format, preserveModules } = outputOptions;
19556
19604
  const preliminaryFileName = this.getPreliminaryFileName();
19557
19605
  const preliminarySourcemapFileName = this.getPreliminarySourcemapFileName();
19558
19606
  const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = this.renderModules(preliminaryFileName.fileName);
@@ -20135,13 +20183,13 @@ class Chunk {
20135
20183
  node.setInternalResolution(resolution.namespace);
20136
20184
  }
20137
20185
  else {
20138
- node.setExternalResolution((facadeChunk || chunk).exportMode, resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, `'${(facadeChunk || chunk).getImportPath(fileName)}'`, !facadeChunk?.strictFacade && chunk.exportNamesByVariable.get(resolution.namespace)[0], null);
20186
+ 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);
20139
20187
  }
20140
20188
  }
20141
20189
  else {
20142
20190
  const { node, resolution } = resolvedDynamicImport;
20143
20191
  const [resolutionString, attributes] = this.getDynamicImportStringAndAttributes(resolution, fileName, node);
20144
- node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes);
20192
+ node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes, this, null);
20145
20193
  }
20146
20194
  }
20147
20195
  }
@@ -20407,15 +20455,16 @@ function* concatLazy(iterables) {
20407
20455
  */
20408
20456
  function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log) {
20409
20457
  const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry);
20410
- const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry } = analyzeModuleGraph(entries);
20458
+ const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry } = analyzeModuleGraph(entries);
20411
20459
  // Each chunk is identified by its position in this array
20412
20460
  const chunkAtoms = getChunksWithSameDependentEntries(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks));
20413
20461
  const staticDependencyAtomsByEntry = getStaticDependencyAtomsByEntry(allEntries, chunkAtoms);
20414
20462
  // Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
20415
20463
  // If we no longer want this, we should make a copy here.
20416
20464
  const alreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
20465
+ const awaitedAlreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry, allEntries);
20417
20466
  // This mutates the dependentEntries in chunkAtoms
20418
- removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry);
20467
+ removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry, awaitedAlreadyLoadedAtomsByEntry);
20419
20468
  const { chunks, sideEffectAtoms, sizeByAtom } = getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize);
20420
20469
  chunkDefinitions.push(...getOptimizedChunks(chunks, minChunkSize, sideEffectAtoms, sizeByAtom, log).map(({ modules }) => ({
20421
20470
  alias: null,
@@ -20451,13 +20500,17 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
20451
20500
  }
20452
20501
  function analyzeModuleGraph(entries) {
20453
20502
  const dynamicEntryModules = new Set();
20503
+ const awaitedDynamicEntryModules = new Set();
20454
20504
  const dependentEntriesByModule = new Map();
20455
20505
  const allEntriesSet = new Set(entries);
20456
20506
  const dynamicImportModulesByEntry = new Array(allEntriesSet.size);
20507
+ const awaitedDynamicImportModulesByEntry = new Array(allEntriesSet.size);
20457
20508
  let entryIndex = 0;
20458
20509
  for (const currentEntry of allEntriesSet) {
20459
20510
  const dynamicImportsForCurrentEntry = new Set();
20511
+ const awaitedDynamicImportsForCurrentEntry = new Set();
20460
20512
  dynamicImportModulesByEntry[entryIndex] = dynamicImportsForCurrentEntry;
20513
+ awaitedDynamicImportModulesByEntry[entryIndex] = awaitedDynamicImportsForCurrentEntry;
20461
20514
  const modulesToHandle = new Set([currentEntry]);
20462
20515
  for (const module of modulesToHandle) {
20463
20516
  getOrCreate(dependentEntriesByModule, module, (getNewSet)).add(entryIndex);
@@ -20473,6 +20526,10 @@ function analyzeModuleGraph(entries) {
20473
20526
  dynamicEntryModules.add(resolution);
20474
20527
  allEntriesSet.add(resolution);
20475
20528
  dynamicImportsForCurrentEntry.add(resolution);
20529
+ if (resolution.includedDirectTopLevelAwaitingDynamicImporters.has(currentEntry)) {
20530
+ awaitedDynamicEntryModules.add(resolution);
20531
+ awaitedDynamicImportsForCurrentEntry.add(resolution);
20532
+ }
20476
20533
  }
20477
20534
  }
20478
20535
  for (const dependency of module.implicitlyLoadedBefore) {
@@ -20485,23 +20542,39 @@ function analyzeModuleGraph(entries) {
20485
20542
  entryIndex++;
20486
20543
  }
20487
20544
  const allEntries = [...allEntriesSet];
20488
- const { dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry);
20545
+ const { awaitedDynamicEntries, awaitedDynamicImportsByEntry, dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry, awaitedDynamicEntryModules, awaitedDynamicImportModulesByEntry);
20489
20546
  return {
20490
20547
  allEntries,
20548
+ awaitedDynamicImportsByEntry,
20491
20549
  dependentEntriesByModule,
20492
- dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries),
20550
+ dynamicallyDependentEntriesByAwaitedDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, awaitedDynamicEntries, allEntries, dynamicEntry => dynamicEntry.includedDirectTopLevelAwaitingDynamicImporters),
20551
+ dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries, dynamicEntry => dynamicEntry.includedDynamicImporters),
20493
20552
  dynamicImportsByEntry
20494
20553
  };
20495
20554
  }
20496
- function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry) {
20555
+ function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry, awaitedDynamicEntryModules, awaitedDynamicImportModulesByEntry) {
20497
20556
  const entryIndexByModule = new Map();
20498
20557
  const dynamicEntries = new Set();
20558
+ const awaitedDynamicEntries = new Set();
20499
20559
  for (const [entryIndex, entry] of allEntries.entries()) {
20500
20560
  entryIndexByModule.set(entry, entryIndex);
20501
20561
  if (dynamicEntryModules.has(entry)) {
20502
20562
  dynamicEntries.add(entryIndex);
20503
20563
  }
20564
+ if (awaitedDynamicEntryModules.has(entry)) {
20565
+ awaitedDynamicEntries.add(entryIndex);
20566
+ }
20504
20567
  }
20568
+ const dynamicImportsByEntry = getDynamicImportsByEntry(dynamicImportModulesByEntry, entryIndexByModule);
20569
+ const awaitedDynamicImportsByEntry = getDynamicImportsByEntry(awaitedDynamicImportModulesByEntry, entryIndexByModule);
20570
+ return {
20571
+ awaitedDynamicEntries,
20572
+ awaitedDynamicImportsByEntry,
20573
+ dynamicEntries,
20574
+ dynamicImportsByEntry
20575
+ };
20576
+ }
20577
+ function getDynamicImportsByEntry(dynamicImportModulesByEntry, entryIndexByModule) {
20505
20578
  const dynamicImportsByEntry = new Array(dynamicImportModulesByEntry.length);
20506
20579
  let index = 0;
20507
20580
  for (const dynamicImportModules of dynamicImportModulesByEntry) {
@@ -20511,15 +20584,15 @@ function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModules
20511
20584
  }
20512
20585
  dynamicImportsByEntry[index++] = dynamicImports;
20513
20586
  }
20514
- return { dynamicEntries, dynamicImportsByEntry };
20587
+ return dynamicImportsByEntry;
20515
20588
  }
20516
- function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries) {
20589
+ function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries, getDynamicImporters) {
20517
20590
  const dynamicallyDependentEntriesByDynamicEntry = new Map();
20518
20591
  for (const dynamicEntryIndex of dynamicEntries) {
20519
20592
  const dynamicallyDependentEntries = getOrCreate(dynamicallyDependentEntriesByDynamicEntry, dynamicEntryIndex, (getNewSet));
20520
20593
  const dynamicEntry = allEntries[dynamicEntryIndex];
20521
20594
  for (const importer of concatLazy([
20522
- dynamicEntry.includedDynamicImporters,
20595
+ getDynamicImporters(dynamicEntry),
20523
20596
  dynamicEntry.implicitlyLoadedAfter
20524
20597
  ])) {
20525
20598
  for (const entry of dependentEntriesByModule.get(importer)) {
@@ -20598,13 +20671,15 @@ function getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyD
20598
20671
  * This removes all unnecessary dynamic entries from the dependentEntries in its
20599
20672
  * first argument if a chunk is already loaded without that entry.
20600
20673
  */
20601
- function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry) {
20674
+ function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry, awaitedAlreadyLoadedAtomsByEntry) {
20602
20675
  // Remove entries from dependent entries if a chunk is already loaded without
20603
- // that entry.
20676
+ // that entry. Do not remove already loaded atoms where all dynamic imports
20677
+ // are awaited to avoid cycles in the output.
20604
20678
  let chunkMask = 1n;
20605
20679
  for (const { dependentEntries } of chunkAtoms) {
20606
20680
  for (const entryIndex of dependentEntries) {
20607
- if ((alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask) {
20681
+ if ((alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask &&
20682
+ (awaitedAlreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === 0n) {
20608
20683
  dependentEntries.delete(entryIndex);
20609
20684
  }
20610
20685
  }
@@ -21491,6 +21566,7 @@ class Bundle {
21491
21566
  this.pluginDriver.setChunkInformation(this.facadeChunkByModule);
21492
21567
  for (const chunk of chunks) {
21493
21568
  chunk.generateExports();
21569
+ chunk.inlineTransitiveImports();
21494
21570
  }
21495
21571
  timeEnd('generate chunks', 2);
21496
21572
  await renderChunks(chunks, outputBundle, this.pluginDriver, this.outputOptions, this.inputOptions.onLog);
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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.35.0
4
- Sat, 08 Mar 2025 06:24:12 GMT - commit 70ef1cce7c740030cc2935b563d13950cc1511f5
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollup",
3
- "version": "4.35.0",
3
+ "version": "4.36.0",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",
@@ -110,25 +110,25 @@
110
110
  "homepage": "https://rollupjs.org/",
111
111
  "optionalDependencies": {
112
112
  "fsevents": "~2.3.2",
113
- "@rollup/rollup-darwin-arm64": "4.35.0",
114
- "@rollup/rollup-android-arm64": "4.35.0",
115
- "@rollup/rollup-win32-arm64-msvc": "4.35.0",
116
- "@rollup/rollup-freebsd-arm64": "4.35.0",
117
- "@rollup/rollup-linux-arm64-gnu": "4.35.0",
118
- "@rollup/rollup-linux-arm64-musl": "4.35.0",
119
- "@rollup/rollup-android-arm-eabi": "4.35.0",
120
- "@rollup/rollup-linux-arm-gnueabihf": "4.35.0",
121
- "@rollup/rollup-linux-arm-musleabihf": "4.35.0",
122
- "@rollup/rollup-win32-ia32-msvc": "4.35.0",
123
- "@rollup/rollup-linux-loongarch64-gnu": "4.35.0",
124
- "@rollup/rollup-linux-riscv64-gnu": "4.35.0",
125
- "@rollup/rollup-linux-powerpc64le-gnu": "4.35.0",
126
- "@rollup/rollup-linux-s390x-gnu": "4.35.0",
127
- "@rollup/rollup-darwin-x64": "4.35.0",
128
- "@rollup/rollup-win32-x64-msvc": "4.35.0",
129
- "@rollup/rollup-freebsd-x64": "4.35.0",
130
- "@rollup/rollup-linux-x64-gnu": "4.35.0",
131
- "@rollup/rollup-linux-x64-musl": "4.35.0"
113
+ "@rollup/rollup-darwin-arm64": "4.36.0",
114
+ "@rollup/rollup-android-arm64": "4.36.0",
115
+ "@rollup/rollup-win32-arm64-msvc": "4.36.0",
116
+ "@rollup/rollup-freebsd-arm64": "4.36.0",
117
+ "@rollup/rollup-linux-arm64-gnu": "4.36.0",
118
+ "@rollup/rollup-linux-arm64-musl": "4.36.0",
119
+ "@rollup/rollup-android-arm-eabi": "4.36.0",
120
+ "@rollup/rollup-linux-arm-gnueabihf": "4.36.0",
121
+ "@rollup/rollup-linux-arm-musleabihf": "4.36.0",
122
+ "@rollup/rollup-win32-ia32-msvc": "4.36.0",
123
+ "@rollup/rollup-linux-loongarch64-gnu": "4.36.0",
124
+ "@rollup/rollup-linux-riscv64-gnu": "4.36.0",
125
+ "@rollup/rollup-linux-powerpc64le-gnu": "4.36.0",
126
+ "@rollup/rollup-linux-s390x-gnu": "4.36.0",
127
+ "@rollup/rollup-darwin-x64": "4.36.0",
128
+ "@rollup/rollup-win32-x64-msvc": "4.36.0",
129
+ "@rollup/rollup-freebsd-x64": "4.36.0",
130
+ "@rollup/rollup-linux-x64-gnu": "4.36.0",
131
+ "@rollup/rollup-linux-x64-musl": "4.36.0"
132
132
  },
133
133
  "dependencies": {
134
134
  "@types/estree": "1.0.6"
@@ -143,14 +143,14 @@
143
143
  "@codemirror/search": "^6.5.10",
144
144
  "@codemirror/state": "^6.5.2",
145
145
  "@codemirror/view": "^6.36.4",
146
- "@eslint/js": "^9.21.0",
147
- "@inquirer/prompts": "^7.3.2",
146
+ "@eslint/js": "^9.22.0",
147
+ "@inquirer/prompts": "^7.3.3",
148
148
  "@jridgewell/sourcemap-codec": "^1.5.0",
149
149
  "@mermaid-js/mermaid-cli": "^11.4.2",
150
150
  "@napi-rs/cli": "^2.18.4",
151
151
  "@rollup/plugin-alias": "^5.1.1",
152
152
  "@rollup/plugin-buble": "^1.0.3",
153
- "@rollup/plugin-commonjs": "^28.0.2",
153
+ "@rollup/plugin-commonjs": "^28.0.3",
154
154
  "@rollup/plugin-json": "^6.1.0",
155
155
  "@rollup/plugin-node-resolve": "^16.0.0",
156
156
  "@rollup/plugin-replace": "^6.0.2",
@@ -159,11 +159,11 @@
159
159
  "@rollup/pluginutils": "^5.1.4",
160
160
  "@shikijs/vitepress-twoslash": "^3.1.0",
161
161
  "@types/mocha": "^10.0.10",
162
- "@types/node": "^18.19.79",
162
+ "@types/node": "^18.19.80",
163
163
  "@types/semver": "^7.5.8",
164
164
  "@types/yargs-parser": "^21.0.3",
165
165
  "@vue/language-server": "^2.2.8",
166
- "acorn": "^8.14.0",
166
+ "acorn": "^8.14.1",
167
167
  "acorn-import-assertions": "^1.9.0",
168
168
  "acorn-jsx": "^5.3.2",
169
169
  "buble": "^0.20.0",
@@ -175,11 +175,11 @@
175
175
  "date-time": "^4.0.0",
176
176
  "es5-shim": "^4.6.7",
177
177
  "es6-shim": "^0.35.8",
178
- "eslint": "^9.21.0",
179
- "eslint-config-prettier": "^10.0.2",
178
+ "eslint": "^9.22.0",
179
+ "eslint-config-prettier": "^10.1.1",
180
180
  "eslint-plugin-prettier": "^5.2.3",
181
181
  "eslint-plugin-unicorn": "^57.0.0",
182
- "eslint-plugin-vue": "^9.32.0",
182
+ "eslint-plugin-vue": "^10.0.0",
183
183
  "fixturify": "^3.0.0",
184
184
  "flru": "^1.0.2",
185
185
  "fs-extra": "^11.3.0",
@@ -201,7 +201,7 @@
201
201
  "pretty-bytes": "^6.1.1",
202
202
  "pretty-ms": "^9.2.0",
203
203
  "requirejs": "^2.3.7",
204
- "rollup": "^4.34.9",
204
+ "rollup": "^4.35.0",
205
205
  "rollup-plugin-license": "^3.6.0",
206
206
  "rollup-plugin-string": "^3.0.0",
207
207
  "semver": "^7.7.1",
@@ -213,8 +213,8 @@
213
213
  "terser": "^5.39.0",
214
214
  "tslib": "^2.8.1",
215
215
  "typescript": "^5.8.2",
216
- "typescript-eslint": "^8.26.0",
217
- "vite": "^6.2.0",
216
+ "typescript-eslint": "^8.26.1",
217
+ "vite": "^6.2.1",
218
218
  "vitepress": "^1.6.3",
219
219
  "vue": "^3.5.13",
220
220
  "vue-tsc": "^2.2.8",
@@ -222,7 +222,7 @@
222
222
  "yargs-parser": "^21.1.1"
223
223
  },
224
224
  "overrides": {
225
- "axios": "^1.8.1",
225
+ "axios": "^1.8.3",
226
226
  "semver": "^7.7.1",
227
227
  "readable-stream": "npm:@built-in/readable-stream@1",
228
228
  "esbuild": ">0.24.2"