rollup 2.50.4 → 2.51.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/es/rollup.js CHANGED
@@ -1,14 +1,14 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.50.4
4
- Sat, 29 May 2021 04:39:28 GMT - commit 184eb6006e0e9a7f170a9208f923af0d568a31b6
3
+ Rollup.js v2.51.1
4
+ Tue, 08 Jun 2021 05:41:03 GMT - commit 76dedd65e6059f60964684ac7c3cfb89ce5c5523
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
8
8
 
9
9
  Released under the MIT License.
10
10
  */
11
- export { version as VERSION, rollup, watch } from './shared/rollup.js';
11
+ export { version as VERSION, defineConfig, rollup, watch } from './shared/rollup.js';
12
12
  import 'path';
13
13
  import 'crypto';
14
14
  import 'fs';
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.50.4
4
- Sat, 29 May 2021 04:39:28 GMT - commit 184eb6006e0e9a7f170a9208f923af0d568a31b6
3
+ Rollup.js v2.51.1
4
+ Tue, 08 Jun 2021 05:41:03 GMT - commit 76dedd65e6059f60964684ac7c3cfb89ce5c5523
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -14,7 +14,7 @@ import * as fs from 'fs';
14
14
  import { lstatSync, realpathSync, readdirSync } from 'fs';
15
15
  import { EventEmitter } from 'events';
16
16
 
17
- var version$1 = "2.50.4";
17
+ var version$1 = "2.51.1";
18
18
 
19
19
  var charToInteger = {};
20
20
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -3397,10 +3397,11 @@ const knownGlobals = {
3397
3397
  Promise: {
3398
3398
  __proto__: null,
3399
3399
  [ValueProperties]: IMPURE,
3400
- all: PF,
3400
+ all: O,
3401
3401
  prototype: O,
3402
- race: PF,
3403
- resolve: PF
3402
+ race: O,
3403
+ reject: O,
3404
+ resolve: O
3404
3405
  },
3405
3406
  propertyIsEnumerable: O,
3406
3407
  Proxy: O,
@@ -4987,8 +4988,14 @@ class SpreadElement extends NodeBase {
4987
4988
  }
4988
4989
  }
4989
4990
  hasEffects(context) {
4991
+ if (!this.deoptimized)
4992
+ this.applyDeoptimizations();
4993
+ const { propertyReadSideEffects } = this.context.options
4994
+ .treeshake;
4990
4995
  return (this.argument.hasEffects(context) ||
4991
- this.argument.hasEffectsWhenAccessedAtPath(UNKNOWN_PATH, context));
4996
+ (propertyReadSideEffects &&
4997
+ (propertyReadSideEffects === 'always' ||
4998
+ this.argument.hasEffectsWhenAccessedAtPath(UNKNOWN_PATH, context))));
4992
4999
  }
4993
5000
  applyDeoptimizations() {
4994
5001
  this.deoptimized = true;
@@ -5183,7 +5190,7 @@ class FunctionNode extends NodeBase {
5183
5190
  }
5184
5191
  }
5185
5192
  getReturnExpressionWhenCalledAtPath(path) {
5186
- return path.length === 0 ? this.scope.getReturnExpression() : UNKNOWN_EXPRESSION;
5193
+ return !this.async && path.length === 0 ? this.scope.getReturnExpression() : UNKNOWN_EXPRESSION;
5187
5194
  }
