rollup 3.16.0 → 3.17.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.16.0
6
- Fri, 17 Feb 2023 13:26:29 GMT - commit 8ba73f4f643e5ffe01fc9ad846748f6d5b7963c2
5
+ Rollup.js v3.17.1
6
+ Sat, 18 Feb 2023 19:47:52 GMT - commit 2a9abba955cfcb187167aba96e64c7c06f3f02ca
7
7
 
8
8
  https://github.com/rollup/rollup
9
9
 
@@ -18,13 +18,14 @@ const rollup = require('../shared/rollup.js');
18
18
  const require$$2 = require('util');
19
19
  const require$$0 = require('path');
20
20
  const require$$0$1 = require('fs');
21
+ const fseventsImporter = require('../shared/fsevents-importer.js');
21
22
  const promises = require('node:fs/promises');
22
23
  const node_path = require('node:path');
23
24
  const loadConfigFile_js = require('../shared/loadConfigFile.js');
25
+ require('tty');
24
26
  require('node:perf_hooks');
25
27
  require('node:crypto');
26
28
  require('node:events');
27
- require('tty');
28
29
  require('node:url');
29
30
 
30
31
  const help = "rollup version __VERSION__\n=====================================\n\nUsage: rollup [options] <entry file>\n\nBasic options:\n\n-c, --config <filename> Use this config file (if argument is used but value\n is unspecified, defaults to rollup.config.js)\n-d, --dir <dirname> Directory for chunks (if absent, prints to stdout)\n-e, --external <ids> Comma-separate list of module IDs to exclude\n-f, --format <format> Type of output (amd, cjs, es, iife, umd, system)\n-g, --globals <pairs> Comma-separate list of `moduleID:Global` pairs\n-h, --help Show this help message\n-i, --input <filename> Input (alternative to <entry file>)\n-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n-n, --name <name> Name for UMD export\n-o, --file <output> Single output file (if absent, prints to stdout)\n-p, --plugin <plugin> Use the plugin specified (may be repeated)\n-v, --version Show version number\n-w, --watch Watch files in bundle and rebuild on changes\n--amd.autoId Generate the AMD ID based off the chunk name\n--amd.basePath <prefix> Path to prepend to auto generated AMD ID\n--amd.define <name> Function to use in place of `define`\n--amd.forceJsExtensionForImports Use `.js` extension in AMD imports\n--amd.id <id> ID for AMD module (default is anonymous)\n--assetFileNames <pattern> Name pattern for emitted assets\n--banner <text> Code to insert at top of bundle (outside wrapper)\n--chunkFileNames <pattern> Name pattern for emitted secondary chunks\n--compact Minify wrapper code\n--context <variable> Specify top-level `this` value\n--no-dynamicImportInCjs Write external dynamic CommonJS imports as require\n--entryFileNames <pattern> Name pattern for emitted entry chunks\n--environment <values> Settings passed to config file (see example)\n--no-esModule Do not add __esModule property\n--exports <mode> Specify export mode (auto, default, named, none)\n--extend Extend global variable defined by --name\n--no-externalImportAssertions Omit import assertions in \"es\" output\n--no-externalLiveBindings Do not generate code to support live bindings\n--failAfterWarnings Exit with an error if the build produced warnings\n--footer <text> Code to insert at end of bundle (outside wrapper)\n--no-freeze Do not freeze namespace objects\n--generatedCode <preset> Which code features to use (es5/es2015)\n--generatedCode.arrowFunctions Use arrow functions in generated code\n--generatedCode.constBindings Use \"const\" in generated code\n--generatedCode.objectShorthand Use shorthand properties in generated code\n--no-generatedCode.reservedNamesAsProps Always quote reserved names as props\n--generatedCode.symbols Use symbols in generated code\n--no-hoistTransitiveImports Do not hoist transitive imports into entry chunks\n--no-indent Don't indent result\n--inlineDynamicImports Create single bundle when using dynamic imports\n--no-interop Do not include interop block\n--intro <text> Code to insert at top of bundle (inside wrapper)\n--no-makeAbsoluteExternalsRelative Prevent normalization of external imports\n--maxParallelFileOps <value> How many files to read in parallel\n--minifyInternalExports Force or disable minification of internal exports\n--noConflict Generate a noConflict method for UMD globals\n--outro <text> Code to insert at end of bundle (inside wrapper)\n--perf Display performance timings\n--no-preserveEntrySignatures Avoid facade chunks for entry points\n--preserveModules Preserve module structure\n--preserveModulesRoot Put preserved modules under this path at root level\n--preserveSymlinks Do not follow symlinks when resolving files\n--no-sanitizeFileName Do not replace invalid characters in file names\n--shimMissingExports Create shim variables for missing exports\n--silent Don't print warnings\n--sourcemapBaseUrl <url> Emit absolute sourcemap URLs with given base\n--sourcemapExcludeSources Do not include source code in source maps\n--sourcemapFile <file> Specify bundle position for source maps\n--stdin=ext Specify file extension used for stdin input\n--no-stdin Do not read \"-\" from stdin\n--no-strict Don't emit `\"use strict\";` in the generated modules\n--strictDeprecations Throw errors for deprecated features\n--no-systemNullSetters Do not replace empty SystemJS setters with `null`\n--no-treeshake Disable tree-shaking optimisations\n--no-treeshake.annotations Ignore pure call annotations\n--treeshake.correctVarValueBeforeDeclaration Deoptimize variables until declared\n--treeshake.manualPureFunctions <names> Manually declare functions as pure\n--no-treeshake.moduleSideEffects Assume modules have no side effects\n--no-treeshake.propertyReadSideEffects Ignore property access side effects\n--no-treeshake.tryCatchDeoptimization Do not turn off try-catch-tree-shaking\n--no-treeshake.unknownGlobalSideEffects Assume unknown globals do not throw\n--validate Validate output\n--waitForBundleInput Wait for bundle input files\n--watch.buildDelay <number> Throttle watch rebuilds\n--no-watch.clearScreen Do not clear the screen when rebuilding\n--watch.exclude <files> Exclude files from being watched\n--watch.include <files> Limit watching to specified files\n--watch.onBundleEnd <cmd> Shell command to run on `\"BUNDLE_END\"` event\n--watch.onBundleStart <cmd> Shell command to run on `\"BUNDLE_START\"` event\n--watch.onEnd <cmd> Shell command to run on `\"END\"` event\n--watch.onError <cmd> Shell command to run on `\"ERROR\"` event\n--watch.onStart <cmd> Shell command to run on `\"START\"` event\n--watch.skipWrite Do not write files to disk when watching\n\nExamples:\n\n# use settings in config file\nrollup -c\n\n# in config file, process.env.INCLUDE_DEPS === 'true'\n# and process.env.BUILD === 'production'\nrollup -c --environment INCLUDE_DEPS,BUILD:production\n\n# create CommonJS bundle.js from src/main.js\nrollup --format=cjs --file=bundle.js -- src/main.js\n\n# create self-executing IIFE using `window.jQuery`\n# and `window._` as external globals\nrollup -f iife --globals jquery:jQuery,lodash:_ \\\n -i src/app.js -o build/app.js -m build/app.js.map\n\nNotes:\n\n* When piping to stdout, only inline sourcemaps are permitted\n\nFor more information visit https://rollupjs.org\n";
