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/es/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
@@ -10,11 +10,10 @@
10
10
  */
11
11
  import { relative as relative$1, resolve, extname, basename, dirname } from 'path';
12
12
  import { createHash as createHash$1 } from 'crypto';
13
- import * as fs from 'fs';
14
- import { lstatSync, realpathSync, readdirSync } from 'fs';
13
+ import fs, { lstatSync, realpathSync, readdirSync } from 'fs';
15
14
  import { EventEmitter } from 'events';
16
15
 
17
- var version$1 = "2.52.8";
16
+ var version$1 = "2.53.3";
18
17
 
19
18
  var charToInteger = {};
20
19
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -2934,8 +2933,8 @@ const MAX_PATH_DEPTH = 7;
2934
2933
  class LocalVariable extends Variable {
2935
2934
  constructor(name, declarator, init, context) {
2936
2935
  super(name);
2937
- this.additionalInitializers = null;
2938
2936
  this.calledFromTryStatement = false;
2937
+ this.additionalInitializers = null;
2939
2938
  this.expressionsToBeDeoptimized = [];
2940
2939
  this.declarations = declarator ? [declarator] : [];
2941
2940
  this.init = init;
@@ -2944,13 +2943,9 @@ class LocalVariable extends Variable {
2944
2943
  }
2945
2944
  addDeclaration(identifier, init) {
2946
2945
  this.declarations.push(identifier);
2947
- if (this.additionalInitializers === null) {
2948
- this.additionalInitializers = this.init === null ? [] : [this.init];
2949
- this.init = UNKNOWN_EXPRESSION;
2950
- this.isReassigned = true;
2951
- }
2946
+ const additionalInitializers = this.markInitializersForDeoptimization();
2952
2947
  if (init !== null) {
2953
- this.additionalInitializers.push(init);
2948
+ additionalInitializers.push(init);
2954
2949
  }
2955
2950
  }
2956
2951
  consolidateInitializers() {
@@ -3066,6 +3061,14 @@ class LocalVariable extends Variable {
3066
3061
  markCalledFromTryStatement() {
3067
3062
  this.calledFromTryStatement = true;
3068
3063
  }
3064
+ markInitializersForDeoptimization() {
3065
+ if (this.additionalInitializers === null) {
3066
+ this.additionalInitializers = this.init === null ? [] : [this.init];
3067
+ this.init = UNKNOWN_EXPRESSION;
3068
+ this.isReassigned = true;
3069
+ }
3070
+ return this.additionalInitializers;
3071
+ }
3069
3072
  }
3070
3073
 
3071
3074
  class Scope$1 {
@@ -4118,7 +4121,7 @@ class Identifier extends NodeBase {
4118
4121
  variable = this.scope.addDeclaration(this, this.context, init, true);
4119
4122
  if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
4120
4123
  // Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
4121
- this.scope.addDeclaration(this, this.context, UNDEFINED_EXPRESSION, true);
4124
+ variable.markInitializersForDeoptimization();
4122
4125
  }
4123
4126
  break;
4124
4127
  case 'function':
@@ -4244,6 +4247,16 @@ class Identifier extends NodeBase {
4244
4247
  !(this.variable.kind in tdzVariableKinds)) {
4245
4248
  return (this.isTDZAccess = false);
4246
4249
  }
4250
+ let decl_id;
4251
+ if (this.variable.declarations &&
4252
+ this.variable.declarations.length === 1 &&
4253
+ (decl_id = this.variable.declarations[0]) &&
4254
+ this.start < decl_id.start &&
4255
+ closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(decl_id)) {
4256
+ // a variable accessed before its declaration
4257
+ // in the same function or at top level of module
4258
+ return (this.isTDZAccess = true);
4259
+ }
4247
4260
  if (!this.variable.initReached) {
4248
4261
  // Either a const/let TDZ violation or
4249
4262
  // var use before declaration was encountered.
@@ -4252,6 +4265,13 @@ class Identifier extends NodeBase {
4252
4265
  return (this.isTDZAccess = false);
4253
4266
  }
4254
4267
  }
4268
+ function closestParentFunctionOrProgram(node) {
4269
+ while (node && !/^Program|Function/.test(node.type)) {
4270
+ node = node.parent;
4271
+ }
4272
+ // one of: ArrowFunctionExpression, FunctionDeclaration, FunctionExpression or Program
4273
+ return node;
4274
+ }
4255
4275
 
4256
4276
  const EVENT_ACCESSED = 0;
4257
4277
  const EVENT_ASSIGNED = 1;
@@ -5937,10 +5957,11 @@ class ArrayPattern extends NodeBase {
5937
5957
  class BlockScope extends ChildScope {
5938
5958
  addDeclaration(identifier, context, init, isHoisted) {
5939
5959
  if (isHoisted) {
5940
- this.parent.addDeclaration(identifier, context, init, isHoisted);
5960
+ const variable = this.parent.addDeclaration(identifier, context, init, isHoisted);
5941
5961
  // Necessary to make sure the init is deoptimized for conditional declarations.
5942
5962
  // We cannot call deoptimizePath here.
5943
- return this.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, isHoisted);
5963
+ variable.markInitializersForDeoptimization();
5964
+ return variable;
5944
5965
  }
5945
5966
  else {
5946
5967
  return super.addDeclaration(identifier, context, init, false);
@@ -6807,10 +6828,13 @@ class CatchScope extends ParameterScope {
6807
6828
  addDeclaration(identifier, context, init, isHoisted) {
6808
6829
  const existingParameter = this.variables.get(identifier.name);
6809
6830
  if (existingParameter) {
6831
+ // While we still create a hoisted declaration, the initializer goes to
6832
+ // the parameter. Note that technically, the declaration now belongs to
6833
+ // two variables, which is not correct but should not cause issues.
6834
+ this.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, isHoisted);
6810
6835
  existingParameter.addDeclaration(identifier, init);
6811
6836
  return existingParameter;
6812
6837
  }
6813
- // as parameters are handled differently, all remaining declarations are hoisted
6814
6838
  return this.parent.addDeclaration(identifier, context, init, isHoisted);
6815
6839
  }
6816
6840
  }
@@ -6820,9 +6844,9 @@ class CatchClause extends NodeBase {
6820
6844
  this.scope = new CatchScope(parentScope, this.context);
6821
6845
  }
6822
6846
  parseNode(esTreeNode) {
6823
- // Parameters need to be declared first as the logic is that hoisted body
6824
- // variables are associated with outside vars unless there is a parameter,
6825
- // in which case they are associated with the parameter
6847
+ // Parameters need to be declared first as the logic is that initializers
6848
+ // of hoisted body variables are associated with parameters of the same
6849
+ // name instead of the variable
6826
6850
  const { param } = esTreeNode;
6827
6851
  if (param) {
6828
6852
  this.param = new (this.context.nodeConstructors[param.type] ||
@@ -7305,7 +7329,7 @@ class TrackingScope extends BlockScope {
7305
7329
  }
7306
7330
  addDeclaration(identifier, context, init, isHoisted) {
7307
7331
  this.hoistedDeclarations.push(identifier);
7308
- return this.parent.addDeclaration(identifier, context, init, isHoisted);
7332
+ return super.addDeclaration(identifier, context, init, isHoisted);
7309
7333
  }
7310
7334
  }
7311
7335
 
@@ -10166,6 +10190,7 @@ class Module {
10166
10190
  }
10167
10191
  includeAllInBundle() {
10168
10192
  this.ast.include(createInclusionContext(), true);
10193
+ this.includeAllExports(false);
10169
10194
  }
10170
10195
  isIncluded() {
10171
10196
  return this.ast.included || this.namespace.included || this.importedFromNotTreeshaken;
@@ -19102,6 +19127,37 @@ function writeFile(dest, data) {
19102
19127
  });
19103
19128
  }
19104
19129
 
19130
+ class Queue {
19131
+ constructor(maxParallel = 1) {
19132
+ this.maxParallel = maxParallel;
19133
+ this.queue = new Array();
19134
+ this.workerCount = 0;
19135
+ }
19136
+ run(task) {
19137
+ return new Promise((resolve, reject) => {
19138
+ this.queue.push({ reject, resolve, task });
19139
+ this.work();
19140
+ });
19141
+ }
19142
+ async work() {
19143
+ if (this.workerCount >= this.maxParallel)
19144
+ return;
19145
+ this.workerCount++;
19146
+ let entry;
19147
+ while ((entry = this.queue.shift())) {
19148
+ const { reject, resolve, task } = entry;
19149
+ try {
19150
+ const result = await task();
19151
+ resolve(result);
19152
+ }
19153
+ catch (err) {
19154
+ reject(err);
19155
+ }
19156
+ }
19157
+ this.workerCount--;
19158
+ }
19159
+ }
19160
+
19105
19161
  function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions) {
19106
19162
  let skipped = null;
19107
19163
  let replaceContext = null;
@@ -19421,6 +19477,7 @@ class ModuleLoader {
19421
19477
  this.indexedEntryModules = [];
19422
19478
  this.latestLoadModulesPromise = Promise.resolve();
19423
19479
  this.nextEntryModuleIndex = 0;
19480
+ this.readQueue = new Queue();
19424
19481
  this.resolveId = async (source, importer, customOptions, skip = null) => {
19425
19482
  return this.addDefaultsToResolvedId(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
19426
19483
  ? false
@@ -19429,6 +19486,7 @@ class ModuleLoader {
19429
19486
  this.hasModuleSideEffects = options.treeshake
19430
19487
  ? options.treeshake.moduleSideEffects
19431
19488
  : () => true;
19489
+ this.readQueue.maxParallel = options.maxParallelFileReads;
19432
19490
  }
19433
19491
  async addAdditionalModules(unresolvedModules) {
19434
19492
  const result = this.extendLoadModulesPromise(Promise.all(unresolvedModules.map(id => this.loadEntryModule(id, false, undefined, null))));
@@ -19514,7 +19572,8 @@ class ModuleLoader {
19514
19572
  timeStart('load modules', 3);
19515
19573
  let source;
19516
19574
  try {
19517
- source = (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await readFile(id));
19575
+ source =
19576
+ (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await this.readQueue.run(async () => readFile(id)));
19518
19577
  }
19519
19578
  catch (err) {
19520
19579
  timeEnd('load modules', 3);
@@ -20355,6 +20414,7 @@ function normalizeInputOptions(config) {
20355
20414
  input: getInput(config),
20356
20415
  makeAbsoluteExternalsRelative: (_c = config.makeAbsoluteExternalsRelative) !== null && _c !== void 0 ? _c : true,
20357
20416
  manualChunks: getManualChunks$1(config, onwarn, strictDeprecations),
20417
+ maxParallelFileReads: getMaxParallelFileReads(config),
20358
20418
  moduleContext: getModuleContext(config, context),
20359
20419
  onwarn,
20360
20420
  perf: config.perf || false,
@@ -20435,6 +20495,15 @@ const getManualChunks$1 = (config, warn, strictDeprecations) => {
20435
20495
  }
20436
20496
  return configManualChunks;
20437
20497
  };
20498
+ const getMaxParallelFileReads = (config) => {
20499
+ const maxParallelFileReads = config.maxParallelFileReads;
20500
+ if (typeof maxParallelFileReads === 'number') {
20501
+ if (maxParallelFileReads <= 0)
20502
+ return Infinity;
20503
+ return maxParallelFileReads;
20504
+ }
20505
+ return 20;
20506
+ };
20438
20507
  const getModuleContext = (config, context) => {
20439
20508
  const configModuleContext = config.moduleContext;
20440
20509
  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
@@ -14,7 +14,7 @@ import require$$0$2 from 'util';
14
14
  import { defaultOnWarn, ensureArray as ensureArray$1, warnUnknownOptions, treeshakePresets, error, errInvalidOption, printQuotedStringList, fseventsImporter, rollupInternal } from './rollup.js';
15
15
  import require$$2, { platform } from 'os';
16
16
  import require$$0$3 from 'events';
17
- import fs__default from 'fs';
17
+ import fs$4 from 'fs';
18
18
  import require$$1 from 'stream';
19
19
  import 'crypto';
20
20
 
@@ -4083,6 +4083,7 @@ function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
4083
4083
  input: getOption('input') || [],
4084
4084
  makeAbsoluteExternalsRelative: getOption('makeAbsoluteExternalsRelative'),
4085
4085
  manualChunks: getOption('manualChunks'),
4086
+ maxParallelFileReads: getOption('maxParallelFileReads'),
4086
4087
  moduleContext: getOption('moduleContext'),
4087
4088
  onwarn: getOnWarn(config, defaultOnWarnHandler),
4088
4089
  perf: getOption('perf'),
@@ -4186,7 +4187,7 @@ function mergeOutputOptions(config, overrides, warn) {
4186
4187
 
4187
4188
  var chokidar = {};
4188
4189
 
4189
- const fs$3 = fs__default;
4190
+ const fs$3 = fs$4;
4190
4191
  const { Readable } = require$$1;
4191
4192
  const sysPath$3 = require$$0__default;
4192
4193
  const { promisify: promisify$3 } = require$$0$2;
@@ -5063,7 +5064,7 @@ exports.isLinux = platform === 'linux';
5063
5064
  exports.isIBMi = os.type() === 'OS400';
5064
5065
  }(constants));
5065
5066
 
5066
- const fs$2 = fs__default;
5067
+ const fs$2 = fs$4;
5067
5068
  const sysPath$2 = require$$0__default;
5068
5069
  const { promisify: promisify$2 } = require$$0$2;
5069
5070
  const isBinaryPath = isBinaryPath$1;
@@ -5702,7 +5703,7 @@ var fseventsHandler = {exports: {}};
5702
5703
 
5703
5704
  var require$$3 = /*@__PURE__*/getAugmentedNamespace(fseventsImporter);
5704
5705
 
5705
- const fs$1 = fs__default;
5706
+ const fs$1 = fs$4;
5706
5707
  const sysPath$1 = require$$0__default;
5707
5708
  const { promisify: promisify$1 } = require$$0$2;
5708
5709
 
@@ -6226,7 +6227,7 @@ fseventsHandler.exports = FsEventsHandler$1;
6226
6227
  fseventsHandler.exports.canUse = canUse;
6227
6228
 
6228
6229
  const { EventEmitter } = require$$0$3;
6229
- const fs = fs__default;
6230
+ const fs = fs$4;
6230
6231
  const sysPath = require$$0__default;
6231
6232
  const { promisify } = require$$0$2;
6232
6233
  const readdirp = readdirp_1;
@@ -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