rollup 3.6.0-0 → 3.6.0-1

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
@@ -2,8 +2,8 @@
2
2
 
3
3
  /*
4
4
  @license
5
- Rollup.js v3.6.0-0
6
- Sun, 27 Nov 2022 06:53:45 GMT - commit 03fdcc007bd49a4c88579d93053248ebe03dcef9
5
+ Rollup.js v3.6.0-1
6
+ Mon, 05 Dec 2022 08:32:45 GMT - commit ae777941edd1a39ab3007c6c6fffee0c17c96b2f
7
7
 
8
8
  https://github.com/rollup/rollup
9
9
 
package/dist/es/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.0-0
4
- Sun, 27 Nov 2022 06:53:45 GMT - commit 03fdcc007bd49a4c88579d93053248ebe03dcef9
3
+ Rollup.js v3.6.0-1
4
+ Mon, 05 Dec 2022 08:32:45 GMT - commit ae777941edd1a39ab3007c6c6fffee0c17c96b2f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.0-0
4
- Sun, 27 Nov 2022 06:53:45 GMT - commit 03fdcc007bd49a4c88579d93053248ebe03dcef9
3
+ Rollup.js v3.6.0-1
4
+ Mon, 05 Dec 2022 08:32:45 GMT - commit ae777941edd1a39ab3007c6c6fffee0c17c96b2f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -16,7 +16,7 @@ import { promises } from 'node:fs';
16
16
  import { EventEmitter } from 'node:events';
17
17
  import * as tty from 'tty';
18
18
 
19
- var version$1 = "3.6.0-0";
19
+ var version$1 = "3.6.0-1";
20
20
 
21
21
  var charToInteger = {};
22
22
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -1681,7 +1681,7 @@ function formatAssertions$1(assertions, { getObject }) {
1681
1681
 
1682
1682
  function getOrCreate(map, key, init) {
1683
1683
  const existing = map.get(key);
1684
- if (existing) {
1684
+ if (existing !== undefined) {
1685
1685
  return existing;
1686
1686
  }
1687
1687
  const value = init();
@@ -15831,7 +15831,7 @@ function* concatLazy(iterables) {
15831
15831
  }
15832
15832
  }
15833
15833
 
15834
- function getChunkAssignments(entryModules, manualChunkAliasByEntry, minChunkSize) {
15834
+ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
15835
15835
  const chunkDefinitions = [];
15836
15836
  const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
15837
15837
  const manualChunkModulesByAlias = Object.create(null);
@@ -15841,53 +15841,19 @@ function getChunkAssignments(entryModules, manualChunkAliasByEntry, minChunkSize
15841
15841
  for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
15842
15842
  chunkDefinitions.push({ alias, modules });
15843
15843
  }
15844
+ const alreadyLoadedModulesByDynamicEntry = getAlreadyLoadedModulesByDynamicEntry(entries);
15844
15845
  const assignedEntryPointsByModule = new Map();
15845
- const { dependentEntryPointsByModule, dynamicEntryModules } = analyzeModuleGraph(entryModules);
15846
- const dynamicallyDependentEntryPointsByDynamicEntry = getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules);
15847
- const staticEntries = new Set(entryModules);
15848
- function assignEntryToStaticDependencies(entry, dynamicDependentEntryPoints) {
15849
- const modulesToHandle = new Set([entry]);
15850
- for (const module of modulesToHandle) {
15851
- const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set());
15852
- if (dynamicDependentEntryPoints &&
15853
- areEntryPointsContainedOrDynamicallyDependent(dynamicDependentEntryPoints, dependentEntryPointsByModule.get(module))) {
15854
- continue;
15855
- }
15856
- else {
15857
- assignedEntryPoints.add(entry);
15858
- }
15859
- for (const dependency of module.getDependenciesToBeIncluded()) {
15860
- if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
15861
- modulesToHandle.add(dependency);
15862
- }
15863
- }
15864
- }
15865
- }
15866
- function areEntryPointsContainedOrDynamicallyDependent(entryPoints, containedIn) {
15867
- const entriesToCheck = new Set(entryPoints);
15868
- for (const entry of entriesToCheck) {
15869
- if (!containedIn.has(entry)) {
15870
- if (staticEntries.has(entry))
15871
- return false;
15872
- const dynamicallyDependentEntryPoints = dynamicallyDependentEntryPointsByDynamicEntry.get(entry);
15873
- for (const dependentEntry of dynamicallyDependentEntryPoints) {
15874
- entriesToCheck.add(dependentEntry);
15875
- }
15876
- }
15877
- }
15878
- return true;
15879
- }
15880
- for (const entry of entryModules) {
15846
+ for (const entry of entries) {
15881
15847
  if (!modulesInManualChunks.has(entry)) {
15882
- assignEntryToStaticDependencies(entry, null);
15848
+ assignEntryToStaticDependencies(entry, undefined, assignedEntryPointsByModule, modulesInManualChunks);
15883
15849
  }
15884
15850
  }
15885
- for (const entry of dynamicEntryModules) {
15851
+ for (const entry of alreadyLoadedModulesByDynamicEntry.keys()) {
15886
15852
  if (!modulesInManualChunks.has(entry)) {
15887
- assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
15853
+ assignEntryToStaticDependencies(entry, alreadyLoadedModulesByDynamicEntry.get(entry), assignedEntryPointsByModule, modulesInManualChunks);
15888
15854
  }
15889
15855
  }
15890
- chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule, minChunkSize));
15856
+ chunkDefinitions.push(...createChunks([...entries, ...alreadyLoadedModulesByDynamicEntry.keys()], assignedEntryPointsByModule, minChunkSize));
15891
15857
  return chunkDefinitions;
15892
15858
  }
15893
15859
  function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
@@ -15902,47 +15868,87 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
15902
15868
  }
15903
15869
  }
15904
15870
  }
15905
- function analyzeModuleGraph(entryModules) {
15906
- const dynamicEntryModules = new Set();
15871
+ function getAlreadyLoadedModulesByDynamicEntry(entryModules) {
15872
+ const allModules = new Set(entryModules);
15907
15873
  const dependentEntryPointsByModule = new Map();
15874
+ const dynamicImportsByEntry = new Map();
15875
+ const dynamicallyDependentEntryPointsByDynamicEntry = new Map();
15908
15876
  const entriesToHandle = new Set(entryModules);
15909
15877
  for (const currentEntry of entriesToHandle) {
15910
15878
  const modulesToHandle = new Set([currentEntry]);
15879
+ const dynamicImports = new Set();
15880
+ dynamicImportsByEntry.set(currentEntry, dynamicImports);
15911
15881
  for (const module of modulesToHandle) {
15912
15882
  getOrCreate(dependentEntryPointsByModule, module, () => new Set()).add(currentEntry);
15913
15883
  for (const dependency of module.getDependenciesToBeIncluded()) {
15914
15884
  if (!(dependency instanceof ExternalModule)) {
15915
15885
  modulesToHandle.add(dependency);
15886
+ allModules.add(dependency);
15916
15887
  }
15917
15888
  }
15918
15889
  for (const { resolution } of module.dynamicImports) {
15919
15890
  if (resolution instanceof Module && resolution.includedDynamicImporters.length > 0) {
15920
- dynamicEntryModules.add(resolution);
15891
+ dynamicImports.add(resolution);
15892
+ getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, resolution, () => new Set()).add(currentEntry);
15921
15893
  entriesToHandle.add(resolution);
15894
+ allModules.add(resolution);
15922
15895
  }
15923
15896
  }
15924
15897
  for (const dependency of module.implicitlyLoadedBefore) {
15925
- dynamicEntryModules.add(dependency);
15898
+ dynamicImports.add(dependency);
15899
+ getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, dependency, () => new Set()).add(currentEntry);
15926
15900
  entriesToHandle.add(dependency);
15901
+ allModules.add(dependency);
15927
15902
  }
15928
15903
  }
15929
15904
  }
15930
- return { dependentEntryPointsByModule, dynamicEntryModules };
15905
+ return buildAlreadyLoadedModulesByDynamicEntry(allModules, dependentEntryPointsByModule, dynamicImportsByEntry, dynamicallyDependentEntryPointsByDynamicEntry);
15931
15906
  }
15932
- function getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules) {
15933
- const dynamicallyDependentEntryPointsByDynamicEntry = new Map();
15934
- for (const dynamicEntry of dynamicEntryModules) {
15935
- const dynamicDependentEntryPoints = getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, dynamicEntry, () => new Set());
15936
- for (const importer of [
15937
- ...dynamicEntry.includedDynamicImporters,
15938
- ...dynamicEntry.implicitlyLoadedAfter
15939
- ]) {
15940
- for (const entryPoint of dependentEntryPointsByModule.get(importer)) {
15941
- dynamicDependentEntryPoints.add(entryPoint);
15907
+ function buildAlreadyLoadedModulesByDynamicEntry(allModules, dependentEntryPointsByModule, dynamicImportsByEntry, dynamicallyDependentEntryPointsByDynamicEntry) {
15908
+ const alreadyLoadedModulesByDynamicEntry = new Map();
15909
+ for (const dynamicEntry of dynamicallyDependentEntryPointsByDynamicEntry.keys()) {
15910
+ alreadyLoadedModulesByDynamicEntry.set(dynamicEntry, new Set());
15911
+ }
15912
+ for (const module of allModules) {
15913
+ const dependentEntryPoints = dependentEntryPointsByModule.get(module);
15914
+ for (const entry of dependentEntryPoints) {
15915
+ const dynamicEntriesToHandle = [...dynamicImportsByEntry.get(entry)];
15916
+ nextDynamicEntry: for (const dynamicEntry of dynamicEntriesToHandle) {
15917
+ const alreadyLoadedModules = alreadyLoadedModulesByDynamicEntry.get(dynamicEntry);
15918
+ if (alreadyLoadedModules.has(module)) {
15919
+ continue;
15920
+ }
15921
+ for (const siblingDependentEntry of dynamicallyDependentEntryPointsByDynamicEntry.get(dynamicEntry)) {
15922
+ if (!(dependentEntryPoints.has(siblingDependentEntry) ||
15923
+ alreadyLoadedModulesByDynamicEntry.get(siblingDependentEntry)?.has(module))) {
15924
+ continue nextDynamicEntry;
15925
+ }
15926
+ }
15927
+ alreadyLoadedModules.add(module);
15928
+ dynamicEntriesToHandle.push(...dynamicImportsByEntry.get(dynamicEntry));
15929
+ }
15930
+ }
15931
+ }
15932
+ return alreadyLoadedModulesByDynamicEntry;
15933
+ }
15934
+ function assignEntryToStaticDependencies(entry, alreadyLoadedModules, assignedEntryPointsByModule, modulesInManualChunks) {
15935
+ const modulesToHandle = new Set([entry]);
15936
+ for (const module of modulesToHandle) {
15937
+ const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set());
15938
+ // If the module is "already loaded" for this dynamic entry, we do not need
15939
+ // to mark it for this dynamic entry
15940
+ if (alreadyLoadedModules?.has(module)) {
15941
+ continue;
15942
+ }
15943
+ else {
15944
+ assignedEntryPoints.add(entry);
15945
+ }
15946
+ for (const dependency of module.getDependenciesToBeIncluded()) {
15947
+ if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
15948
+ modulesToHandle.add(dependency);
15942
15949
  }
15943
15950
  }
15944
15951
  }
15945
- return dynamicallyDependentEntryPointsByDynamicEntry;
15946
15952
  }
15947
15953
  function createChunks(allEntryPoints, assignedEntryPointsByModule, minChunkSize) {
15948
15954
  const chunkModulesBySignature = getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints);
@@ -16023,9 +16029,24 @@ function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
16023
16029
  for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
16024
16030
  let size = 0;
16025
16031
  let pure = true;
16032
+ const dependencies = new Set();
16033
+ const transitiveDependencies = new Set();
16026
16034
  for (const module of modules) {
16027
16035
  pure && (pure = !module.hasEffects());
16028
16036
  size += module.magicString.toString().length;
16037
+ for (const dependency of module.getDependenciesToBeIncluded()) {
16038
+ if (!(dependency instanceof ExternalModule)) {
16039
+ dependencies.add(dependency);
16040
+ transitiveDependencies.add(dependency);
16041
+ }
16042
+ }
16043
+ }
16044
+ for (const module of transitiveDependencies) {
16045
+ for (const dependency of module.getDependenciesToBeIncluded()) {
16046
+ if (!(dependency instanceof ExternalModule)) {
16047
+ transitiveDependencies.add(dependency);
16048
+ }
16049
+ }
16029
16050
  }
16030
16051
  (size < minChunkSize
16031
16052
  ? pure
@@ -16033,7 +16054,7 @@ function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
16033
16054
  : smallSideEffectChunks
16034
16055
  : pure
16035
16056
  ? bigPureChunks
16036
- : bigSideEffectChunks).push({ modules, pure, signature, size });
16057
+ : bigSideEffectChunks).push({ dependencies, modules, pure, signature, size, transitiveDependencies });
16037
16058
  }
16038
16059
  for (const chunks of [
16039
16060
  bigPureChunks,
@@ -16062,11 +16083,11 @@ function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartitio
16062
16083
  const distance = pure
16063
16084
  ? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
16064
16085
  : getSignatureDistance(targetChunk.signature, signature, true);
16065
- if (distance === 1) {
16066
- closestChunk = targetChunk;
16067
- break;
16068
- }
16069
- else if (distance < closestChunkDistance) {
16086
+ if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk)) {
16087
+ if (distance === 1) {
16088
+ closestChunk = targetChunk;
16089
+ break;
16090
+ }
16070
16091
  closestChunk = targetChunk;
16071
16092
  closestChunkDistance = distance;
16072
16093
  }
@@ -16078,10 +16099,30 @@ function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartitio
16078
16099
  closestChunk.size += size;
16079
16100
  closestChunk.pure && (closestChunk.pure = pure);
16080
16101
  closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
16102
+ const { dependencies, transitiveDependencies } = closestChunk;
16103
+ for (const dependency of mergedChunk.dependencies) {
16104
+ dependencies.add(dependency);
16105
+ }
16106
+ for (const dependency of mergedChunk.transitiveDependencies) {
16107
+ transitiveDependencies.add(dependency);
16108
+ }
16081
16109
  getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
16082
16110
  }
16083
16111
  }
16084
16112
  }
16113
+ // If a module is a transitive but not a direct dependency of the other chunk,
16114
+ // merging is prohibited as that would create a new cyclic dependency.
16115
+ function isValidMerge(mergedChunk, targetChunk) {
16116
+ for (const module of mergedChunk.modules) {
16117
+ if (targetChunk.transitiveDependencies.has(module) && !targetChunk.dependencies.has(module))
16118
+ return false;
16119
+ }
16120
+ for (const module of targetChunk.modules) {
16121
+ if (mergedChunk.transitiveDependencies.has(module) && !mergedChunk.dependencies.has(module))
16122
+ return false;
16123
+ }
16124
+ return true;
16125
+ }
16085
16126
  function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
16086
16127
  const subPartition = chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
16087
16128
  return chunk.pure ? subPartition.pure : subPartition.sideEffect;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.0-0
4
- Sun, 27 Nov 2022 06:53:45 GMT - commit 03fdcc007bd49a4c88579d93053248ebe03dcef9
3
+ Rollup.js v3.6.0-1
4
+ Mon, 05 Dec 2022 08:32:45 GMT - commit ae777941edd1a39ab3007c6c6fffee0c17c96b2f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.0-0
4
- Sun, 27 Nov 2022 06:53:45 GMT - commit 03fdcc007bd49a4c88579d93053248ebe03dcef9
3
+ Rollup.js v3.6.0-1
4
+ Mon, 05 Dec 2022 08:32:45 GMT - commit ae777941edd1a39ab3007c6c6fffee0c17c96b2f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/rollup.d.ts CHANGED
@@ -927,3 +927,8 @@ interface AcornNode {
927
927
 
928
928
  export function defineConfig(options: RollupOptions): RollupOptions;
929
929
  export function defineConfig(options: RollupOptions[]): RollupOptions[];
930
+ export function defineConfig(optionsFunction: RollupOptionsFunction): RollupOptionsFunction;
931
+
932
+ export type RollupOptionsFunction = (
933
+ commandLineArguments: Record<string, any>
934
+ ) => MaybePromise<RollupOptions | RollupOptions[]>;
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.0-0
4
- Sun, 27 Nov 2022 06:53:45 GMT - commit 03fdcc007bd49a4c88579d93053248ebe03dcef9
3
+ Rollup.js v3.6.0-1
4
+ Mon, 05 Dec 2022 08:32:45 GMT - commit ae777941edd1a39ab3007c6c6fffee0c17c96b2f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.0-0
4
- Sun, 27 Nov 2022 06:53:45 GMT - commit 03fdcc007bd49a4c88579d93053248ebe03dcef9
3
+ Rollup.js v3.6.0-1
4
+ Mon, 05 Dec 2022 08:32:45 GMT - commit ae777941edd1a39ab3007c6c6fffee0c17c96b2f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.0-0
4
- Sun, 27 Nov 2022 06:53:45 GMT - commit 03fdcc007bd49a4c88579d93053248ebe03dcef9
3
+ Rollup.js v3.6.0-1
4
+ Mon, 05 Dec 2022 08:32:45 GMT - commit ae777941edd1a39ab3007c6c6fffee0c17c96b2f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.0-0
4
- Sun, 27 Nov 2022 06:53:45 GMT - commit 03fdcc007bd49a4c88579d93053248ebe03dcef9
3
+ Rollup.js v3.6.0-1
4
+ Mon, 05 Dec 2022 08:32:45 GMT - commit ae777941edd1a39ab3007c6c6fffee0c17c96b2f
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$1 = "3.6.0-0";
34
+ var version$1 = "3.6.0-1";
35
35
 
36
36
  function ensureArray$1(items) {
37
37
  if (Array.isArray(items)) {
@@ -2828,7 +2828,7 @@ function formatAssertions(assertions, { getObject }) {
2828
2828
 
2829
2829
  function getOrCreate(map, key, init) {
2830
2830
  const existing = map.get(key);
2831
- if (existing) {
2831
+ if (existing !== undefined) {
2832
2832
  return existing;
2833
2833
  }
2834
2834
  const value = init();
@@ -16346,7 +16346,7 @@ function* concatLazy(iterables) {
16346
16346
  }
16347
16347
  }
16348
16348
 
16349
- function getChunkAssignments(entryModules, manualChunkAliasByEntry, minChunkSize) {
16349
+ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
16350
16350
  const chunkDefinitions = [];
16351
16351
  const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
16352
16352
  const manualChunkModulesByAlias = Object.create(null);
@@ -16356,53 +16356,19 @@ function getChunkAssignments(entryModules, manualChunkAliasByEntry, minChunkSize
16356
16356
  for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
16357
16357
  chunkDefinitions.push({ alias, modules });
16358
16358
  }
16359
+ const alreadyLoadedModulesByDynamicEntry = getAlreadyLoadedModulesByDynamicEntry(entries);
16359
16360
  const assignedEntryPointsByModule = new Map();
16360
- const { dependentEntryPointsByModule, dynamicEntryModules } = analyzeModuleGraph(entryModules);
16361
- const dynamicallyDependentEntryPointsByDynamicEntry = getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules);
16362
- const staticEntries = new Set(entryModules);
16363
- function assignEntryToStaticDependencies(entry, dynamicDependentEntryPoints) {
16364
- const modulesToHandle = new Set([entry]);
16365
- for (const module of modulesToHandle) {
16366
- const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set());
16367
- if (dynamicDependentEntryPoints &&
16368
- areEntryPointsContainedOrDynamicallyDependent(dynamicDependentEntryPoints, dependentEntryPointsByModule.get(module))) {
16369
- continue;
16370
- }
16371
- else {
16372
- assignedEntryPoints.add(entry);
16373
- }
16374
- for (const dependency of module.getDependenciesToBeIncluded()) {
16375
- if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
16376
- modulesToHandle.add(dependency);
16377
- }
16378
- }
16379
- }
16380
- }
16381
- function areEntryPointsContainedOrDynamicallyDependent(entryPoints, containedIn) {
16382
- const entriesToCheck = new Set(entryPoints);
16383
- for (const entry of entriesToCheck) {
16384
- if (!containedIn.has(entry)) {
16385
- if (staticEntries.has(entry))
16386
- return false;
16387
- const dynamicallyDependentEntryPoints = dynamicallyDependentEntryPointsByDynamicEntry.get(entry);
16388
- for (const dependentEntry of dynamicallyDependentEntryPoints) {
16389
- entriesToCheck.add(dependentEntry);
16390
- }
16391
- }
16392
- }
16393
- return true;
16394
- }
16395
- for (const entry of entryModules) {
16361
+ for (const entry of entries) {
16396
16362
  if (!modulesInManualChunks.has(entry)) {
16397
- assignEntryToStaticDependencies(entry, null);
16363
+ assignEntryToStaticDependencies(entry, undefined, assignedEntryPointsByModule, modulesInManualChunks);
16398
16364
  }
16399
16365
  }
16400
- for (const entry of dynamicEntryModules) {
16366
+ for (const entry of alreadyLoadedModulesByDynamicEntry.keys()) {
16401
16367
  if (!modulesInManualChunks.has(entry)) {
16402
- assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
16368
+ assignEntryToStaticDependencies(entry, alreadyLoadedModulesByDynamicEntry.get(entry), assignedEntryPointsByModule, modulesInManualChunks);
16403
16369
  }
16404
16370
  }
16405
- chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule, minChunkSize));
16371
+ chunkDefinitions.push(...createChunks([...entries, ...alreadyLoadedModulesByDynamicEntry.keys()], assignedEntryPointsByModule, minChunkSize));
16406
16372
  return chunkDefinitions;
16407
16373
  }
16408
16374
  function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
@@ -16417,47 +16383,87 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
16417
16383
  }
16418
16384
  }
16419
16385
  }
16420
- function analyzeModuleGraph(entryModules) {
16421
- const dynamicEntryModules = new Set();
16386
+ function getAlreadyLoadedModulesByDynamicEntry(entryModules) {
16387
+ const allModules = new Set(entryModules);
16422
16388
  const dependentEntryPointsByModule = new Map();
16389
+ const dynamicImportsByEntry = new Map();
16390
+ const dynamicallyDependentEntryPointsByDynamicEntry = new Map();
16423
16391
  const entriesToHandle = new Set(entryModules);
16424
16392
  for (const currentEntry of entriesToHandle) {
16425
16393
  const modulesToHandle = new Set([currentEntry]);
16394
+ const dynamicImports = new Set();
16395
+ dynamicImportsByEntry.set(currentEntry, dynamicImports);
16426
16396
  for (const module of modulesToHandle) {
16427
16397
  getOrCreate(dependentEntryPointsByModule, module, () => new Set()).add(currentEntry);
16428
16398
  for (const dependency of module.getDependenciesToBeIncluded()) {
16429
16399
  if (!(dependency instanceof ExternalModule)) {
16430
16400
  modulesToHandle.add(dependency);
16401
+ allModules.add(dependency);
16431
16402
  }
16432
16403
  }
16433
16404
  for (const { resolution } of module.dynamicImports) {
16434
16405
  if (resolution instanceof Module && resolution.includedDynamicImporters.length > 0) {
16435
- dynamicEntryModules.add(resolution);
16406
+ dynamicImports.add(resolution);
16407
+ getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, resolution, () => new Set()).add(currentEntry);
16436
16408
  entriesToHandle.add(resolution);
16409
+ allModules.add(resolution);
16437
16410
  }
16438
16411
  }
16439
16412
  for (const dependency of module.implicitlyLoadedBefore) {
16440
- dynamicEntryModules.add(dependency);
16413
+ dynamicImports.add(dependency);
16414
+ getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, dependency, () => new Set()).add(currentEntry);
16441
16415
  entriesToHandle.add(dependency);
16416
+ allModules.add(dependency);
16442
16417
  }
16443
16418
  }
16444
16419
  }
16445
- return { dependentEntryPointsByModule, dynamicEntryModules };
16420
+ return buildAlreadyLoadedModulesByDynamicEntry(allModules, dependentEntryPointsByModule, dynamicImportsByEntry, dynamicallyDependentEntryPointsByDynamicEntry);
16446
16421
  }
16447
- function getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEntryModules) {
16448
- const dynamicallyDependentEntryPointsByDynamicEntry = new Map();
16449
- for (const dynamicEntry of dynamicEntryModules) {
16450
- const dynamicDependentEntryPoints = getOrCreate(dynamicallyDependentEntryPointsByDynamicEntry, dynamicEntry, () => new Set());
16451
- for (const importer of [
16452
- ...dynamicEntry.includedDynamicImporters,
16453
- ...dynamicEntry.implicitlyLoadedAfter
16454
- ]) {
16455
- for (const entryPoint of dependentEntryPointsByModule.get(importer)) {
16456
- dynamicDependentEntryPoints.add(entryPoint);
16422
+ function buildAlreadyLoadedModulesByDynamicEntry(allModules, dependentEntryPointsByModule, dynamicImportsByEntry, dynamicallyDependentEntryPointsByDynamicEntry) {
16423
+ const alreadyLoadedModulesByDynamicEntry = new Map();
16424
+ for (const dynamicEntry of dynamicallyDependentEntryPointsByDynamicEntry.keys()) {
16425
+ alreadyLoadedModulesByDynamicEntry.set(dynamicEntry, new Set());
16426
+ }
16427
+ for (const module of allModules) {
16428
+ const dependentEntryPoints = dependentEntryPointsByModule.get(module);
16429
+ for (const entry of dependentEntryPoints) {
16430
+ const dynamicEntriesToHandle = [...dynamicImportsByEntry.get(entry)];
16431
+ nextDynamicEntry: for (const dynamicEntry of dynamicEntriesToHandle) {
16432
+ const alreadyLoadedModules = alreadyLoadedModulesByDynamicEntry.get(dynamicEntry);
16433
+ if (alreadyLoadedModules.has(module)) {
16434
+ continue;
16435
+ }
16436
+ for (const siblingDependentEntry of dynamicallyDependentEntryPointsByDynamicEntry.get(dynamicEntry)) {
16437
+ if (!(dependentEntryPoints.has(siblingDependentEntry) ||
16438
+ alreadyLoadedModulesByDynamicEntry.get(siblingDependentEntry)?.has(module))) {
16439
+ continue nextDynamicEntry;
16440
+ }
16441
+ }
16442
+ alreadyLoadedModules.add(module);
16443
+ dynamicEntriesToHandle.push(...dynamicImportsByEntry.get(dynamicEntry));
16444
+ }
16445
+ }
16446
+ }
16447
+ return alreadyLoadedModulesByDynamicEntry;
16448
+ }
16449
+ function assignEntryToStaticDependencies(entry, alreadyLoadedModules, assignedEntryPointsByModule, modulesInManualChunks) {
16450
+ const modulesToHandle = new Set([entry]);
16451
+ for (const module of modulesToHandle) {
16452
+ const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set());
16453
+ // If the module is "already loaded" for this dynamic entry, we do not need
16454
+ // to mark it for this dynamic entry
16455
+ if (alreadyLoadedModules?.has(module)) {
16456
+ continue;
16457
+ }
16458
+ else {
16459
+ assignedEntryPoints.add(entry);
16460
+ }
16461
+ for (const dependency of module.getDependenciesToBeIncluded()) {
16462
+ if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
16463
+ modulesToHandle.add(dependency);
16457
16464
  }
16458
16465
  }
16459
16466
  }
16460
- return dynamicallyDependentEntryPointsByDynamicEntry;
16461
16467
  }
16462
16468
  function createChunks(allEntryPoints, assignedEntryPointsByModule, minChunkSize) {
16463
16469
  const chunkModulesBySignature = getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints);
@@ -16538,9 +16544,24 @@ function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
16538
16544
  for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
16539
16545
  let size = 0;
16540
16546
  let pure = true;
16547
+ const dependencies = new Set();
16548
+ const transitiveDependencies = new Set();
16541
16549
  for (const module of modules) {
16542
16550
  pure && (pure = !module.hasEffects());
16543
16551
  size += module.magicString.toString().length;
16552
+ for (const dependency of module.getDependenciesToBeIncluded()) {
16553
+ if (!(dependency instanceof ExternalModule)) {
16554
+ dependencies.add(dependency);
16555
+ transitiveDependencies.add(dependency);
16556
+ }
16557
+ }
16558
+ }
16559
+ for (const module of transitiveDependencies) {
16560
+ for (const dependency of module.getDependenciesToBeIncluded()) {
16561
+ if (!(dependency instanceof ExternalModule)) {
16562
+ transitiveDependencies.add(dependency);
16563
+ }
16564
+ }
16544
16565
  }
16545
16566
  (size < minChunkSize
16546
16567
  ? pure
@@ -16548,7 +16569,7 @@ function getPartitionedChunks(chunkModulesBySignature, minChunkSize) {
16548
16569
  : smallSideEffectChunks
16549
16570
  : pure
16550
16571
  ? bigPureChunks
16551
- : bigSideEffectChunks).push({ modules, pure, signature, size });
16572
+ : bigSideEffectChunks).push({ dependencies, modules, pure, signature, size, transitiveDependencies });
16552
16573
  }
16553
16574
  for (const chunks of [
16554
16575
  bigPureChunks,
@@ -16577,11 +16598,11 @@ function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartitio
16577
16598
  const distance = pure
16578
16599
  ? getSignatureDistance(signature, targetChunk.signature, !targetChunk.pure)
16579
16600
  : getSignatureDistance(targetChunk.signature, signature, true);
16580
- if (distance === 1) {
16581
- closestChunk = targetChunk;
16582
- break;
16583
- }
16584
- else if (distance < closestChunkDistance) {
16601
+ if (distance < closestChunkDistance && isValidMerge(mergedChunk, targetChunk)) {
16602
+ if (distance === 1) {
16603
+ closestChunk = targetChunk;
16604
+ break;
16605
+ }
16585
16606
  closestChunk = targetChunk;
16586
16607
  closestChunkDistance = distance;
16587
16608
  }
@@ -16593,10 +16614,30 @@ function mergeChunks(chunksToBeMerged, targetChunks, minChunkSize, chunkPartitio
16593
16614
  closestChunk.size += size;
16594
16615
  closestChunk.pure && (closestChunk.pure = pure);
16595
16616
  closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
16617
+ const { dependencies, transitiveDependencies } = closestChunk;
16618
+ for (const dependency of mergedChunk.dependencies) {
16619
+ dependencies.add(dependency);
16620
+ }
16621
+ for (const dependency of mergedChunk.transitiveDependencies) {
16622
+ transitiveDependencies.add(dependency);
16623
+ }
16596
16624
  getChunksInPartition(closestChunk, minChunkSize, chunkPartition).add(closestChunk);
16597
16625
  }
16598
16626
  }
16599
16627
  }
16628
+ // If a module is a transitive but not a direct dependency of the other chunk,
16629
+ // merging is prohibited as that would create a new cyclic dependency.
16630
+ function isValidMerge(mergedChunk, targetChunk) {
16631
+ for (const module of mergedChunk.modules) {
16632
+ if (targetChunk.transitiveDependencies.has(module) && !targetChunk.dependencies.has(module))
16633
+ return false;
16634
+ }
16635
+ for (const module of targetChunk.modules) {
16636
+ if (mergedChunk.transitiveDependencies.has(module) && !mergedChunk.dependencies.has(module))
16637
+ return false;
16638
+ }
16639
+ return true;
16640
+ }
16600
16641
  function getChunksInPartition(chunk, minChunkSize, chunkPartition) {
16601
16642
  const subPartition = chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big;
16602
16643
  return chunk.pure ? subPartition.pure : subPartition.sideEffect;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.0-0
4
- Sun, 27 Nov 2022 06:53:45 GMT - commit 03fdcc007bd49a4c88579d93053248ebe03dcef9
3
+ Rollup.js v3.6.0-1
4
+ Mon, 05 Dec 2022 08:32:45 GMT - commit ae777941edd1a39ab3007c6c6fffee0c17c96b2f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.6.0-0
4
- Sun, 27 Nov 2022 06:53:45 GMT - commit 03fdcc007bd49a4c88579d93053248ebe03dcef9
3
+ Rollup.js v3.6.0-1
4
+ Mon, 05 Dec 2022 08:32:45 GMT - commit ae777941edd1a39ab3007c6c6fffee0c17c96b2f
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": "3.6.0-0",
3
+ "version": "3.6.0-1",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",