rollup 3.2.5 → 3.3.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/README.md CHANGED
@@ -118,7 +118,7 @@ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com
118
118
 
119
119
  Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/rollup#sponsor)]
120
120
 
121
- <a href="https://opencollective.com/rollup/sponsor/0/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/0/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/1/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/1/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/2/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/2/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/3/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/3/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/4/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/4/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/5/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/5/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/6/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/6/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/7/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/7/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/8/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/8/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/9/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/9/avatar.svg"></a>
121
+ <a href="https://opencollective.com/rollup/sponsor/0/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/0/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/1/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/1/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/2/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/2/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/3/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/3/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/4/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/4/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/5/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/5/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/6/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/6/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/7/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/7/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/8/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/8/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/9/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/9/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/10/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/10/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/11/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/11/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/12/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/12/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/13/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/13/avatar.svg"></a> <a href="https://opencollective.com/rollup/sponsor/14/website" target="_blank"><img src="https://opencollective.com/rollup/sponsor/14/avatar.svg"></a>
122
122
 
123
123
  ## License
124
124
 
package/dist/bin/rollup CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  /*
4
4
  @license
5
- Rollup.js v3.2.5
6
- Tue, 01 Nov 2022 05:28:36 GMT - commit 465d2396ba8dabba0366461d4014998cc13a9cc2
5
+ Rollup.js v3.3.0
6
+ Sat, 12 Nov 2022 05:21:34 GMT - commit ff286e5a14e32b6e820b188ccd63ac27bdd8adc9
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.2.5
4
- Tue, 01 Nov 2022 05:28:36 GMT - commit 465d2396ba8dabba0366461d4014998cc13a9cc2
3
+ Rollup.js v3.3.0
4
+ Sat, 12 Nov 2022 05:21:34 GMT - commit ff286e5a14e32b6e820b188ccd63ac27bdd8adc9
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.2.5
4
- Tue, 01 Nov 2022 05:28:36 GMT - commit 465d2396ba8dabba0366461d4014998cc13a9cc2
3
+ Rollup.js v3.3.0
4
+ Sat, 12 Nov 2022 05:21:34 GMT - commit ff286e5a14e32b6e820b188ccd63ac27bdd8adc9
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.2.5";
19
+ var version$1 = "3.3.0";
20
20
 
21
21
  var charToInteger = {};
22
22
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -12618,13 +12618,21 @@ function getPluginWithTimers(plugin, index) {
12618
12618
  timerLabel += ` (${plugin.name})`;
12619
12619
  }
12620
12620
  timerLabel += ` - ${hook}`;
12621
- const hookFunction = plugin[hook];
12622
- plugin[hook] = function (...parameters) {
12621
+ const handler = function (...parameters) {
12623
12622
  timeStart(timerLabel, 4);
12624
12623
  const result = hookFunction.apply(this, parameters);
12625
12624
  timeEnd(timerLabel, 4);
12626
12625
  return result;
12627
12626
  };
12627
+ let hookFunction;
12628
+ if (typeof plugin[hook].handler === 'function') {
12629
+ hookFunction = plugin[hook].handler;
12630
+ plugin[hook].handler = handler;
12631
+ }
12632
+ else {
12633
+ hookFunction = plugin[hook];
12634
+ plugin[hook] = handler;
12635
+ }
12628
12636
  }
12629
12637
  }
12630
12638
  return plugin;
@@ -13876,11 +13884,9 @@ function getImportBlock(dependencies, { _ }) {
13876
13884
  }
13877
13885
  else if (importedNames.length > 0) {
13878
13886
  importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
13879
- .map(specifier => {
13880
- return specifier.imported === specifier.local
13881
- ? specifier.imported
13882
- : `${specifier.imported} as ${specifier.local}`;
13883
- })
13887
+ .map(specifier => specifier.imported === specifier.local
13888
+ ? specifier.imported
13889
+ : `${specifier.imported} as ${specifier.local}`)
13884
13890
  .join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
13885
13891
  }
13886
13892
  }
@@ -13913,11 +13919,9 @@ function getImportBlock(dependencies, { _ }) {
13913
13919
  }
13914
13920
  if (namedReexports.length > 0) {
13915
13921
  importBlock.push(`export${_}{${_}${namedReexports
13916
- .map(specifier => {
13917
- return specifier.imported === specifier.reexported
13918
- ? specifier.imported
13919
- : `${specifier.imported} as ${specifier.reexported}`;
13920
- })
13922
+ .map(specifier => specifier.imported === specifier.reexported
13923
+ ? specifier.imported
13924
+ : `${specifier.imported} as ${specifier.reexported}`)
13921
13925
  .join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
13922
13926
  }
13923
13927
  }
@@ -15635,14 +15639,23 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
15635
15639
  const QUERY_HASH_REGEX = /[#?]/;
15636
15640
  const resolveFileName = (dependency) => dependency.getFileName();
15637
15641
 
15638
- function getChunkAssignments(entryModules, manualChunkAliasByEntry) {
15642
+ /**
15643
+ * Concatenate a number of iterables to a new iterable without fully evaluating
15644
+ * their iterators. Useful when e.g. working with large sets or lists and when
15645
+ * there is a chance that the iterators will not be fully exhausted.
15646
+ */
15647
+ function* concatLazy(...iterables) {
15648
+ for (const iterable of iterables) {
15649
+ yield* iterable;
15650
+ }
15651
+ }
15652
+
15653
+ function getChunkAssignments(entryModules, manualChunkAliasByEntry, minChunkSize) {
15639
15654
  const chunkDefinitions = [];
15640
15655
  const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
15641
15656
  const manualChunkModulesByAlias = Object.create(null);
15642
15657
  for (const [entry, alias] of manualChunkAliasByEntry) {
15643
- const chunkModules = (manualChunkModulesByAlias[alias] =
15644
- manualChunkModulesByAlias[alias] || []);
15645
- addStaticDependenciesToManualChunk(entry, chunkModules, modulesInManualChunks);
15658
+ addStaticDependenciesToManualChunk(entry, (manualChunkModulesByAlias[alias] || (manualChunkModulesByAlias[alias] = [])), modulesInManualChunks);
15646
15659
  }
15647
15660
  for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
15648
15661
  chunkDefinitions.push({ alias, modules });
@@ -15693,7 +15706,7 @@ function getChunkAssignments(entryModules, manualChunkAliasByEntry) {
15693
15706
  assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
15694
15707
  }
15695
15708
  }