5188
5195
  hasEffects() {
5189
5196
  return this.id !== null && this.id.hasEffects();
@@ -5202,6 +5209,17 @@ class FunctionNode extends NodeBase {
5202
5209
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
5203
5210
  if (path.length > 0)
5204
5211
  return true;
5212
+ if (this.async) {
5213
+ const { propertyReadSideEffects } = this.context.options
5214
+ .treeshake;
5215
+ const returnExpression = this.scope.getReturnExpression();
5216
+ if (returnExpression.hasEffectsWhenCalledAtPath(['then'], { args: NO_ARGS, thisParam: null, withNew: false }, context) ||
5217
+ (propertyReadSideEffects &&
5218
+ (propertyReadSideEffects === 'always' ||
5219
+ returnExpression.hasEffectsWhenAccessedAtPath(['then'], context)))) {
5220
+ return true;
5221
+ }
5222
+ }
5205
5223
  for (const param of this.params) {
5206
5224
  if (param.hasEffects(context))
5207
5225
  return true;
@@ -5941,7 +5959,7 @@ class ArrowFunctionExpression extends NodeBase {
5941
5959
  // Arrow functions do not mutate their context
5942
5960
  deoptimizeThisOnEventAtPath() { }
5943
5961
  getReturnExpressionWhenCalledAtPath(path) {
5944
- return path.length === 0 ? this.scope.getReturnExpression() : UNKNOWN_EXPRESSION;
5962
+ return !this.async && path.length === 0 ? this.scope.getReturnExpression() : UNKNOWN_EXPRESSION;
5945
5963
  }
5946
5964
  hasEffects() {
5947
5965
  return false;
@@ -5955,6 +5973,17 @@ class ArrowFunctionExpression extends NodeBase {
5955
5973
  hasEffectsWhenCalledAtPath(path, _callOptions, context) {
5956
5974
  if (path.length > 0)
5957
5975
  return true;
5976
+ if (this.async) {
5977
+ const { propertyReadSideEffects } = this.context.options
5978
+ .treeshake;
5979
+ const returnExpression = this.scope.getReturnExpression();
5980
+ if (returnExpression.hasEffectsWhenCalledAtPath(['then'], { args: NO_ARGS, thisParam: null, withNew: false }, context) ||
5981
+ (propertyReadSideEffects &&
5982
+ (propertyReadSideEffects === 'always' ||
5983
+ returnExpression.hasEffectsWhenAccessedAtPath(['then'], context)))) {
5984
+ return true;
5985
+ }
5986
+ }
5958
5987
  for (const param of this.params) {
5959
5988
  if (param.hasEffects(context))
5960
5989
  return true;
@@ -6110,7 +6139,14 @@ class AssignmentPattern extends NodeBase {
6110
6139
 
6111
6140
  class AwaitExpression extends NodeBase {
6112
6141
  hasEffects(context) {
6113
- return !context.ignore.returnAwaitYield || this.argument.hasEffects(context);
6142
+ const { propertyReadSideEffects } = this.context.options
6143
+ .treeshake;
6144
+ return (!context.ignore.returnAwaitYield ||
6145
+ this.argument.hasEffects(context) ||
6146
+ this.argument.hasEffectsWhenCalledAtPath(['then'], { args: NO_ARGS, thisParam: null, withNew: false }, context) ||
6147
+ (propertyReadSideEffects &&
6148
+ (propertyReadSideEffects === 'always' ||
6149
+ this.argument.hasEffectsWhenAccessedAtPath(['then'], context))));
6114
6150
  }
6115
6151
  include(context, includeChildrenRecursively) {
6116
6152
  if (!this.included) {
@@ -11240,6 +11276,7 @@ class Link {
11240
11276
  const sources = [];
11241
11277
  const sourcesContent = [];
11242
11278
  const names = [];
11279
+ const nameIndexMap = new Map();
11243
11280
  const mappings = [];
11244
11281
  for (const line of this.mappings) {
11245
11282
  const tracedLine = [];
@@ -11274,10 +11311,11 @@ class Link {
11274
11311
  traced.column
11275
11312
  ];
11276
11313
  if (traced.name) {
11277
- let nameIndex = names.indexOf(traced.name);
11278
- if (nameIndex === -1) {
11314
+ let nameIndex = nameIndexMap.get(traced.name);
11315
+ if (nameIndex === undefined) {
11279
11316
  nameIndex = names.length;
11280
11317
  names.push(traced.name);
11318
+ nameIndexMap.set(traced.name, nameIndex);
11281
11319
  }
11282
11320
  tracedSegment[4] = nameIndex;
11283
11321
  }
@@ -20746,6 +20784,14 @@ function writeOutputFile(outputFile, outputOptions) {
20746
20784
  }
20747
20785
  return Promise.all([writeFile(fileName, source), writeSourceMapPromise]);
20748
20786
  }
20787
+ /**
20788
+ * Auxiliary function for defining rollup configuration
20789
+ * Mainly to facilitate IDE code prompts, after all, export default does not prompt, even if you add @type annotations, it is not accurate
20790
+ * @param options
20791
+ */
20792
+ function defineConfig(options) {
20793
+ return options;
20794
+ }
20749
20795
 
20750
20796
  let fsEvents;
20751
20797
  let fsEventsImportError;
@@ -20793,4 +20839,4 @@ function watch(configs) {
20793
20839
  return emitter;
20794
20840
  }
20795
20841
 
20796
- export { defaultOnWarn, ensureArray, fseventsImporter, rollup, rollupInternal, version$1 as version, warnUnknownOptions, watch };
20842
+ export { defaultOnWarn, defineConfig, ensureArray, fseventsImporter, rollup, rollupInternal, version$1 as version, warnUnknownOptions, watch };
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.50.4
4
- Sat, 29 May 2021 04:39:28 GMT - commit 184eb6006e0e9a7f170a9208f923af0d568a31b6
3
+ Rollup.js v2.51.1
4
+ Tue, 08 Jun 2021 05:41:03 GMT - commit 76dedd65e6059f60964684ac7c3cfb89ce5c5523
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.50.4
4
- Sat, 29 May 2021 04:39:28 GMT - commit 184eb6006e0e9a7f170a9208f923af0d568a31b6
3
+ Rollup.js v2.51.1
4
+ Tue, 08 Jun 2021 05:41:03 GMT - commit 76dedd65e6059f60964684ac7c3cfb89ce5c5523
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup