rollup 2.52.8 → 2.53.3

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/rollup.d.ts CHANGED
@@ -537,6 +537,7 @@ export interface InputOptions {
537
537
  makeAbsoluteExternalsRelative?: boolean | 'ifRelativeSource';
538
538
  /** @deprecated Use the "manualChunks" output option instead. */
539
539
  manualChunks?: ManualChunksOption;
540
+ maxParallelFileReads?: number;
540
541
  moduleContext?: ((id: string) => string | null | undefined) | { [id: string]: string };
541
542
  onwarn?: WarningHandlerWithDefault;
542
543
  perf?: boolean;
@@ -564,6 +565,7 @@ export interface NormalizedInputOptions {
564
565
  makeAbsoluteExternalsRelative: boolean | 'ifRelativeSource';
565
566
  /** @deprecated Use the "manualChunks" output option instead. */
566
567
  manualChunks: ManualChunksOption | undefined;
568
+ maxParallelFileReads: number;
567
569
  moduleContext: (id: string) => string;
568
570
  onwarn: WarningHandler;
569
571
  perf: boolean;
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.8
4
- Wed, 07 Jul 2021 04:39:13 GMT - commit b3d5f7d02d2ac1597801c23e10f10651b158f3c4
3
+ Rollup.js v2.53.3
4
+ Wed, 21 Jul 2021 06:45:44 GMT - commit ae8f57f926433f9ef3a3ecdd39b224674c7e68af
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.8
4
- Wed, 07 Jul 2021 04:39:13 GMT - commit b3d5f7d02d2ac1597801c23e10f10651b158f3c4
3
+ Rollup.js v2.53.3
4
+ Wed, 21 Jul 2021 06:45:44 GMT - commit ae8f57f926433f9ef3a3ecdd39b224674c7e68af
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.8
4
- Wed, 07 Jul 2021 04:39:13 GMT - commit b3d5f7d02d2ac1597801c23e10f10651b158f3c4
3
+ Rollup.js v2.53.3
4
+ Wed, 21 Jul 2021 06:45:44 GMT - commit ae8f57f926433f9ef3a3ecdd39b224674c7e68af
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.8
4
- Wed, 07 Jul 2021 04:39:13 GMT - commit b3d5f7d02d2ac1597801c23e10f10651b158f3c4
3
+ Rollup.js v2.53.3
4
+ Wed, 21 Jul 2021 06:45:44 GMT - commit ae8f57f926433f9ef3a3ecdd39b224674c7e68af
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -74,6 +74,7 @@ function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
74
74
  input: getOption('input') || [],
75
75
  makeAbsoluteExternalsRelative: getOption('makeAbsoluteExternalsRelative'),
76
76
  manualChunks: getOption('manualChunks'),
77
+ maxParallelFileReads: getOption('maxParallelFileReads'),
77
78
  moduleContext: getOption('moduleContext'),
78
79
  onwarn: getOnWarn(config, defaultOnWarnHandler),
79
80
  perf: getOption('perf'),
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.8
4
- Wed, 07 Jul 2021 04:39:13 GMT - commit b3d5f7d02d2ac1597801c23e10f10651b158f3c4
3
+ Rollup.js v2.53.3
4
+ Wed, 21 Jul 2021 06:45:44 GMT - commit ae8f57f926433f9ef3a3ecdd39b224674c7e68af
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -19,20 +19,7 @@ function _interopNamespaceDefaultOnly(e) {
19
19
  return {__proto__: null, 'default': e};
20
20
  }
21
21
 
22
- function _interopNamespaceDefault(e) {
23
- var n = Object.create(null);
24
- if (e) {
25
- Object.keys(e).forEach(function (k) {
26
- n[k] = e[k];
27
- });
28
- }
29
- n['default'] = e;
30
- return n;
31
- }
32
-
33
- var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
34
-
35
- var version$1 = "2.52.8";
22
+ var version$1 = "2.53.3";
36
23
 
37
24
  function ensureArray(items) {
38
25
  if (Array.isArray(items)) {
@@ -3407,8 +3394,8 @@ const MAX_PATH_DEPTH = 7;
3407
3394
  class LocalVariable extends Variable {
3408
3395
  constructor(name, declarator, init, context) {
3409
3396
  super(name);
3410
- this.additionalInitializers = null;
3411
3397
  this.calledFromTryStatement = false;
3398
+ this.additionalInitializers = null;
3412
3399
  this.expressionsToBeDeoptimized = [];
3413
3400
  this.declarations = declarator ? [declarator] : [];
3414
3401
  this.init = init;
@@ -3417,13 +3404,9 @@ class LocalVariable extends Variable {
3417
3404
  }
3418
3405
  addDeclaration(identifier, init) {
3419
3406
  this.declarations.push(identifier);
3420
- if (this.additionalInitializers === null) {
3421
- this.additionalInitializers = this.init === null ? [] : [this.init];
3422
- this.init = UNKNOWN_EXPRESSION;
3423
- this.isReassigned = true;
3424
- }
3407
+ const additionalInitializers = this.markInitializersForDeoptimization();
3425
3408
  if (init !== null) {
3426
- this.additionalInitializers.push(init);
3409
+ additionalInitializers.push(init);
3427
3410
  }
3428
3411
  }
3429
3412
  consolidateInitializers() {
@@ -3539,6 +3522,14 @@ class LocalVariable extends Variable {
3539
3522
  markCalledFromTryStatement() {
3540
3523
  this.calledFromTryStatement = true;
3541
3524
  }
3525
+ markInitializersForDeoptimization() {
3526
+ if (this.additionalInitializers === null) {
3527
+ this.additionalInitializers = this.init === null ? [] : [this.init];
3528
+ this.init = UNKNOWN_EXPRESSION;
3529
+ this.isReassigned = true;
3530
+ }
3531
+ return this.additionalInitializers;
3532
+ }
3542
3533
  }
3543
3534
 
3544
3535
  class Scope$1 {
@@ -4591,7 +4582,7 @@ class Identifier extends NodeBase {
4591
4582
  variable = this.scope.addDeclaration(this, this.context, init, true);
4592
4583
  if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
4593
4584
  // Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
4594
- this.scope.addDeclaration(this, this.context, UNDEFINED_EXPRESSION, true);
4585
+ variable.markInitializersForDeoptimization();
4595
4586
  }
4596
4587
  break;
4597
4588
  case 'function':
@@ -4717,6 +4708,16 @@ class Identifier extends NodeBase {
4717
4708
  !(this.variable.kind in tdzVariableKinds)) {
4718
4709
  return (this.isTDZAccess = false);
4719
4710
  }
4711
+ let decl_id;
4712
+ if (this.variable.declarations &&
4713
+ this.variable.declarations.length === 1 &&
4714
+ (decl_id = this.variable.declarations[0]) &&
4715
+ this.start < decl_id.start &&
4716
+ closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(decl_id)) {
4717
+ // a variable accessed before its declaration
4718
+ // in the same function or at top level of module
4719
+ return (this.isTDZAccess = true);
4720
+ }
4720
4721
  if (!this.variable.initReached) {
4721
4722
  // Either a const/let TDZ violation or
4722
4723
  // var use before declaration was encountered.
@@ -4725,6 +4726,13 @@ class Identifier extends NodeBase {
4725
4726
  return (this.isTDZAccess = false);
4726
4727
  }
4727
4728
  }
4729
+ function closestParentFunctionOrProgram(node) {
4730
+ while (node && !/^Program|Function/.test(node.type)) {
4731
+ node = node.parent;
4732
+ }
4733
+ // one of: ArrowFunctionExpression, FunctionDeclaration, FunctionExpression or Program
4734
+ return node;
4735
+ }
4728
4736
 
4729
4737
  const EVENT_ACCESSED = 0;
4730
4738
  const EVENT_ASSIGNED = 1;
@@ -6410,10 +6418,11 @@ class ArrayPattern extends NodeBase {
6410
6418
  class BlockScope extends ChildScope {
6411
6419
  addDeclaration(identifier, context, init, isHoisted) {
6412
6420
  if (isHoisted) {
6413
- this.parent.addDeclaration(identifier, context, init, isHoisted);
6421
+ const variable = this.parent.addDeclaration(identifier, context, init, isHoisted);
6414
6422
  // Necessary to make sure the init is deoptimized for conditional declarations.
6415
6423
  // We cannot call deoptimizePath here.
6416
- return this.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, isHoisted);
6424
+ variable.markInitializersForDeoptimization();
6425
+ return variable;
6417
6426
  }
6418
6427
  else {
6419
6428
  return super.addDeclaration(identifier, context, init, false);
@@ -7280,10 +7289,13 @@ class CatchScope extends ParameterScope {
7280
7289
  addDeclaration(identifier, context, init, isHoisted) {
7281
7290
  const existingParameter = this.variables.get(identifier.name);
7282
7291
  if (existingParameter) {
7292
+ // While we still create a hoisted declaration, the initializer goes to
7293
+ // the parameter. Note that technically, the declaration now belongs to
7294
+ // two variables, which is not correct but should not cause issues.
7295
+ this.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, isHoisted);
7283
7296
  existingParameter.addDeclaration(identifier, init);
7284
7297
  return existingParameter;
7285
7298
  }
7286
- // as parameters are handled differently, all remaining declarations are hoisted
7287
7299
  return this.parent.addDeclaration(identifier, context, init, isHoisted);
7288
7300
  }
7289
7301
  }
@@ -7293,9 +7305,9 @@ class CatchClause extends NodeBase {
7293
7305
  this.scope = new CatchScope(parentScope, this.context);
7294
7306
  }
7295
7307
  parseNode(esTreeNode) {
7296
- // Parameters need to be declared first as the logic is that hoisted body
7297
- // variables are associated with outside vars unless there is a parameter,
7298
- // in which case they are associated with the parameter
7308
+ // Parameters need to be declared first as the logic is that initializers
7309
+ // of hoisted body variables are associated with parameters of the same
7310
+ // name instead of the variable
7299
7311
  const { param } = esTreeNode;
7300
7312
  if (param) {
7301
7313
  this.param = new (this.context.nodeConstructors[param.type] ||
@@ -7778,7 +7790,7 @@ class TrackingScope extends BlockScope {
7778
7790
  }
7779
7791
  addDeclaration(identifier, context, init, isHoisted) {
7780
7792
  this.hoistedDeclarations.push(identifier);
7781
- return this.parent.addDeclaration(identifier, context, init, isHoisted);
7793
+ return super.addDeclaration(identifier, context, init, isHoisted);
7782
7794
  }
7783
7795
  }
7784
7796
 
@@ -10260,6 +10272,7 @@ class Module {
10260
10272
  }
10261
10273
  includeAllInBundle() {
10262
10274
  this.ast.include(createInclusionContext(), true);
10275
+ this.includeAllExports(false);
10263
10276
  }
10264
10277
  isIncluded() {
10265
10278
  return this.ast.included || this.namespace.included || this.importedFromNotTreeshaken;
@@ -19164,16 +19177,16 @@ Parser.acorn = {
19164
19177
  nonASCIIwhitespace: nonASCIIwhitespace
19165
19178
  };
19166
19179
 
19167
- const readFile = (file) => new Promise((fulfil, reject) => fs__namespace.readFile(file, 'utf-8', (err, contents) => (err ? reject(err) : fulfil(contents))));
19180
+ const readFile = (file) => new Promise((fulfil, reject) => fs.readFile(file, 'utf-8', (err, contents) => (err ? reject(err) : fulfil(contents))));
19168
19181
  function mkdirpath(path$1) {
19169
19182
  const dir = path.dirname(path$1);
19170
19183
  try {
19171
- fs__namespace.readdirSync(dir);
19184
+ fs.readdirSync(dir);
19172
19185
  }
19173
19186
  catch (err) {
19174
19187
  mkdirpath(dir);
19175
19188
  try {
19176
- fs__namespace.mkdirSync(dir);
19189
+ fs.mkdirSync(dir);
19177
19190
  }
19178
19191
  catch (err2) {
19179
19192
  if (err2.code !== 'EEXIST') {
@@ -19185,7 +19198,7 @@ function mkdirpath(path$1) {
19185
19198
  function writeFile(dest, data) {
19186
19199
  return new Promise((fulfil, reject) => {
19187
19200
  mkdirpath(dest);
19188
- fs__namespace.writeFile(dest, data, err => {
19201
+ fs.writeFile(dest, data, err => {
19189
19202
  if (err) {
19190
19203
  reject(err);
19191
19204
  }
@@ -19196,6 +19209,37 @@ function writeFile(dest, data) {
19196
19209
  });
19197
19210
  }
19198
19211
 
19212
+ class Queue {
19213
+ constructor(maxParallel = 1) {
19214
+ this.maxParallel = maxParallel;
19215
+ this.queue = new Array();
19216
+ this.workerCount = 0;
19217
+ }
19218
+ run(task) {
19219
+ return new Promise((resolve, reject) => {
19220
+ this.queue.push({ reject, resolve, task });
19221
+ this.work();
19222
+ });
19223
+ }
19224
+ async work() {
19225
+ if (this.workerCount >= this.maxParallel)
19226
+ return;
19227
+ this.workerCount++;
19228
+ let entry;
19229
+ while ((entry = this.queue.shift())) {
19230
+ const { reject, resolve, task } = entry;
19231
+ try {
19232
+ const result = await task();
19233
+ resolve(result);
19234
+ }
19235
+ catch (err) {
19236
+ reject(err);
19237
+ }
19238
+ }
19239
+ this.workerCount--;
19240
+ }
19241
+ }
19242
+
19199
19243
  function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions) {
19200
19244
  let skipped = null;
19201
19245
  let replaceContext = null;
@@ -19515,6 +19559,7 @@ class ModuleLoader {
19515
19559
  this.indexedEntryModules = [];
19516
19560
  this.latestLoadModulesPromise = Promise.resolve();
19517
19561
  this.nextEntryModuleIndex = 0;
19562
+ this.readQueue = new Queue();
19518
19563
  this.resolveId = async (source, importer, customOptions, skip = null) => {
19519
19564
  return this.addDefaultsToResolvedId(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
19520
19565
  ? false
@@ -19523,6 +19568,7 @@ class ModuleLoader {
19523
19568
  this.hasModuleSideEffects = options.treeshake
19524
19569
  ? options.treeshake.moduleSideEffects
19525
19570
  : () => true;
19571
+ this.readQueue.maxParallel = options.maxParallelFileReads;
19526
19572
  }
19527
19573
  async addAdditionalModules(unresolvedModules) {
19528
19574
  const result = this.extendLoadModulesPromise(Promise.all(unresolvedModules.map(id => this.loadEntryModule(id, false, undefined, null))));
@@ -19608,7 +19654,8 @@ class ModuleLoader {
19608
19654
  timeStart('load modules', 3);
19609
19655
  let source;
19610
19656
  try {
19611
- source = (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await readFile(id));
19657
+ source =
19658
+ (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await this.readQueue.run(async () => readFile(id)));
19612
19659
  }
19613
19660
  catch (err) {
19614
19661
  timeEnd('load modules', 3);
@@ -20397,6 +20444,7 @@ function normalizeInputOptions(config) {
20397
20444
  input: getInput(config),
20398
20445
  makeAbsoluteExternalsRelative: (_c = config.makeAbsoluteExternalsRelative) !== null && _c !== void 0 ? _c : true,
20399
20446
  manualChunks: getManualChunks$1(config, onwarn, strictDeprecations),
20447
+ maxParallelFileReads: getMaxParallelFileReads(config),
20400
20448
  moduleContext: getModuleContext(config, context),
20401
20449
  onwarn,
20402
20450
  perf: config.perf || false,
@@ -20477,6 +20525,15 @@ const getManualChunks$1 = (config, warn, strictDeprecations) => {
20477
20525
  }
20478
20526
  return configManualChunks;
20479
20527
  };
20528
+ const getMaxParallelFileReads = (config) => {
20529
+ const maxParallelFileReads = config.maxParallelFileReads;
20530
+ if (typeof maxParallelFileReads === 'number') {
20531
+ if (maxParallelFileReads <= 0)
20532
+ return Infinity;
20533
+ return maxParallelFileReads;
20534
+ }
20535
+ return 20;
20536
+ };
20480
20537
  const getModuleContext = (config, context) => {
20481
20538
  const configModuleContext = config.moduleContext;
20482
20539
  if (typeof configModuleContext === 'function') {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.8
4
- Wed, 07 Jul 2021 04:39:13 GMT - commit b3d5f7d02d2ac1597801c23e10f10651b158f3c4
3
+ Rollup.js v2.53.3
4
+ Wed, 21 Jul 2021 06:45:44 GMT - commit ae8f57f926433f9ef3a3ecdd39b224674c7e68af
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.52.8
4
- Wed, 07 Jul 2021 04:39:13 GMT - commit b3d5f7d02d2ac1597801c23e10f10651b158f3c4
3
+ Rollup.js v2.53.3
4
+ Wed, 21 Jul 2021 06:45:44 GMT - commit ae8f57f926433f9ef3a3ecdd39b224674c7e68af
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollup",
3
- "version": "2.52.8",
3
+ "version": "2.53.3",
4
4
  "description": "Next-generation ES module bundler",
5
5
  "main": "dist/rollup.js",
6
6
  "module": "dist/es/rollup.js",