@@ -1648,7 +1649,7 @@ async function runRollup(command) {
1648
1649
  }
1649
1650
  }
1650
1651
  if (rollup.isWatchEnabled(command.watch)) {
1651
- await rollup.loadFsEvents();
1652
+ await fseventsImporter.loadFsEvents();
1652
1653
  const { watch } = await Promise.resolve().then(() => require('../shared/watch-cli.js'));
1653
1654
  watch(command);
1654
1655
  }
package/dist/es/rollup.js CHANGED
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.16.0
4
- Fri, 17 Feb 2023 13:26:29 GMT - commit 8ba73f4f643e5ffe01fc9ad846748f6d5b7963c2
3
+ Rollup.js v3.17.1
4
+ Sat, 18 Feb 2023 19:47:52 GMT - commit 2a9abba955cfcb187167aba96e64c7c06f3f02ca
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
8
8
  Released under the MIT License.
9
9
  */
10
- export { version as VERSION, defineConfig, rollup, watch } from './shared/rollup.js';
10
+ export { version as VERSION, defineConfig, rollup, watch } from './shared/node-entry.js';
11
11
  import 'node:path';
12
12
  import 'path';
13
13
  import 'node:process';
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.16.0
4
- Fri, 17 Feb 2023 13:26:29 GMT - commit 8ba73f4f643e5ffe01fc9ad846748f6d5b7963c2
3
+ Rollup.js v3.17.1
4
+ Sat, 18 Feb 2023 19:47:52 GMT - commit 2a9abba955cfcb187167aba96e64c7c06f3f02ca
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -16,7 +16,7 @@ import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/pr
16
16
  import { EventEmitter } from 'node:events';
17
17
  import * as tty from 'tty';
18
18
 
19
- var version$1 = "3.16.0";
19
+ var version$1 = "3.17.1";
20
20
 
21
21
  const comma = ','.charCodeAt(0);
22
22
  const semicolon = ';'.charCodeAt(0);
@@ -1798,7 +1798,7 @@ class DiscriminatedPathTracker {
1798
1798
  currentPaths[pathSegment] ||
1799
1799
  Object.create(null, { [EntitiesKey]: { value: new Map() } });
1800
1800
  }
1801
- const trackedEntities = getOrCreate(currentPaths[EntitiesKey], discriminator, getNewSet);
1801
+ const trackedEntities = getOrCreate(currentPaths[EntitiesKey], discriminator, (getNewSet));
1802
1802
  if (trackedEntities.has(entity))
1803
1803
  return true;
1804
1804
  trackedEntities.add(entity);
@@ -2071,6 +2071,7 @@ const URL_OUTPUT_EXPORTS = 'configuration-options/#output-exports';
2071
2071
  const URL_OUTPUT_EXTEND = 'configuration-options/#output-extend';
2072
2072
  const URL_OUTPUT_FORMAT = 'configuration-options/#output-format';
2073
2073
  const URL_OUTPUT_GENERATEDCODE = 'configuration-options/#output-generatedcode';
2074
+ const URL_OUTPUT_EXPERIMENTALDEEPCHUNKOPTIMIZATION = 'configuration-options/#output-experimentaldeepdynamicchunkoptimization';
2074
2075
  const URL_OUTPUT_GENERATEDCODE_CONSTBINDINGS = 'configuration-options/#output-generatedcode-constbindings';
2075
2076
  const URL_OUTPUT_GENERATEDCODE_SYMBOLS = 'configuration-options/#output-generatedcode-symbols';
2076
2077
  const URL_OUTPUT_GLOBALS = 'configuration-options/#output-globals';
@@ -8016,9 +8017,12 @@ class Identifier extends NodeBase {
8016
8017
  // return cached value to avoid issues with the next tree-shaking pass
8017
8018
  if (this.isTDZAccess !== null)
8018
8019
  return this.isTDZAccess;
8019
- if (!(this.variable instanceof LocalVariable) ||
8020
- !this.variable.kind ||
8021
- !(this.variable.kind in tdzVariableKinds)) {
8020
+ if (!(this.variable instanceof LocalVariable &&
8021
+ this.variable.kind &&
8022
+ this.variable.kind in tdzVariableKinds &&
8023
+ // we ignore possible TDZs due to circular module dependencies as
8024
+ // otherwise we get many false positives
8025
+ this.variable.module === this.context.module)) {
8022
8026
  return (this.isTDZAccess = false);
8023
8027
  }
8024
8028
  let decl_id;
@@ -12966,7 +12970,7 @@ function getVariableForExportNameRecursive(target, name, importerForSideEffects,
12966
12970
  });
12967
12971
  }
12968
12972
  function getAndExtendSideEffectModules(variable, module) {
12969
- const sideEffectModules = getOrCreate(module.sideEffectDependenciesByVariable, variable, getNewSet);
12973
+ const sideEffectModules = getOrCreate(module.sideEffectDependenciesByVariable, variable, (getNewSet));
12970
12974
  let currentVariable = variable;
12971
12975
  const referencedVariables = new Set([currentVariable]);
12972
12976
  while (true) {
@@ -13305,7 +13309,7 @@ class Module {
13305
13309
  searchedNamesAndModules
13306
13310
  });
13307
13311
  if (importerForSideEffects) {
13308
- getOrCreate(importerForSideEffects.sideEffectDependenciesByVariable, variable, getNewSet).add(this);
13312
+ getOrCreate(importerForSideEffects.sideEffectDependenciesByVariable, variable, (getNewSet)).add(this);
13309
13313
  setAlternativeExporterIfCyclic(variable, importerForSideEffects, this);
13310
13314
  }
13311
13315
  return [variable];
@@ -16059,7 +16063,137 @@ function* concatLazy(iterables) {
16059
16063
  }
16060
16064
  }
16061
16065
 