15696
- chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule));
15709
+ chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule, minChunkSize));
15697
15710
  return chunkDefinitions;
15698
15711
  }
15699
15712
  function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
@@ -15750,12 +15763,60 @@ function getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEnt
15750
15763
  }
15751
15764
  return dynamicallyDependentEntryPointsByDynamicEntry;
15752
15765
  }
15753
- function createChunks(allEntryPoints, assignedEntryPointsByModule) {
15766
+ function createChunks(allEntryPoints, assignedEntryPointsByModule, minChunkSize) {
15767
+ const chunkModulesBySignature = getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints);
15768
+ return minChunkSize === 0
15769
+ ? Object.values(chunkModulesBySignature).map(modules => ({
15770
+ alias: null,
15771
+ modules
15772
+ }))
15773
+ : getOptimizedChunks(chunkModulesBySignature, minChunkSize);
15774
+ }
15775
+ function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
15776
+ timeStart('optimize chunks', 3);
15777
+ const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
15778
+ for (const sourceChunk of chunksToBeMerged) {
15779
+ chunksToBeMerged.delete(sourceChunk);
15780
+ let closestChunk = null;
15781
+ let closestChunkDistance = Infinity;
15782
+ const { signature, size, modules } = sourceChunk;
15783
+ for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
15784
+ const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
15785
+ if (distance === 1) {
15786
+ closestChunk = targetChunk;
15787
+ break;
15788
+ }
15789
+ else if (distance < closestChunkDistance) {
15790
+ closestChunk = targetChunk;
15791
+ closestChunkDistance = distance;
15792
+ }
15793
+ }
15794
+ if (closestChunk) {
15795
+ closestChunk.modules.push(...modules);
15796
+ if (chunksToBeMerged.has(closestChunk)) {
15797
+ closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
15798
+ if ((closestChunk.size += size) > minChunkSize) {
15799
+ chunksToBeMerged.delete(closestChunk);
15800
+ unmergeableChunks.push(closestChunk);
15801
+ }
15802
+ }
15803
+ }
15804
+ else {
15805
+ unmergeableChunks.push(sourceChunk);
15806
+ }
15807
+ }
15808
+ timeEnd('optimize chunks', 3);
15809
+ return unmergeableChunks;
15810
+ }
15811
+ const CHAR_DEPENDENT = 'X';
15812
+ const CHAR_INDEPENDENT = '_';
15813
+ const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
15814
+ function getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints) {
15754
15815
  const chunkModules = Object.create(null);
15755
15816
  for (const [module, assignedEntryPoints] of assignedEntryPointsByModule) {
15756
15817
  let chunkSignature = '';
15757
15818
  for (const entry of allEntryPoints) {
15758
- chunkSignature += assignedEntryPoints.has(entry) ? 'X' : '_';
15819
+ chunkSignature += assignedEntryPoints.has(entry) ? CHAR_DEPENDENT : CHAR_INDEPENDENT;
15759
15820
  }
15760
15821
  const chunk = chunkModules[chunkSignature];
15761
15822
  if (chunk) {
@@ -15765,10 +15826,56 @@ function createChunks(allEntryPoints, assignedEntryPointsByModule) {
15765
15826
  chunkModules[chunkSignature] = [module];
15766
15827
  }
15767
15828
  }
15768
- return Object.values(chunkModules).map(modules => ({
15769
- alias: null,
15770
- modules
15771
- }));
15829
+ return chunkModules;
15830
+ }
15831
+ function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
15832
+ const chunksToBeMerged = new Set();
15833
+ const unmergeableChunks = [];
15834
+ const alias = null;
15835
+ for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
15836
+ let size = 0;
15837
+ checkModules: {
15838
+ for (const module of modules) {
15839
+ if (module.hasEffects()) {
15840
+ break checkModules;
15841
+ }
15842
+ size += module.magicString.toString().length;
15843
+ if (size > minChunkSize) {
15844
+ break checkModules;
15845
+ }
15846
+ }
15847
+ chunksToBeMerged.add({ alias, modules, signature, size });
15848
+ continue;
15849
+ }
15850
+ unmergeableChunks.push({ alias, modules, signature, size: null });
15851
+ }
15852
+ return { chunksToBeMerged, unmergeableChunks };
15853
+ }
15854
+ function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
15855
+ let distance = 0;
15856
+ const { length } = sourceSignature;
15857
+ for (let index = 0; index < length; index++) {
15858
+ const sourceValue = sourceSignature.charCodeAt(index);
15859
+ if (sourceValue !== targetSignature.charCodeAt(index)) {
15860
+ if (enforceSubset && sourceValue === CHAR_CODE_DEPENDENT) {
15861
+ return Infinity;
15862
+ }
15863
+ distance++;
15864
+ }
15865
+ }
15866
+ return distance;
15867
+ }
15868
+ function mergeSignatures(sourceSignature, targetSignature) {
15869
+ let signature = '';
15870
+ const { length } = sourceSignature;
15871
+ for (let index = 0; index < length; index++) {
15872
+ signature +=
15873
+ sourceSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT ||
15874
+ targetSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT
15875
+ ? CHAR_DEPENDENT
15876
+ : CHAR_INDEPENDENT;
15877
+ }
15878
+ return signature;
15772
15879
  }
15773
15880
 
15774
15881
  // ported from https://github.com/substack/node-commondir
@@ -16372,7 +16479,7 @@ class Bundle {
16372
16479
  this.pluginDriver.finaliseAssets();
16373
16480
  }
16374
16481
  async generateChunks(bundle, getHashPlaceholder) {
16375
- const { inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
16482
+ const { experimentalMinChunkSize, inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
16376
16483
  const manualChunkAliasByEntry = typeof manualChunks === 'object'
16377
16484
  ? await this.addManualChunks(manualChunks)
16378
16485
  : this.assignManualChunks(manualChunks);
@@ -16386,7 +16493,7 @@ class Bundle {
16386
16493
  ? [{ alias: null, modules: includedModules }]
16387
16494
  : preserveModules
16388
16495
  ? includedModules.map(module => ({ alias: null, modules: [module] }))
16389
- : getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry)) {
16496
+ : getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize)) {
16390
16497
  sortByExecutionOrder(modules);
16391
16498
  const chunk = new Chunk(modules, this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.graph.modulesById, chunkByModule, externalChunkByModule, this.facadeChunkByModule, this.includedNamespaces, alias, getHashPlaceholder, bundle, inputBase, snippets);
16392
16499
  chunks.push(chunk);
@@ -22058,9 +22165,7 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
22058
22165
  }
22059
22166
  replaceContext = (pluginContext, plugin) => ({
22060
22167
  ...pluginContext,
22061
- resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => {
22062
- return moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip);
22063
- }
22168
+ resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip)
22064
22169
  });
22065
22170
  }
22066
22171
  return pluginDriver.hookFirst('resolveId', [source, importer, { assertions, custom: customOptions, isEntry }], replaceContext, skipped);
@@ -22749,17 +22854,17 @@ class GlobalScope extends Scope$1 {
22749
22854
  }
22750
22855
  }
22751
22856
 
22752
- function generateAssetFileName(name, source, outputOptions, bundle) {
22857
+ function getSourceHash(source) {
22858
+ return createHash().update(source).digest('hex');
22859
+ }
22860
+ function generateAssetFileName(name, source, sourceHash, outputOptions, bundle) {
22753
22861
  const emittedName = outputOptions.sanitizeFileName(name || 'asset');
22754
22862
  return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
22755
22863
  ? outputOptions.assetFileNames({ name, source, type: 'asset' })
22756
22864
  : outputOptions.assetFileNames, 'output.assetFileNames', {
22757
22865
  ext: () => extname(emittedName).slice(1),
22758
22866
  extname: () => extname(emittedName),
22759
- hash: size => createHash()
22760
- .update(source)
22761
- .digest('hex')
22762
- .slice(0, Math.max(0, size || defaultHashSize)),
22867
+ hash: size => sourceHash.slice(0, Math.max(0, size || defaultHashSize)),
22763
22868
  name: () => emittedName.slice(0, Math.max(0, emittedName.length - extname(emittedName).length))
22764
22869
  }), bundle);
22765
22870
  }
@@ -22864,9 +22969,6 @@ class FileEmitter {
22864
22969
  for (const emittedFile of this.filesByReferenceId.values()) {
22865
22970
  if (emittedFile.fileName) {
22866
22971
  reserveFileNameInBundle(emittedFile.fileName, output, this.options.onwarn);
22867
- if (emittedFile.type === 'asset' && typeof emittedFile.source === 'string') {
22868
- fileNamesBySource.set(emittedFile.source, emittedFile.fileName);
22869
- }
22870
22972
  }
22871
22973
  }
22872
22974
  for (const [referenceId, consumedFile] of this.filesByReferenceId) {
@@ -22934,15 +23036,19 @@ class FileEmitter {
22934
23036
  return this.assignReferenceId(consumedChunk, emittedChunk.id);
22935
23037
  }
22936
23038
  finalizeAsset(consumedFile, source, referenceId, { bundle, fileNamesBySource, outputOptions }) {
22937
- const fileName = consumedFile.fileName ||
22938
- (typeof source === 'string' && fileNamesBySource.get(source)) ||
22939
- generateAssetFileName(consumedFile.name, source, outputOptions, bundle);
23039
+ let fileName = consumedFile.fileName;
23040
+ // Deduplicate assets if an explicit fileName is not provided
23041
+ if (!fileName) {
23042
+ const sourceHash = getSourceHash(source);
23043
+ fileName = fileNamesBySource.get(sourceHash);
23044
+ if (!fileName) {
23045
+ fileName = generateAssetFileName(consumedFile.name, source, sourceHash, outputOptions, bundle);
23046
+ fileNamesBySource.set(sourceHash, fileName);
23047
+ }
23048
+ }
22940
23049
  // We must not modify the original assets to avoid interaction between outputs
22941
23050
  const assetWithFileName = { ...consumedFile, fileName, source };
22942
23051
  this.filesByReferenceId.set(referenceId, assetWithFileName);
22943
- if (typeof source === 'string') {
22944
- fileNamesBySource.set(source, fileName);
22945
- }
22946
23052
  bundle[fileName] = {
22947
23053
  fileName,
22948
23054
  name: consumedFile.name,
@@ -24153,6 +24259,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
24153
24259
  dynamicImportInCjs: config.dynamicImportInCjs ?? true,
24154
24260
  entryFileNames: getEntryFileNames(config, unsetOptions),
24155
24261
  esModule: config.esModule ?? 'if-default-prop',
24262
+ experimentalMinChunkSize: config.experimentalMinChunkSize || 0,
24156
24263
  exports: getExports(config, unsetOptions),
24157
24264
  extend: config.extend || false,
24158
24265
  externalImportAssertions: config.externalImportAssertions ?? true,
@@ -24843,6 +24950,7 @@ async function mergeOutputOptions(config, overrides, warn) {
24843
24950
  dynamicImportInCjs: getOption('dynamicImportInCjs'),
24844
24951
  entryFileNames: getOption('entryFileNames'),
24845
24952
  esModule: getOption('esModule'),
24953
+ experimentalMinChunkSize: getOption('experimentalMinChunkSize'),
24846
24954
  exports: getOption('exports'),
24847
24955
  extend: getOption('extend'),
24848
24956
  externalImportAssertions: getOption('externalImportAssertions'),
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.2.5
4
- Tue, 01 Nov 2022 05:28:36 GMT - commit 465d2396ba8dabba0366461d4014998cc13a9cc2
3
+ Rollup.js v3.3.0
4
+ Sat, 12 Nov 2022 05:21:34 GMT - commit ff286e5a14e32b6e820b188ccd63ac27bdd8adc9
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.2.5
4
- Tue, 01 Nov 2022 05:28:36 GMT - commit 465d2396ba8dabba0366461d4014998cc13a9cc2
3
+ Rollup.js v3.3.0
4
+ Sat, 12 Nov 2022 05:21:34 GMT - commit ff286e5a14e32b6e820b188ccd63ac27bdd8adc9
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/rollup.d.ts CHANGED
@@ -639,6 +639,7 @@ export interface OutputOptions {
639
639
  dynamicImportInCjs?: boolean;
640
640
  entryFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
641
641
  esModule?: boolean | 'if-default-prop';
642
+ experimentalMinChunkSize?: number;
642
643
  exports?: 'default' | 'named' | 'none' | 'auto';
643
644
  extend?: boolean;
644
645
  externalImportAssertions?: boolean;
@@ -691,6 +692,7 @@ export interface NormalizedOutputOptions {
691
692
  dynamicImportInCjs: boolean;
692
693
  entryFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
693
694
  esModule: boolean | 'if-default-prop';
695
+ experimentalMinChunkSize: number;
694
696
  exports: 'default' | 'named' | 'none' | 'auto';
695
697
  extend: boolean;
696
698
  externalImportAssertions: boolean;
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.2.5
4
- Tue, 01 Nov 2022 05:28:36 GMT - commit 465d2396ba8dabba0366461d4014998cc13a9cc2
3
+ Rollup.js v3.3.0
4
+ Sat, 12 Nov 2022 05:21:34 GMT - commit ff286e5a14e32b6e820b188ccd63ac27bdd8adc9
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.2.5
4
- Tue, 01 Nov 2022 05:28:36 GMT - commit 465d2396ba8dabba0366461d4014998cc13a9cc2
3
+ Rollup.js v3.3.0
4
+ Sat, 12 Nov 2022 05:21:34 GMT - commit ff286e5a14e32b6e820b188ccd63ac27bdd8adc9
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.2.5
4
- Tue, 01 Nov 2022 05:28:36 GMT - commit 465d2396ba8dabba0366461d4014998cc13a9cc2
3
+ Rollup.js v3.3.0
4
+ Sat, 12 Nov 2022 05:21:34 GMT - commit ff286e5a14e32b6e820b188ccd63ac27bdd8adc9
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.2.5
4
- Tue, 01 Nov 2022 05:28:36 GMT - commit 465d2396ba8dabba0366461d4014998cc13a9cc2
3
+ Rollup.js v3.3.0
4
+ Sat, 12 Nov 2022 05:21:34 GMT - commit ff286e5a14e32b6e820b188ccd63ac27bdd8adc9
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.2.5";
34
+ var version$1 = "3.3.0";
35
35
 
36
36
  function ensureArray$1(items) {
37
37
  if (Array.isArray(items)) {
@@ -1016,6 +1016,7 @@ async function mergeOutputOptions(config, overrides, warn) {
1016
1016
  dynamicImportInCjs: getOption('dynamicImportInCjs'),
1017
1017
  entryFileNames: getOption('entryFileNames'),
1018
1018
  esModule: getOption('esModule'),
1019
+ experimentalMinChunkSize: getOption('experimentalMinChunkSize'),
1019
1020
  exports: getOption('exports'),
1020
1021
  extend: getOption('extend'),
1021
1022
  externalImportAssertions: getOption('externalImportAssertions'),
@@ -13129,13 +13130,21 @@ function getPluginWithTimers(plugin, index) {
13129
13130
  timerLabel += ` (${plugin.name})`;
13130
13131
  }
13131
13132
  timerLabel += ` - ${hook}`;
13132
- const hookFunction = plugin[hook];
13133
- plugin[hook] = function (...parameters) {
13133
+ const handler = function (...parameters) {
13134
13134
  timeStart(timerLabel, 4);
13135
13135
  const result = hookFunction.apply(this, parameters);
13136
13136
  timeEnd(timerLabel, 4);
13137
13137
  return result;
13138
13138
  };
13139
+ let hookFunction;
13140
+ if (typeof plugin[hook].handler === 'function') {
13141
+ hookFunction = plugin[hook].handler;
13142
+ plugin[hook].handler = handler;
13143
+ }
13144
+ else {
13145
+ hookFunction = plugin[hook];
13146
+ plugin[hook] = handler;
13147
+ }
13139
13148
  }
13140
13149
  }
13141
13150
  return plugin;
@@ -14387,11 +14396,9 @@ function getImportBlock(dependencies, { _ }) {
14387
14396
  }
14388
14397
  else if (importedNames.length > 0) {
14389
14398
  importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
14390
- .map(specifier => {
14391
- return specifier.imported === specifier.local
14392
- ? specifier.imported
14393
- : `${specifier.imported} as ${specifier.local}`;
14394
- })
14399
+ .map(specifier => specifier.imported === specifier.local
14400
+ ? specifier.imported
14401
+ : `${specifier.imported} as ${specifier.local}`)
14395
14402
  .join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
14396
14403
  }
14397
14404
  }
@@ -14424,11 +14431,9 @@ function getImportBlock(dependencies, { _ }) {
14424
14431
  }
14425
14432
  if (namedReexports.length > 0) {
14426
14433
  importBlock.push(`export${_}{${_}${namedReexports
14427
- .map(specifier => {
14428
- return specifier.imported === specifier.reexported
14429
- ? specifier.imported
14430
- : `${specifier.imported} as ${specifier.reexported}`;
14431
- })
14434
+ .map(specifier => specifier.imported === specifier.reexported
14435
+ ? specifier.imported
14436
+ : `${specifier.imported} as ${specifier.reexported}`)
14432
14437
  .join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}`);
14433
14438
  }
14434
14439
  }
@@ -16146,14 +16151,23 @@ function getImportedBindingsPerDependency(renderedDependencies, resolveFileName)
16146
16151
  const QUERY_HASH_REGEX = /[#?]/;
16147
16152
  const resolveFileName = (dependency) => dependency.getFileName();
16148
16153
 
16149
- function getChunkAssignments(entryModules, manualChunkAliasByEntry) {
16154
+ /**
16155
+ * Concatenate a number of iterables to a new iterable without fully evaluating
16156
+ * their iterators. Useful when e.g. working with large sets or lists and when
16157
+ * there is a chance that the iterators will not be fully exhausted.
16158
+ */
16159
+ function* concatLazy(...iterables) {
16160
+ for (const iterable of iterables) {
16161
+ yield* iterable;
16162
+ }
16163
+ }
16164
+
16165
+ function getChunkAssignments(entryModules, manualChunkAliasByEntry, minChunkSize) {
16150
16166
  const chunkDefinitions = [];
16151
16167
  const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
16152
16168
  const manualChunkModulesByAlias = Object.create(null);
16153
16169
  for (const [entry, alias] of manualChunkAliasByEntry) {
16154
- const chunkModules = (manualChunkModulesByAlias[alias] =
16155
- manualChunkModulesByAlias[alias] || []);
16156
- addStaticDependenciesToManualChunk(entry, chunkModules, modulesInManualChunks);
16170
+ addStaticDependenciesToManualChunk(entry, (manualChunkModulesByAlias[alias] || (manualChunkModulesByAlias[alias] = [])), modulesInManualChunks);
16157
16171
  }
16158
16172
  for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
16159
16173
  chunkDefinitions.push({ alias, modules });
@@ -16204,7 +16218,7 @@ function getChunkAssignments(entryModules, manualChunkAliasByEntry) {
16204
16218
  assignEntryToStaticDependencies(entry, dynamicallyDependentEntryPointsByDynamicEntry.get(entry));
16205
16219
  }
16206
16220
  }
16207
- chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule));
16221
+ chunkDefinitions.push(...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule, minChunkSize));
16208
16222
  return chunkDefinitions;
16209
16223
  }
16210
16224
  function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
@@ -16261,12 +16275,60 @@ function getDynamicDependentEntryPoints(dependentEntryPointsByModule, dynamicEnt
16261
16275
  }
16262
16276
  return dynamicallyDependentEntryPointsByDynamicEntry;
16263
16277
  }
16264
- function createChunks(allEntryPoints, assignedEntryPointsByModule) {
16278
+ function createChunks(allEntryPoints, assignedEntryPointsByModule, minChunkSize) {
16279
+ const chunkModulesBySignature = getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints);
16280
+ return minChunkSize === 0
16281
+ ? Object.values(chunkModulesBySignature).map(modules => ({
16282
+ alias: null,
16283
+ modules
16284
+ }))
16285
+ : getOptimizedChunks(chunkModulesBySignature, minChunkSize);
16286
+ }
16287
+ function getOptimizedChunks(chunkModulesBySignature, minChunkSize) {
16288
+ timeStart('optimize chunks', 3);
16289
+ const { chunksToBeMerged, unmergeableChunks } = getMergeableChunks(chunkModulesBySignature, minChunkSize);
16290
+ for (const sourceChunk of chunksToBeMerged) {
16291
+ chunksToBeMerged.delete(sourceChunk);
16292
+ let closestChunk = null;
16293
+ let closestChunkDistance = Infinity;
16294
+ const { signature, size, modules } = sourceChunk;
16295
+ for (const targetChunk of concatLazy(chunksToBeMerged, unmergeableChunks)) {
16296
+ const distance = getSignatureDistance(signature, targetChunk.signature, !chunksToBeMerged.has(targetChunk));
16297
+ if (distance === 1) {
16298
+ closestChunk = targetChunk;
16299
+ break;
16300
+ }
16301
+ else if (distance < closestChunkDistance) {
16302
+ closestChunk = targetChunk;
16303
+ closestChunkDistance = distance;
16304
+ }
16305
+ }
16306
+ if (closestChunk) {
16307
+ closestChunk.modules.push(...modules);
16308
+ if (chunksToBeMerged.has(closestChunk)) {
16309
+ closestChunk.signature = mergeSignatures(signature, closestChunk.signature);
16310
+ if ((closestChunk.size += size) > minChunkSize) {
16311
+ chunksToBeMerged.delete(closestChunk);
16312
+ unmergeableChunks.push(closestChunk);
16313
+ }
16314
+ }
16315
+ }
16316
+ else {
16317
+ unmergeableChunks.push(sourceChunk);
16318
+ }
16319
+ }
16320
+ timeEnd('optimize chunks', 3);
16321
+ return unmergeableChunks;
16322
+ }
16323
+ const CHAR_DEPENDENT = 'X';
16324
+ const CHAR_INDEPENDENT = '_';
16325
+ const CHAR_CODE_DEPENDENT = CHAR_DEPENDENT.charCodeAt(0);
16326
+ function getChunkModulesBySignature(assignedEntryPointsByModule, allEntryPoints) {
16265
16327
  const chunkModules = Object.create(null);
16266
16328
  for (const [module, assignedEntryPoints] of assignedEntryPointsByModule) {
16267
16329
  let chunkSignature = '';
16268
16330
  for (const entry of allEntryPoints) {
16269
- chunkSignature += assignedEntryPoints.has(entry) ? 'X' : '_';
16331
+ chunkSignature += assignedEntryPoints.has(entry) ? CHAR_DEPENDENT : CHAR_INDEPENDENT;
16270
16332
  }
16271
16333
  const chunk = chunkModules[chunkSignature];
16272
16334
  if (chunk) {
@@ -16276,10 +16338,56 @@ function createChunks(allEntryPoints, assignedEntryPointsByModule) {
16276
16338
  chunkModules[chunkSignature] = [module];
16277
16339
  }
16278
16340
  }
16279
- return Object.values(chunkModules).map(modules => ({
16280
- alias: null,
16281
- modules
16282
- }));
16341
+ return chunkModules;
16342
+ }
16343
+ function getMergeableChunks(chunkModulesBySignature, minChunkSize) {
16344
+ const chunksToBeMerged = new Set();
16345
+ const unmergeableChunks = [];
16346
+ const alias = null;
16347
+ for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
16348
+ let size = 0;
16349
+ checkModules: {
16350
+ for (const module of modules) {
16351
+ if (module.hasEffects()) {
16352
+ break checkModules;
16353
+ }
16354
+ size += module.magicString.toString().length;
16355
+ if (size > minChunkSize) {
16356
+ break checkModules;
16357
+ }
16358
+ }
16359
+ chunksToBeMerged.add({ alias, modules, signature, size });
16360
+ continue;
16361
+ }
16362
+ unmergeableChunks.push({ alias, modules, signature, size: null });
16363
+ }
16364
+ return { chunksToBeMerged, unmergeableChunks };
16365
+ }
16366
+ function getSignatureDistance(sourceSignature, targetSignature, enforceSubset) {
16367
+ let distance = 0;
16368
+ const { length } = sourceSignature;
16369
+ for (let index = 0; index < length; index++) {
16370
+ const sourceValue = sourceSignature.charCodeAt(index);
16371
+ if (sourceValue !== targetSignature.charCodeAt(index)) {
16372
+ if (enforceSubset && sourceValue === CHAR_CODE_DEPENDENT) {
16373
+ return Infinity;
16374
+ }
16375
+ distance++;
16376
+ }
16377
+ }
16378
+ return distance;
16379
+ }
16380
+ function mergeSignatures(sourceSignature, targetSignature) {
16381
+ let signature = '';
16382
+ const { length } = sourceSignature;
16383
+ for (let index = 0; index < length; index++) {
16384
+ signature +=
16385
+ sourceSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT ||
16386
+ targetSignature.charCodeAt(index) === CHAR_CODE_DEPENDENT
16387
+ ? CHAR_DEPENDENT
16388
+ : CHAR_INDEPENDENT;
16389
+ }
16390
+ return signature;
16283
16391
  }
16284
16392
 
16285
16393
  // ported from https://github.com/substack/node-commondir
@@ -16883,7 +16991,7 @@ class Bundle {
16883
16991
  this.pluginDriver.finaliseAssets();
16884
16992
  }
16885
16993
  async generateChunks(bundle, getHashPlaceholder) {
16886
- const { inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
16994
+ const { experimentalMinChunkSize, inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
16887
16995
  const manualChunkAliasByEntry = typeof manualChunks === 'object'
16888
16996
  ? await this.addManualChunks(manualChunks)
16889
16997
  : this.assignManualChunks(manualChunks);
@@ -16897,7 +17005,7 @@ class Bundle {
16897
17005
  ? [{ alias: null, modules: includedModules }]
16898
17006
  : preserveModules
16899
17007
  ? includedModules.map(module => ({ alias: null, modules: [module] }))
16900
- : getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry)) {
17008
+ : getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize)) {
16901
17009
  sortByExecutionOrder(modules);
16902
17010
  const chunk = new Chunk(modules, this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.graph.modulesById, chunkByModule, externalChunkByModule, this.facadeChunkByModule, this.includedNamespaces, alias, getHashPlaceholder, bundle, inputBase, snippets);
16903
17011
  chunks.push(chunk);
@@ -22569,9 +22677,7 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
22569
22677
  }
22570
22678
  replaceContext = (pluginContext, plugin) => ({
22571
22679
  ...pluginContext,
22572
- resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => {
22573
- return moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip);
22574
- }
22680
+ resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip)
22575
22681
  });
22576
22682
  }
22577
22683
  return pluginDriver.hookFirst('resolveId', [source, importer, { assertions, custom: customOptions, isEntry }], replaceContext, skipped);
@@ -23260,17 +23366,17 @@ class GlobalScope extends Scope$1 {
23260
23366
  }
23261
23367
  }
23262
23368
 
23263
- function generateAssetFileName(name, source, outputOptions, bundle) {
23369
+ function getSourceHash(source) {
23370
+ return createHash().update(source).digest('hex');
23371
+ }
23372
+ function generateAssetFileName(name, source, sourceHash, outputOptions, bundle) {
23264
23373
  const emittedName = outputOptions.sanitizeFileName(name || 'asset');
23265
23374
  return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
23266
23375
  ? outputOptions.assetFileNames({ name, source, type: 'asset' })
23267
23376
  : outputOptions.assetFileNames, 'output.assetFileNames', {
23268
23377
  ext: () => node_path.extname(emittedName).slice(1),
23269
23378
  extname: () => node_path.extname(emittedName),
23270
- hash: size => createHash()
23271
- .update(source)
23272
- .digest('hex')
23273
- .slice(0, Math.max(0, size || defaultHashSize)),
23379
+ hash: size => sourceHash.slice(0, Math.max(0, size || defaultHashSize)),
23274
23380
  name: () => emittedName.slice(0, Math.max(0, emittedName.length - node_path.extname(emittedName).length))
23275
23381
  }), bundle);
23276
23382
  }
