rollup 4.35.0 → 4.37.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.37.0
5
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.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);
@@ -12435,7 +12442,18 @@ class ExportNamedDeclaration extends NodeBase {
12435
12442
  code.remove(start, end);
12436
12443
  }
12437
12444
  else {
12438
- code.remove(this.start, this.declaration.start);
12445
+ let endBoundary = this.declaration.start;
12446
+ // the start of the decorator may be before the start of the class declaration
12447
+ if (this.declaration instanceof ClassDeclaration) {
12448
+ const decorators = this.declaration.decorators;
12449
+ for (const decorator of decorators) {
12450
+ endBoundary = Math.min(endBoundary, decorator.start);
12451
+ }
12452
+ if (endBoundary <= this.start) {
12453
+ endBoundary = this.declaration.start;
12454
+ }
12455
+ }
12456
+ code.remove(this.start, endBoundary);
12439
12457
  this.declaration.render(code, options, { end, start });
12440
12458
  }
12441
12459
  }
@@ -12887,6 +12905,9 @@ class VariableDeclarator extends NodeBase {
12887
12905
  }
12888
12906
  VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
12889
12907
 
12908
+ function getChunkInfoWithPath(chunk) {
12909
+ return { fileName: chunk.getFileName(), ...chunk.getPreRenderedChunkInfo() };
12910
+ }
12890
12911
  class ImportExpression extends NodeBase {
12891
12912
  constructor() {
12892
12913
  super(...arguments);
@@ -12903,6 +12924,9 @@ class ImportExpression extends NodeBase {
12903
12924
  bind() {
12904
12925
  this.source.bind();
12905
12926
  }
12927
+ get isFollowingTopLevelAwait() {
12928
+ return this.parent instanceof AwaitExpression && this.parent.isTopLevelAwait;
12929
+ }
12906
12930
  /**
12907
12931
  * Get imported variables for deterministic usage, valid cases are:
12908
12932
  *
@@ -13055,7 +13079,7 @@ class ImportExpression extends NodeBase {
13055
13079
  }
13056
13080
  }
13057
13081
  }
13058
- setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, attributes) {
13082
+ setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, attributes, ownChunk, targetChunk) {
13059
13083
  const { format } = options;
13060
13084
  this.inlineNamespace = null;
13061
13085
  this.resolution = resolution;
@@ -13064,7 +13088,7 @@ class ImportExpression extends NodeBase {
13064
13088
  this.attributes = attributes;
13065
13089
  const accessedGlobals = [...(accessedImportGlobals[format] || [])];
13066
13090
  let helper;
13067
- ({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver));
13091
+ ({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver, ownChunk, targetChunk));
13068
13092
  if (helper) {
13069
13093
  accessedGlobals.push(helper);
13070
13094
  }
@@ -13075,12 +13099,39 @@ class ImportExpression extends NodeBase {
13075
13099
  setInternalResolution(inlineNamespace) {
13076
13100
  this.inlineNamespace = inlineNamespace;
13077
13101
  }
13078
- getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
13102
+ getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver, ownChunk, targetChunk) {
13079
13103
  const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
13080
13104
  {
13105
+ chunk: getChunkInfoWithPath(ownChunk),
13081
13106
  customResolution: typeof this.resolution === 'string' ? this.resolution : null,
13082
13107
  format,
13108
+ getTargetChunkImports() {
13109
+ if (targetChunk === null)
13110
+ return null;
13111
+ const chunkInfos = [];
13112
+ const importerPath = ownChunk.getFileName();
13113
+ for (const dep of targetChunk.dependencies) {
13114
+ const resolvedImportPath = `'${dep.getImportPath(importerPath)}'`;
13115
+ if (dep instanceof ExternalChunk) {
13116
+ chunkInfos.push({
13117
+ fileName: dep.getFileName(),
13118
+ resolvedImportPath,
13119
+ type: 'external'
13120
+ });
13121
+ }
13122
+ else {
13123
+ chunkInfos.push({
13124
+ chunk: dep.getPreRenderedChunkInfo(),
13125
+ fileName: dep.getFileName(),
13126
+ resolvedImportPath,
13127
+ type: 'internal'
13128
+ });
13129
+ }
13130
+ }
13131
+ return chunkInfos;
13132
+ },
13083
13133
  moduleId: this.scope.context.module.id,
13134
+ targetChunk: targetChunk ? getChunkInfoWithPath(targetChunk) : null,
13084
13135
  targetModuleId: this.resolution && typeof this.resolution !== 'string' ? this.resolution.id : null
13085
13136
  }
13086
13137
  ]);
@@ -16530,6 +16581,7 @@ class Module {
16530
16581
  this.importedFromNotTreeshaken = false;
16531
16582
  this.importers = [];
16532
16583
  this.includedDynamicImporters = [];
16584
+ this.includedDirectTopLevelAwaitingDynamicImporters = new Set();
16533
16585
  this.includedImports = new Set();
16534
16586
  this.isExecuted = false;
16535
16587
  this.isUserDefinedEntryPoint = false;
@@ -17386,6 +17438,9 @@ class Module {
17386
17438
  if (resolution instanceof Module) {
17387
17439
  if (!resolution.includedDynamicImporters.includes(this)) {
17388
17440
  resolution.includedDynamicImporters.push(this);
17441
+ if (node.isFollowingTopLevelAwait) {
17442
+ resolution.includedDirectTopLevelAwaitingDynamicImporters.add(this);
17443
+ }
17389
17444
  }
17390
17445
  const importedNames = this.options.treeshake
17391
17446
  ? node.getDeterministicImportedNames()
@@ -17879,13 +17934,13 @@ class Chunk {
17879
17934
  this.bundle = bundle;
17880
17935
  this.inputBase = inputBase;
17881
17936
  this.snippets = snippets;
17937
+ this.dependencies = new Set();
17882
17938
  this.entryModules = [];
17883
17939
  this.exportMode = 'named';
17884
17940
  this.facadeModule = null;
17885
17941
  this.namespaceVariableName = '';
17886
17942
  this.variableName = '';
17887
17943
  this.accessedGlobalsByScope = new Map();
17888
- this.dependencies = new Set();
17889
17944
  this.dynamicEntryModules = [];
17890
17945
  this.dynamicName = null;
17891
17946
  this.exportNamesByVariable = new Map();
@@ -18190,9 +18245,9 @@ class Chunk {
18190
18245
  this.setUpChunkImportsAndExportsForModule(module);
18191
18246
  }
18192
18247
  }
18193
- async render() {
18194
- const { dependencies, exportMode, facadeModule, inputOptions: { onLog }, outputOptions, pluginDriver, snippets } = this;
18195
- const { format, hoistTransitiveImports, preserveModules } = outputOptions;
18248
+ inlineTransitiveImports() {
18249
+ const { facadeModule, dependencies, outputOptions } = this;
18250
+ const { hoistTransitiveImports, preserveModules } = outputOptions;
18196
18251
  // for static and dynamic entry points, add transitive dependencies to this
18197
18252
  // chunk's dependencies to avoid loading latency
18198
18253
  if (hoistTransitiveImports && !preserveModules && facadeModule !== null) {
@@ -18201,6 +18256,10 @@ class Chunk {
18201
18256
  this.inlineChunkDependencies(dep);
18202
18257
  }
18203
18258
  }
18259
+ }
18260
+ async render() {
18261
+ const { exportMode, facadeModule, inputOptions: { onLog }, outputOptions, pluginDriver, snippets } = this;
18262
+ const { format, preserveModules } = outputOptions;
18204
18263
  const preliminaryFileName = this.getPreliminaryFileName();
18205
18264
  const preliminarySourcemapFileName = this.getPreliminarySourcemapFileName();
18206
18265
  const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = this.renderModules(preliminaryFileName.fileName);
@@ -18783,13 +18842,13 @@ class Chunk {
18783
18842
  node.setInternalResolution(resolution.namespace);
18784
18843
  }
18785
18844
  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);
18845
+ 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
18846
  }
18788
18847
  }
18789
18848
  else {
18790
18849
  const { node, resolution } = resolvedDynamicImport;
18791
18850
  const [resolutionString, attributes] = this.getDynamicImportStringAndAttributes(resolution, fileName, node);
18792
- node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes);
18851
+ node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes, this, null);
18793
18852
  }
18794
18853
  }
18795
18854
  }
@@ -19055,15 +19114,16 @@ function* concatLazy(iterables) {
19055
19114
  */
19056
19115
  function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log) {
19057
19116
  const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry);
19058
- const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry } = analyzeModuleGraph(entries);
19117
+ const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry } = analyzeModuleGraph(entries);
19059
19118
  // Each chunk is identified by its position in this array
