rollup 4.7.0 → 4.8.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.7.0
5
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
4
+ Rollup.js v4.8.0
5
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
6
6
 
7
7
  https://github.com/rollup/rollup
8
8
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
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.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -16,7 +16,7 @@ import { xxhashBase64Url } from '../../native.js';
16
16
  import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
17
17
  import * as tty from 'tty';
18
18
 
19
- var version = "4.7.0";
19
+ var version = "4.8.0";
20
20
 
21
21
  const comma = ','.charCodeAt(0);
22
22
  const semicolon = ';'.charCodeAt(0);
@@ -15913,11 +15913,15 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log
15913
15913
  const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry);
15914
15914
  const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry } = analyzeModuleGraph(entries);
15915
15915
  // Each chunk is identified by its position in this array
15916
- const initialChunks = getChunksFromDependentEntries(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks));
15917
- // This mutates initialChunks but also clears
15918
- // dynamicallyDependentEntriesByDynamicEntry as side effect
15919
- removeUnnecessaryDependentEntries(initialChunks, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
15920
- chunkDefinitions.push(...getOptimizedChunks(getChunksFromDependentEntries(initialChunks), allEntries.length, minChunkSize, log).map(({ modules }) => ({
15916
+ const chunkAtoms = getChunksWithSameDependentEntries(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks));
15917
+ const staticDependencyAtomsByEntry = getStaticDependencyAtomsByEntry(allEntries, chunkAtoms);
15918
+ // Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
15919
+ // If we no longer want this, we should make a copy here.
15920
+ const alreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
15921
+ // This mutates the dependentEntries in chunkAtoms
15922
+ removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry);
15923
+ const { chunks, sideEffectAtoms, sizeByAtom } = getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize);
15924
+ chunkDefinitions.push(...getOptimizedChunks(chunks, minChunkSize, sideEffectAtoms, sizeByAtom, log).map(({ modules }) => ({
15921
15925
  alias: null,
15922
15926
  modules
15923
15927
  })));
@@ -16026,7 +16030,7 @@ function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule,
16026
16030
  }
16027
16031
  return dynamicallyDependentEntriesByDynamicEntry;
16028
16032
  }