16062
- function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, deepChunkOptimization) {
16066
+ /**
16067
+ * At its core, the algorithm first starts from each static or dynamic entry
16068
+ * point and then assigns that entry point to all modules than can be reached
16069
+ * via static imports. We call this the *dependent entry points* of that
16070
+ * module.
16071
+ *
16072
+ * Then we group all modules with the same dependent entry points into chunks
16073
+ * as those modules will always be loaded together.
16074
+ *
16075
+ * One non-trivial optimization we can apply is that dynamic entries are
16076
+ * different from static entries in so far as when a dynamic import occurs,
16077
+ * some
16078
+ * modules are already in memory. If some of these modules are also
16079
+ * dependencies
16080
+ * of the dynamic entry, then it does not make sense to create a separate chunk
16081
+ * for them. Instead, the dynamic import target can load them from the
16082
+ * importing
16083
+ * chunk.
16084
+ *
16085
+ * With regard to chunking, if B is implicitly loaded after A, then this can be
16086
+ * handled the same way as if there was a dynamic import A => B.
16087
+ *
16088
+ * Example:
16089
+ * Assume A -> B (A imports B), A => C (A dynamically imports C) and C -> B.
16090
+ * Then the initial algorithm would assign A into the A chunk, C into the C
16091
+ * chunk and B into the AC chunk, i.e. the chunk with the dependent entry
16092
+ * points
16093
+ * A and C.
16094
+ * However we know that C can only be loaded from A, so A and its dependency B
16095
+ * must already be in memory when C is loaded. So it is enough to create only
16096
+ * two chunks A containing [AB] and C containing [C].
16097
+ *
16098
+ * So we do not assign the dynamic entry C as dependent entry point to modules
16099
+ * that are already loaded.
16100
+ *
16101
+ * In a more complex example, let us assume that we have entry points X and Y.
16102
+ * Further, let us assume
16103
+ * X -> A, X -> B, X -> C,
16104
+ * Y -> A, Y -> B,
16105
+ * A => D,
16106
+ * D -> B, D -> C
16107
+ * So without dynamic import optimization, the dependent entry points are
16108
+ * A: XY, B: DXY, C: DX, D: D, X: X, Y: Y,
16109
+ * so we would for now create six chunks.
16110
+ *
16111
+ * Now D is loaded only after A is loaded. But A is loaded if either X is
16112
+ * loaded
16113
+ * or Y is loaded. So the modules that are already in memory when D is loaded
16114
+ * are the intersection of all modules that X depends on with all modules that
16115
+ * Y
16116
+ * depends on, which in this case are the modules A and B.
16117
+ * We could also say they are all modules that have both X and Y as dependent
16118
+ * entry points.
16119
+ *
16120
+ * So we can remove D as dependent entry point from A and B, which means they
16121
+ * both now have only XY as dependent entry points and can be merged into the
16122
+ * same chunk.
16123
+ *
16124
+ * Now let us extend this to the most general case where we have several
16125
+ * dynamic
16126
+ * importers for one dynamic entry point.
16127
+ *
16128
+ * In the most general form, it works like this:
16129
+ * For each dynamic entry point, we have a number of dynamic importers, which
16130
+ * are the modules importing it. Using the previous ideas, we can determine
16131
+ * the modules already in memory for each dynamic importer by looking for all
16132
+ * modules that have all the dependent entry points of the dynamic importer as
16133
+ * dependent entry points.
16134
+ * So the modules that are guaranteed to be in memory when the dynamic entry
16135
+ * point is loaded are the intersection of the modules already in memory for
16136
+ * each dynamic importer.
16137
+ *
16138
+ * Assuming that A => D and B => D and A has dependent entry points XY and B
16139
+ * has
16140
+ * dependent entry points YZ, then the modules guaranteed to be in memory are
16141
+ * all modules that have at least XYZ as dependent entry points.
16142
+ * We call XYZ the *dynamically dependent entry points* of D.
16143
+ *
16144
+ * Now there is one last case to consider: If one of the dynamically dependent
16145
+ * entries is itself a dynamic entry, then any module is in memory that either
16146
+ * is a dependency of that dynamic entry or again has the dynamic dependent
16147
+ * entries of that dynamic entry as dependent entry points.
16148
+ *
16149
+ * A naive algorithm for this proved to be costly as it contained an O(n^3)
16150
+ * complexity with regard to dynamic entries that blew up for very large
16151
+ * projects.
16152
+ *
16153
+ * If we have an efficient way to do Set operations, an alternative approach
16154
+ * would be to instead collect already loaded modules per dynamic entry. And as
16155
+ * all chunks from the initial grouping would behave the same, we can instead
16156
+ * collect already loaded chunks for a performance improvement.
16157
+ *
16158
+ * To do that efficiently, need
16159
+ * - a Map of dynamic imports per dynamic entry, which contains all dynamic
16160
+ * imports that can be triggered by a dynamic entry
16161
+ * - a Map of static dependencies per entry
16162
+ * - a Map of already loaded chunks per entry that we initially populate with
16163
+ * empty Sets for static entries and Sets containing all entries for dynamic
16164
+ * entries
16165
+ *
16166
+ * For efficient operations, we assign each entry a numerical index and
16167
+ * represent Sets of Chunks as BigInt values where each chunk corresponds to a
16168
+ * bit index. Then thw last two maps can be represented as arrays of BigInt
16169
+ * values.
16170
+ *
16171
+ * Then we iterate through each dynamic entry. We set the already loaded modules
16172
+ * to the intersection of the previously already loaded modules with the union
16173
+ * of the already loaded modules of that chunk with its static dependencies.
16174
+ *
16175
+ * If the already loaded modules changed, then we use the Map of dynamic imports
16176
+ * per dynamic entry to marks all dynamic entry dependencies as "dirty" and put
16177
+ * them back into the iteration. As an additional optimization, we note for
16178
+ * each dynamic entry which dynamic dependent entries have changed and only
16179
+ * intersect those entries again on subsequent interations.
16180
+ *
16181
+ * Then we remove the dynamic entries from the list of dependent entries for
16182
+ * those chunks that are already loaded for that dynamic entry and create
16183
+ * another round of chunks.
16184
+ */
16185
+ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
16186
+ const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry);
16187
+ const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry } = analyzeModuleGraph(entries);
16188
+ // Each chunk is identified by its position in this array
16189
+ const initialChunks = Object.values(getChunksBySignature(getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks)));
16190
+ // This mutates initialChunks but also clears
16191
+ // dynamicallyDependentEntriesByDynamicEntry as side effect
16192
+ removeUnnecessaryDependentEntries(initialChunks, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
16193
+ chunkDefinitions.push(...createChunks(allEntries, getChunksBySignature(initialChunks), minChunkSize));
16194
+ return chunkDefinitions;
16195
+ }
16196
+ function getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry) {
16063
16197
  const chunkDefinitions = [];
16064
16198
  const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys());
16065
16199
  const manualChunkModulesByAlias = Object.create(null);
@@ -16069,16 +16203,7 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, dee
16069
16203
  for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) {
16070
16204
  chunkDefinitions.push({ alias, modules });
16071
16205
  }
16072
- const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry } = analyzeModuleGraph(entries);
16073
- const staticEntries = new Set(entries);
16074
- const assignedEntriesByModule = new Map();
16075
- for (const entry of allEntries) {
16076
- if (!modulesInManualChunks.has(entry)) {
16077
- assignEntryToStaticDependencies(entry, dependentEntriesByModule, assignedEntriesByModule, modulesInManualChunks, staticEntries, dynamicallyDependentEntriesByDynamicEntry, deepChunkOptimization);
16078
- }
16079
- }
16080
- chunkDefinitions.push(...createChunks(allEntries, assignedEntriesByModule, minChunkSize));
16081
- return chunkDefinitions;
16206
+ return { chunkDefinitions, modulesInManualChunks };
16082
16207
  }