@@ -23375,9 +23481,6 @@ class FileEmitter {
23375
23481
  for (const emittedFile of this.filesByReferenceId.values()) {
23376
23482
  if (emittedFile.fileName) {
23377
23483
  reserveFileNameInBundle(emittedFile.fileName, output, this.options.onwarn);
23378
- if (emittedFile.type === 'asset' && typeof emittedFile.source === 'string') {
23379
- fileNamesBySource.set(emittedFile.source, emittedFile.fileName);
23380
- }
23381
23484
  }
23382
23485
  }
23383
23486
  for (const [referenceId, consumedFile] of this.filesByReferenceId) {
@@ -23445,15 +23548,19 @@ class FileEmitter {
23445
23548
  return this.assignReferenceId(consumedChunk, emittedChunk.id);
23446
23549
  }
23447
23550
  finalizeAsset(consumedFile, source, referenceId, { bundle, fileNamesBySource, outputOptions }) {
23448
- const fileName = consumedFile.fileName ||
23449
- (typeof source === 'string' && fileNamesBySource.get(source)) ||
23450
- generateAssetFileName(consumedFile.name, source, outputOptions, bundle);
23551
+ let fileName = consumedFile.fileName;
23552
+ // Deduplicate assets if an explicit fileName is not provided
23553
+ if (!fileName) {
23554
+ const sourceHash = getSourceHash(source);
23555
+ fileName = fileNamesBySource.get(sourceHash);
23556
+ if (!fileName) {
23557
+ fileName = generateAssetFileName(consumedFile.name, source, sourceHash, outputOptions, bundle);
23558
+ fileNamesBySource.set(sourceHash, fileName);
23559
+ }
23560
+ }
23451
23561
  // We must not modify the original assets to avoid interaction between outputs
23452
23562
  const assetWithFileName = { ...consumedFile, fileName, source };
23453
23563
  this.filesByReferenceId.set(referenceId, assetWithFileName);
23454
- if (typeof source === 'string') {
23455
- fileNamesBySource.set(source, fileName);
23456
- }
23457
23564
  bundle[fileName] = {
23458
23565
  fileName,
23459
23566
  name: consumedFile.name,
@@ -24570,6 +24677,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
24570
24677
  dynamicImportInCjs: config.dynamicImportInCjs ?? true,
24571
24678
  entryFileNames: getEntryFileNames(config, unsetOptions),
24572
24679
  esModule: config.esModule ?? 'if-default-prop',
24680
+ experimentalMinChunkSize: config.experimentalMinChunkSize || 0,
24573
24681
  exports: getExports(config, unsetOptions),
24574
24682
  extend: config.extend || false,
24575
24683
  externalImportAssertions: config.externalImportAssertions ?? true,
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.2.5
4
- Tue, 01 Nov 2022 05:28:36 GMT - commit 465d2396ba8dabba0366461d4014998cc13a9cc2
3
+ Rollup.js v3.3.0
4
+ Sat, 12 Nov 2022 05:21:34 GMT - commit ff286e5a14e32b6e820b188ccd63ac27bdd8adc9
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.2.5
4
- Tue, 01 Nov 2022 05:28:36 GMT - commit 465d2396ba8dabba0366461d4014998cc13a9cc2
3
+ Rollup.js v3.3.0
4
+ Sat, 12 Nov 2022 05:21:34 GMT - commit ff286e5a14e32b6e820b188ccd63ac27bdd8adc9
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.2.5",
3
+ "version": "3.3.0",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",