16029
- function getChunksFromDependentEntries(modulesWithDependentEntries) {
16033
+ function getChunksWithSameDependentEntries(modulesWithDependentEntries) {
16030
16034
  const chunkModules = Object.create(null);
16031
16035
  for (const { dependentEntries, modules } of modulesWithDependentEntries) {
16032
16036
  let chunkSignature = 0n;
@@ -16047,55 +16051,152 @@ function* getModulesWithDependentEntries(dependentEntriesByModule, modulesInManu
16047
16051
  }
16048
16052
  }
16049
16053
  }
16050
- /**
16051
- * This removes all unnecessary dynamic entries from the dependenEntries in its
16052
- * first argument. It will also consume its second argument, so if
16053
- * dynamicallyDependentEntriesByDynamicEntry is ever needed after this, we
16054
- * should make a copy.
16055
- */
16056
- function removeUnnecessaryDependentEntries(chunks, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries) {
16057
- // The indices correspond to the indices in allEntries. The chunks correspond
16054
+ function getStaticDependencyAtomsByEntry(allEntries, chunkAtoms) {
16055
+ // The indices correspond to the indices in allEntries. The atoms correspond
16058
16056
  // to bits in the bigint values where chunk 0 is the lowest bit.
16059
- const staticDependenciesPerEntry = allEntries.map(() => 0n);
16060
- const alreadyLoadedChunksPerEntry = allEntries.map((_entry, entryIndex) => dynamicallyDependentEntriesByDynamicEntry.has(entryIndex) ? -1n : 0n);
16061
- // This toggles the bits for each chunk that is a dependency of an entry
16062
- let chunkMask = 1n;
16063
- for (const { dependentEntries } of chunks) {
16057
+ const staticDependencyAtomsByEntry = allEntries.map(() => 0n);
16058
+ // This toggles the bits for each atom that is a dependency of an entry
16059
+ let atomMask = 1n;
16060
+ for (const { dependentEntries } of chunkAtoms) {
16064
16061
  for (const entryIndex of dependentEntries) {
16065
- staticDependenciesPerEntry[entryIndex] |= chunkMask;
16066
- }
16067
- chunkMask <<= 1n;
16068
- }
16069
- // Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
16070
- // If we no longer want this, we should make a copy here.
16071
- const updatedDynamicallyDependentEntriesByDynamicEntry = dynamicallyDependentEntriesByDynamicEntry;
16072
- for (const [dynamicEntryIndex, updatedDynamicallyDependentEntries] of updatedDynamicallyDependentEntriesByDynamicEntry) {
16073
- updatedDynamicallyDependentEntriesByDynamicEntry.delete(dynamicEntryIndex);
16074
- const previousLoadedModules = alreadyLoadedChunksPerEntry[dynamicEntryIndex];
16075
- let newLoadedModules = previousLoadedModules;
16076
- for (const entryIndex of updatedDynamicallyDependentEntries) {
16077
- newLoadedModules &=
16078
- staticDependenciesPerEntry[entryIndex] | alreadyLoadedChunksPerEntry[entryIndex];
16079
- }
16080
- if (newLoadedModules !== previousLoadedModules) {
16081
- alreadyLoadedChunksPerEntry[dynamicEntryIndex] = newLoadedModules;
16062
+ staticDependencyAtomsByEntry[entryIndex] |= atomMask;
16063
+ }
16064
+ atomMask <<= 1n;
16065
+ }
16066
+ return staticDependencyAtomsByEntry;
16067
+ }
16068
+ // Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
16069
+ function getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries) {
16070
+ // Dynamic entries have all atoms as already loaded initially because we then
16071
+ // intersect with the static dependency atoms of all dynamic importers.
16072
+ // Static entries cannot have already loaded atoms.
16073
+ const alreadyLoadedAtomsByEntry = allEntries.map((_entry, entryIndex) => dynamicallyDependentEntriesByDynamicEntry.has(entryIndex) ? -1n : 0n);
16074
+ for (const [dynamicEntryIndex, dynamicallyDependentEntries] of dynamicallyDependentEntriesByDynamicEntry) {
16075
+ // We delete here so that they can be added again if necessary to be handled
16076
+ // again by the loop
16077
+ dynamicallyDependentEntriesByDynamicEntry.delete(dynamicEntryIndex);
16078
+ const knownLoadedAtoms = alreadyLoadedAtomsByEntry[dynamicEntryIndex];
16079
+ let updatedLoadedAtoms = knownLoadedAtoms;
16080
+ for (const entryIndex of dynamicallyDependentEntries) {
16081
+ updatedLoadedAtoms &=
16082
+ staticDependencyAtomsByEntry[entryIndex] | alreadyLoadedAtomsByEntry[entryIndex];
16083
+ }
16084
+ // If the knownLoadedAtoms changed, all dependent dynamic entries need to be
16085
+ // updated again
16086
+ if (updatedLoadedAtoms !== knownLoadedAtoms) {
16087
+ alreadyLoadedAtomsByEntry[dynamicEntryIndex] = updatedLoadedAtoms;
16082
16088
  for (const dynamicImport of dynamicImportsByEntry[dynamicEntryIndex]) {
16083
- getOrCreate(updatedDynamicallyDependentEntriesByDynamicEntry, dynamicImport, (getNewSet)).add(dynamicEntryIndex);
16089
+ // If this adds an entry that was deleted before, it will be handled
16090
+ // again. This is the reason why we delete every entry from this map
16091
+ // that we processed.
16092
+ getOrCreate(dynamicallyDependentEntriesByDynamicEntry, dynamicImport, (getNewSet)).add(dynamicEntryIndex);
16084
16093
  }
16085
16094
  }
16086
16095
  }
16096
+ return alreadyLoadedAtomsByEntry;
16097
+ }
16098
+ /**
16099
+ * This removes all unnecessary dynamic entries from the dependentEntries in its
16100
+ * first argument if a chunk is already loaded without that entry.
16101
+ */
16102
+ function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry) {
16087
16103
  // Remove entries from dependent entries if a chunk is already loaded without
16088
16104
  // that entry.
16089
- chunkMask = 1n;
16090
- for (const { dependentEntries } of chunks) {
16105
+ let chunkMask = 1n;
16106
+ for (const { dependentEntries } of chunkAtoms) {
16091
16107
  for (const entryIndex of dependentEntries) {
16092
- if ((alreadyLoadedChunksPerEntry[entryIndex] & chunkMask) === chunkMask) {
16108
+ if ((alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask) {
16093
16109
  dependentEntries.delete(entryIndex);
16094
16110
  }
16095
16111
  }
16096
16112
  chunkMask <<= 1n;
16097
16113
  }
16098
16114
  }
16115
+ function getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize) {
16116
+ const chunksBySignature = Object.create(null);
16117
+ const chunkByModule = new Map();
16118
+ const sizeByAtom = [];
16119
+ let sideEffectAtoms = 0n;
16120
+ let atomMask = 1n;
16121
+ for (const { dependentEntries, modules } of chunkAtoms) {
16122
+ let chunkSignature = 0n;
16123
+ let correlatedAtoms = -1n;
16124
+ for (const entryIndex of dependentEntries) {
16125
+ chunkSignature |= 1n << BigInt(entryIndex);
16126
+ // Correlated atoms are the atoms that are guaranteed to be loaded as
16127
+ // well when a given atom is loaded. It is the intersection of the already
16128
+ // loaded modules of each chunk merged with its static dependencies.
16129
+ correlatedAtoms &=
16130
+ staticDependencyAtomsByEntry[entryIndex] | alreadyLoadedAtomsByEntry[entryIndex];
16131
+ }
16132
+ const chunk = (chunksBySignature[String(chunkSignature)] ||= {
16133
+ containedAtoms: 0n,
16134
+ correlatedAtoms,
16135
+ dependencies: new Set(),
16136
+ dependentChunks: new Set(),
16137
+ dependentEntries: new Set(dependentEntries),
16138
+ modules: [],
16139
+ pure: true,
16140
+ size: 0
16141
+ });
16142
+ let atomSize = 0;
16143
+ let pure = true;
16144
+ for (const module of modules) {
16145
+ chunkByModule.set(module, chunk);
16146
+ // Unfortunately, we cannot take tree-shaking into account here because
16147
+ // rendering did not happen yet, but we can detect empty modules
16148
+ if (module.isIncluded()) {
16149
+ pure &&= !module.hasEffects();
16150
+ // we use a trivial size for the default minChunkSize to improve
16151
+ // performance
16152
+ atomSize += minChunkSize > 1 ? module.estimateSize() : 1;
16153
+ }
16154
+ }
16155
+ if (!pure) {
16156
+ sideEffectAtoms |= atomMask;
16157
+ }
16158
+ sizeByAtom.push(atomSize);
16159
+ chunk.containedAtoms |= atomMask;
16160
+ chunk.modules.push(...modules);
16161
+ chunk.pure &&= pure;
16162
+ chunk.size += atomSize;
16163
+ atomMask <<= 1n;
16164
+ }
16165
+ const chunks = Object.values(chunksBySignature);
16166
+ sideEffectAtoms |= addChunkDependenciesAndGetExternalSideEffectAtoms(chunks, chunkByModule, atomMask);
16167
+ return { chunks, sideEffectAtoms, sizeByAtom };
16168
+ }
16169
+ function addChunkDependenciesAndGetExternalSideEffectAtoms(chunks, chunkByModule, nextAvailableAtomMask) {
16170
+ const signatureByExternalModule = new Map();
16171
+ let externalSideEffectAtoms = 0n;
16172
+ for (const chunk of chunks) {
16173
+ const { dependencies, modules } = chunk;
16174
+ for (const module of modules) {
16175
+ for (const dependency of module.getDependenciesToBeIncluded()) {
16176
+ if (dependency instanceof ExternalModule) {
16177
+ if (dependency.info.moduleSideEffects) {
16178
+ const signature = getOrCreate(signatureByExternalModule, dependency, () => {
16179
+ const signature = nextAvailableAtomMask;
16180
+ nextAvailableAtomMask <<= 1n;
16181
+ externalSideEffectAtoms |= signature;
16182
+ return signature;
16183
+ });
16184
+ chunk.containedAtoms |= signature;
16185
+ chunk.correlatedAtoms |= signature;
16186
+ }
16187
+ }
16188
+ else {
16189
+ const dependencyChunk = chunkByModule.get(dependency);
16190
+ if (dependencyChunk && dependencyChunk !== chunk) {
16191
+ dependencies.add(dependencyChunk);
16192
+ dependencyChunk.dependentChunks.add(chunk);
16193
+ }
16194
+ }
16195
+ }
16196
+ }
16197
+ }
16198
+ return externalSideEffectAtoms;
16199
+ }
16099
16200
  /**
16100
16201
  * This function tries to get rid of small chunks by merging them with other
16101
16202
  * chunks.
@@ -16172,77 +16273,44 @@ function removeUnnecessaryDependentEntries(chunks, dynamicallyDependentEntriesBy
16172
16273
  * following the rule (a), starting with the smallest chunks to look for
16173
16274
  * possible merge targets.
16174
16275
  */
16175
- function getOptimizedChunks(initialChunks, numberOfEntries, minChunkSize, log) {
16276
+ function getOptimizedChunks(chunks, minChunkSize, sideEffectAtoms, sizeByAtom, log) {
16176
16277
  timeStart('optimize chunks', 3);
16177
- const chunkPartition = getPartitionedChunks(initialChunks, numberOfEntries, minChunkSize);
16278
+ const chunkPartition = getPartitionedChunks(chunks, minChunkSize);
16178
16279
  if (!chunkPartition) {
16179
16280
  timeEnd('optimize chunks', 3);
16180
- return initialChunks; // the actual modules
16281
+ return chunks; // the actual modules
16181
16282
  }
16182
16283
  minChunkSize > 1 &&
16183
- log('info', logOptimizeChunkStatus(initialChunks.length, chunkPartition.small.size, 'Initially'));
16184
- mergeChunks(chunkPartition, minChunkSize);
16284
+ log('info', logOptimizeChunkStatus(chunks.length, chunkPartition.small.size, 'Initially'));
16285
+ mergeChunks(chunkPartition, minChunkSize, sideEffectAtoms, sizeByAtom);
16185
16286
  minChunkSize > 1 &&
16186
16287
  log('info', logOptimizeChunkStatus(chunkPartition.small.size + chunkPartition.big.size, chunkPartition.small.size, 'After merging chunks'));
16187
16288
  timeEnd('optimize chunks', 3);
16188
16289
  return [...chunkPartition.small, ...chunkPartition.big];
16189
16290
  }
16190
- function getPartitionedChunks(initialChunks, numberOfEntries, minChunkSize) {
16291
+ function getPartitionedChunks(chunks, minChunkSize) {
16191
16292
  const smallChunks = [];
16192
16293
  const bigChunks = [];
16193
- const chunkByModule = new Map();
16194
- const sizeByAtom = [];
16195
- let sideEffectAtoms = 0n;
16196
- let containedAtoms = 1n;
16197
- for (const { dependentEntries, modules } of initialChunks) {
16198
- const chunkDescription = {
16199
- containedAtoms,
16200
- correlatedAtoms: 0n,
16201
- dependencies: new Set(),
16202
- dependentChunks: new Set(),
16203
- dependentEntries,
16204
- modules,
16205
- pure: true,
16206
- size: 0
16207
- };
16208
- let size = 0;
16209
- let pure = true;
16210
- for (const module of modules) {
16211
- chunkByModule.set(module, chunkDescription);
16212
- // Unfortunately, we cannot take tree-shaking into account here because
16213
- // rendering did not happen yet, but we can detect empty modules
16214
- if (module.isIncluded()) {
16215
- pure &&= !module.hasEffects();
16216
- // we use a trivial size for the default minChunkSize to improve
16217
- // performance
16218
- size += minChunkSize > 1 ? module.estimateSize() : 1;
16219
- }
16220
- }
16221
- chunkDescription.pure = pure;
16222
- chunkDescription.size = size;
16223
- sizeByAtom.push(size);
16224
- if (!pure) {
16225
- sideEffectAtoms |= containedAtoms;
16226
- }
16227
- (size < minChunkSize ? smallChunks : bigChunks).push(chunkDescription);
16228
- containedAtoms <<= 1n;
16294
+ for (const chunk of chunks) {
16295
+ (chunk.size < minChunkSize ? smallChunks : bigChunks).push(chunk);
16229
16296
  }
16230
- // If there are no small chunks, we will not optimize
16231
16297
  if (smallChunks.length === 0) {
16232
16298
  return null;
16233
16299
  }
16234
- sideEffectAtoms |= addChunkDependenciesAndAtomsAndGetSideEffectAtoms([bigChunks, smallChunks], chunkByModule, numberOfEntries, containedAtoms);
16300
+ smallChunks.sort(compareChunkSize);
16301
+ bigChunks.sort(compareChunkSize);
16235
16302
  return {
16236
16303
  big: new Set(bigChunks),
16237
- sideEffectAtoms,
16238
- sizeByAtom,
16239
16304
  small: new Set(smallChunks)
16240
16305
  };
16241
16306
  }
16242
- function mergeChunks(chunkPartition, minChunkSize) {
16307
+ function compareChunkSize({ size: sizeA }, { size: sizeB }) {
16308
+ return sizeA - sizeB;
16309
+ }
16310
+ function mergeChunks(chunkPartition, minChunkSize, sideEffectAtoms, sizeByAtom) {
16243
16311
  const { small } = chunkPartition;
16244
16312
  for (const mergedChunk of small) {
16245
- const bestTargetChunk = findBestMergeTarget(mergedChunk, chunkPartition,
16313
+ const bestTargetChunk = findBestMergeTarget(mergedChunk, chunkPartition, sideEffectAtoms, sizeByAtom,
16246
16314
  // In the default case, we do not accept size increases
16247
16315
  minChunkSize <= 1 ? 1 : Infinity);
16248
16316
  if (bestTargetChunk) {
@@ -16274,57 +16342,7 @@ function mergeChunks(chunkPartition, minChunkSize) {
16274
16342
  }
16275
16343
  }
16276
16344
  }
16277
- function addChunkDependenciesAndAtomsAndGetSideEffectAtoms(chunkLists, chunkByModule, numberOfEntries, nextAtomSignature) {
16278
- const signatureByExternalModule = new Map();
16279
- let sideEffectAtoms = 0n;
16280
- const atomsByEntry = [];
16281
- for (let index = 0; index < numberOfEntries; index++) {
16282
- atomsByEntry.push(0n);
16283
- }
16284
- for (const chunks of chunkLists) {
16285
- chunks.sort(compareChunkSize);
16286
- for (const chunk of chunks) {
16287
- const { dependencies, dependentEntries, modules } = chunk;
16288
- for (const module of modules) {
16289
- for (const dependency of module.getDependenciesToBeIncluded()) {
16290
- if (dependency instanceof ExternalModule) {
16291
- if (dependency.info.moduleSideEffects) {
16292
- chunk.containedAtoms |= getOrCreate(signatureByExternalModule, dependency, () => {
16293
- const signature = nextAtomSignature;
16294
- nextAtomSignature <<= 1n;
16295
- sideEffectAtoms |= signature;
16296
- return signature;
16297
- });
16298
- }
16299
- }
16300
- else {
16301
- const dependencyChunk = chunkByModule.get(dependency);
16302
- if (dependencyChunk && dependencyChunk !== chunk) {
16303
- dependencies.add(dependencyChunk);
16304
- dependencyChunk.dependentChunks.add(chunk);
16305
- }
16306
- }
16307
- }
16308
- }
16309
- const { containedAtoms } = chunk;
16310
- for (const entryIndex of dependentEntries) {
16311
- atomsByEntry[entryIndex] |= containedAtoms;
16312
- }
16313
- }
16314
- }
16315
- for (const chunks of chunkLists) {
16316
- for (const chunk of chunks) {
16317
- const { dependentEntries } = chunk;
16318
- // Correlated atoms are the intersection of all entry atoms
16319
- chunk.correlatedAtoms = -1n;
16320
- for (const entryIndex of dependentEntries) {
16321
- chunk.correlatedAtoms &= atomsByEntry[entryIndex];
16322
- }
16323
- }
16324
- }
16325
- return sideEffectAtoms;
16326
- }
16327
- function findBestMergeTarget(mergedChunk, { big, sideEffectAtoms, sizeByAtom, small }, smallestAdditionalSize) {
16345
+ function findBestMergeTarget(mergedChunk, { big, small }, sideEffectAtoms, sizeByAtom, smallestAdditionalSize) {
16328
16346
  let bestTargetChunk = null;
16329
16347
  // In the default case, we do not accept size increases
16330
16348
  for (const targetChunk of concatLazy([small, big])) {
@@ -16340,12 +16358,6 @@ function findBestMergeTarget(mergedChunk, { big, sideEffectAtoms, sizeByAtom, sm
16340
16358
  }
16341
16359
  return bestTargetChunk;
16342
16360
  }
16343
- function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
16344
- return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
16345
- }
16346
- function compareChunkSize({ size: sizeA }, { size: sizeB }) {
16347
- return sizeA - sizeB;
16348
- }
16349
16361
  /**
16350
16362
  * Determine the additional unused code size that would be added by merging the
16351
16363
  * two chunks. This is not an exact measurement but rather an upper bound. If
@@ -16403,6 +16415,9 @@ function getAtomsSizeIfBelowLimit(atoms, currentAdditionalSize, sizeByAtom) {
16403
16415
  }
16404
16416
  return size;
16405
16417
  }
16418
+ function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
16419
+ return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
16420
+ }
16406
16421
 
16407
16422
  // ported from https://github.com/substack/node-commondir
16408
16423
  function commondir(files) {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
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.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -12,21 +12,89 @@
12
12
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
13
13
 
14
14
  const rollup = require('./shared/rollup.js');
15
- const watchProxy = require('./shared/watch-proxy.js');
16
- require('./shared/parseAst.js');
17
- require('./native.js');
18
- require('node:path');
15
+ const parseAst_js = require('./shared/parseAst.js');
16
+ const fseventsImporter = require('./shared/fsevents-importer.js');
19
17
  require('node:process');
20
18
  require('tty');
19
+ require('node:path');
21
20
  require('path');
22
21
  require('node:perf_hooks');
22
+ require('./native.js');
23
23
  require('node:fs/promises');
24
- require('./shared/fsevents-importer.js');
25
24
 
25
+ class WatchEmitter {
26
+ constructor() {
27
+ this.currentHandlers = Object.create(null);
28
+ this.persistentHandlers = Object.create(null);
29
+ }
30
+ // Will be overwritten by Rollup
31
+ async close() { }
32
+ emit(event, ...parameters) {
33
+ return Promise.all([...this.getCurrentHandlers(event), ...this.getPersistentHandlers(event)].map(handler => handler(...parameters)));
34
+ }
35
+ off(event, listener) {
36
+ const listeners = this.persistentHandlers[event];
37
+ if (listeners) {
38
+ // A hack stolen from "mitt": ">>> 0" does not change numbers >= 0, but -1
39
+ // (which would remove the last array element if used unchanged) is turned
40
+ // into max_int, which is outside the array and does not change anything.
41
+ listeners.splice(listeners.indexOf(listener) >>> 0, 1);
42
+ }
43
+ return this;
44
+ }
45
+ on(event, listener) {
46
+ this.getPersistentHandlers(event).push(listener);
47
+ return this;
48
+ }
49
+ onCurrentRun(event, listener) {
50
+ this.getCurrentHandlers(event).push(listener);
51
+ return this;
52
+ }
53
+ once(event, listener) {
54
+ const selfRemovingListener = (...parameters) => {
55
+ this.off(event, selfRemovingListener);
56
+ return listener(...parameters);
57
+ };
58
+ this.on(event, selfRemovingListener);
59
+ return this;
60
+ }
61
+ removeAllListeners() {
62
+ this.removeListenersForCurrentRun();
63
+ this.persistentHandlers = Object.create(null);
64
+ return this;
65
+ }
66
+ removeListenersForCurrentRun() {
67
+ this.currentHandlers = Object.create(null);
68
+ return this;
69
+ }
70
+ getCurrentHandlers(event) {
71
+ return this.currentHandlers[event] || (this.currentHandlers[event] = []);
72
+ }
73
+ getPersistentHandlers(event) {
74
+ return this.persistentHandlers[event] || (this.persistentHandlers[event] = []);
75
+ }
76
+ }
26
77
 
78
+ function watch(configs) {
79
+ const emitter = new WatchEmitter();
80
+ watchInternal(configs, emitter).catch(error => {
81
+ rollup.handleError(error);
82
+ });
83
+ return emitter;
84
+ }
85
+ async function watchInternal(configs, emitter) {
86
+ const optionsList = await Promise.all(rollup.ensureArray(configs).map(config => rollup.mergeOptions(config, true)));
87
+ const watchOptionsList = optionsList.filter(config => config.watch !== false);
88
+ if (watchOptionsList.length === 0) {
89
+ return parseAst_js.error(parseAst_js.logInvalidOption('watch', parseAst_js.URL_WATCH, 'there must be at least one config where "watch" is not set to "false"'));
90
+ }
91
+ await fseventsImporter.loadFsEvents();
92
+ const { Watcher } = await Promise.resolve().then(() => require('./shared/watch.js'));
93
+ new Watcher(watchOptionsList, emitter);
94
+ }
27
95
 
28
96
  exports.VERSION = rollup.version;
29
97
  exports.defineConfig = rollup.defineConfig;
30
98
  exports.rollup = rollup.rollup;
31
- exports.watch = watchProxy.watch;
99
+ exports.watch = watch;
32
100
  //# sourceMappingURL=rollup.js.map
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
31
31
 
32
32
  const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
33
33
 
34
- var version = "4.7.0";
34
+ var version = "4.8.0";
35
35
 
36
36
  function ensureArray$1(items) {
37
37
  if (Array.isArray(items)) {
@@ -17233,11 +17233,15 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log
17233
17233
  const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry);
17234
17234
  const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry } = analyzeModuleGraph(entries);
17235
17235
  // Each chunk is identified by its position in this array
17236
- const initialChunks = getChunksFromDependentEntries(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks));
17237
- // This mutates initialChunks but also clears
17238
- // dynamicallyDependentEntriesByDynamicEntry as side effect
17239
- removeUnnecessaryDependentEntries(initialChunks, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
17240
- chunkDefinitions.push(...getOptimizedChunks(getChunksFromDependentEntries(initialChunks), allEntries.length, minChunkSize, log).map(({ modules }) => ({
17236
+ const chunkAtoms = getChunksWithSameDependentEntries(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks));
17237
+ const staticDependencyAtomsByEntry = getStaticDependencyAtomsByEntry(allEntries, chunkAtoms);
17238
+ // Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
17239
+ // If we no longer want this, we should make a copy here.
17240
+ const alreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
17241
+ // This mutates the dependentEntries in chunkAtoms
17242
+ removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry);
17243
+ const { chunks, sideEffectAtoms, sizeByAtom } = getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize);
17244
+ chunkDefinitions.push(...getOptimizedChunks(chunks, minChunkSize, sideEffectAtoms, sizeByAtom, log).map(({ modules }) => ({
17241
17245
  alias: null,
17242
17246
  modules
17243
17247
  })));
@@ -17346,7 +17350,7 @@ function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule,
17346
17350
  }
17347
17351
  return dynamicallyDependentEntriesByDynamicEntry;
17348
17352
  }
17349
- function getChunksFromDependentEntries(modulesWithDependentEntries) {
17353
+ function getChunksWithSameDependentEntries(modulesWithDependentEntries) {
17350
17354
  const chunkModules = Object.create(null);
17351
17355
  for (const { dependentEntries, modules } of modulesWithDependentEntries) {
17352
17356
  let chunkSignature = 0n;
@@ -17367,55 +17371,152 @@ function* getModulesWithDependentEntries(dependentEntriesByModule, modulesInManu
17367
17371
  }
17368
17372
  }
17369
17373
  }
17370
- /**
17371
- * This removes all unnecessary dynamic entries from the dependenEntries in its
17372
- * first argument. It will also consume its second argument, so if
17373
- * dynamicallyDependentEntriesByDynamicEntry is ever needed after this, we
17374
- * should make a copy.
17375
- */
17376
- function removeUnnecessaryDependentEntries(chunks, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries) {
17377
- // The indices correspond to the indices in allEntries. The chunks correspond
17374
+ function getStaticDependencyAtomsByEntry(allEntries, chunkAtoms) {
17375
+ // The indices correspond to the indices in allEntries. The atoms correspond
17378
17376
  // to bits in the bigint values where chunk 0 is the lowest bit.
17379
- const staticDependenciesPerEntry = allEntries.map(() => 0n);
17380
- const alreadyLoadedChunksPerEntry = allEntries.map((_entry, entryIndex) => dynamicallyDependentEntriesByDynamicEntry.has(entryIndex) ? -1n : 0n);
17381
- // This toggles the bits for each chunk that is a dependency of an entry
17382
- let chunkMask = 1n;
17383
- for (const { dependentEntries } of chunks) {
17377
+ const staticDependencyAtomsByEntry = allEntries.map(() => 0n);
17378
+ // This toggles the bits for each atom that is a dependency of an entry
17379
+ let atomMask = 1n;
17380
+ for (const { dependentEntries } of chunkAtoms) {
17384
17381
  for (const entryIndex of dependentEntries) {
17385
- staticDependenciesPerEntry[entryIndex] |= chunkMask;
17386
- }
17387
- chunkMask <<= 1n;
17388
- }
17389
- // Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
17390
- // If we no longer want this, we should make a copy here.
17391
- const updatedDynamicallyDependentEntriesByDynamicEntry = dynamicallyDependentEntriesByDynamicEntry;
17392
- for (const [dynamicEntryIndex, updatedDynamicallyDependentEntries] of updatedDynamicallyDependentEntriesByDynamicEntry) {
17393
- updatedDynamicallyDependentEntriesByDynamicEntry.delete(dynamicEntryIndex);
17394
- const previousLoadedModules = alreadyLoadedChunksPerEntry[dynamicEntryIndex];
17395
- let newLoadedModules = previousLoadedModules;
17396
- for (const entryIndex of updatedDynamicallyDependentEntries) {
17397
- newLoadedModules &=
17398
- staticDependenciesPerEntry[entryIndex] | alreadyLoadedChunksPerEntry[entryIndex];
17399
- }
17400
- if (newLoadedModules !== previousLoadedModules) {
17401
- alreadyLoadedChunksPerEntry[dynamicEntryIndex] = newLoadedModules;
17382
+ staticDependencyAtomsByEntry[entryIndex] |= atomMask;
17383
+ }
17384
+ atomMask <<= 1n;
17385
+ }
17386
+ return staticDependencyAtomsByEntry;
17387
+ }
17388
+ // Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
17389
+ function getAlreadyLoadedAtomsByEntry(staticDependencyAtomsByEntry, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries) {
17390
+ // Dynamic entries have all atoms as already loaded initially because we then
17391
+ // intersect with the static dependency atoms of all dynamic importers.
17392
+ // Static entries cannot have already loaded atoms.
17393
+ const alreadyLoadedAtomsByEntry = allEntries.map((_entry, entryIndex) => dynamicallyDependentEntriesByDynamicEntry.has(entryIndex) ? -1n : 0n);
17394
+ for (const [dynamicEntryIndex, dynamicallyDependentEntries] of dynamicallyDependentEntriesByDynamicEntry) {
17395
+ // We delete here so that they can be added again if necessary to be handled
17396
+ // again by the loop
17397
+ dynamicallyDependentEntriesByDynamicEntry.delete(dynamicEntryIndex);
17398
+ const knownLoadedAtoms = alreadyLoadedAtomsByEntry[dynamicEntryIndex];
17399
+ let updatedLoadedAtoms = knownLoadedAtoms;
17400
+ for (const entryIndex of dynamicallyDependentEntries) {
17401
+ updatedLoadedAtoms &=
17402
+ staticDependencyAtomsByEntry[entryIndex] | alreadyLoadedAtomsByEntry[entryIndex];
17403
+ }
17404
+ // If the knownLoadedAtoms changed, all dependent dynamic entries need to be
17405
+ // updated again
17406
+ if (updatedLoadedAtoms !== knownLoadedAtoms) {
17407
+ alreadyLoadedAtomsByEntry[dynamicEntryIndex] = updatedLoadedAtoms;
17402
17408
  for (const dynamicImport of dynamicImportsByEntry[dynamicEntryIndex]) {
17403
- getOrCreate(updatedDynamicallyDependentEntriesByDynamicEntry, dynamicImport, (getNewSet)).add(dynamicEntryIndex);
17409
+ // If this adds an entry that was deleted before, it will be handled
17410
+ // again. This is the reason why we delete every entry from this map
17411
+ // that we processed.
17412
+ getOrCreate(dynamicallyDependentEntriesByDynamicEntry, dynamicImport, (getNewSet)).add(dynamicEntryIndex);
17404
17413
  }
17405
17414
  }
17406
17415
  }
17416
+ return alreadyLoadedAtomsByEntry;
17417
+ }
17418
+ /**
17419
+ * This removes all unnecessary dynamic entries from the dependentEntries in its
17420
+ * first argument if a chunk is already loaded without that entry.
17421
+ */
17422
+ function removeUnnecessaryDependentEntries(chunkAtoms, alreadyLoadedAtomsByEntry) {
17407
17423
  // Remove entries from dependent entries if a chunk is already loaded without
17408
17424
  // that entry.
17409
- chunkMask = 1n;
17410
- for (const { dependentEntries } of chunks) {
17425
+ let chunkMask = 1n;
17426
+ for (const { dependentEntries } of chunkAtoms) {
17411
17427
  for (const entryIndex of dependentEntries) {
17412
- if ((alreadyLoadedChunksPerEntry[entryIndex] & chunkMask) === chunkMask) {
17428
+ if ((alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask) {
17413
17429
  dependentEntries.delete(entryIndex);
17414
17430
  }
17415
17431
  }
17416
17432
  chunkMask <<= 1n;
17417
17433
  }
17418
17434
  }
17435
+ function getChunksWithSameDependentEntriesAndCorrelatedAtoms(chunkAtoms, staticDependencyAtomsByEntry, alreadyLoadedAtomsByEntry, minChunkSize) {
17436
+ const chunksBySignature = Object.create(null);
17437
+ const chunkByModule = new Map();
17438
+ const sizeByAtom = [];
17439
+ let sideEffectAtoms = 0n;
17440
+ let atomMask = 1n;
17441
+ for (const { dependentEntries, modules } of chunkAtoms) {
17442
+ let chunkSignature = 0n;
17443
+ let correlatedAtoms = -1n;
17444
+ for (const entryIndex of dependentEntries) {
17445
+ chunkSignature |= 1n << BigInt(entryIndex);
17446
+ // Correlated atoms are the atoms that are guaranteed to be loaded as
17447
+ // well when a given atom is loaded. It is the intersection of the already
17448
+ // loaded modules of each chunk merged with its static dependencies.
17449
+ correlatedAtoms &=
17450
+ staticDependencyAtomsByEntry[entryIndex] | alreadyLoadedAtomsByEntry[entryIndex];
17451
+ }
17452
+ const chunk = (chunksBySignature[String(chunkSignature)] ||= {
17453
+ containedAtoms: 0n,
17454
+ correlatedAtoms,
17455
+ dependencies: new Set(),
17456
+ dependentChunks: new Set(),
17457
+ dependentEntries: new Set(dependentEntries),
17458
+ modules: [],
17459
+ pure: true,
17460
+ size: 0
17461
+ });
17462
+ let atomSize = 0;
17463
+ let pure = true;
17464
+ for (const module of modules) {
17465
+ chunkByModule.set(module, chunk);
17466
+ // Unfortunately, we cannot take tree-shaking into account here because
17467
+ // rendering did not happen yet, but we can detect empty modules
17468
+ if (module.isIncluded()) {
17469
+ pure &&= !module.hasEffects();
17470
+ // we use a trivial size for the default minChunkSize to improve
17471
+ // performance
17472
+ atomSize += minChunkSize > 1 ? module.estimateSize() : 1;
17473
+ }
17474
+ }
17475
+ if (!pure) {
17476
+ sideEffectAtoms |= atomMask;
17477
+ }
17478
+ sizeByAtom.push(atomSize);
17479
+ chunk.containedAtoms |= atomMask;
17480
+ chunk.modules.push(...modules);
17481
+ chunk.pure &&= pure;
17482
+ chunk.size += atomSize;
17483
+ atomMask <<= 1n;
17484
+ }
17485
+ const chunks = Object.values(chunksBySignature);
17486
+ sideEffectAtoms |= addChunkDependenciesAndGetExternalSideEffectAtoms(chunks, chunkByModule, atomMask);
17487
+ return { chunks, sideEffectAtoms, sizeByAtom };
17488
+ }
17489
+ function addChunkDependenciesAndGetExternalSideEffectAtoms(chunks, chunkByModule, nextAvailableAtomMask) {
17490
+ const signatureByExternalModule = new Map();
17491
+ let externalSideEffectAtoms = 0n;
17492
+ for (const chunk of chunks) {
17493
+ const { dependencies, modules } = chunk;
17494
+ for (const module of modules) {
17495
+ for (const dependency of module.getDependenciesToBeIncluded()) {
17496
+ if (dependency instanceof ExternalModule) {
17497
+ if (dependency.info.moduleSideEffects) {
17498
+ const signature = getOrCreate(signatureByExternalModule, dependency, () => {
17499
+ const signature = nextAvailableAtomMask;
17500
+ nextAvailableAtomMask <<= 1n;
17501
+ externalSideEffectAtoms |= signature;
17502
+ return signature;
17503
+ });
17504
+ chunk.containedAtoms |= signature;
17505
+ chunk.correlatedAtoms |= signature;
17506
+ }
17507
+ }
17508
+ else {
17509
+ const dependencyChunk = chunkByModule.get(dependency);
17510
+ if (dependencyChunk && dependencyChunk !== chunk) {
17511
+ dependencies.add(dependencyChunk);
17512
+ dependencyChunk.dependentChunks.add(chunk);
17513
+ }
17514
+ }
17515
+ }
17516
+ }
17517
+ }
17518
+ return externalSideEffectAtoms;
17519
+ }
17419
17520
  /**
17420
17521
  * This function tries to get rid of small chunks by merging them with other
17421
17522
  * chunks.
@@ -17492,77 +17593,44 @@ function removeUnnecessaryDependentEntries(chunks, dynamicallyDependentEntriesBy
17492
17593
  * following the rule (a), starting with the smallest chunks to look for
17493
17594
  * possible merge targets.
17494
17595
  */
17495
- function getOptimizedChunks(initialChunks, numberOfEntries, minChunkSize, log) {
17596
+ function getOptimizedChunks(chunks, minChunkSize, sideEffectAtoms, sizeByAtom, log) {
17496
17597
  timeStart('optimize chunks', 3);
17497
- const chunkPartition = getPartitionedChunks(initialChunks, numberOfEntries, minChunkSize);
17598
+ const chunkPartition = getPartitionedChunks(chunks, minChunkSize);
17498
17599
  if (!chunkPartition) {
17499
17600
  timeEnd('optimize chunks', 3);
17500
- return initialChunks; // the actual modules
17601
+ return chunks; // the actual modules
17501
17602
  }
17502
17603
  minChunkSize > 1 &&
17503
- log('info', parseAst_js.logOptimizeChunkStatus(initialChunks.length, chunkPartition.small.size, 'Initially'));
17504
- mergeChunks(chunkPartition, minChunkSize);
17604
+ log('info', parseAst_js.logOptimizeChunkStatus(chunks.length, chunkPartition.small.size, 'Initially'));
17605
+ mergeChunks(chunkPartition, minChunkSize, sideEffectAtoms, sizeByAtom);
17505
17606
  minChunkSize > 1 &&
17506
17607
  log('info', parseAst_js.logOptimizeChunkStatus(chunkPartition.small.size + chunkPartition.big.size, chunkPartition.small.size, 'After merging chunks'));
17507
17608
  timeEnd('optimize chunks', 3);
17508
17609
  return [...chunkPartition.small, ...chunkPartition.big];
17509
17610
  }
17510
- function getPartitionedChunks(initialChunks, numberOfEntries, minChunkSize) {
17611
+ function getPartitionedChunks(chunks, minChunkSize) {
17511
17612
  const smallChunks = [];
17512
17613
  const bigChunks = [];
17513
- const chunkByModule = new Map();
17514
- const sizeByAtom = [];
17515
- let sideEffectAtoms = 0n;
17516
- let containedAtoms = 1n;
17517
- for (const { dependentEntries, modules } of initialChunks) {
17518
- const chunkDescription = {
17519
- containedAtoms,
17520
- correlatedAtoms: 0n,
17521
- dependencies: new Set(),
17522
- dependentChunks: new Set(),
17523
- dependentEntries,
17524
- modules,
17525
- pure: true,
17526
- size: 0
17527
- };
17528
- let size = 0;
17529
- let pure = true;
17530
- for (const module of modules) {
17531
- chunkByModule.set(module, chunkDescription);
17532
- // Unfortunately, we cannot take tree-shaking into account here because
17533
- // rendering did not happen yet, but we can detect empty modules
17534
- if (module.isIncluded()) {
17535
- pure &&= !module.hasEffects();
17536
- // we use a trivial size for the default minChunkSize to improve
17537
- // performance
17538
- size += minChunkSize > 1 ? module.estimateSize() : 1;
17539
- }
17540
- }
17541
- chunkDescription.pure = pure;
17542
- chunkDescription.size = size;
17543
- sizeByAtom.push(size);
17544
- if (!pure) {
17545
- sideEffectAtoms |= containedAtoms;
17546
- }
17547
- (size < minChunkSize ? smallChunks : bigChunks).push(chunkDescription);
17548
- containedAtoms <<= 1n;
17614
+ for (const chunk of chunks) {
17615
+ (chunk.size < minChunkSize ? smallChunks : bigChunks).push(chunk);
17549
17616
  }
17550
- // If there are no small chunks, we will not optimize
17551
17617
  if (smallChunks.length === 0) {
17552
17618
  return null;
17553
17619
  }
17554
- sideEffectAtoms |= addChunkDependenciesAndAtomsAndGetSideEffectAtoms([bigChunks, smallChunks], chunkByModule, numberOfEntries, containedAtoms);
17620
+ smallChunks.sort(compareChunkSize);
17621
+ bigChunks.sort(compareChunkSize);
17555
17622
  return {
17556
17623
  big: new Set(bigChunks),
17557
- sideEffectAtoms,
17558
- sizeByAtom,
17559
17624
  small: new Set(smallChunks)
17560
17625
  };
17561
17626
  }
17562
- function mergeChunks(chunkPartition, minChunkSize) {
17627
+ function compareChunkSize({ size: sizeA }, { size: sizeB }) {
17628
+ return sizeA - sizeB;
17629
+ }
17630
+ function mergeChunks(chunkPartition, minChunkSize, sideEffectAtoms, sizeByAtom) {
17563
17631
  const { small } = chunkPartition;
17564
17632
  for (const mergedChunk of small) {
17565
- const bestTargetChunk = findBestMergeTarget(mergedChunk, chunkPartition,
17633
+ const bestTargetChunk = findBestMergeTarget(mergedChunk, chunkPartition, sideEffectAtoms, sizeByAtom,
17566
17634
  // In the default case, we do not accept size increases
17567
17635
  minChunkSize <= 1 ? 1 : Infinity);
17568
17636
  if (bestTargetChunk) {
@@ -17594,57 +17662,7 @@ function mergeChunks(chunkPartition, minChunkSize) {
17594
17662
  }
17595
17663
  }
17596
17664
  }
17597
- function addChunkDependenciesAndAtomsAndGetSideEffectAtoms(chunkLists, chunkByModule, numberOfEntries, nextAtomSignature) {
17598
- const signatureByExternalModule = new Map();
17599
- let sideEffectAtoms = 0n;
17600
- const atomsByEntry = [];
17601
- for (let index = 0; index < numberOfEntries; index++) {
17602
- atomsByEntry.push(0n);
17603
- }
17604
- for (const chunks of chunkLists) {
17605
- chunks.sort(compareChunkSize);
17606
- for (const chunk of chunks) {
17607
- const { dependencies, dependentEntries, modules } = chunk;
17608
- for (const module of modules) {
17609
- for (const dependency of module.getDependenciesToBeIncluded()) {
17610
- if (dependency instanceof ExternalModule) {
17611
- if (dependency.info.moduleSideEffects) {
17612
- chunk.containedAtoms |= getOrCreate(signatureByExternalModule, dependency, () => {
17613
- const signature = nextAtomSignature;
17614
- nextAtomSignature <<= 1n;
17615
- sideEffectAtoms |= signature;
17616
- return signature;
17617
- });
17618
- }
17619
- }
17620
- else {
17621
- const dependencyChunk = chunkByModule.get(dependency);
17622
- if (dependencyChunk && dependencyChunk !== chunk) {
17623
- dependencies.add(dependencyChunk);
17624
- dependencyChunk.dependentChunks.add(chunk);
17625
- }
17626
- }
17627
- }
17628
- }
17629
- const { containedAtoms } = chunk;
17630
- for (const entryIndex of dependentEntries) {
17631
- atomsByEntry[entryIndex] |= containedAtoms;
17632
- }
17633
- }
17634
- }
17635
- for (const chunks of chunkLists) {
17636
- for (const chunk of chunks) {
17637
- const { dependentEntries } = chunk;
17638
- // Correlated atoms are the intersection of all entry atoms
17639
- chunk.correlatedAtoms = -1n;
17640
- for (const entryIndex of dependentEntries) {
17641
- chunk.correlatedAtoms &= atomsByEntry[entryIndex];
17642
- }
17643
- }
17644
- }
17645
- return sideEffectAtoms;
17646
- }
17647
- function findBestMergeTarget(mergedChunk, { big, sideEffectAtoms, sizeByAtom, small }, smallestAdditionalSize) {
17665
+ function findBestMergeTarget(mergedChunk, { big, small }, sideEffectAtoms, sizeByAtom, smallestAdditionalSize) {
17648
17666
  let bestTargetChunk = null;
17649
17667
  // In the default case, we do not accept size increases
17650
17668
  for (const targetChunk of concatLazy([small, big])) {
@@ -17660,12 +17678,6 @@ function findBestMergeTarget(mergedChunk, { big, sideEffectAtoms, sizeByAtom, sm
17660
17678
  }
17661
17679
  return bestTargetChunk;
17662
17680
  }
17663
- function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
17664
- return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
17665
- }
17666
- function compareChunkSize({ size: sizeA }, { size: sizeB }) {
17667
- return sizeA - sizeB;
17668
- }
17669
17681
  /**
17670
17682
  * Determine the additional unused code size that would be added by merging the
17671
17683
  * two chunks. This is not an exact measurement but rather an upper bound. If
@@ -17723,6 +17735,9 @@ function getAtomsSizeIfBelowLimit(atoms, currentAdditionalSize, sizeByAtom) {
17723
17735
  }
17724
17736
  return size;
17725
17737
  }
17738
+ function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
17739
+ return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
17740
+ }
17726
17741
 
17727
17742
  // ported from https://github.com/substack/node-commondir
17728
17743
  function commondir(files) {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -19,7 +19,7 @@ const rollup = require('./rollup.js');
19
19
  const parseAst_js = require('./parseAst.js');
20
20
  const loadConfigFile_js = require('./loadConfigFile.js');
21
21
  const node_child_process = require('node:child_process');
22
- const watchProxy = require('./watch-proxy.js');
22
+ const rollup_js = require('../rollup.js');
23
23
  require('fs');
24
24
  require('util');
25
25
  require('stream');
@@ -485,7 +485,7 @@ async function watch(command) {
485
485
  await start(options, warnings);
486
486
  }
487
487
  async function start(configs, warnings) {
488
- watcher = watchProxy.watch(configs);
488
+ watcher = rollup_js.watch(configs);
489
489
  watcher.on('event', event => {
490
490
  switch (event.code) {
491
491
  case 'ERROR': {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
3
+ Rollup.js v4.8.0
4
+ Mon, 11 Dec 2023 06:24:24 GMT - commit 62b648e1cc6a1f00260bb85aa2050097bb4afd2b
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.7.0",
3
+ "version": "4.8.0",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",
@@ -101,19 +101,19 @@
101
101
  "homepage": "https://rollupjs.org/",
102
102
  "optionalDependencies": {
103
103
  "fsevents": "~2.3.2",
104
- "@rollup/rollup-darwin-arm64": "4.7.0",
105
- "@rollup/rollup-android-arm64": "4.7.0",
106
- "@rollup/rollup-win32-arm64-msvc": "4.7.0",
107
- "@rollup/rollup-linux-arm64-gnu": "4.7.0",
108
- "@rollup/rollup-linux-arm64-musl": "4.7.0",
109
- "@rollup/rollup-android-arm-eabi": "4.7.0",
110
- "@rollup/rollup-linux-arm-gnueabihf": "4.7.0",
111
- "@rollup/rollup-win32-ia32-msvc": "4.7.0",
112
- "@rollup/rollup-linux-riscv64-gnu": "4.7.0",
113
- "@rollup/rollup-darwin-x64": "4.7.0",
114
- "@rollup/rollup-win32-x64-msvc": "4.7.0",
115
- "@rollup/rollup-linux-x64-gnu": "4.7.0",
116
- "@rollup/rollup-linux-x64-musl": "4.7.0"
104
+ "@rollup/rollup-darwin-arm64": "4.8.0",
105
+ "@rollup/rollup-android-arm64": "4.8.0",
106
+ "@rollup/rollup-win32-arm64-msvc": "4.8.0",
107
+ "@rollup/rollup-linux-arm64-gnu": "4.8.0",
108
+ "@rollup/rollup-linux-arm64-musl": "4.8.0",
109
+ "@rollup/rollup-android-arm-eabi": "4.8.0",
110
+ "@rollup/rollup-linux-arm-gnueabihf": "4.8.0",
111
+ "@rollup/rollup-win32-ia32-msvc": "4.8.0",
112
+ "@rollup/rollup-linux-riscv64-gnu": "4.8.0",
113
+ "@rollup/rollup-darwin-x64": "4.8.0",
114
+ "@rollup/rollup-win32-x64-msvc": "4.8.0",
115
+ "@rollup/rollup-linux-x64-gnu": "4.8.0",
116
+ "@rollup/rollup-linux-x64-musl": "4.8.0"
117
117
  },
118
118
  "devDependenciesComments": {
119
119
  "@rollup/plugin-typescript": "It appears that 11.1.3 breaks sourcemaps"
@@ -1,88 +0,0 @@
1
- /*
2
- @license
3
- Rollup.js v4.7.0
4
- Fri, 08 Dec 2023 07:57:30 GMT - commit 098e29ca3e0643006870f9ed94710fd3004a9043
5
-
6
- https://github.com/rollup/rollup
7
-
8
- Released under the MIT License.
9
- */
10
- 'use strict';
11
-
12
- const rollup = require('./rollup.js');
13
- const parseAst_js = require('./parseAst.js');
14
- const fseventsImporter = require('./fsevents-importer.js');
15
-
16
- class WatchEmitter {
17
- constructor() {
18
- this.currentHandlers = Object.create(null);
19
- this.persistentHandlers = Object.create(null);
20
- }
21
- // Will be overwritten by Rollup
22
- async close() { }
23
- emit(event, ...parameters) {
24
- return Promise.all([...this.getCurrentHandlers(event), ...this.getPersistentHandlers(event)].map(handler => handler(...parameters)));
25
- }
26
- off(event, listener) {
27
- const listeners = this.persistentHandlers[event];
28
- if (listeners) {
29
- // A hack stolen from "mitt": ">>> 0" does not change numbers >= 0, but -1
30
- // (which would remove the last array element if used unchanged) is turned
31
- // into max_int, which is outside the array and does not change anything.
32
- listeners.splice(listeners.indexOf(listener) >>> 0, 1);
33
- }
34
- return this;
35
- }
36
- on(event, listener) {
37
- this.getPersistentHandlers(event).push(listener);
38
- return this;
39
- }
40
- onCurrentRun(event, listener) {
41
- this.getCurrentHandlers(event).push(listener);
42
- return this;
43
- }
44
- once(event, listener) {
45
- const selfRemovingListener = (...parameters) => {
46
- this.off(event, selfRemovingListener);
47
- return listener(...parameters);
48
- };
49
- this.on(event, selfRemovingListener);
50
- return this;
51
- }
52
- removeAllListeners() {
53
- this.removeListenersForCurrentRun();
54
- this.persistentHandlers = Object.create(null);
55
- return this;
56
- }
57
- removeListenersForCurrentRun() {
58
- this.currentHandlers = Object.create(null);
59
- return this;
60
- }
61
- getCurrentHandlers(event) {
62
- return this.currentHandlers[event] || (this.currentHandlers[event] = []);
63
- }
64
- getPersistentHandlers(event) {
65
- return this.persistentHandlers[event] || (this.persistentHandlers[event] = []);
66
- }
67
- }
68
-
69
- function watch(configs) {
70
- const emitter = new WatchEmitter();
71
- watchInternal(configs, emitter).catch(error => {
72
- rollup.handleError(error);
73
- });
74
- return emitter;
75
- }
76
- async function watchInternal(configs, emitter) {
77
- const optionsList = await Promise.all(rollup.ensureArray(configs).map(config => rollup.mergeOptions(config, true)));
78
- const watchOptionsList = optionsList.filter(config => config.watch !== false);
79
- if (watchOptionsList.length === 0) {
80
- return parseAst_js.error(parseAst_js.logInvalidOption('watch', parseAst_js.URL_WATCH, 'there must be at least one config where "watch" is not set to "false"'));
81
- }
82
- await fseventsImporter.loadFsEvents();
83
- const { Watcher } = await Promise.resolve().then(() => require('./watch.js'));
84
- new Watcher(watchOptionsList, emitter);
85
- }
86
-
87
- exports.watch = watch;
88
- //# sourceMappingURL=watch-proxy.js.map