rollup 2.50.5 → 2.51.2

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.5
4
- Sun, 30 May 2021 18:56:20 GMT - commit b3d130b1a5448a2abc07fa3d7cde749c3169d220
3
+ Rollup.js v2.51.2
4
+ Fri, 11 Jun 2021 05:35:15 GMT - commit bfae7910ea7553d56782cb5ee0c8581e2b451729
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.5
4
- Sun, 30 May 2021 18:56:20 GMT - commit b3d130b1a5448a2abc07fa3d7cde749c3169d220
3
+ Rollup.js v2.51.2
4
+ Fri, 11 Jun 2021 05:35:15 GMT - commit bfae7910ea7553d56782cb5ee0c8581e2b451729
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.5";
17
+ var version$1 = "2.51.2";
18
18
 
19
19
  var charToInteger = {};
20
20
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -4988,8 +4988,14 @@ class SpreadElement extends NodeBase {
4988
4988
  }
4989
4989
  }
4990
4990
  hasEffects(context) {
4991
+ if (!this.deoptimized)
4992
+ this.applyDeoptimizations();
4993
+ const { propertyReadSideEffects } = this.context.options
4994
+ .treeshake;
4991
4995
  return (this.argument.hasEffects(context) ||
4992
- this.argument.hasEffectsWhenAccessedAtPath(UNKNOWN_PATH, context));
4996
+ (propertyReadSideEffects &&
4997
+ (propertyReadSideEffects === 'always' ||
4998
+ this.argument.hasEffectsWhenAccessedAtPath(UNKNOWN_PATH, context))));
4993
4999
  }
4994
5000
  applyDeoptimizations() {
4995
5001
  this.deoptimized = true;
@@ -5203,11 +5209,16 @@ class FunctionNode extends NodeBase {
5203
5209
  hasEffectsWhenCalledAtPath(path, callOptions, context) {
5204
5210
  if (path.length > 0)
5205
5211
  return true;
5206
- if (this.async &&
5207
- this.scope
5208
- .getReturnExpression()
5209
- .hasEffectsWhenCalledAtPath(['then'], { args: NO_ARGS, thisParam: null, withNew: false }, context)) {
5210
- 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
+ }
5211
5222
  }
5212
5223
  for (const param of this.params) {
5213
5224
  if (param.hasEffects(context))
@@ -5948,7 +5959,7 @@ class ArrowFunctionExpression extends NodeBase {
5948
5959
  // Arrow functions do not mutate their context
5949
5960
  deoptimizeThisOnEventAtPath() { }
5950
5961
  getReturnExpressionWhenCalledAtPath(path) {
5951
- return path.length === 0 ? this.scope.getReturnExpression() : UNKNOWN_EXPRESSION;
5962
+ return !this.async && path.length === 0 ? this.scope.getReturnExpression() : UNKNOWN_EXPRESSION;
5952
5963
  }
5953
5964
  hasEffects() {
5954
5965
  return false;
@@ -5962,6 +5973,17 @@ class ArrowFunctionExpression extends NodeBase {
5962
5973
  hasEffectsWhenCalledAtPath(path, _callOptions, context) {
5963
5974
  if (path.length > 0)
5964
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
+ }
5965
5987
  for (const param of this.params) {
5966
5988
  if (param.hasEffects(context))
5967
5989
  return true;
@@ -9696,6 +9718,7 @@ class Module {
9696
9718
  this.implicitlyLoadedBefore = new Set();
9697
9719
  this.importDescriptions = Object.create(null);
9698
9720
  this.importMetas = [];
9721
+ this.importedFromNotTreeshaken = false;
9699
9722
  this.importers = [];
9700
9723
  this.imports = new Set();
9701
9724
  this.includedDynamicImporters = [];
@@ -9827,12 +9850,12 @@ class Module {
9827
9850
  }
9828
9851
  if (!this.options.treeshake || this.info.hasModuleSideEffects === 'no-treeshake') {
9829
9852
  for (const dependency of this.dependencies) {
9830
- if (dependency instanceof ExternalModule || dependency.isIncluded()) {
9831
- relevantDependencies.add(dependency);
9832
- }
9853
+ relevantDependencies.add(dependency);
9833
9854
  }
9834
9855
  }
9835
- this.addRelevantSideEffectDependencies(relevantDependencies, necessaryDependencies, alwaysCheckedDependencies);
9856
+ else {
9857
+ this.addRelevantSideEffectDependencies(relevantDependencies, necessaryDependencies, alwaysCheckedDependencies);
9858
+ }
9836
9859
  for (const dependency of necessaryDependencies) {
9837
9860
  relevantDependencies.add(dependency);
9838
9861
  }
@@ -10020,7 +10043,7 @@ class Module {
10020
10043
  this.ast.include(createInclusionContext(), true);
10021
10044
  }
10022
10045
  isIncluded() {
10023
- return this.ast.included || this.namespace.included;
10046
+ return this.ast.included || this.namespace.included || this.importedFromNotTreeshaken;
10024
10047
  }
10025
10048
  linkImports() {
10026
10049
  this.addModulesToImportDescriptions(this.importDescriptions);
@@ -11254,6 +11277,7 @@ class Link {
11254
11277
  const sources = [];
11255
11278
  const sourcesContent = [];
11256
11279
  const names = [];
11280
+ const nameIndexMap = new Map();
11257
11281
  const mappings = [];
11258
11282
  for (const line of this.mappings) {
11259
11283
  const tracedLine = [];
@@ -11288,10 +11312,11 @@ class Link {
11288
11312
  traced.column
11289
11313
  ];
11290
11314
  if (traced.name) {
11291
- let nameIndex = names.indexOf(traced.name);
11292
- if (nameIndex === -1) {
11315
+ let nameIndex = nameIndexMap.get(traced.name);
11316
+ if (nameIndex === undefined) {
11293
11317
  nameIndex = names.length;
11294
11318
  names.push(traced.name);
11319
+ nameIndexMap.set(traced.name, nameIndex);
11295
11320
  }
11296
11321
  tracedSegment[4] = nameIndex;
11297
11322
  }
@@ -19459,6 +19484,13 @@ class ModuleLoader {
19459
19484
  module.dependencies.add(dependency);
19460
19485
  dependency.importers.push(module.id);
19461
19486
  }
19487
+ if (!this.options.treeshake || module.info.hasModuleSideEffects === 'no-treeshake') {
19488
+ for (const dependency of module.dependencies) {
19489
+ if (dependency instanceof Module) {
19490
+ dependency.importedFromNotTreeshaken = true;
19491
+ }
19492
+ }
19493
+ }
19462
19494
  }
19463
19495
  getNormalizedResolvedIdWithoutDefaults(resolveIdResult, importer, source) {
19464
19496
  const { makeAbsoluteExternalsRelative } = this.options;
@@ -20760,6 +20792,14 @@ function writeOutputFile(outputFile, outputOptions) {
20760
20792
  }
20761
20793
  return Promise.all([writeFile(fileName, source), writeSourceMapPromise]);
20762
20794
  }
20795
+ /**
20796
+ * Auxiliary function for defining rollup configuration
20797
+ * Mainly to facilitate IDE code prompts, after all, export default does not prompt, even if you add @type annotations, it is not accurate
20798
+ * @param options
20799
+ */
20800
+ function defineConfig(options) {
20801
+ return options;
20802
+ }
20763
20803
 
20764
20804
  let fsEvents;
20765
20805
  let fsEventsImportError;
@@ -20807,4 +20847,4 @@ function watch(configs) {
20807
20847
  return emitter;
20808
20848
  }
20809
20849
 
20810
- export { defaultOnWarn, ensureArray, fseventsImporter, rollup, rollupInternal, version$1 as version, warnUnknownOptions, watch };
20850
+ 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.5
4
- Sun, 30 May 2021 18:56:20 GMT - commit b3d130b1a5448a2abc07fa3d7cde749c3169d220
3
+ Rollup.js v2.51.2
4
+ Fri, 11 Jun 2021 05:35:15 GMT - commit bfae7910ea7553d56782cb5ee0c8581e2b451729
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.5
4
- Sun, 30 May 2021 18:56:20 GMT - commit b3d130b1a5448a2abc07fa3d7cde749c3169d220
3
+ Rollup.js v2.51.2
4
+ Fri, 11 Jun 2021 05:35:15 GMT - commit bfae7910ea7553d56782cb5ee0c8581e2b451729
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup