rollup 3.0.0-4 → 3.0.0-5

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.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.0.0-3
4
- Mon, 15 Aug 2022 04:43:13 GMT - commit 84a4a595851ef71494b6f2ab558968bfbc148bdb
3
+ Rollup.js v3.0.0-4
4
+ Wed, 31 Aug 2022 05:26:36 GMT - commit 392609619bcb75a0c7216f38e40d9573419a8e3f
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -15,7 +15,7 @@ import { createHash as createHash$1 } from 'node:crypto';
15
15
  import { promises } from 'node:fs';
16
16
  import { EventEmitter } from 'node:events';
17
17
 
18
- var version$1 = "3.0.0-3";
18
+ var version$1 = "3.0.0-4";
19
19
 
20
20
  var charToInteger = {};
21
21
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -308,15 +308,20 @@ class Chunk$1 {
308
308
  }
309
309
  }
310
310
 
311
- let btoa = () => {
312
- throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
313
- };
314
- if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
315
- btoa = (str) => window.btoa(unescape(encodeURIComponent(str)));
316
- } else if (typeof Buffer === 'function') {
317
- btoa = (str) => Buffer.from(str, 'utf-8').toString('base64');
311
+ function getBtoa () {
312
+ if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
313
+ return (str) => window.btoa(unescape(encodeURIComponent(str)));
314
+ } else if (typeof Buffer === 'function') {
315
+ return (str) => Buffer.from(str, 'utf-8').toString('base64');
316
+ } else {
317
+ return () => {
318
+ throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
319
+ };
320
+ }
318
321
  }
319
322
 