19060
19119
  const chunkAtoms = getChunksWithSameDependentEntries(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks));
19061
19120
  const staticDependencyAtomsByEntry = getStaticDependencyAtomsByEntry(allEntries, chunkAtoms);
19062
19121
  // Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
19063
19122
  // If we no longer want this, we should make a copy here.
19064
19123
  const alreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
19124
+ const awaitedAlreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry, allEntries);
19065
19125
  // This mutates the dependentEntries in chunkAtoms
19066
- removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry);
19126
+ removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry, awaitedAlreadyLoadedAtomsByEntry);
19067
19127
  const { chunks, sideEffectAtoms, sizeByAtom } = getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize);
19068
19128
  chunkDefinitions.push(...getOptimizedChunks(chunks, minChunkSize, sideEffectAtoms, sizeByAtom, log).map(({ modules }) => ({
19069
19129
  alias: null,
@@ -19099,13 +19159,17 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
19099
19159
  }
19100
19160
  function analyzeModuleGraph(entries) {
19101
19161
  const dynamicEntryModules = new Set();
19162
+ const awaitedDynamicEntryModules = new Set();
19102
19163
  const dependentEntriesByModule = new Map();
19103
19164
  const allEntriesSet = new Set(entries);
19104
19165
  const dynamicImportModulesByEntry = new Array(allEntriesSet.size);
19166
+ const awaitedDynamicImportModulesByEntry = new Array(allEntriesSet.size);
19105
19167
  let entryIndex = 0;
19106
19168
  for (const currentEntry of allEntriesSet) {
19107
19169
  const dynamicImportsForCurrentEntry = new Set();
19170
+ const awaitedDynamicImportsForCurrentEntry = new Set();
19108
19171
  dynamicImportModulesByEntry[entryIndex] = dynamicImportsForCurrentEntry;
19172
+ awaitedDynamicImportModulesByEntry[entryIndex] = awaitedDynamicImportsForCurrentEntry;
19109
19173
  const modulesToHandle = new Set([currentEntry]);
19110
19174
  for (const module of modulesToHandle) {
19111
19175
  getOrCreate(dependentEntriesByModule, module, (getNewSet)).add(entryIndex);
@@ -19121,6 +19185,10 @@ function analyzeModuleGraph(entries) {
19121
19185
  dynamicEntryModules.add(resolution);
19122
19186
  allEntriesSet.add(resolution);
19123
19187
  dynamicImportsForCurrentEntry.add(resolution);
19188
+ if (resolution.includedDirectTopLevelAwaitingDynamicImporters.has(currentEntry)) {
19189
+ awaitedDynamicEntryModules.add(resolution);
19190
+ awaitedDynamicImportsForCurrentEntry.add(resolution);
19191
+ }
19124
19192
  }
19125
19193
  }
19126
19194
  for (const dependency of module.implicitlyLoadedBefore) {
@@ -19133,23 +19201,39 @@ function analyzeModuleGraph(entries) {
19133
19201
  entryIndex++;
19134
19202
  }
19135
19203
  const allEntries = [...allEntriesSet];
19136
- const { dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry);
19204
+ const { awaitedDynamicEntries, awaitedDynamicImportsByEntry, dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry, awaitedDynamicEntryModules, awaitedDynamicImportModulesByEntry);
19137
19205
  return {
19138
19206
  allEntries,
19207
+ awaitedDynamicImportsByEntry,
19139
19208
  dependentEntriesByModule,
19140
- dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries),
19209
+ dynamicallyDependentEntriesByAwaitedDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, awaitedDynamicEntries, allEntries, dynamicEntry => dynamicEntry.includedDirectTopLevelAwaitingDynamicImporters),
19210
+ dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries, dynamicEntry => dynamicEntry.includedDynamicImporters),
19141
19211
  dynamicImportsByEntry
19142
19212
  };
19143
19213
  }
19144
- function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry) {
19214
+ function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry, awaitedDynamicEntryModules, awaitedDynamicImportModulesByEntry) {
19145
19215
  const entryIndexByModule = new Map();
19146
19216
  const dynamicEntries = new Set();
19217
+ const awaitedDynamicEntries = new Set();
19147
19218
  for (const [entryIndex, entry] of allEntries.entries()) {
19148
19219
  entryIndexByModule.set(entry, entryIndex);
19149
19220
  if (dynamicEntryModules.has(entry)) {
19150
19221
  dynamicEntries.add(entryIndex);
19151
19222
  }
19223
+ if (awaitedDynamicEntryModules.has(entry)) {
19224
+ awaitedDynamicEntries.add(entryIndex);
19225
+ }
19152
19226
  }
19227
+ const dynamicImportsByEntry = getDynamicImportsByEntry(dynamicImportModulesByEntry, entryIndexByModule);
19228
+ const awaitedDynamicImportsByEntry = getDynamicImportsByEntry(awaitedDynamicImportModulesByEntry, entryIndexByModule);
19229
+ return {
19230
+ awaitedDynamicEntries,
19231
+ awaitedDynamicImportsByEntry,
19232
+ dynamicEntries,
19233
+ dynamicImportsByEntry
19234
+ };
19235
+ }
19236
+ function getDynamicImportsByEntry(dynamicImportModulesByEntry, entryIndexByModule) {
19153
19237
  const dynamicImportsByEntry = new Array(dynamicImportModulesByEntry.length);
19154
19238
  let index = 0;
19155
19239
  for (const dynamicImportModules of dynamicImportModulesByEntry) {
@@ -19159,15 +19243,15 @@ function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModules
19159
19243
  }
19160
19244
  dynamicImportsByEntry[index++] = dynamicImports;
19161
19245
  }
19162
- return { dynamicEntries, dynamicImportsByEntry };
19246
+ return dynamicImportsByEntry;
19163
19247
  }