16083
16208
  function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesInManualChunks) {
16084
16209
  const modulesToHandle = new Set([entry]);
@@ -16093,13 +16218,17 @@ function addStaticDependenciesToManualChunk(entry, manualChunkModules, modulesIn
16093
16218
  }
16094
16219
  }
16095
16220
  function analyzeModuleGraph(entries) {
16096
- const dynamicEntries = new Set();
16221
+ const dynamicEntryModules = new Set();
16097
16222
  const dependentEntriesByModule = new Map();
16098
- const allEntries = new Set(entries);
16099
- for (const currentEntry of allEntries) {
16223
+ const dynamicImportModulesByEntry = [];
16224
+ const allEntriesSet = new Set(entries);
16225
+ let entryIndex = 0;
16226
+ for (const currentEntry of allEntriesSet) {
16227
+ const dynamicImportsForCurrentEntry = new Set();
16228
+ dynamicImportModulesByEntry.push(dynamicImportsForCurrentEntry);
16100
16229
  const modulesToHandle = new Set([currentEntry]);
16101
16230
  for (const module of modulesToHandle) {
16102
- getOrCreate(dependentEntriesByModule, module, getNewSet).add(currentEntry);
16231
+ getOrCreate(dependentEntriesByModule, module, (getNewSet)).add(entryIndex);
16103
16232
  for (const dependency of module.getDependenciesToBeIncluded()) {
16104
16233
  if (!(dependency instanceof ExternalModule)) {
16105
16234
  modulesToHandle.add(dependency);
@@ -16108,33 +16237,58 @@ function analyzeModuleGraph(entries) {
16108
16237
  for (const { resolution } of module.dynamicImports) {
16109
16238
  if (resolution instanceof Module &&
16110
16239
  resolution.includedDynamicImporters.length > 0 &&
16111
- !allEntries.has(resolution)) {
16112
- dynamicEntries.add(resolution);
16113
- allEntries.add(resolution);
16240
+ !allEntriesSet.has(resolution)) {
16241
+ dynamicEntryModules.add(resolution);
16242
+ allEntriesSet.add(resolution);
16243
+ dynamicImportsForCurrentEntry.add(resolution);
16114
16244
  }
16115
16245
  }
16116
16246
  for (const dependency of module.implicitlyLoadedBefore) {
16117
- if (!allEntries.has(dependency)) {
16118
- dynamicEntries.add(dependency);
16119
- allEntries.add(dependency);
16247
+ if (!allEntriesSet.has(dependency)) {
16248
+ dynamicEntryModules.add(dependency);
16249
+ allEntriesSet.add(dependency);
16120
16250
  }
16121
16251
  }
16122
16252
  }
16253
+ entryIndex++;
16123
16254
  }
16255
+ const allEntries = [...allEntriesSet];
16256
+ const { dynamicEntries, dynamicImportsByEntry } = getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry);
16124
16257
  return {
16125
- allEntries: [...allEntries],
16258
+ allEntries,
16126
16259
  dependentEntriesByModule,
16127
- dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries)
16260
+ dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries),
16261
+ dynamicImportsByEntry
16128
16262
  };
16129
16263
  }
16130
- function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries) {
16264
+ function getDynamicEntries(allEntries, dynamicEntryModules, dynamicImportModulesByEntry) {
16265
+ const entryIndexByModule = new Map();
16266
+ const dynamicEntries = new Set();
16267
+ for (const [entryIndex, entry] of allEntries.entries()) {
16268
+ entryIndexByModule.set(entry, entryIndex);
16269
+ if (dynamicEntryModules.has(entry)) {
16270
+ dynamicEntries.add(entryIndex);
16271
+ }
16272
+ }
16273
+ const dynamicImportsByEntry = [];
16274
+ for (const dynamicImportModules of dynamicImportModulesByEntry) {
16275
+ const dynamicImports = new Set();
16276
+ for (const dynamicEntry of dynamicImportModules) {
16277
+ dynamicImports.add(entryIndexByModule.get(dynamicEntry));
16278
+ }
16279
+ dynamicImportsByEntry.push(dynamicImports);
16280
+ }
16281
+ return { dynamicEntries, dynamicImportsByEntry };
16282
+ }
16283
+ function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule, dynamicEntries, allEntries) {
16131
16284
  const dynamicallyDependentEntriesByDynamicEntry = new Map();
16132
- for (const dynamicEntry of dynamicEntries) {
16133
- const dynamicallyDependentEntries = getOrCreate(dynamicallyDependentEntriesByDynamicEntry, dynamicEntry, getNewSet);
16134
- for (const importer of [
16135
- ...dynamicEntry.includedDynamicImporters,
16136
- ...dynamicEntry.implicitlyLoadedAfter
16137
- ]) {
16285
+ for (const dynamicEntryIndex of dynamicEntries) {
16286
+ const dynamicallyDependentEntries = getOrCreate(dynamicallyDependentEntriesByDynamicEntry, dynamicEntryIndex, (getNewSet));
16287
+ const dynamicEntry = allEntries[dynamicEntryIndex];
16288
+ for (const importer of concatLazy([
16289
+ dynamicEntry.includedDynamicImporters,
16290
+ dynamicEntry.implicitlyLoadedAfter
16291
+ ])) {
16138
16292
  for (const entry of dependentEntriesByModule.get(importer)) {
16139
16293
  dynamicallyDependentEntries.add(entry);
16140
16294
  }
@@ -16142,57 +16296,80 @@ function getDynamicallyDependentEntriesByDynamicEntry(dependentEntriesByModule,
16142
16296
  }
16143
16297
  return dynamicallyDependentEntriesByDynamicEntry;
16144
16298
  }
16145
- function assignEntryToStaticDependencies(entry, dependentEntriesByModule, assignedEntriesByModule, modulesInManualChunks, staticEntries, dynamicallyDependentEntriesByDynamicEntry, deepChunkOptimization) {
16146
- const dynamicallyDependentEntries = dynamicallyDependentEntriesByDynamicEntry.get(entry);
16147
- const modulesToHandle = new Set([entry]);
16148
- for (const module of modulesToHandle) {
16149
- const assignedEntries = getOrCreate(assignedEntriesByModule, module, getNewSet);
16150
- if (dynamicallyDependentEntries &&
16151
- isModuleAlreadyLoaded(dynamicallyDependentEntries, dependentEntriesByModule.get(module), staticEntries, dynamicallyDependentEntriesByDynamicEntry, deepChunkOptimization)) {
16152
- continue;
16153
- }
16154
- else {
16155
- assignedEntries.add(entry);
16156
- }
16157
- for (const dependency of module.getDependenciesToBeIncluded()) {
16158
- if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) {
16159
- modulesToHandle.add(dependency);
16160
- }
16299
+ function getChunksBySignature(modulesWithDependentEntries) {
16300
+ var _a;
16301
+ const chunkModules = Object.create(null);
16302
+ for (const { dependentEntries, modules } of modulesWithDependentEntries) {
16303
+ let chunkSignature = 0n;
16304
+ for (const entryIndex of dependentEntries) {
16305
+ chunkSignature |= 1n << BigInt(entryIndex);
16161
16306
  }
16307
+ (chunkModules[_a = String(chunkSignature)] || (chunkModules[_a] = {
16308
+ dependentEntries: new Set(dependentEntries),
16309
+ modules: []
16310
+ })).modules.push(...modules);
16162
16311
  }
16312
+ return chunkModules;
16163
16313
  }
16164
- const MAX_ENTRIES_TO_CHECK_FOR_SHARED_DEPENDENCIES = 3;
16165
- // An approach to further speed this up might be
16166
- // - first, create chunks without looking for modules already in memory
16167
- // - all modules that are in the same chunk after this will behave the same
16168
- // -> Do not iterate by module but by equivalence group and merge chunks
16169
- function isModuleAlreadyLoaded(dynamicallyDependentEntries, containedIn, staticEntries, dynamicallyDependentEntriesByDynamicEntry, deepChunkOptimization) {
16170
- if (!deepChunkOptimization &&
16171
- dynamicallyDependentEntries.size > MAX_ENTRIES_TO_CHECK_FOR_SHARED_DEPENDENCIES) {
16172
- return false;
16173
- }
16174
- const entriesToCheck = new Set(dynamicallyDependentEntries);
16175
- for (const entry of entriesToCheck) {
16176
- if (!containedIn.has(entry)) {
16177
- if (staticEntries.has(entry)) {
16178
- return false;
16179
- }
16180
- const dynamicallyDependentEntries = dynamicallyDependentEntriesByDynamicEntry.get(entry);
16181
- if (!deepChunkOptimization &&
16182
- dynamicallyDependentEntries.size > MAX_ENTRIES_TO_CHECK_FOR_SHARED_DEPENDENCIES) {
16183
- return false;
16184
- }
16185
- for (const dependentEntry of dynamicallyDependentEntries) {
16186
- entriesToCheck.add(dependentEntry);
16187
- }
16314
+ function* getModulesWithDependentEntries(dependentEntriesByModule, modulesInManualChunks) {
16315
+ for (const [module, dependentEntries] of dependentEntriesByModule) {
16316
+ if (!modulesInManualChunks.has(module)) {
16317
+ yield { dependentEntries, modules: [module] };
16188
16318
  }
16189
16319
  }
16190
- return true;
16191
16320
  }
16192
- function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
16193
- const chunkModulesBySignature = getChunkModulesBySignature(assignedEntriesByModule, allEntries);
16321
+ /**
16322
+ * This removes all unnecessary dynamic entries from the dependenEntries in its
16323
+ * first argument. It will also consume its second argument, so if
16324
+ * dynamicallyDependentEntriesByDynamicEntry is ever needed after this, we
16325
+ * should make a copy.
16326
+ */
16327
+ function removeUnnecessaryDependentEntries(chunks, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries) {
16328
+ // The indices correspond to the indices in allEntries. The chunks correspond
16329
+ // to bits in the bigint values where chunk 0 is the lowest bit.
16330
+ const staticDependenciesPerEntry = allEntries.map(() => 0n);
16331
+ const alreadyLoadedChunksPerEntry = allEntries.map((_entry, entryIndex) => dynamicallyDependentEntriesByDynamicEntry.has(entryIndex) ? -1n : 0n);
16332
+ // This toggles the bits for each chunk that is a dependency of an entry
16333
+ let chunkMask = 1n;
16334
+ for (const { dependentEntries } of chunks) {
16335
+ for (const entryIndex of dependentEntries) {
16336
+ staticDependenciesPerEntry[entryIndex] |= chunkMask;
16337
+ }
16338
+ chunkMask <<= 1n;
16339
+ }
16340
+ // Warning: This will consume dynamicallyDependentEntriesByDynamicEntry.
16341
+ // If we no longer want this, we should make a copy here.
16342
+ const updatedDynamicallyDependentEntriesByDynamicEntry = dynamicallyDependentEntriesByDynamicEntry;
16343
+ for (const [dynamicEntryIndex, updatedDynamicallyDependentEntries] of updatedDynamicallyDependentEntriesByDynamicEntry) {
16344
+ updatedDynamicallyDependentEntriesByDynamicEntry.delete(dynamicEntryIndex);
16345
+ const previousLoadedModules = alreadyLoadedChunksPerEntry[dynamicEntryIndex];
16346
+ let newLoadedModules = previousLoadedModules;
16347
+ for (const entryIndex of updatedDynamicallyDependentEntries) {
16348
+ newLoadedModules &=
16349
+ staticDependenciesPerEntry[entryIndex] | alreadyLoadedChunksPerEntry[entryIndex];
16350
+ }
16351
+ if (newLoadedModules !== previousLoadedModules) {
16352
+ alreadyLoadedChunksPerEntry[dynamicEntryIndex] = newLoadedModules;
16353
+ for (const dynamicImport of dynamicImportsByEntry[dynamicEntryIndex]) {
16354
+ getOrCreate(updatedDynamicallyDependentEntriesByDynamicEntry, dynamicImport, (getNewSet)).add(dynamicEntryIndex);
16355
+ }
16356
+ }
16357
+ }
16358
+ // Remove entries from dependent entries if a chunk is already loaded without
16359
+ // that entry.
16360
+ chunkMask = 1n;
16361
+ for (const { dependentEntries } of chunks) {
16362
+ for (const entryIndex of dependentEntries) {
16363
+ if ((alreadyLoadedChunksPerEntry[entryIndex] & chunkMask) === chunkMask) {
16364
+ dependentEntries.delete(entryIndex);
16365
+ }
16366
+ }
16367
+ chunkMask <<= 1n;
16368
+ }
16369
+ }
16370
+ function createChunks(allEntries, chunkModulesBySignature, minChunkSize) {
16194
16371
  return minChunkSize === 0
16195
- ? Object.values(chunkModulesBySignature).map(modules => ({
16372
+ ? Object.values(chunkModulesBySignature).map(({ modules }) => ({
16196
16373
  alias: null,
16197
16374
  modules
16198
16375
  }))
@@ -16201,23 +16378,6 @@ function createChunks(allEntries, assignedEntriesByModule, minChunkSize) {
16201
16378
  modules
16202
16379
  }));
16203
16380
  }
16204
- function getChunkModulesBySignature(assignedEntriesByModule, allEntries) {
16205
- const chunkModules = Object.create(null);
16206
- for (const [module, assignedEntries] of assignedEntriesByModule) {
16207
- let chunkSignature = '';
16208
- for (const entry of allEntries) {
16209
- chunkSignature += assignedEntries.has(entry) ? CHAR_DEPENDENT : CHAR_INDEPENDENT;
16210
- }
16211
- const chunk = chunkModules[chunkSignature];
16212
- if (chunk) {
16213
- chunk.push(module);
16214
- }
16215
- else {
16216
- chunkModules[chunkSignature] = [module];
16217
- }
16218
- }
16219
- return chunkModules;
16220
- }
16221
16381
  /**
16222
16382
  * This function tries to get rid of small chunks by merging them with other
16223
16383
  * chunks.
@@ -16303,8 +16463,6 @@ function getOptimizedChunks(chunkModulesBySignature, numberOfEntries, minChunkSi
16303
16463
  timeEnd('optimize chunks', 3);
16304
16464
  return [...chunkPartition.small, ...chunkPartition.big];
16305
16465
  }
16306
- const CHAR_DEPENDENT = 'X';
16307
- const CHAR_INDEPENDENT = '_';
16308
16466
  function getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunkSize) {
16309
16467
  const smallChunks = [];
16310
16468
  const bigChunks = [];
@@ -16313,13 +16471,7 @@ function getPartitionedChunks(chunkModulesBySignature, numberOfEntries, minChunk
16313
16471
  for (let index = 0; index < numberOfEntries; index++) {
16314
16472
  sideEffectsByEntry.push(new Set());
16315
16473
  }
16316
- for (const [signature, modules] of Object.entries(chunkModulesBySignature)) {
16317
- const dependentEntries = new Set();
16318
- for (let position = 0; position < numberOfEntries; position++) {
16319
- if (signature[position] === CHAR_DEPENDENT) {
16320
- dependentEntries.add(position);
16321
- }
16322
- }
16474
+ for (const [signature, { dependentEntries, modules }] of Object.entries(chunkModulesBySignature)) {
16323
16475
  const chunkDescription = {
16324
16476
  correlatedSideEffects: new Set(),
16325
16477
  dependencies: new Set(),
@@ -17115,7 +17267,7 @@ class Bundle {
17115
17267
  this.pluginDriver.finaliseAssets();
17116
17268
  }
17117
17269
  async generateChunks(bundle, getHashPlaceholder) {
17118
- const { experimentalDeepDynamicChunkOptimization, experimentalMinChunkSize, inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
17270
+ const { experimentalMinChunkSize, inlineDynamicImports, manualChunks, preserveModules } = this.outputOptions;
17119
17271
  const manualChunkAliasByEntry = typeof manualChunks === 'object'
17120
17272
  ? await this.addManualChunks(manualChunks)
17121
17273
  : this.assignManualChunks(manualChunks);
@@ -17129,7 +17281,7 @@ class Bundle {
17129
17281
  ? [{ alias: null, modules: includedModules }]
17130
17282
  : preserveModules
17131
17283
  ? includedModules.map(module => ({ alias: null, modules: [module] }))
17132
- : getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize, experimentalDeepDynamicChunkOptimization)) {
17284
+ : getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize)) {
17133
17285
  sortByExecutionOrder(modules);
17134
17286
  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);
17135
17287
  chunks.push(chunk);
@@ -24923,7 +25075,7 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
24923
25075
  dynamicImportInCjs: config.dynamicImportInCjs ?? true,
24924
25076
  entryFileNames: getEntryFileNames(config, unsetOptions),
24925
25077
  esModule: config.esModule ?? 'if-default-prop',
24926
- experimentalDeepDynamicChunkOptimization: config.experimentalDeepDynamicChunkOptimization || false,
25078
+ experimentalDeepDynamicChunkOptimization: getExperimentalDeepDynamicChunkOptimization(config, inputOptions),
24927
25079
  experimentalMinChunkSize: config.experimentalMinChunkSize || 0,
24928
25080
  exports: getExports(config, unsetOptions),
24929
25081
  extend: config.extend || false,
@@ -25101,6 +25253,13 @@ const getEntryFileNames = (config, unsetOptions) => {
25101
25253
  }
25102
25254
  return configEntryFileNames ?? '[name].js';
25103
25255
  };
25256
+ function getExperimentalDeepDynamicChunkOptimization(config, inputOptions) {
25257
+ const configExperimentalDeepDynamicChunkOptimization = config.experimentalDeepDynamicChunkOptimization;
25258
+ if (configExperimentalDeepDynamicChunkOptimization != null) {
25259
+ warnDeprecation(`The "output.experimentalDeepDynamicChunkOptimization" option is deprecated as Rollup always runs the full chunking algorithm now. The option should be removed.`, URL_OUTPUT_EXPERIMENTALDEEPCHUNKOPTIMIZATION, true, inputOptions);
25260
+ }
25261
+ return configExperimentalDeepDynamicChunkOptimization || false;
25262
+ }
25104
25263
  function getExports(config, unsetOptions) {
25105
25264
  const configExports = config.exports;
25106
25265
  if (configExports == null) {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.16.0
4
- Fri, 17 Feb 2023 13:26:29 GMT - commit 8ba73f4f643e5ffe01fc9ad846748f6d5b7963c2
3
+ Rollup.js v3.17.1
4
+ Sat, 18 Feb 2023 19:47:52 GMT - commit 2a9abba955cfcb187167aba96e64c7c06f3f02ca
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { resolve } from 'node:path';
11
11
  import process$1 from 'node:process';
12
- import { picomatchExports, getAugmentedNamespace, fseventsImporter, createFilter, rollupInternal } from './rollup.js';
12
+ import { picomatchExports, getAugmentedNamespace, fseventsImporter, createFilter, rollupInternal } from './node-entry.js';
13
13
  import { platform } from 'node:os';
14
14
  import require$$0$1 from 'fs';
15
15
  import require$$2 from 'util';
@@ -0,0 +1,18 @@
1
+ import type { MergedRollupOptions, RollupWarning } from './rollup';
2
+
3
+ export interface BatchWarnings {
4
+ add: (warning: RollupWarning) => void;
5
+ readonly count: number;
6
+ flush: () => void;
7
+ readonly warningOccurred: boolean;
8
+ }
9
+
10
+ export type LoadConfigFile = typeof loadConfigFile;
11
+
12
+ export function loadConfigFile(
13
+ fileName: string,
14
+ commandOptions: any
15
+ ): Promise<{
16
+ options: MergedRollupOptions[];
17
+ warnings: BatchWarnings;
18
+ }>;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.16.0
4
- Fri, 17 Feb 2023 13:26:29 GMT - commit 8ba73f4f643e5ffe01fc9ad846748f6d5b7963c2
3
+ Rollup.js v3.17.1
4
+ Sat, 18 Feb 2023 19:47:52 GMT - commit 2a9abba955cfcb187167aba96e64c7c06f3f02ca
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -17,11 +17,11 @@ require('node:process');
17
17
  require('node:url');
18
18
  require('./shared/rollup.js');
19
19
  const loadConfigFile_js = require('./shared/loadConfigFile.js');
20
+ require('tty');
20
21
  require('path');
21
22
  require('node:perf_hooks');
22
23
  require('node:crypto');
23
24
  require('node:events');
24
- require('tty');
25
25
 
26
26
 
27
27