323
+ const btoa = /*#__PURE__*/ getBtoa();
324
+
320
325
  class SourceMap {
321
326
  constructor(properties) {
322
327
  this.version = 3;
@@ -508,7 +513,7 @@ class MagicString {
508
513
  indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
509
514
  sourcemapLocations: { writable: true, value: new BitSet() },
510
515
  storedNames: { writable: true, value: {} },
511
- indentStr: { writable: true, value: guessIndent(string) },
516
+ indentStr: { writable: true, value: undefined },
512
517
  });
513
518
 
514
519
  this.byStart[0] = chunk;
@@ -638,7 +643,19 @@ class MagicString {
638
643
  return new SourceMap(this.generateDecodedMap(options));
639
644
  }
640
645
 
646
+ _ensureindentStr() {
647
+ if (this.indentStr === undefined) {
648
+ this.indentStr = guessIndent(this.original);
649
+ }
650
+ }
651
+
652
+ _getRawIndentString() {
653
+ this._ensureindentStr();
654
+ return this.indentStr;
655
+ }
656
+
641
657
  getIndentString() {
658
+ this._ensureindentStr();
642
659
  return this.indentStr === null ? '\t' : this.indentStr;
643
660
  }
644
661
 
@@ -650,7 +667,10 @@ class MagicString {
650
667
  indentStr = undefined;
651
668
  }
652
669
 
653
- indentStr = indentStr !== undefined ? indentStr : this.indentStr || '\t';
670
+ if (indentStr === undefined) {
671
+ this._ensureindentStr();
672
+ indentStr = this.indentStr || '\t';
673
+ }
654
674
 
655
675
  if (indentStr === '') return this; // noop
656
676
 
@@ -1366,7 +1386,7 @@ class Bundle$1 {
1366
1386
  const indentStringCounts = {};
1367
1387
 
1368
1388
  this.sources.forEach((source) => {
1369
- const indentStr = source.content.indentStr;
1389
+ const indentStr = source.content._getRawIndentString();
1370
1390
 
1371
1391
  if (indentStr === null) return;
1372
1392
 
@@ -1606,6 +1626,7 @@ function getOrCreate(map, key, init) {
1606
1626
  const UnknownKey = Symbol('Unknown Key');
1607
1627
  const UnknownNonAccessorKey = Symbol('Unknown Non-Accessor Key');
1608
1628
  const UnknownInteger = Symbol('Unknown Integer');
1629
+ const SymbolToStringTag = Symbol('Symbol.toStringTag');
1609
1630
  const EMPTY_PATH = [];
1610
1631
  const UNKNOWN_PATH = [UnknownKey];
1611
1632
  // For deoptimizations, this means we are modifying an unknown property but did
@@ -1683,7 +1704,7 @@ class ExpressionEntity {
1683
1704
  /**
1684
1705
  * If possible it returns a stringifyable literal value for this node that can be used
1685
1706
  * for inlining or comparing values.
1686
- * Otherwise it should return UnknownValue.
1707
+ * Otherwise, it should return UnknownValue.
1687
1708
  */
1688
1709
  getLiteralValueAtPath(_path, _recursionTracker, _origin) {
1689
1710
  return UnknownValue;
@@ -1915,7 +1936,7 @@ function augmentCodeLocation(props, pos, source, id) {
1915
1936
  }
1916
1937
  // Error codes should be sorted alphabetically while errors should be sorted by
1917
1938
  // error code below
1918
- const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', PREFER_NAMED_EXPORTS = 'PREFER_NAMED_EXPORTS', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
1939
+ const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
1919
1940
  function errAddonNotGenerated(message, hook, plugin) {
1920
1941
  return {
1921
1942
  code: ADDON_ERROR,
@@ -2290,15 +2311,6 @@ function errPluginError(error, plugin, { hook, id } = {}) {
2290
2311
  }
2291
2312
  return error;
2292
2313
  }
2293
- function errPreferNamedExports(facadeModuleId) {
2294
- const file = relativeId(facadeModuleId);
2295
- return {
2296
- code: PREFER_NAMED_EXPORTS,
2297
- id: facadeModuleId,
2298
- message: `Entry module "${file}" is implicitly using "default" export mode, which means for CommonJS output that its default export is assigned to "module.exports". For many tools, such CommonJS output will not be interchangeable with the original ES module. If this is intended, explicitly set "output.exports" to either "auto" or "default", otherwise you might want to consider changing the signature of "${file}" to use named exports only.`,
2299
- url: `https://rollupjs.org/guide/en/#outputexports`
2300
- };
2301
- }
2302
2314
  function errShimmedExport(id, binding) {
2303
2315
  return {
2304
2316
  binding,
@@ -2483,15 +2495,16 @@ const RESERVED_NAMES$1 = RESERVED_NAMES;
2483
2495
 
2484
2496
  const illegalCharacters = /[^$_a-zA-Z0-9]/g;
2485
2497
  const startsWithDigit = (str) => /\d/.test(str[0]);
2498
+ const needsEscape = (str) => startsWithDigit(str) || RESERVED_NAMES$1.has(str) || str === 'arguments';
2486
2499
  function isLegal(str) {
2487
- if (startsWithDigit(str) || RESERVED_NAMES$1.has(str)) {
2500
+ if (needsEscape(str)) {
2488
2501
  return false;
2489
2502
  }
2490
2503
  return !illegalCharacters.test(str);
2491
2504
  }
2492
2505
  function makeLegal(str) {
2493
2506
  str = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(illegalCharacters, '_');
2494
- if (startsWithDigit(str) || RESERVED_NAMES$1.has(str))
2507
+ if (needsEscape(str))
2495
2508
  str = `_${str}`;
2496
2509
  return str || '_';
2497
2510
  }
@@ -6723,15 +6736,16 @@ function is_reference (node, parent) {
6723
6736
 
6724
6737
  /* eslint sort-keys: "off" */
6725
6738
  const ValueProperties = Symbol('Value Properties');
6739
+ const getTruthyLiteralValue = () => UnknownTruthyValue;
6740
+ const returnFalse = () => false;
6741
+ const returnTrue = () => true;
6726
6742
  const PURE = {
6727
- hasEffectsWhenCalled() {
6728
- return false;
6729
- }
6743
+ getLiteralValue: getTruthyLiteralValue,
6744
+ hasEffectsWhenCalled: returnFalse
6730
6745
  };
6731
6746
  const IMPURE = {
6732
- hasEffectsWhenCalled() {
6733
- return true;
6734
- }
6747
+ getLiteralValue: getTruthyLiteralValue,
6748
+ hasEffectsWhenCalled: returnTrue
6735
6749
  };
6736
6750
  // We use shortened variables to reduce file size here
6737
6751
  /* OBJECT */
@@ -6748,6 +6762,7 @@ const PF = {
6748
6762
  const MUTATES_ARG_WITHOUT_ACCESSOR = {
6749
6763
  __proto__: null,
6750
6764
  [ValueProperties]: {
6765
+ getLiteralValue: getTruthyLiteralValue,
6751
6766
  hasEffectsWhenCalled({ args }, context) {
6752
6767
  return (!args.length ||
6753
6768
  args[0].hasEffectsOnInteractionAtPath(UNKNOWN_NON_ACCESSOR_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context));
@@ -6943,7 +6958,16 @@ const knownGlobals = {
6943
6958
  [ValueProperties]: PURE,
6944
6959
  for: PF,
6945
6960
  keyFor: PF,
6946
- prototype: O
6961
+ prototype: O,
6962
+ toStringTag: {
6963
+ __proto__: null,
6964
+ [ValueProperties]: {
6965
+ getLiteralValue() {
6966
+ return SymbolToStringTag;
6967
+ },
6968
+ hasEffectsWhenCalled: returnTrue
6969
+ }
6970
+ }
6947
6971
  },
6948
6972
  SyntaxError: PC,
6949
6973
  toLocaleString: O,
@@ -7589,7 +7613,8 @@ class GlobalVariable extends Variable {
7589
7613
  this.isReassigned = true;
7590
7614
  }
7591
7615
  getLiteralValueAtPath(path, _recursionTracker, _origin) {
7592
- return getGlobalAtPath([this.name, ...path]) ? UnknownTruthyValue : UnknownValue;
7616
+ const globalAtPath = getGlobalAtPath([this.name, ...path]);
7617
+ return globalAtPath ? globalAtPath.getLiteralValue() : UnknownValue;
7593
7618
  }
7594
7619
  hasEffectsOnInteractionAtPath(path, interaction, context) {
7595
7620
  switch (interaction.type) {
@@ -8780,7 +8805,7 @@ class MemberExpression extends NodeBase {
8780
8805
  this.assignmentDeoptimized = false;
8781
8806
  this.bound = false;
8782
8807
  this.expressionsToBeDeoptimized = [];
8783
- this.replacement = null;
8808
+ this.isUndefined = false;
8784
8809
  }
8785
8810
  bind() {
8786
8811
  this.bound = true;
@@ -8791,8 +8816,8 @@ class MemberExpression extends NodeBase {
8791
8816
  if (!resolvedVariable) {
8792
8817
  super.bind();
8793
8818
  }
8794
- else if (typeof resolvedVariable === 'string') {
8795
- this.replacement = resolvedVariable;
8819
+ else if (resolvedVariable === 'undefined') {
8820
+ this.isUndefined = true;
8796
8821
  }
8797
8822
  else {
8798
8823
  this.variable = resolvedVariable;
@@ -8818,7 +8843,7 @@ class MemberExpression extends NodeBase {
8818
8843
  if (this.variable) {
8819
8844
  this.variable.deoptimizePath(path);
8820
8845
  }
8821
- else if (!this.replacement) {
8846
+ else if (!this.isUndefined) {
8822
8847
  if (path.length < MAX_PATH_DEPTH) {
8823
8848
  const propertyKey = this.getPropertyKey();
8824
8849
  this.object.deoptimizePath([
@@ -8832,7 +8857,7 @@ class MemberExpression extends NodeBase {
8832
8857
  if (this.variable) {
8833
8858
  this.variable.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
8834
8859
  }
8835
- else if (!this.replacement) {
8860
+ else if (!this.isUndefined) {
8836
8861
  if (path.length < MAX_PATH_DEPTH) {
8837
8862
  this.object.deoptimizeThisOnInteractionAtPath(interaction, [this.getPropertyKey(), ...path], recursionTracker);
8838
8863
  }
@@ -8845,8 +8870,8 @@ class MemberExpression extends NodeBase {
8845
8870
  if (this.variable) {
8846
8871
  return this.variable.getLiteralValueAtPath(path, recursionTracker, origin);
8847
8872
  }
8848
- if (this.replacement) {
8849
- return UnknownValue;
8873
+ if (this.isUndefined) {
8874
+ return undefined;
8850
8875
  }
8851
8876
  this.expressionsToBeDeoptimized.push(origin);
8852
8877
  if (path.length < MAX_PATH_DEPTH) {
@@ -8858,8 +8883,8 @@ class MemberExpression extends NodeBase {
8858
8883
  if (this.variable) {
8859
8884
  return this.variable.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
8860
8885
  }
8861
- if (this.replacement) {
8862
- return UNKNOWN_EXPRESSION;
8886
+ if (this.isUndefined) {
8887
+ return UNDEFINED_EXPRESSION;
8863
8888
  }
8864
8889
  this.expressionsToBeDeoptimized.push(origin);
8865
8890
  if (path.length < MAX_PATH_DEPTH) {
@@ -8888,7 +8913,7 @@ class MemberExpression extends NodeBase {
8888
8913
  if (this.variable) {
8889
8914
  return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
8890
8915
  }
8891
- if (this.replacement) {
8916
+ if (this.isUndefined) {
8892
8917
  return true;
8893
8918
  }
8894
8919
  if (path.length < MAX_PATH_DEPTH) {
@@ -8924,9 +8949,9 @@ class MemberExpression extends NodeBase {
8924
8949
  this.accessInteraction = { thisArg: this.object, type: INTERACTION_ACCESSED };
8925
8950
  }
8926
8951
  render(code, options, { renderedParentType, isCalleeOfRenderedParent, renderedSurroundingElement } = BLANK) {
8927
- if (this.variable || this.replacement) {
8952
+ if (this.variable || this.isUndefined) {
8928
8953
  const { snippets: { getPropertyAccess } } = options;
8929
- let replacement = this.variable ? this.variable.getName(getPropertyAccess) : this.replacement;
8954
+ let replacement = this.variable ? this.variable.getName(getPropertyAccess) : 'undefined';
8930
8955
  if (renderedParentType && isCalleeOfRenderedParent)
8931
8956
  replacement = '0, ' + replacement;
8932
8957
  code.overwrite(this.start, this.end, replacement, {
@@ -8957,7 +8982,7 @@ class MemberExpression extends NodeBase {
8957
8982
  // Namespaces are not bound and should not be deoptimized
8958
8983
  this.bound &&
8959
8984
  propertyReadSideEffects &&
8960
- !(this.variable || this.replacement)) {
8985
+ !(this.variable || this.isUndefined)) {
8961
8986
  const propertyKey = this.getPropertyKey();
8962
8987
  this.object.deoptimizeThisOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
8963
8988
  this.context.requestTreeshakingPass();
@@ -8971,7 +8996,7 @@ class MemberExpression extends NodeBase {
8971
8996
  // Namespaces are not bound and should not be deoptimized
8972
8997
  this.bound &&
8973
8998
  propertyReadSideEffects &&
8974
- !(this.variable || this.replacement)) {
8999
+ !(this.variable || this.isUndefined)) {
8975
9000
  this.object.deoptimizeThisOnInteractionAtPath(this.assignmentInteraction, [this.getPropertyKey()], SHARED_RECURSION_TRACKER);
8976
9001
  this.context.requestTreeshakingPass();
8977
9002
  }
@@ -8991,14 +9016,19 @@ class MemberExpression extends NodeBase {
8991
9016
  if (this.propertyKey === null) {
8992
9017
  this.propertyKey = UnknownKey;
8993
9018
  const value = this.property.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
8994
- return (this.propertyKey = typeof value === 'symbol' ? UnknownKey : String(value));
9019
+ return (this.propertyKey =
9020
+ value === SymbolToStringTag
9021
+ ? value
9022
+ : typeof value === 'symbol'
9023
+ ? UnknownKey
9024
+ : String(value));
8995
9025
  }
8996
9026
  return this.propertyKey;
8997
9027
  }
8998
9028
  hasAccessEffect(context) {
8999
9029
  const { propertyReadSideEffects } = this.context.options
9000
9030
  .treeshake;
9001
- return (!(this.variable || this.replacement) &&
9031
+ return (!(this.variable || this.isUndefined) &&
9002
9032
  propertyReadSideEffects &&
9003
9033
  (propertyReadSideEffects === 'always' ||
9004
9034
  this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey()], this.accessInteraction, context)));
@@ -10205,31 +10235,29 @@ class ImportDefaultSpecifier extends NodeBase {
10205
10235
  }
10206
10236
 
10207
10237
  const INTEROP_DEFAULT_VARIABLE = '_interopDefault';
10208
- const INTEROP_DEFAULT_LEGACY_VARIABLE = '_interopDefaultLegacy';
10238
+ const INTEROP_DEFAULT_COMPAT_VARIABLE = '_interopDefaultCompat';
10209
10239
  const INTEROP_NAMESPACE_VARIABLE = '_interopNamespace';
10240
+ const INTEROP_NAMESPACE_COMPAT_VARIABLE = '_interopNamespaceCompat';
10210
10241
  const INTEROP_NAMESPACE_DEFAULT_VARIABLE = '_interopNamespaceDefault';
10211
10242
  const INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE = '_interopNamespaceDefaultOnly';
10212
10243
  const MERGE_NAMESPACES_VARIABLE = '_mergeNamespaces';
10213
10244
  const defaultInteropHelpersByInteropType = {
10214
10245
  auto: INTEROP_DEFAULT_VARIABLE,
10246
+ compat: INTEROP_DEFAULT_COMPAT_VARIABLE,
10215
10247
  default: null,
10216
10248
  defaultOnly: null,
10217
- esModule: null,
10218
- false: null,
10219
- true: INTEROP_DEFAULT_LEGACY_VARIABLE
10249
+ esModule: null
10220
10250
  };
10221
10251
  const isDefaultAProperty = (interopType, externalLiveBindings) => interopType === 'esModule' ||
10222
- (externalLiveBindings && (interopType === 'auto' || interopType === 'true'));
10252
+ (externalLiveBindings && (interopType === 'auto' || interopType === 'compat'));
10223
10253
  const namespaceInteropHelpersByInteropType = {
10224
10254
  auto: INTEROP_NAMESPACE_VARIABLE,
10255
+ compat: INTEROP_NAMESPACE_COMPAT_VARIABLE,
10225
10256
  default: INTEROP_NAMESPACE_DEFAULT_VARIABLE,
10226
10257
  defaultOnly: INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE,
10227
- esModule: null,
10228
- false: null,
10229
- true: INTEROP_NAMESPACE_VARIABLE
10258
+ esModule: null
10230
10259
  };
10231
- const canDefaultBeTakenFromNamespace = (interopType, externalLiveBindings) => isDefaultAProperty(interopType, externalLiveBindings) &&
10232
- defaultInteropHelpersByInteropType[interopType] === INTEROP_DEFAULT_VARIABLE;
10260
+ const canDefaultBeTakenFromNamespace = (interopType, externalLiveBindings) => interopType !== 'esModule' && isDefaultAProperty(interopType, externalLiveBindings);
10233
10261
  const getHelpersBlock = (additionalHelpers, accessedGlobals, indent, snippets, liveBindings, freeze, namespaceToStringTag) => {
10234
10262
  const usedHelpers = new Set(additionalHelpers);
10235
10263
  for (const variable of HELPER_NAMES) {
@@ -10242,14 +10270,14 @@ const getHelpersBlock = (additionalHelpers, accessedGlobals, indent, snippets, l
10242
10270
  : '').join('');
10243
10271
  };
10244
10272
  const HELPER_GENERATORS = {
10245
- [INTEROP_DEFAULT_LEGACY_VARIABLE](_t, snippets, liveBindings) {
10273
+ [INTEROP_DEFAULT_COMPAT_VARIABLE](_t, snippets, liveBindings) {
10246
10274
  const { _, getDirectReturnFunction, n } = snippets;
10247
10275
  const [left, right] = getDirectReturnFunction(['e'], {
10248
10276
  functionReturn: true,
10249
10277
  lineBreakIndent: null,
10250
- name: INTEROP_DEFAULT_LEGACY_VARIABLE
10278
+ name: INTEROP_DEFAULT_COMPAT_VARIABLE
10251
10279
  });
10252
- return (`${left}e${_}&&${_}typeof e${_}===${_}'object'${_}&&${_}'default'${_}in e${_}?${_}` +
10280
+ return (`${left}${getIsCompatNamespace(snippets)}${_}?${_}` +
10253
10281
  `${liveBindings ? getDefaultLiveBinding(snippets) : getDefaultStatic(snippets)}${right}${n}${n}`);
10254
10282
  },
10255
10283
  [INTEROP_DEFAULT_VARIABLE](_t, snippets, liveBindings) {
@@ -10262,6 +10290,21 @@ const HELPER_GENERATORS = {
10262
10290
  return (`${left}e${_}&&${_}e.__esModule${_}?${_}` +
10263
10291
  `${liveBindings ? getDefaultLiveBinding(snippets) : getDefaultStatic(snippets)}${right}${n}${n}`);
10264
10292
  },
10293
+ [INTEROP_NAMESPACE_COMPAT_VARIABLE](t, snippets, liveBindings, freeze, namespaceToStringTag, usedHelpers) {
10294
+ const { _, getDirectReturnFunction, n } = snippets;
10295
+ if (usedHelpers.has(INTEROP_NAMESPACE_DEFAULT_VARIABLE)) {
10296
+ const [left, right] = getDirectReturnFunction(['e'], {
10297
+ functionReturn: true,
10298
+ lineBreakIndent: null,
10299
+ name: INTEROP_NAMESPACE_COMPAT_VARIABLE
10300
+ });
10301
+ return `${left}${getIsCompatNamespace(snippets)}${_}?${_}e${_}:${_}${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${right}${n}${n}`;
10302
+ }
10303
+ return (`function ${INTEROP_NAMESPACE_COMPAT_VARIABLE}(e)${_}{${n}` +
10304
+ `${t}if${_}(${getIsCompatNamespace(snippets)})${_}return e;${n}` +
10305
+ createNamespaceObject(t, t, snippets, liveBindings, freeze, namespaceToStringTag) +
10306
+ `}${n}${n}`);
10307
+ },
10265
10308
  [INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE](_t, snippets, _liveBindings, freeze, namespaceToStringTag) {
10266
10309
  const { getDirectReturnFunction, getObject, n } = snippets;
10267
10310
  const [left, right] = getDirectReturnFunction(['e'], {
@@ -10314,6 +10357,7 @@ const HELPER_GENERATORS = {
10314
10357
  };
10315
10358
  const getDefaultLiveBinding = ({ _, getObject }) => `e${_}:${_}${getObject([['default', 'e']], { lineBreakIndent: null })}`;
10316
10359
  const getDefaultStatic = ({ _, getPropertyAccess }) => `e${getPropertyAccess('default')}${_}:${_}e`;
10360
+ const getIsCompatNamespace = ({ _ }) => `e${_}&&${_}typeof e${_}===${_}'object'${_}&&${_}'default'${_}in e`;
10317
10361
  const createNamespaceObject = (t, i, snippets, liveBindings, freeze, namespaceToStringTag) => {
10318
10362
  const { _, cnst, getObject, getPropertyAccess, n, s } = snippets;
10319
10363
  const copyProperty = `{${n}` +
@@ -10564,7 +10608,7 @@ class ImportExpression extends NodeBase {
10564
10608
  }
10565
10609
  function getInteropHelper(resolution, exportMode, interop) {
10566
10610
  return exportMode === 'external'
10567
- ? namespaceInteropHelpersByInteropType[String(interop(resolution instanceof ExternalModule ? resolution.id : null))]
10611
+ ? namespaceInteropHelpersByInteropType[interop(resolution instanceof ExternalModule ? resolution.id : null)]
10568
10612
  : exportMode === 'default'
10569
10613
  ? INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE
10570
10614
  : null;
@@ -12135,6 +12179,10 @@ class NamespaceVariable extends Variable {
12135
12179
  this.references.push(identifier);
12136
12180
  this.name = identifier.name;
12137
12181
  }
12182
+ getLiteralValueAtPath() {
12183
+ // This can only happen for Symbol.toStringTag right now
12184
+ return 'Module';
12185
+ }
12138
12186
  getMemberVariables() {
12139
12187
  if (this.memberVariables) {
12140
12188
  return this.memberVariables;
@@ -12150,6 +12198,9 @@ class NamespaceVariable extends Variable {
12150
12198
  }
12151
12199
  return (this.memberVariables = memberVariables);
12152
12200
  }
12201
+ hasEffectsOnInteractionAtPath() {
12202
+ return false;
12203
+ }
12153
12204
  include() {
12154
12205
  this.included = true;
12155
12206
  this.context.includeAllExports();
@@ -13323,7 +13374,7 @@ function getSingleDefaultExport(exports, dependencies, interop, externalLiveBind
13323
13374
  function getReexportedImportName(moduleVariableName, imported, depNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, moduleId, externalLiveBindings, getPropertyAccess) {
13324
13375
  if (imported === 'default') {
13325
13376
  if (!isChunk) {
13326
- const moduleInterop = String(interop(moduleId));
13377
+ const moduleInterop = interop(moduleId);
13327
13378
  const variableName = defaultInteropHelpersByInteropType[moduleInterop]
13328
13379
  ? defaultVariableName
13329
13380
  : moduleVariableName;
@@ -13336,9 +13387,7 @@ function getReexportedImportName(moduleVariableName, imported, depNamedExportsMo
13336
13387
  : moduleVariableName;
13337
13388
  }
13338
13389
  if (imported === '*') {
13339
- return (isChunk
13340
- ? !depNamedExportsMode
13341
- : namespaceInteropHelpersByInteropType[String(interop(moduleId))])
13390
+ return (isChunk ? !depNamedExportsMode : namespaceInteropHelpersByInteropType[interop(moduleId)])
13342
13391
  ? namespaceVariableName
13343
13392
  : moduleVariableName;
13344
13393
  }
@@ -13405,7 +13454,7 @@ function getInteropBlock(dependencies, interop, externalLiveBindings, freeze, na
13405
13454
  }
13406
13455
  }
13407
13456
  else {
13408
- const moduleInterop = String(interop(importPath));
13457
+ const moduleInterop = interop(importPath);
13409
13458
  let hasDefault = false;
13410
13459
  let hasNamespace = false;
13411
13460
  for (const { imported, reexported } of [
@@ -13439,11 +13488,18 @@ function getInteropBlock(dependencies, interop, externalLiveBindings, freeze, na
13439
13488
  return `${getHelpersBlock(neededInteropHelpers, accessedGlobals, indent, snippets, externalLiveBindings, freeze, namespaceToStringTag)}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`;
13440
13489
  }
13441
13490
 
13491
+ function addJsExtension(name) {
13492
+ return name.endsWith('.js') ? name : name + '.js';
13493
+ }
13494
+
13442
13495
  // AMD resolution will only respect the AMD baseUrl if the .js extension is omitted.
13443
13496
  // The assumption is that this makes sense for all relative ids:
13444
13497
  // https://requirejs.org/docs/api.html#jsfiles
13445
- function removeExtensionFromRelativeAmdId(id) {
13446
- return id[0] === '.' ? removeJsExtension(id) : id;
13498
+ function updateExtensionForRelativeAmdId(id, forceJsExtensionForImports) {
13499
+ if (id[0] !== '.') {
13500
+ return id;
13501
+ }
13502
+ return forceJsExtensionForImports ? addJsExtension(id) : removeJsExtension(id);
13447
13503
  }
13448
13504
 
13449
13505
  const builtins = {
@@ -13478,9 +13534,9 @@ function warnOnBuiltins(warn, dependencies) {
13478
13534
  warn(errMissingNodeBuiltins(externalBuiltins));
13479
13535
  }
13480
13536
 
13481
- function amd(magicString, { accessedGlobals, dependencies, exports, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets, onwarn }, { amd, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
13537
+ function amd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets, onwarn }, { amd, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
13482
13538
  warnOnBuiltins(onwarn, dependencies);
13483
- const deps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.importPath)}'`);
13539
+ const deps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
13484
13540
  const args = dependencies.map(m => m.name);
13485
13541
  const { n, getNonArrowFunctionIntro, _ } = snippets;
13486
13542
  if (namedExportsMode && hasExports) {
@@ -13501,7 +13557,7 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports,
13501
13557
  const useStrict = strict ? `${_}'use strict';` : '';
13502
13558
  magicString.prepend(`${intro}${getInteropBlock(dependencies, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, t, snippets)}`);
13503
13559
  const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
13504
- let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, snippets);
13560
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && (esModule === true || (esModule === 'if-default-prop' && hasDefaultExport)), isModuleFacade && namespaceToStringTag, snippets);
13505
13561
  if (namespaceMarkers) {
13506
13562
  namespaceMarkers = n + n + namespaceMarkers;
13507
13563
  }
@@ -13517,10 +13573,10 @@ function amd(magicString, { accessedGlobals, dependencies, exports, hasExports,
13517
13573
  .append(`${n}${n}}));`);
13518
13574
  }
13519
13575
 
13520
- function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets }, { compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
13576
+ function cjs(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets }, { compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
13521
13577
  const { _, n } = snippets;
13522
13578
  const useStrict = strict ? `'use strict';${n}${n}` : '';
13523
- let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && esModule, isModuleFacade && namespaceToStringTag, snippets);
13579
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, isEntryFacade && (esModule === true || (esModule === 'if-default-prop' && hasDefaultExport)), isModuleFacade && namespaceToStringTag, snippets);
13524
13580
  if (namespaceMarkers) {
13525
13581
  namespaceMarkers += n + n;
13526
13582
  }
@@ -13712,7 +13768,7 @@ function trimEmptyImports(dependencies) {
13712
13768
  return [];
13713
13769
  }
13714
13770
 
13715
- function iife(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, namespaceToStringTag, strict }) {
13771
+ function iife(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, namespaceToStringTag, strict }) {
13716
13772
  const { _, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets;
13717
13773
  const isNamespaced = name && name.includes('.');
13718
13774
  const useVariableAssignment = !extend && !isNamespaced;
@@ -13758,7 +13814,7 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
13758
13814
  wrapperOutro = `${n}${n}${t}return exports;${wrapperOutro}`;
13759
13815
  }
13760
13816
  const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
13761
- let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, snippets);
13817
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule === true || (esModule === 'if-default-prop' && hasDefaultExport), namespaceToStringTag, snippets);
13762
13818
  if (namespaceMarkers) {
13763
13819
  namespaceMarkers = n + n + namespaceMarkers;
13764
13820
  }
@@ -13913,7 +13969,7 @@ function safeAccess(name, globalVar, { _, getPropertyAccess }) {
13913
13969
  .map(part => (propertyPath += getPropertyAccess(part)))
13914
13970
  .join(`${_}&&${_}`);
13915
13971
  }
13916
- function umd(magicString, { accessedGlobals, dependencies, exports, hasExports, id, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { amd, compact, esModule, extend, externalLiveBindings, freeze, interop, name, namespaceToStringTag, globals, noConflict, strict }) {
13972
+ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { amd, compact, esModule, extend, externalLiveBindings, freeze, interop, name, namespaceToStringTag, globals, noConflict, strict }) {
13917
13973
  const { _, cnst, getFunctionIntro, getNonArrowFunctionIntro, getPropertyAccess, n, s } = snippets;
13918
13974
  const factoryVar = compact ? 'f' : 'factory';
13919
13975
  const globalVar = compact ? 'g' : 'global';
@@ -13921,7 +13977,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
13921
13977
  return error(errMissingNameOptionForUmdExport());
13922
13978
  }
13923
13979
  warnOnBuiltins(onwarn, dependencies);
13924
- const amdDeps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.importPath)}'`);
13980
+ const amdDeps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
13925
13981
  const cjsDeps = dependencies.map(m => `require('${m.importPath}')`);
13926
13982
  const trimmedImports = trimEmptyImports(dependencies);
13927
13983
  const globalDeps = trimmedImports.map(module => globalProp(module.globalName, globalVar, getPropertyAccess));
@@ -13995,7 +14051,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
13995
14051
  const wrapperOutro = n + n + '}));';
13996
14052
  magicString.prepend(`${intro}${getInteropBlock(dependencies, interop, externalLiveBindings, freeze, namespaceToStringTag, accessedGlobals, t, snippets)}`);
13997
14053
  const exportBlock = getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings);
13998
- let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule, namespaceToStringTag, snippets);
14054
+ let namespaceMarkers = getNamespaceMarkers(namedExportsMode && hasExports, esModule === true || (esModule === 'if-default-prop' && hasDefaultExport), namespaceToStringTag, snippets);
13999
14055
  if (namespaceMarkers) {
14000
14056
  namespaceMarkers = n + n + namespaceMarkers;
14001
14057
  }
@@ -14378,7 +14434,7 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
14378
14434
  }
14379
14435
  for (const externalModule of deconflictedDefault) {
14380
14436
  if (deconflictedNamespace.has(externalModule) &&
14381
- canDefaultBeTakenFromNamespace(String(interop(externalModule.id)), externalLiveBindings)) {
14437
+ canDefaultBeTakenFromNamespace(interop(externalModule.id), externalLiveBindings)) {
14382
14438
  externalModule.defaultVariableName = externalModule.namespaceVariableName;
14383
14439
  }
14384
14440
  else {
@@ -14391,7 +14447,7 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
14391
14447
  const chunk = externalChunkByModule.get(module);
14392
14448
  const name = variable.name;
14393
14449
  if (name === 'default') {
14394
- const moduleInterop = String(interop(module.id));
14450
+ const moduleInterop = interop(module.id);
14395
14451
  const variableName = defaultInteropHelpersByInteropType[moduleInterop]
14396
14452
  ? chunk.defaultVariableName
14397
14453
  : chunk.variableName;
@@ -14403,7 +14459,7 @@ function deconflictImportsOther(usedNames, imports, { deconflictedDefault, decon
14403
14459
  }
14404
14460
  }
14405
14461
  else if (name === '*') {
14406
- variable.setRenderNames(null, namespaceInteropHelpersByInteropType[String(interop(module.id))]
14462
+ variable.setRenderNames(null, namespaceInteropHelpersByInteropType[interop(module.id)]
14407
14463
  ? chunk.namespaceVariableName
14408
14464
  : chunk.variableName);
14409
14465
  }
@@ -14473,7 +14529,7 @@ function assignExportsToNames(exports, exportsByName, exportNamesByVariable) {
14473
14529
  }
14474
14530
  }
14475
14531
 
14476
- function getExportMode(chunk, { exports: exportMode, name, format }, unsetOptions, facadeModuleId, warn) {
14532
+ function getExportMode(chunk, { exports: exportMode, name, format }, facadeModuleId, warn) {
14477
14533
  const exportKeys = chunk.getExportNames();
14478
14534
  if (exportMode === 'default') {
14479
14535
  if (exportKeys.length !== 1 || exportKeys[0] !== 'default') {
@@ -14488,9 +14544,6 @@ function getExportMode(chunk, { exports: exportMode, name, format }, unsetOption
14488
14544
  exportMode = 'none';
14489
14545
  }
14490
14546
  else if (exportKeys.length === 1 && exportKeys[0] === 'default') {
14491
- if (format === 'cjs' && unsetOptions.has('exports')) {
14492
- warn(errPreferNamedExports(facadeModuleId));
14493
- }
14494
14547
  exportMode = 'default';
14495
14548
  }
14496
14549
  else {
@@ -14715,7 +14768,7 @@ class Chunk {
14715
14768
  assignExportsToNames(remainingExports, this.exportsByName, this.exportNamesByVariable);
14716
14769
  }
14717
14770
  if (this.outputOptions.preserveModules || (this.facadeModule && this.facadeModule.info.isEntry))
14718
- this.exportMode = getExportMode(this, this.outputOptions, this.unsetOptions, this.facadeModule.id, this.inputOptions.onwarn);
14771
+ this.exportMode = getExportMode(this, this.outputOptions, this.facadeModule.id, this.inputOptions.onwarn);
14719
14772
  }
14720
14773
  generateFacades() {
14721
14774
  var _a;
@@ -14816,7 +14869,7 @@ class Chunk {
14816
14869
  return ((_a = this.preliminaryFileName) === null || _a === void 0 ? void 0 : _a.fileName) || this.getPreliminaryFileName().fileName;
14817
14870
  }
14818
14871
  getImportPath(importer) {
14819
- return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd', true));
14872
+ return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd' && !this.outputOptions.amd.forceJsExtensionForImports, true));
14820
14873
  }
14821
14874
  getPreliminaryFileName() {
14822
14875
  var _a;
@@ -14895,13 +14948,31 @@ class Chunk {
14895
14948
  const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = this.renderModules(preliminaryFileName.fileName);
14896
14949
  const renderedDependencies = [...this.getRenderedDependencies().values()];
14897
14950
  const renderedExports = exportMode === 'none' ? [] : this.getChunkExportDeclarations(format);
14898
- const hasExports = renderedExports.length !== 0 ||
14899
- renderedDependencies.some(dep => (dep.reexports && dep.reexports.length !== 0));
14951
+ let hasExports = renderedExports.length !== 0;
14952
+ let hasDefaultExport = false;
14953
+ for (const { reexports } of renderedDependencies) {
14954
+ if (reexports === null || reexports === void 0 ? void 0 : reexports.length) {
14955
+ hasExports = true;
14956
+ if (reexports.some(reexport => reexport.reexported === 'default')) {
14957
+ hasDefaultExport = true;
14958
+ break;
14959
+ }
14960
+ }
14961
+ }
14962
+ if (!hasDefaultExport) {
14963
+ for (const { exported } of renderedExports) {
14964
+ if (exported === 'default') {
14965
+ hasDefaultExport = true;
14966
+ break;
14967
+ }
14968
+ }
14969
+ }
14900
14970
  const { intro, outro, banner, footer } = await createAddons(outputOptions, pluginDriver, this.getRenderedChunkInfo());
14901
14971
  finalisers[format](renderedSource, {
14902
14972
  accessedGlobals,
14903
14973
  dependencies: renderedDependencies,
14904
14974
  exports: renderedExports,
14975
+ hasDefaultExport,
14905
14976
  hasExports,
14906
14977
  id: preliminaryFileName.fileName,
14907
14978
  indent,
@@ -15062,12 +15133,12 @@ class Chunk {
15062
15133
  dependencies.add(chunk);
15063
15134
  if (addNonNamespacesAndInteropHelpers) {
15064
15135
  if (variable.name === 'default') {
15065
- if (defaultInteropHelpersByInteropType[String(interop(module.id))]) {
15136
+ if (defaultInteropHelpersByInteropType[interop(module.id)]) {
15066
15137
  deconflictedDefault.add(chunk);
15067
15138
  }
15068
15139
  }
15069
15140
  else if (variable.name === '*') {
15070
- if (namespaceInteropHelpersByInteropType[String(interop(module.id))]) {
15141
+ if (namespaceInteropHelpersByInteropType[interop(module.id)]) {
15071
15142
  deconflictedNamespace.add(chunk);
15072
15143
  }
15073
15144
  }
@@ -15241,7 +15312,7 @@ class Chunk {
15241
15312
  }
15242
15313
  needsLiveBinding =
15243
15314
  externalLiveBindings &&
15244
- (imported !== 'default' || isDefaultAProperty(String(interop(module.id)), true));
15315
+ (imported !== 'default' || isDefaultAProperty(interop(module.id), true));
15245
15316
  }
15246
15317
  }
15247
15318
  getOrCreate(reexportSpecifiers, dependency, () => []).push({
@@ -16664,10 +16735,10 @@ function getLineInfo(input, offset) {
16664
16735
  var defaultOptions = {
16665
16736
  // `ecmaVersion` indicates the ECMAScript version to parse. Must be
16666
16737
  // either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
16667
- // (2019), 11 (2020), 12 (2021), 13 (2022), or `"latest"` (the
16668
- // latest version the library supports). This influences support
16669
- // for strict mode, the set of reserved words, and support for
16670
- // new syntax features.
16738
+ // (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"`
16739
+ // (the latest version the library supports). This influences
16740
+ // support for strict mode, the set of reserved words, and support
16741
+ // for new syntax features.
16671
16742
  ecmaVersion: null,
16672
16743
  // `sourceType` indicates the mode the code should be parsed in.
16673
16744
  // Can be either `"script"` or `"module"`. This influences global
@@ -16701,8 +16772,9 @@ var defaultOptions = {
16701
16772
  // When enabled, super identifiers are not constrained to
16702
16773
  // appearing in methods and do not raise an error when they appear elsewhere.
16703
16774
  allowSuperOutsideMethod: null,
16704
- // When enabled, hashbang directive in the beginning of file
16705
- // is allowed and treated as a line comment.
16775
+ // When enabled, hashbang directive in the beginning of file is
16776
+ // allowed and treated as a line comment. Enabled by default when
16777
+ // `ecmaVersion` >= 2023.
16706
16778
  allowHashBang: false,
16707
16779
  // When `locations` is on, `loc` properties holding objects with
16708
16780
  // `start` and `end` properties in `{line, column}` form (with
@@ -16777,6 +16849,9 @@ function getOptions(opts) {
16777
16849
  if (options.allowReserved == null)
16778
16850
  { options.allowReserved = options.ecmaVersion < 5; }
16779
16851
 
16852
+ if (opts.allowHashBang == null)
16853
+ { options.allowHashBang = options.ecmaVersion >= 14; }
16854
+
16780
16855
  if (isArray(options.onToken)) {
16781
16856
  var tokens = options.onToken;
16782
16857
  options.onToken = function (token) { return tokens.push(token); };
@@ -17107,7 +17182,7 @@ pp$9.checkPatternErrors = function(refDestructuringErrors, isAssign) {
17107
17182
  if (refDestructuringErrors.trailingComma > -1)
17108
17183
  { this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
17109
17184
  var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
17110
- if (parens > -1) { this.raiseRecoverable(parens, "Parenthesized pattern"); }
17185
+ if (parens > -1) { this.raiseRecoverable(parens, isAssign ? "Assigning to rvalue" : "Parenthesized pattern"); }
17111
17186
  };
17112
17187
 
17113
17188
  pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
@@ -18203,6 +18278,7 @@ pp$8.adaptDirectivePrologue = function(statements) {
18203
18278
  };
18204
18279
  pp$8.isDirectiveCandidate = function(statement) {
18205
18280
  return (
18281
+ this.options.ecmaVersion >= 5 &&
18206
18282
  statement.type === "ExpressionStatement" &&
18207
18283
  statement.expression.type === "Literal" &&
18208
18284
  typeof statement.expression.value === "string" &&
@@ -18613,7 +18689,8 @@ pp$6.updateContext = function(prevType) {
18613
18689
  { this.exprAllowed = type.beforeExpr; }
18614
18690
  };
18615
18691
 
18616
- // Used to handle egde case when token context could not be inferred correctly in tokenize phase
18692
+ // Used to handle egde cases when token context could not be inferred correctly during tokenization phase
18693
+
18617
18694
  pp$6.overrideContext = function(tokenCtx) {
18618
18695
  if (this.curContext() !== tokenCtx) {
18619
18696
  this.context[this.context.length - 1] = tokenCtx;
@@ -19429,15 +19506,6 @@ pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
19429
19506
  }
19430
19507
  return this.finishNode(prop, "RestElement")
19431
19508
  }
19432
- // To disallow parenthesized identifier via `this.toAssignable()`.
19433
- if (this.type === types$1.parenL && refDestructuringErrors) {
19434
- if (refDestructuringErrors.parenthesizedAssign < 0) {
19435
- refDestructuringErrors.parenthesizedAssign = this.start;
19436
- }
19437
- if (refDestructuringErrors.parenthesizedBind < 0) {
19438
- refDestructuringErrors.parenthesizedBind = this.start;
19439
- }
19440
- }
19441
19509
  // Parse argument.
19442
19510
  prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
19443
19511
  // To disallow trailing comma via `this.toAssignable()`.
@@ -21867,7 +21935,7 @@ pp.readWord = function() {
21867
21935
 
21868
21936
  // Acorn is a tiny, fast JavaScript parser written in JavaScript.
21869
21937
 
21870
- var version = "8.7.1";
21938
+ var version = "8.8.0";
21871
21939
 
21872
21940
  Parser.acorn = {
21873
21941
  Parser: Parser,
@@ -22998,8 +23066,8 @@ class Graph {
22998
23066
  this.watchMode = true;
22999
23067
  const handleChange = (...args) => this.pluginDriver.hookParallel('watchChange', args);
23000
23068
  const handleClose = () => this.pluginDriver.hookParallel('closeWatcher', []);
23001
- watcher.onCurrentAwaited('change', handleChange);
23002
- watcher.onCurrentAwaited('close', handleClose);
23069
+ watcher.onCurrentRun('change', handleChange);
23070
+ watcher.onCurrentRun('close', handleClose);
23003
23071
  }
23004
23072
  this.pluginDriver = new PluginDriver(this, options, options.plugins, this.pluginCache);
23005
23073
  this.acornParser = Parser.extend(...options.acornInjectPlugins);
@@ -23486,7 +23554,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
23486
23554
  dir: getDir(config, file),
23487
23555
  dynamicImportFunction: getDynamicImportFunction(config, inputOptions, format),
23488
23556
  entryFileNames: getEntryFileNames(config, unsetOptions),
23489
- esModule: (_c = config.esModule) !== null && _c !== void 0 ? _c : true,
23557
+ esModule: (_c = config.esModule) !== null && _c !== void 0 ? _c : 'if-default-prop',
23490
23558
  exports: getExports(config, unsetOptions),
23491
23559
  extend: config.extend || false,
23492
23560
  externalLiveBindings: (_d = config.externalLiveBindings) !== null && _d !== void 0 ? _d : true,
@@ -23499,7 +23567,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
23499
23567
  hoistTransitiveImports: (_f = config.hoistTransitiveImports) !== null && _f !== void 0 ? _f : true,
23500
23568
  indent: getIndent(config, compact),
23501
23569
  inlineDynamicImports,
23502
- interop: getInterop(config, inputOptions),
23570
+ interop: getInterop(config),
23503
23571
  intro: getAddon(config, 'intro'),
23504
23572
  manualChunks: getManualChunks(config, inlineDynamicImports, preserveModules, inputOptions),
23505
23573
  minifyInternalExports: getMinifyInternalExports(config, format, compact),
@@ -23606,6 +23674,7 @@ const getAmd = (config) => {
23606
23674
  autoId: false,
23607
23675
  basePath: '',
23608
23676
  define: 'define',
23677
+ forceJsExtensionForImports: false,
23609
23678
  ...config.amd
23610
23679
  };
23611
23680
  if ((mergedOption.autoId || mergedOption.basePath) && mergedOption.id) {
@@ -23619,13 +23688,15 @@ const getAmd = (config) => {
23619
23688
  normalized = {
23620
23689
  autoId: true,
23621
23690
  basePath: mergedOption.basePath,
23622
- define: mergedOption.define
23691
+ define: mergedOption.define,
23692
+ forceJsExtensionForImports: mergedOption.forceJsExtensionForImports
23623
23693
  };
23624
23694
  }
23625
23695
  else {
23626
23696
  normalized = {
23627
23697
  autoId: false,
23628
23698
  define: mergedOption.define,
23699
+ forceJsExtensionForImports: mergedOption.forceJsExtensionForImports,
23629
23700
  id: mergedOption.id
23630
23701
  };
23631
23702
  }
@@ -23690,28 +23761,17 @@ const getIndent = (config, compact) => {
23690
23761
  return configIndent === false ? '' : configIndent !== null && configIndent !== void 0 ? configIndent : true;
23691
23762
  };
23692
23763
  const ALLOWED_INTEROP_TYPES = new Set([
23764
+ 'compat',
23693
23765
  'auto',
23694
23766
  'esModule',
23695
23767
  'default',
23696
- 'defaultOnly',
23697
- true,
23698
- false
23768
+ 'defaultOnly'
23699
23769
  ]);
23700
- const getInterop = (config, inputOptions) => {
23770
+ const getInterop = (config) => {
23701
23771
  const configInterop = config.interop;
23702
- const validatedInteropTypes = new Set();
23703
23772
  const validateInterop = (interop) => {
23704
- if (!validatedInteropTypes.has(interop)) {
23705
- validatedInteropTypes.add(interop);
23706
- if (!ALLOWED_INTEROP_TYPES.has(interop)) {
23707
- return error(errInvalidOption('output.interop', 'outputinterop', `use one of ${Array.from(ALLOWED_INTEROP_TYPES, value => JSON.stringify(value)).join(', ')}`, interop));
23708
- }
23709
- if (typeof interop === 'boolean') {
23710
- warnDeprecation({
23711
- message: `The boolean value "${interop}" for the "output.interop" option is deprecated. Use ${interop ? '"auto"' : '"esModule", "default" or "defaultOnly"'} instead.`,
23712
- url: 'https://rollupjs.org/guide/en/#outputinterop'
23713
- }, true, inputOptions);
23714
- }
23773
+ if (!ALLOWED_INTEROP_TYPES.has(interop)) {
23774
+ return error(errInvalidOption('output.interop', 'outputinterop', `use one of ${Array.from(ALLOWED_INTEROP_TYPES, value => JSON.stringify(value)).join(', ')}`, interop));
23715
23775
  }
23716
23776
  return interop;
23717
23777
  };
@@ -23724,7 +23784,7 @@ const getInterop = (config, inputOptions) => {
23724
23784
  ? interopPerId[id]
23725
23785
  : validateInterop((interopPerId[id] = configInterop(id)));
23726
23786
  }
23727
- return configInterop === undefined ? () => true : () => validateInterop(configInterop);
23787
+ return configInterop === undefined ? () => 'default' : () => validateInterop(configInterop);
23728
23788
  };
23729
23789
  const getManualChunks = (config, inlineDynamicImports, preserveModules, inputOptions) => {
23730
23790
  const configManualChunks = config.manualChunks || inputOptions.manualChunks;
@@ -23915,30 +23975,58 @@ function defineConfig(options) {
23915
23975
  return options;
23916
23976
  }
23917
23977
 
23918
- class WatchEmitter extends EventEmitter {
23978
+ class WatchEmitter {
23919
23979
  constructor() {
23920
- super();
23921
- this.awaitedHandlers = Object.create(null);
23922
- // Allows more than 10 bundles to be watched without
23923
- // showing the `MaxListenersExceededWarning` to the user.
23924
- this.setMaxListeners(Infinity);
23980
+ this.currentHandlers = Object.create(null);
23981
+ this.persistentHandlers = Object.create(null);
23925
23982
  }
23926
23983
  // Will be overwritten by Rollup
23927
23984
  async close() { }
23928
- emitAndAwait(event, ...args) {
23929
- this.emit(event, ...args);
23930
- return Promise.all(this.getHandlers(event).map(handler => handler(...args)));
23985
+ emit(event, ...args) {
23986
+ return Promise.all(this.getCurrentHandlers(event)
23987
+ .concat(this.getPersistentHandlers(event))
23988
+ .map(handler => handler(...args)));
23989
+ }
23990
+ off(event, listener) {
23991
+ const listeners = this.persistentHandlers[event];
23992
+ if (listeners) {
23993
+ // A hack stolen from "mitt": ">>> 0" does not change numbers >= 0, but -1
23994
+ // (which would remove the last array element if used unchanged) is turned
23995
+ // into max_int, which is outside the array and does not change anything.
23996
+ listeners.splice(listeners.indexOf(listener) >>> 0, 1);
23997
+ }
23998
+ return this;
23931
23999
  }
23932
- onCurrentAwaited(event, listener) {
23933
- this.getHandlers(event).push(listener);
24000
+ on(event, listener) {
24001
+ this.getPersistentHandlers(event).push(listener);
23934
24002
  return this;
23935
24003
  }
23936
- removeAwaited() {
23937
- this.awaitedHandlers = {};
24004
+ onCurrentRun(event, listener) {
24005
+ this.getCurrentHandlers(event).push(listener);
23938
24006
  return this;
23939
24007
  }
23940
- getHandlers(event) {
23941
- return this.awaitedHandlers[event] || (this.awaitedHandlers[event] = []);
24008
+ once(event, listener) {
24009
+ const selfRemovingListener = (...args) => {
24010
+ this.off(event, selfRemovingListener);
24011
+ return listener(...args);
24012
+ };
24013
+ this.on(event, selfRemovingListener);
24014
+ return this;
24015
+ }
24016
+ removeAllListeners() {
24017
+ this.removeListenersForCurrentRun();
24018
+ this.persistentHandlers = Object.create(null);
24019
+ return this;
24020
+ }
24021
+ removeListenersForCurrentRun() {
24022
+ this.currentHandlers = Object.create(null);
24023
+ return this;
24024
+ }
24025
+ getCurrentHandlers(event) {
24026
+ return this.currentHandlers[event] || (this.currentHandlers[event] = []);
24027
+ }
24028
+ getPersistentHandlers(event) {
24029
+ return this.persistentHandlers[event] || (this.persistentHandlers[event] = []);
23942
24030
  }
23943
24031
  }
23944
24032