19164
- function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries) {
19248
+ function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries, getDynamicImporters) {
19165
19249
  const dynamicallyDependentEntriesByDynamicEntry = new Map();
19166
19250
  for (const dynamicEntryIndex of dynamicEntries) {
19167
19251
  const dynamicallyDependentEntries = getOrCreate(dynamicallyDependentEntriesByDynamicEntry, dynamicEntryIndex, (getNewSet));
19168
19252
  const dynamicEntry = allEntries[dynamicEntryIndex];
19169
19253
  for (const importer of concatLazy([
19170
- dynamicEntry.includedDynamicImporters,
19254
+ getDynamicImporters(dynamicEntry),
19171
19255
  dynamicEntry.implicitlyLoadedAfter
19172
19256
  ])) {
19173
19257
  for (const entry of dependentEntriesByModule.get(importer)) {
@@ -19246,13 +19330,15 @@ function getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyD
19246
19330
  * This removes all unnecessary dynamic entries from the dependentEntries in its
19247
19331
  * first argument if a chunk is already loaded without that entry.
19248
19332
  */
19249
- function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry) {
19333
+ function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry, awaitedAlreadyLoadedAtomsByEntry) {
19250
19334
  // Remove entries from dependent entries if a chunk is already loaded without
19251
- // that entry.
19335
+ // that entry. Do not remove already loaded atoms where all dynamic imports
19336
+ // are awaited to avoid cycles in the output.
19252
19337
  let chunkMask = 1n;
19253
19338
  for (const { dependentEntries } of chunkAtoms) {
19254
19339
  for (const entryIndex of dependentEntries) {
19255
- if ((alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask) {
19340
+ if ((alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask &&
19341
+ (awaitedAlreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === 0n) {
19256
19342
  dependentEntries.delete(entryIndex);
19257
19343
  }
19258
19344
  }
@@ -20159,6 +20245,7 @@ class Bundle {
20159
20245
  this.pluginDriver.setChunkInformation(this.facadeChunkByModule);
20160
20246
  for (const chunk of chunks) {
20161
20247
  chunk.generateExports();
20248
+ chunk.inlineTransitiveImports();
20162
20249
  }
20163
20250
  timeEnd('generate chunks', 2);
20164
20251
  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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/native.js CHANGED
@@ -22,7 +22,7 @@ const bindingsByPlatformAndArch = {
22
22
  arm64: { base: 'linux-arm64-gnu', musl: 'linux-arm64-musl' },
23
23
  loong64: { base: 'linux-loongarch64-gnu', musl: null },
24
24
  ppc64: { base: 'linux-powerpc64le-gnu', musl: null },
25
- riscv64: { base: 'linux-riscv64-gnu', musl: null },
25
+ riscv64: { base: 'linux-riscv64-gnu', musl: 'linux-riscv64-musl' },
26
26
  s390x: { base: 'linux-s390x-gnu', musl: null },
27
27
  x64: { base: 'linux-x64-gnu', musl: 'linux-x64-musl' }
28
28
  },
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.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);
@@ -13903,7 +13910,18 @@ class ExportNamedDeclaration extends NodeBase {
13903
13910
  code.remove(start, end);
13904
13911
  }
13905
13912
  else {
13906
- code.remove(this.start, this.declaration.start);
13913
+ let endBoundary = this.declaration.start;
13914
+ // the start of the decorator may be before the start of the class declaration
13915
+ if (this.declaration instanceof ClassDeclaration) {
13916
+ const decorators = this.declaration.decorators;
13917
+ for (const decorator of decorators) {
13918
+ endBoundary = Math.min(endBoundary, decorator.start);
13919
+ }
13920
+ if (endBoundary <= this.start) {
13921
+ endBoundary = this.declaration.start;
13922
+ }
13923
+ }
13924
+ code.remove(this.start, endBoundary);
13907
13925
  this.declaration.render(code, options, { end, start });
13908
13926
  }
13909
13927
  }
@@ -14355,6 +14373,9 @@ class VariableDeclarator extends NodeBase {
14355
14373
  }
14356
14374
  VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
14357
14375
 
14376
+ function getChunkInfoWithPath(chunk) {
14377
+ return { fileName: chunk.getFileName(), ...chunk.getPreRenderedChunkInfo() };
14378
+ }
14358
14379
  class ImportExpression extends NodeBase {
14359
14380
  constructor() {
14360
14381
  super(...arguments);
@@ -14371,6 +14392,9 @@ class ImportExpression extends NodeBase {
14371
14392
  bind() {
14372
14393
  this.source.bind();
14373
14394
  }
14395
+ get isFollowingTopLevelAwait() {
14396
+ return this.parent instanceof AwaitExpression && this.parent.isTopLevelAwait;
14397
+ }
14374
14398
  /**
14375
14399
  * Get imported variables for deterministic usage, valid cases are:
14376
14400
  *
@@ -14523,7 +14547,7 @@ class ImportExpression extends NodeBase {
14523
14547
  }
14524
14548
  }
14525
14549
  }
14526
- setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, attributes) {
14550
+ setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName, attributes, ownChunk, targetChunk) {
14527
14551
  const { format } = options;
14528
14552
  this.inlineNamespace = null;
14529
14553
  this.resolution = resolution;
@@ -14532,7 +14556,7 @@ class ImportExpression extends NodeBase {
14532
14556
  this.attributes = attributes;
14533
14557
  const accessedGlobals = [...(accessedImportGlobals[format] || [])];
14534
14558
  let helper;
14535
- ({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver));
14559
+ ({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper(resolution, exportMode, options, snippets, pluginDriver, ownChunk, targetChunk));
14536
14560
  if (helper) {
14537
14561
  accessedGlobals.push(helper);
14538
14562
  }
@@ -14543,12 +14567,39 @@ class ImportExpression extends NodeBase {
14543
14567
  setInternalResolution(inlineNamespace) {
14544
14568
  this.inlineNamespace = inlineNamespace;
14545
14569
  }
14546
- getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
14570
+ getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver, ownChunk, targetChunk) {
14547
14571
  const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
14548
14572
  {
14573
+ chunk: getChunkInfoWithPath(ownChunk),
14549
14574
  customResolution: typeof this.resolution === 'string' ? this.resolution : null,
14550
14575
  format,
14576
+ getTargetChunkImports() {
14577
+ if (targetChunk === null)
14578
+ return null;
14579
+ const chunkInfos = [];
14580
+ const importerPath = ownChunk.getFileName();
14581
+ for (const dep of targetChunk.dependencies) {
14582
+ const resolvedImportPath = `'${dep.getImportPath(importerPath)}'`;
14583
+ if (dep instanceof ExternalChunk) {
14584
+ chunkInfos.push({
14585
+ fileName: dep.getFileName(),
14586
+ resolvedImportPath,
14587
+ type: 'external'
14588
+ });
14589
+ }
14590
+ else {
14591
+ chunkInfos.push({
14592
+ chunk: dep.getPreRenderedChunkInfo(),
14593
+ fileName: dep.getFileName(),
14594
+ resolvedImportPath,
14595
+ type: 'internal'
14596
+ });
14597
+ }
14598
+ }
14599
+ return chunkInfos;
14600
+ },
14551
14601
  moduleId: this.scope.context.module.id,
14602
+ targetChunk: targetChunk ? getChunkInfoWithPath(targetChunk) : null,
14552
14603
  targetModuleId: this.resolution && typeof this.resolution !== 'string' ? this.resolution.id : null
14553
14604
  }
14554
14605
  ]);
@@ -17991,6 +18042,7 @@ class Module {
17991
18042
  this.importedFromNotTreeshaken = false;
17992
18043
  this.importers = [];
17993
18044
  this.includedDynamicImporters = [];
18045
+ this.includedDirectTopLevelAwaitingDynamicImporters = new Set();
17994
18046
  this.includedImports = new Set();
17995
18047
  this.isExecuted = false;
17996
18048
  this.isUserDefinedEntryPoint = false;
@@ -18847,6 +18899,9 @@ class Module {
18847
18899
  if (resolution instanceof Module) {
18848
18900
  if (!resolution.includedDynamicImporters.includes(this)) {
18849
18901
  resolution.includedDynamicImporters.push(this);
18902
+ if (node.isFollowingTopLevelAwait) {
18903
+ resolution.includedDirectTopLevelAwaitingDynamicImporters.add(this);
18904
+ }
18850
18905
  }
18851
18906
  const importedNames = this.options.treeshake
18852
18907
  ? node.getDeterministicImportedNames()
@@ -19231,13 +19286,13 @@ class Chunk {
19231
19286
  this.bundle = bundle;
19232
19287
  this.inputBase = inputBase;
19233
19288
  this.snippets = snippets;
19289
+ this.dependencies = new Set();
19234
19290
  this.entryModules = [];
19235
19291
  this.exportMode = 'named';
19236
19292
  this.facadeModule = null;
19237
19293
  this.namespaceVariableName = '';
19238
19294
  this.variableName = '';
19239
19295
  this.accessedGlobalsByScope = new Map();
19240
- this.dependencies = new Set();
19241
19296
  this.dynamicEntryModules = [];
19242
19297
  this.dynamicName = null;
19243
19298
  this.exportNamesByVariable = new Map();
@@ -19542,9 +19597,9 @@ class Chunk {
19542
19597
  this.setUpChunkImportsAndExportsForModule(module);
19543
19598
  }
19544
19599
  }
19545
- async render() {
19546
- const { dependencies, exportMode, facadeModule, inputOptions: { onLog }, outputOptions, pluginDriver, snippets } = this;
19547
- const { format, hoistTransitiveImports, preserveModules } = outputOptions;
19600
+ inlineTransitiveImports() {
19601
+ const { facadeModule, dependencies, outputOptions } = this;
19602
+ const { hoistTransitiveImports, preserveModules } = outputOptions;
19548
19603
  // for static and dynamic entry points, add transitive dependencies to this
19549
19604
  // chunk's dependencies to avoid loading latency
19550
19605
  if (hoistTransitiveImports && !preserveModules && facadeModule !== null) {
@@ -19553,6 +19608,10 @@ class Chunk {
19553
19608
  this.inlineChunkDependencies(dep);
19554
19609
  }
19555
19610
  }
19611
+ }
19612
+ async render() {
19613
+ const { exportMode, facadeModule, inputOptions: { onLog }, outputOptions, pluginDriver, snippets } = this;
19614
+ const { format, preserveModules } = outputOptions;
19556
19615
  const preliminaryFileName = this.getPreliminaryFileName();
19557
19616
  const preliminarySourcemapFileName = this.getPreliminarySourcemapFileName();
19558
19617
  const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = this.renderModules(preliminaryFileName.fileName);
@@ -20135,13 +20194,13 @@ class Chunk {
20135
20194
  node.setInternalResolution(resolution.namespace);
20136
20195
  }
20137
20196
  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);
20197
+ 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
20198
  }
20140
20199
  }
20141
20200
  else {
20142
20201
  const { node, resolution } = resolvedDynamicImport;
20143
20202
  const [resolutionString, attributes] = this.getDynamicImportStringAndAttributes(resolution, fileName, node);
20144
- node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes);
20203
+ node.setExternalResolution('external', resolution, outputOptions, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, false, attributes, this, null);
20145
20204
  }
20146
20205
  }
20147
20206
  }
@@ -20407,15 +20466,16 @@ function* concatLazy(iterables) {
20407
20466
  */
20408
20467
  function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log) {
20409
20468
  const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry);
20410
- const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry } = analyzeModuleGraph(entries);
20469
+ const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry } = analyzeModuleGraph(entries);
20411
20470
  // Each chunk is identified by its position in this array
20412
20471
  const chunkAtoms = getChunksWithSameDependentEntries(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks));
20413
20472
  const staticDependencyAtomsByEntry = getStaticDependencyAtomsByEntry(allEntries, chunkAtoms);
20414
20473
  // Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
20415
20474
  // If we no longer want this, we should make a copy here.
20416
20475
  const alreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
20476
+ const awaitedAlreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByAwaitedDynamicEntry, awaitedDynamicImportsByEntry, allEntries);
20417
20477
  // This mutates the dependentEntries in chunkAtoms
20418
- removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry);
20478
+ removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry, awaitedAlreadyLoadedAtomsByEntry);
20419
20479
  const { chunks, sideEffectAtoms, sizeByAtom } = getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize);
20420
20480
  chunkDefinitions.push(...getOptimizedChunks(chunks, minChunkSize, sideEffectAtoms, sizeByAtom, log).map(({ modules }) => ({
20421
20481
  alias: null,
@@ -20451,13 +20511,17 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
20451
20511
  }
20452
20512
  function analyzeModuleGraph(entries) {
20453
20513
  const dynamicEntryModules = new Set();
20514
+ const awaitedDynamicEntryModules = new Set();
20454
20515
  const dependentEntriesByModule = new Map();
20455
20516
  const allEntriesSet = new Set(entries);
20456
20517
  const dynamicImportModulesByEntry = new Array(allEntriesSet.size);
20518
+ const awaitedDynamicImportModulesByEntry = new Array(allEntriesSet.size);
20457
20519
  let entryIndex = 0;
20458
20520
  for (const currentEntry of allEntriesSet) {
20459
20521
  const dynamicImportsForCurrentEntry = new Set();
20522
+ const awaitedDynamicImportsForCurrentEntry = new Set();
20460
20523
  dynamicImportModulesByEntry[entryIndex] = dynamicImportsForCurrentEntry;
20524
+ awaitedDynamicImportModulesByEntry[entryIndex] = awaitedDynamicImportsForCurrentEntry;
20461
20525
  const modulesToHandle = new Set([currentEntry]);
20462
20526
  for (const module of modulesToHandle) {
20463
20527
  getOrCreate(dependentEntriesByModule, module, (getNewSet)).add(entryIndex);
@@ -20473,6 +20537,10 @@ function analyzeModuleGraph(entries) {
20473
20537
  dynamicEntryModules.add(resolution);
20474
20538
  allEntriesSet.add(resolution);
20475
20539
  dynamicImportsForCurrentEntry.add(resolution);
20540
+ if (resolution.includedDirectTopLevelAwaitingDynamicImporters.has(currentEntry)) {
20541
+ awaitedDynamicEntryModules.add(resolution);
20542
+ awaitedDynamicImportsForCurrentEntry.add(resolution);
20543
+ }
20476
20544
  }
20477
20545
  }
20478
20546
  for (const dependency of module.implicitlyLoadedBefore) {
@@ -20485,23 +20553,39 @@ function analyzeModuleGraph(entries) {
20485
20553
  entryIndex++;
20486
20554
  }
20487
20555
  const allEntries = [...allEntriesSet];
20488
- const { dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry);
20556
+ const { awaitedDynamicEntries, awaitedDynamicImportsByEntry, dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry, awaitedDynamicEntryModules, awaitedDynamicImportModulesByEntry);
20489
20557
  return {
20490
20558
  allEntries,
20559
+ awaitedDynamicImportsByEntry,
20491
20560
  dependentEntriesByModule,
20492
- dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries),
20561
+ dynamicallyDependentEntriesByAwaitedDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, awaitedDynamicEntries, allEntries, dynamicEntry => dynamicEntry.includedDirectTopLevelAwaitingDynamicImporters),
20562
+ dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries, dynamicEntry => dynamicEntry.includedDynamicImporters),
20493
20563
  dynamicImportsByEntry
20494
20564
  };
20495
20565
  }
20496
- function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry) {
20566
+ function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry, awaitedDynamicEntryModules, awaitedDynamicImportModulesByEntry) {
20497
20567
  const entryIndexByModule = new Map();
20498
20568
  const dynamicEntries = new Set();
20569
+ const awaitedDynamicEntries = new Set();
20499
20570
  for (const [entryIndex, entry] of allEntries.entries()) {
20500
20571
  entryIndexByModule.set(entry, entryIndex);
20501
20572
  if (dynamicEntryModules.has(entry)) {
20502
20573
  dynamicEntries.add(entryIndex);
20503
20574
  }
20575
+ if (awaitedDynamicEntryModules.has(entry)) {
20576
+ awaitedDynamicEntries.add(entryIndex);
20577
+ }
20504
20578
  }
20579
+ const dynamicImportsByEntry = getDynamicImportsByEntry(dynamicImportModulesByEntry, entryIndexByModule);
20580
+ const awaitedDynamicImportsByEntry = getDynamicImportsByEntry(awaitedDynamicImportModulesByEntry, entryIndexByModule);
20581
+ return {
20582
+ awaitedDynamicEntries,
20583
+ awaitedDynamicImportsByEntry,
20584
+ dynamicEntries,
20585
+ dynamicImportsByEntry
20586
+ };
20587
+ }
20588
+ function getDynamicImportsByEntry(dynamicImportModulesByEntry, entryIndexByModule) {
20505
20589
  const dynamicImportsByEntry = new Array(dynamicImportModulesByEntry.length);
20506
20590
  let index = 0;
20507
20591
  for (const dynamicImportModules of dynamicImportModulesByEntry) {
@@ -20511,15 +20595,15 @@ function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModules
20511
20595
  }
20512
20596
  dynamicImportsByEntry[index++] = dynamicImports;
20513
20597
  }
20514
- return { dynamicEntries, dynamicImportsByEntry };
20598
+ return dynamicImportsByEntry;
20515
20599
  }
20516
- function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries) {
20600
+ function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries, getDynamicImporters) {
20517
20601
  const dynamicallyDependentEntriesByDynamicEntry = new Map();
20518
20602
  for (const dynamicEntryIndex of dynamicEntries) {
20519
20603
  const dynamicallyDependentEntries = getOrCreate(dynamicallyDependentEntriesByDynamicEntry, dynamicEntryIndex, (getNewSet));
20520
20604
  const dynamicEntry = allEntries[dynamicEntryIndex];
20521
20605
  for (const importer of concatLazy([
20522
- dynamicEntry.includedDynamicImporters,
20606
+ getDynamicImporters(dynamicEntry),
20523
20607
  dynamicEntry.implicitlyLoadedAfter
20524
20608
  ])) {
20525
20609
  for (const entry of dependentEntriesByModule.get(importer)) {
@@ -20598,13 +20682,15 @@ function getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyD
20598
20682
  * This removes all unnecessary dynamic entries from the dependentEntries in its
20599
20683
  * first argument if a chunk is already loaded without that entry.
20600
20684
  */
20601
- function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry) {
20685
+ function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry, awaitedAlreadyLoadedAtomsByEntry) {
20602
20686
  // Remove entries from dependent entries if a chunk is already loaded without
20603
- // that entry.
20687
+ // that entry. Do not remove already loaded atoms where all dynamic imports
20688
+ // are awaited to avoid cycles in the output.
20604
20689
  let chunkMask = 1n;
20605
20690
  for (const { dependentEntries } of chunkAtoms) {
20606
20691
  for (const entryIndex of dependentEntries) {
20607
- if ((alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask) {
20692
+ if ((alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask &&
20693
+ (awaitedAlreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === 0n) {
20608
20694
  dependentEntries.delete(entryIndex);
20609
20695
  }
20610
20696
  }
@@ -21491,6 +21577,7 @@ class Bundle {
21491
21577
  this.pluginDriver.setChunkInformation(this.facadeChunkByModule);
21492
21578
  for (const chunk of chunks) {
21493
21579
  chunk.generateExports();
21580
+ chunk.inlineTransitiveImports();
21494
21581
  }
21495
21582
  timeEnd('generate chunks', 2);
21496
21583
  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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0
4
+ Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
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.37.0",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",
@@ -28,6 +28,7 @@
28
28
  "i686-pc-windows-msvc",
29
29
  "loongarch64-unknown-linux-gnu",
30
30
  "riscv64gc-unknown-linux-gnu",
31
+ "riscv64gc-unknown-linux-musl",
31
32
  "powerpc64le-unknown-linux-gnu",
32
33
  "s390x-unknown-linux-gnu",
33
34
  "x86_64-apple-darwin",
@@ -110,25 +111,26 @@
110
111
  "homepage": "https://rollupjs.org/",
111
112
  "optionalDependencies": {
112
113
  "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"
114
+ "@rollup/rollup-darwin-arm64": "4.37.0",
115
+ "@rollup/rollup-android-arm64": "4.37.0",
116
+ "@rollup/rollup-win32-arm64-msvc": "4.37.0",
117
+ "@rollup/rollup-freebsd-arm64": "4.37.0",
118
+ "@rollup/rollup-linux-arm64-gnu": "4.37.0",
119
+ "@rollup/rollup-linux-arm64-musl": "4.37.0",
120
+ "@rollup/rollup-android-arm-eabi": "4.37.0",
121
+ "@rollup/rollup-linux-arm-gnueabihf": "4.37.0",
122
+ "@rollup/rollup-linux-arm-musleabihf": "4.37.0",
123
+ "@rollup/rollup-win32-ia32-msvc": "4.37.0",
124
+ "@rollup/rollup-linux-loongarch64-gnu": "4.37.0",
125
+ "@rollup/rollup-linux-riscv64-gnu": "4.37.0",
126
+ "@rollup/rollup-linux-riscv64-musl": "4.37.0",
127
+ "@rollup/rollup-linux-powerpc64le-gnu": "4.37.0",
128
+ "@rollup/rollup-linux-s390x-gnu": "4.37.0",
129
+ "@rollup/rollup-darwin-x64": "4.37.0",
130
+ "@rollup/rollup-win32-x64-msvc": "4.37.0",
131
+ "@rollup/rollup-freebsd-x64": "4.37.0",
132
+ "@rollup/rollup-linux-x64-gnu": "4.37.0",
133
+ "@rollup/rollup-linux-x64-musl": "4.37.0"
132
134
  },
133
135
  "dependencies": {
134
136
  "@types/estree": "1.0.6"
@@ -139,31 +141,31 @@
139
141
  "devDependencies": {
140
142
  "@codemirror/commands": "^6.8.0",
141
143
  "@codemirror/lang-javascript": "^6.2.3",
142
- "@codemirror/language": "^6.10.8",
144
+ "@codemirror/language": "^6.11.0",
143
145
  "@codemirror/search": "^6.5.10",
144
146
  "@codemirror/state": "^6.5.2",
145
147
  "@codemirror/view": "^6.36.4",
146
- "@eslint/js": "^9.21.0",
147
- "@inquirer/prompts": "^7.3.2",
148
+ "@eslint/js": "^9.22.0",
149
+ "@inquirer/prompts": "^7.4.0",
148
150
  "@jridgewell/sourcemap-codec": "^1.5.0",
149
151
  "@mermaid-js/mermaid-cli": "^11.4.2",
150
152
  "@napi-rs/cli": "^2.18.4",
151
153
  "@rollup/plugin-alias": "^5.1.1",
152
154
  "@rollup/plugin-buble": "^1.0.3",
153
- "@rollup/plugin-commonjs": "^28.0.2",
155
+ "@rollup/plugin-commonjs": "^28.0.3",
154
156
  "@rollup/plugin-json": "^6.1.0",
155
- "@rollup/plugin-node-resolve": "^16.0.0",
157
+ "@rollup/plugin-node-resolve": "^16.0.1",
156
158
  "@rollup/plugin-replace": "^6.0.2",
157
159
  "@rollup/plugin-terser": "^0.4.4",
158
160
  "@rollup/plugin-typescript": "^12.1.2",
159
161
  "@rollup/pluginutils": "^5.1.4",
160
- "@shikijs/vitepress-twoslash": "^3.1.0",
162
+ "@shikijs/vitepress-twoslash": "^3.2.1",
161
163
  "@types/mocha": "^10.0.10",
162
- "@types/node": "^18.19.79",
164
+ "@types/node": "^18.19.80",
163
165
  "@types/semver": "^7.5.8",
164
166
  "@types/yargs-parser": "^21.0.3",
165
167
  "@vue/language-server": "^2.2.8",
166
- "acorn": "^8.14.0",
168
+ "acorn": "^8.14.1",
167
169
  "acorn-import-assertions": "^1.9.0",
168
170
  "acorn-jsx": "^5.3.2",
169
171
  "buble": "^0.20.0",
@@ -175,11 +177,11 @@
175
177
  "date-time": "^4.0.0",
176
178
  "es5-shim": "^4.6.7",
177
179
  "es6-shim": "^0.35.8",
178
- "eslint": "^9.21.0",
179
- "eslint-config-prettier": "^10.0.2",
180
+ "eslint": "^9.22.0",
181
+ "eslint-config-prettier": "^10.1.1",
180
182
  "eslint-plugin-prettier": "^5.2.3",
181
183
  "eslint-plugin-unicorn": "^57.0.0",
182
- "eslint-plugin-vue": "^9.32.0",
184
+ "eslint-plugin-vue": "^10.0.0",
183
185
  "fixturify": "^3.0.0",
184
186
  "flru": "^1.0.2",
185
187
  "fs-extra": "^11.3.0",
@@ -187,7 +189,7 @@
187
189
  "globals": "^16.0.0",
188
190
  "husky": "^9.1.7",
189
191
  "is-reference": "^3.0.3",
190
- "lint-staged": "^15.4.3",
192
+ "lint-staged": "^15.5.0",
191
193
  "locate-character": "^3.0.0",
192
194
  "magic-string": "^0.30.17",
193
195
  "mocha": "^11.1.0",
@@ -201,11 +203,11 @@
201
203
  "pretty-bytes": "^6.1.1",
202
204
  "pretty-ms": "^9.2.0",
203
205
  "requirejs": "^2.3.7",
204
- "rollup": "^4.34.9",
206
+ "rollup": "^4.36.0",
205
207
  "rollup-plugin-license": "^3.6.0",
206
208
  "rollup-plugin-string": "^3.0.0",
207
209
  "semver": "^7.7.1",
208
- "shx": "^0.3.4",
210
+ "shx": "^0.4.0",
209
211
  "signal-exit": "^4.1.0",
210
212
  "source-map": "^0.7.4",
211
213
  "source-map-support": "^0.5.21",
@@ -213,8 +215,8 @@
213
215
  "terser": "^5.39.0",
214
216
  "tslib": "^2.8.1",
215
217
  "typescript": "^5.8.2",
216
- "typescript-eslint": "^8.26.0",
217
- "vite": "^6.2.0",
218
+ "typescript-eslint": "^8.26.1",
219
+ "vite": "^6.2.2",
218
220
  "vitepress": "^1.6.3",
219
221
  "vue": "^3.5.13",
220
222
  "vue-tsc": "^2.2.8",
@@ -222,7 +224,7 @@
222
224
  "yargs-parser": "^21.1.1"
223
225
  },
224
226
  "overrides": {
225
- "axios": "^1.8.1",
227
+ "axios": "^1.8.3",
226
228
  "semver": "^7.7.1",
227
229
  "readable-stream": "npm:@built-in/readable-stream@1",
228
230
  "esbuild": ">0.24.2"