rollup 3.9.1 → 3.10.0

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.9.1
4
- Mon, 02 Jan 2023 13:46:34 GMT - commit c6c884433e748cde70f3f4299dd48b81af97ec14
3
+ Rollup.js v3.10.0
4
+ Thu, 12 Jan 2023 07:56:20 GMT - commit ffc19b0091267d9bf5072b16969599e457a63f5c
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -10,7 +10,7 @@
10
10
  'use strict';
11
11
 
12
12
  const node_path = require('node:path');
13
- const require$$0$2 = require('path');
13
+ const require$$0$1 = require('path');
14
14
  const process$1 = require('node:process');
15
15
  const node_perf_hooks = require('node:perf_hooks');
16
16
  const node_crypto = require('node:crypto');
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
31
31
 
32
32
  const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
33
33
 
34
- var version$1 = "3.9.1";
34
+ var version$1 = "3.10.0";
35
35
 
36
36
  function ensureArray$1(items) {
37
37
  if (Array.isArray(items)) {
@@ -95,19 +95,6 @@ function locate(source, search, options) {
95
95
  return getLocator$1(source, options)(search, options && options.startIndex);
96
96
  }
97
97
 
98
- const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Za-z]:)?[/\\|])/;
99
- const RELATIVE_PATH_REGEX = /^\.?\.(\/|$)/;
100
- function isAbsolute(path) {
101
- return ABSOLUTE_PATH_REGEX.test(path);
102
- }
103
- function isRelative(path) {
104
- return RELATIVE_PATH_REGEX.test(path);
105
- }
106
- const BACKSLASH_REGEX = /\\/g;
107
- function normalize(path) {
108
- return path.replace(BACKSLASH_REGEX, '/');
109
- }
110
-
111
98
  function spaces(index) {
112
99
  let result = '';
113
100
  while (index--)
@@ -142,6 +129,19 @@ function getCodeFrame(source, line, column) {
142
129
  .join('\n');
143
130
  }
144
131
 
132
+ const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Za-z]:)?[/\\|])/;
133
+ const RELATIVE_PATH_REGEX = /^\.?\.(\/|$)/;
134
+ function isAbsolute(path) {
135
+ return ABSOLUTE_PATH_REGEX.test(path);
136
+ }
137
+ function isRelative(path) {
138
+ return RELATIVE_PATH_REGEX.test(path);
139
+ }
140
+ const BACKSLASH_REGEX = /\\/g;
141
+ function normalize(path) {
142
+ return path.replace(BACKSLASH_REGEX, '/');
143
+ }
144
+
145
145
  function printQuotedStringList(list, verbs) {
146
146
  const isSingleItem = list.length <= 1;
147
147
  const quotedList = list.map(item => `"${item}"`);
@@ -1233,11 +1233,11 @@ function handleError(error, recover = false) {
1233
1233
 
1234
1234
  const comma = ','.charCodeAt(0);
1235
1235
  const semicolon = ';'.charCodeAt(0);
1236
- const chars$2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
1236
+ const chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
1237
1237
  const intToChar = new Uint8Array(64); // 64 possible chars.
1238
1238
  const charToInt = new Uint8Array(128); // z is 122 in ASCII
1239
- for (let i = 0; i < chars$2.length; i++) {
1240
- const c = chars$2.charCodeAt(i);
1239
+ for (let i = 0; i < chars$1.length; i++) {
1240
+ const c = chars$1.charCodeAt(i);
1241
1241
  intToChar[i] = c;
1242
1242
  charToInt[c] = i;
1243
1243
  }
@@ -1260,6 +1260,80 @@ const td = typeof TextDecoder !== 'undefined'
1260
1260
  return out;
1261
1261
  },
1262
1262
  };
1263
+ function decode(mappings) {
1264
+ const state = new Int32Array(5);
1265
+ const decoded = [];
1266
+ let index = 0;
1267
+ do {
1268
+ const semi = indexOf(mappings, index);
1269
+ const line = [];
1270
+ let sorted = true;
1271
+ let lastCol = 0;
1272
+ state[0] = 0;
1273
+ for (let i = index; i < semi; i++) {
1274
+ let seg;
1275
+ i = decodeInteger(mappings, i, state, 0); // genColumn
1276
+ const col = state[0];
1277
+ if (col < lastCol)
1278
+ sorted = false;
1279
+ lastCol = col;
1280
+ if (hasMoreVlq(mappings, i, semi)) {
1281
+ i = decodeInteger(mappings, i, state, 1); // sourcesIndex
1282
+ i = decodeInteger(mappings, i, state, 2); // sourceLine
1283
+ i = decodeInteger(mappings, i, state, 3); // sourceColumn
1284
+ if (hasMoreVlq(mappings, i, semi)) {
1285
+ i = decodeInteger(mappings, i, state, 4); // namesIndex
1286
+ seg = [col, state[1], state[2], state[3], state[4]];
1287
+ }
1288
+ else {
1289
+ seg = [col, state[1], state[2], state[3]];
1290
+ }
1291
+ }
1292
+ else {
1293
+ seg = [col];
1294
+ }
1295
+ line.push(seg);
1296
+ }
1297
+ if (!sorted)
1298
+ sort(line);
1299
+ decoded.push(line);
1300
+ index = semi + 1;
1301
+ } while (index <= mappings.length);
1302
+ return decoded;
1303
+ }
1304
+ function indexOf(mappings, index) {
1305
+ const idx = mappings.indexOf(';', index);
1306
+ return idx === -1 ? mappings.length : idx;
1307
+ }
1308
+ function decodeInteger(mappings, pos, state, j) {
1309
+ let value = 0;
1310
+ let shift = 0;
1311
+ let integer = 0;
1312
+ do {
1313
+ const c = mappings.charCodeAt(pos++);
1314
+ integer = charToInt[c];
1315
+ value |= (integer & 31) << shift;
1316
+ shift += 5;
1317
+ } while (integer & 32);
1318
+ const shouldNegate = value & 1;
1319
+ value >>>= 1;
1320
+ if (shouldNegate) {
1321
+ value = -0x80000000 | -value;
1322
+ }
1323
+ state[j] += value;
1324
+ return pos;
1325
+ }
1326
+ function hasMoreVlq(mappings, i, length) {
1327
+ if (i >= length)
1328
+ return false;
1329
+ return mappings.charCodeAt(i) !== comma;
1330
+ }
1331
+ function sort(line) {
1332
+ line.sort(sortComparator);
1333
+ }
1334
+ function sortComparator(a, b) {
1335
+ return a[0] - b[0];
1336
+ }
1263
1337
  function encode(decoded) {
1264
1338
  const state = new Int32Array(5);
1265
1339
  const bufLength = 1024 * 16;
@@ -3219,7 +3293,7 @@ var picomatch$1 = {
3219
3293
 
3220
3294
  var utils$3 = {};
3221
3295
 
3222
- const path$1 = require$$0$2;
3296
+ const path$1 = require$$0$1;
3223
3297
  const WIN_SLASH = '\\\\/';
3224
3298
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
3225
3299
 
@@ -3399,7 +3473,7 @@ var constants$2 = {
3399
3473
 
3400
3474
  (function (exports) {
3401
3475
 
3402
- const path = require$$0$2;
3476
+ const path = require$$0$1;
3403
3477
  const win32 = process.platform === 'win32';
3404
3478
  const {
3405
3479
  REGEX_BACKSLASH,
@@ -4936,7 +5010,7 @@ parse$2.fastpaths = (input, options) => {
4936
5010
 
4937
5011
  var parse_1 = parse$2;
4938
5012
 
4939
- const path = require$$0$2;
5013
+ const path = require$$0$1;
4940
5014
  const scan = scan_1;
4941
5015
  const parse$1 = parse_1;
4942
5016
  const utils = utils$3;
@@ -5332,22 +5406,22 @@ function ensureArray(thing) {
5332
5406
  }
5333
5407
 
5334
5408
  const normalizePath = function normalizePath(filename) {
5335
- return filename.split(require$$0$2.win32.sep).join(require$$0$2.posix.sep);
5409
+ return filename.split(require$$0$1.win32.sep).join(require$$0$1.posix.sep);
5336
5410
  };
5337
5411
 
5338
5412
  function getMatcherString(id, resolutionBase) {
5339
- if (resolutionBase === false || require$$0$2.isAbsolute(id) || id.startsWith('*')) {
5413
+ if (resolutionBase === false || require$$0$1.isAbsolute(id) || id.startsWith('*')) {
5340
5414
  return normalizePath(id);
5341
5415
  }
5342
5416
  // resolve('') is valid and will default to process.cwd()
5343
- const basePath = normalizePath(require$$0$2.resolve(resolutionBase || ''))
5417
+ const basePath = normalizePath(require$$0$1.resolve(resolutionBase || ''))
5344
5418
  // escape all possible (posix + win) path characters that might interfere with regex
5345
5419
  .replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
5346
5420
  // Note that we use posix.join because:
5347
5421
  // 1. the basePath has been normalized to use /
5348
5422
  // 2. the incoming glob (id) matcher, also uses /
5349
5423
  // otherwise Node will force backslash (\) on windows
5350
- return require$$0$2.posix.join(basePath, normalizePath(id));
5424
+ return require$$0$1.posix.join(basePath, normalizePath(id));
5351
5425
  }
5352
5426
  const createFilter = function createFilter(include, exclude, options) {
5353
5427
  const resolutionBase = options && options.resolve;
@@ -7077,14 +7151,14 @@ class LocalVariable extends Variable {
7077
7151
  }
7078
7152
  }
7079
7153
 
7080
- const chars$1 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
7154
+ const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
7081
7155
  const base = 64;
7082
7156
  function toBase64(value) {
7083
7157
  let outString = '';
7084
7158
  do {
7085
7159
  const currentDigit = value % base;
7086
7160
  value = (value / base) | 0;
7087
- outString = chars$1[currentDigit] + outString;
7161
+ outString = chars[currentDigit] + outString;
7088
7162
  } while (value !== 0);
7089
7163
  return outString;
7090
7164
  }
@@ -7308,7 +7382,6 @@ class ReturnValueScope extends ParameterScope {
7308
7382
  }
7309
7383
  }
7310
7384
 
7311
- //@ts-check
7312
7385
  /** @typedef { import('estree').Node} Node */
7313
7386
  /** @typedef {Node | {
7314
7387
  * type: 'PropertyDefinition';
@@ -7320,7 +7393,7 @@ class ReturnValueScope extends ParameterScope {
7320
7393
  *
7321
7394
  * @param {NodeWithPropertyDefinition} node
7322
7395
  * @param {NodeWithPropertyDefinition} parent
7323
- * @returns boolean
7396
+ * @returns {boolean}
7324
7397
  */
7325
7398
  function is_reference (node, parent) {
7326
7399
  if (node.type === 'MemberExpression') {
@@ -9924,7 +9997,34 @@ class CatchClause extends NodeBase {
9924
9997
  }
9925
9998
  }
9926
9999
 
10000
+ const unset$1 = Symbol('unset');
9927
10001
  class ChainExpression extends NodeBase {
10002
+ constructor() {
10003
+ super(...arguments);
10004
+ this.objectValue = unset$1;
10005
+ }
10006
+ deoptimizeCache() {
10007
+ this.objectValue = UnknownValue;
10008
+ }
10009
+ getLiteralValueAtPath() {
10010
+ if (this.getObjectValue() == null)
10011
+ return undefined;
10012
+ return UnknownValue;
10013
+ }
10014
+ hasEffects(context) {
10015
+ if (this.getObjectValue() == null)
10016
+ return false;
10017
+ return this.expression.hasEffects(context);
10018
+ }
10019
+ getObjectValue() {
10020
+ if (this.objectValue === unset$1) {
10021
+ let object = this.expression.type === 'CallExpression' ? this.expression.callee : this.expression.object;
10022
+ if (object.type === 'MemberExpression')
10023
+ object = object.object;
10024
+ this.objectValue = object.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
10025
+ }
10026
+ return this.objectValue;
10027
+ }
9928
10028
  }
9929
10029
 
9930
10030
  class ClassBodyScope extends ChildScope {
@@ -13760,10 +13860,10 @@ class Module {
13760
13860
  this.transformDependencies = transformDependencies;
13761
13861
  this.customTransformCache = customTransformCache;
13762
13862
  this.updateOptions(moduleOptions);
13763
- const moduleAst = ast || this.tryParse();
13863
+ const moduleAst = ast ?? this.tryParse();
13764
13864
  timeEnd('generate ast', 3);
13765
13865
  timeStart('analyze ast', 3);
13766
- this.resolvedIds = resolvedIds || Object.create(null);
13866
+ this.resolvedIds = resolvedIds ?? Object.create(null);
13767
13867
  // By default, `id` is the file name. Custom resolvers and loaders
13768
13868
  // can change that, but it makes sense to use it for the source file name
13769
13869
  const fileName = this.id;
@@ -13864,14 +13964,6 @@ class Module {
13864
13964
  }
13865
13965
  return null;
13866
13966
  }
13867
- tryParse() {
13868
- try {
13869
- return this.graph.contextParse(this.info.code);
13870
- }
13871
- catch (error_) {
13872
- return this.error(errorParseError(error_, this.id), error_.pos);
13873
- }
13874
- }
13875
13967
  updateOptions({ meta, moduleSideEffects, syntheticNamedExports }) {
13876
13968
  if (moduleSideEffects != null) {
13877
13969
  this.info.moduleSideEffects = moduleSideEffects;
@@ -14153,6 +14245,14 @@ class Module {
14153
14245
  this.options.onwarn(errorShimmedExport(this.id, name));
14154
14246
  this.exports.set(name, MISSING_EXPORT_SHIM_DESCRIPTION);
14155
14247
  }
14248
+ tryParse() {
14249
+ try {
14250
+ return this.graph.contextParse(this.info.code);
14251
+ }
14252
+ catch (error_) {
14253
+ return this.error(errorParseError(error_, this.id), error_.pos);
14254
+ }
14255
+ }
14156
14256
  }
14157
14257
  // if there is a cyclic import in the reexport chain, we should not
14158
14258
  // import from the original module but from the cyclic module to not
@@ -14396,7 +14496,7 @@ var _static = {
14396
14496
  set exports(v){ _staticExports = v; },
14397
14497
  };
14398
14498
 
14399
- const require$$0$1 = [
14499
+ const require$$0 = [
14400
14500
  "assert",
14401
14501
  "async_hooks",
14402
14502
  "buffer",
@@ -14441,7 +14541,7 @@ const require$$0$1 = [
14441
14541
  ];
14442
14542
 
14443
14543
  (function (module) {
14444
- module.exports = require$$0$1;
14544
+ module.exports = require$$0;
14445
14545
  } (_static));
14446
14546
 
14447
14547
  const builtinModules = /*@__PURE__*/getDefaultExportFromCjs(_staticExports);
@@ -16919,78 +17019,6 @@ function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain,
16919
17019
 
16920
17020
  const createHash = () => node_crypto.createHash('sha256');
16921
17021
 
16922
- var charToInteger = {};
16923
- var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
16924
- for (var i$1 = 0; i$1 < chars.length; i$1++) {
16925
- charToInteger[chars.charCodeAt(i$1)] = i$1;
16926
- }
16927
- function decode(mappings) {
16928
- var decoded = [];
16929
- var line = [];
16930
- var segment = [
16931
- 0,
16932
- 0,
16933
- 0,
16934
- 0,
16935
- 0,
16936
- ];
16937
- var j = 0;
16938
- for (var i = 0, shift = 0, value = 0; i < mappings.length; i++) {
16939
- var c = mappings.charCodeAt(i);
16940
- if (c === 44) { // ","
16941
- segmentify(line, segment, j);
16942
- j = 0;
16943
- }
16944
- else if (c === 59) { // ";"
16945
- segmentify(line, segment, j);
16946
- j = 0;
16947
- decoded.push(line);
16948
- line = [];
16949
- segment[0] = 0;
16950
- }
16951
- else {
16952
- var integer = charToInteger[c];
16953
- if (integer === undefined) {
16954
- throw new Error('Invalid character (' + String.fromCharCode(c) + ')');
16955
- }
16956
- var hasContinuationBit = integer & 32;
16957
- integer &= 31;
16958
- value += integer << shift;
16959
- if (hasContinuationBit) {
16960
- shift += 5;
16961
- }
16962
- else {
16963
- var shouldNegate = value & 1;
16964
- value >>>= 1;
16965
- if (shouldNegate) {
16966
- value = value === 0 ? -0x80000000 : -value;
16967
- }
16968
- segment[j] += value;
16969
- j++;
16970
- value = shift = 0; // reset
16971
- }
16972
- }
16973
- }
16974
- segmentify(line, segment, j);
16975
- decoded.push(line);
16976
- return decoded;
16977
- }
16978
- function segmentify(line, segment, j) {
16979
- // This looks ugly, but we're creating specialized arrays with a specific
16980
- // length. This is much faster than creating a new array (which v8 expands to
16981
- // a capacity of 17 after pushing the first item), or slicing out a subarray
16982
- // (which is slow). Length 4 is assumed to be the most frequent, followed by
16983
- // length 5 (since not everything will have an associated name), followed by
16984
- // length 1 (it's probably rare for a source substring to not have an
16985
- // associated segment data).
16986
- if (j === 4)
16987
- line.push([segment[0], segment[1], segment[2], segment[3]]);
16988
- else if (j === 5)
16989
- line.push([segment[0], segment[1], segment[2], segment[3], segment[4]]);
16990
- else if (j === 1)
16991
- line.push([segment[0]]);
16992
- }
16993
-
16994
17022
  function decodedSourcemap(map) {
16995
17023
  if (!map)
16996
17024
  return null;
@@ -17283,7 +17311,6 @@ class Bundle {
17283
17311
  if ('code' in file) {
17284
17312
  try {
17285
17313
  this.graph.contextParse(file.code, {
17286
- allowHashBang: true,
17287
17314
  ecmaVersion: 'latest'
17288
17315
  });
17289
17316
  }
@@ -22944,7 +22971,7 @@ function tokenizer(input, options) {
22944
22971
  return Parser.tokenizer(input, options)
22945
22972
  }
22946
22973
 
22947
- const acorn = /*#__PURE__*/Object.defineProperty({
22974
+ const _acorn = /*#__PURE__*/Object.defineProperty({
22948
22975
  __proto__: null,
22949
22976
  Node,
22950
22977
  Parser,
@@ -23029,13 +23056,27 @@ function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolve
23029
23056
  resolve: (source, importer, { assertions, custom, isEntry, skipSelf } = BLANK) => moduleLoaderResolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip)
23030
23057
  });
23031
23058
  }
23032
- return pluginDriver.hookFirst('resolveId', [source, importer, { assertions, custom: customOptions, isEntry }], replaceContext, skipped);
23059
+ return pluginDriver.hookFirstAndGetPlugin('resolveId', [source, importer, { assertions, custom: customOptions, isEntry }], replaceContext, skipped);
23033
23060
  }
23034
23061
 
23035
23062
  async function resolveId(source, importer, preserveSymlinks, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions) {
23036
23063
  const pluginResult = await resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry, assertions);
23037
- if (pluginResult != null)
23038
- return pluginResult;
23064
+ if (pluginResult != null) {
23065
+ const [resolveIdResult, plugin] = pluginResult;
23066
+ if (typeof resolveIdResult === 'object' && !resolveIdResult.resolvedBy) {
23067
+ return {
23068
+ ...resolveIdResult,
23069
+ resolvedBy: plugin.name
23070
+ };
23071
+ }
23072
+ if (typeof resolveIdResult === 'string') {
23073
+ return {
23074
+ id: resolveIdResult,
23075
+ resolvedBy: plugin.name
23076
+ };
23077
+ }
23078
+ return resolveIdResult;
23079
+ }
23039
23080
  // external modules (non-entry modules that start with neither '.' or '/')
23040
23081
  // are skipped at this stage.
23041
23082
  if (importer !== undefined && !isAbsolute(source) && source[0] !== '.')
@@ -23585,6 +23626,7 @@ class ModuleLoader {
23585
23626
  id: resolvedId.id,
23586
23627
  meta: resolvedId.meta || {},
23587
23628
  moduleSideEffects: resolvedId.moduleSideEffects ?? this.hasModuleSideEffects(resolvedId.id, !!external),
23629
+ resolvedBy: resolvedId.resolvedBy ?? 'rollup',
23588
23630
  syntheticNamedExports: resolvedId.syntheticNamedExports ?? false
23589
23631
  };
23590
23632
  }
@@ -23617,6 +23659,7 @@ class ModuleLoader {
23617
23659
  id: source,
23618
23660
  meta: {},
23619
23661
  moduleSideEffects: this.hasModuleSideEffects(source, true),
23662
+ resolvedBy: 'rollup',
23620
23663
  syntheticNamedExports: false
23621
23664
  };
23622
23665
  }
@@ -24067,17 +24110,18 @@ class PluginDriver {
24067
24110
  }
24068
24111
  // chains, first non-null result stops and returns
24069
24112
  hookFirst(hookName, parameters, replaceContext, skipped) {
24070
- let promise = Promise.resolve(null);
24113
+ return this.hookFirstAndGetPlugin(hookName, parameters, replaceContext, skipped).then(result => result && result[0]);
24114
+ }
24115
+ // chains, first non-null result stops and returns result and last plugin
24116
+ async hookFirstAndGetPlugin(hookName, parameters, replaceContext, skipped) {
24071
24117
  for (const plugin of this.getSortedPlugins(hookName)) {
24072
- if (skipped && skipped.has(plugin))
24118
+ if (skipped?.has(plugin))
24073
24119
  continue;
24074
- promise = promise.then(result => {
24075
- if (result != null)
24076
- return result;
24077
- return this.runHook(hookName, parameters, plugin, replaceContext);
24078
- });
24120
+ const result = await this.runHook(hookName, parameters, plugin, replaceContext);
24121
+ if (result != null)
24122
+ return [result, plugin];
24079
24123
  }
24080
- return promise;
24124
+ return null;
24081
24125
  }
24082
24126
  // chains synchronously, first non-null result stops and returns
24083
24127
  hookFirstSync(hookName, parameters, replaceContext) {
@@ -24540,26 +24584,11 @@ async function catchUnfinishedHookActions(pluginDriver, callback) {
24540
24584
  return result;
24541
24585
  }
24542
24586
 
24543
- var lib = {};
24544
-
24545
- const require$$0 = /*@__PURE__*/getAugmentedNamespace(acorn);
24546
-
24547
- Object.defineProperty(lib, "__esModule", {
24548
- value: true
24549
- });
24550
- var importAssertions_1 = lib.importAssertions = importAssertions;
24551
-
24552
- var _acorn = _interopRequireWildcard(require$$0);
24553
-
24554
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24555
-
24556
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24557
-
24558
24587
  const leftCurlyBrace = "{".charCodeAt(0);
24559
24588
  const space = " ".charCodeAt(0);
24589
+
24560
24590
  const keyword = "assert";
24561
- const FUNC_STATEMENT = 1,
24562
- FUNC_NULLABLE_ID = 4;
24591
+ const FUNC_STATEMENT = 1, FUNC_NULLABLE_ID = 4;
24563
24592
 
24564
24593
  function importAssertions(Parser) {
24565
24594
  // Use supplied version acorn version if present, to avoid
@@ -24568,10 +24597,8 @@ function importAssertions(Parser) {
24568
24597
  // its own internal version of acorn and thereby sidesteps
24569
24598
  // the package manager.
24570
24599
  const acorn = Parser.acorn || _acorn;
24571
- const {
24572
- tokTypes: tt,
24573
- TokenType
24574
- } = acorn;
24600
+ const { tokTypes: tt, TokenType } = acorn;
24601
+
24575
24602
  return class extends Parser {
24576
24603
  constructor(...args) {
24577
24604
  super(...args);
@@ -24586,21 +24613,19 @@ function importAssertions(Parser) {
24586
24613
  if (this.type !== t) {
24587
24614
  this.unexpected();
24588
24615
  }
24589
-
24590
24616
  this.next();
24591
24617
  }
24592
24618
 
24593
24619
  readToken(code) {
24594
24620
  let i = 0;
24595
-
24596
24621
  for (; i < keyword.length; i++) {
24597
24622
  if (this._codeAt(this.pos + i) !== keyword.charCodeAt(i)) {
24598
24623
  return super.readToken(code);
24599
24624
  }
24600
- } // ensure that the keyword is at the correct location
24601
- // ie `assert{...` or `assert {...`
24602
-
24625
+ }
24603
24626
 
24627
+ // ensure that the keyword is at the correct location
24628
+ // ie `assert{...` or `assert {...`
24604
24629
  for (;; i++) {
24605
24630
  if (this._codeAt(this.pos + i) === leftCurlyBrace) {
24606
24631
  // Found '{'
@@ -24611,11 +24636,11 @@ function importAssertions(Parser) {
24611
24636
  } else {
24612
24637
  return super.readToken(code);
24613
24638
  }
24614
- } // If we're inside a dynamic import expression we'll parse
24639
+ }
24640
+
24641
+ // If we're inside a dynamic import expression we'll parse
24615
24642
  // the `assert` keyword as a standard object property name
24616
24643
  // ie `import(""./foo.json", { assert: { type: "json" } })`
24617
-
24618
-
24619
24644
  if (this.type.label === "{") {
24620
24645
  return super.readToken(code);
24621
24646
  }
@@ -24626,24 +24651,22 @@ function importAssertions(Parser) {
24626
24651
 
24627
24652
  parseDynamicImport(node) {
24628
24653
  this.next(); // skip `(`
24629
- // Parse node.source.
24630
24654
 
24655
+ // Parse node.source.
24631
24656
  node.source = this.parseMaybeAssign();
24632
24657
 
24633
24658
  if (this.eat(tt.comma)) {
24634
24659
  const obj = this.parseObj(false);
24635
24660
  node.arguments = [obj];
24636
24661
  }
24637
-
24638
24662
  this._eat(tt.parenR);
24639
-
24640
24663
  return this.finishNode(node, "ImportExpression");
24641
- } // ported from acorn/src/statement.js pp.parseExport
24642
-
24664
+ }
24643
24665
 
24666
+ // ported from acorn/src/statement.js pp.parseExport
24644
24667
  parseExport(node, exports) {
24645
- this.next(); // export * from '...'
24646
-
24668
+ this.next();
24669
+ // export * from '...'
24647
24670
  if (this.eat(tt.star)) {
24648
24671
  if (this.options.ecmaVersion >= 11) {
24649
24672
  if (this.eatContextual("as")) {
@@ -24653,41 +24676,28 @@ function importAssertions(Parser) {
24653
24676
  node.exported = null;
24654
24677
  }
24655
24678
  }
24656
-
24657
24679
  this.expectContextual("from");
24658
-
24659
- if (this.type !== tt.string) {
24660
- this.unexpected();
24661
- }
24662
-
24680
+ if (this.type !== tt.string) { this.unexpected(); }
24663
24681
  node.source = this.parseExprAtom();
24664
24682
 
24665
24683
  if (this.type === this.assertToken) {
24666
24684
  this.next();
24667
24685
  const assertions = this.parseImportAssertions();
24668
-
24669
24686
  if (assertions) {
24670
24687
  node.assertions = assertions;
24671
24688
  }
24672
24689
  }
24673
24690
 
24674
24691
  this.semicolon();
24675
- return this.finishNode(node, "ExportAllDeclaration");
24692
+ return this.finishNode(node, "ExportAllDeclaration")
24676
24693
  }
24677
-
24678
- if (this.eat(tt._default)) {
24679
- // export default ...
24694
+ if (this.eat(tt._default)) { // export default ...
24680
24695
  this.checkExport(exports, "default", this.lastTokStart);
24681
24696
  var isAsync;
24682
-
24683
24697
  if (this.type === tt._function || (isAsync = this.isAsyncFunction())) {
24684
24698
  var fNode = this.startNode();
24685
24699
  this.next();
24686
-
24687
- if (isAsync) {
24688
- this.next();
24689
- }
24690
-
24700
+ if (isAsync) { this.next(); }
24691
24701
  node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
24692
24702
  } else if (this.type === tt._class) {
24693
24703
  var cNode = this.startNode();
@@ -24696,38 +24706,27 @@ function importAssertions(Parser) {
24696
24706
  node.declaration = this.parseMaybeAssign();
24697
24707
  this.semicolon();
24698
24708
  }
24699
-
24700
- return this.finishNode(node, "ExportDefaultDeclaration");
24701
- } // export var|const|let|function|class ...
24702
-
24703
-
24709
+ return this.finishNode(node, "ExportDefaultDeclaration")
24710
+ }
24711
+ // export var|const|let|function|class ...
24704
24712
  if (this.shouldParseExportStatement()) {
24705
24713
  node.declaration = this.parseStatement(null);
24706
-
24707
- if (node.declaration.type === "VariableDeclaration") {
24708
- this.checkVariableExport(exports, node.declaration.declarations);
24709
- } else {
24710
- this.checkExport(exports, node.declaration.id.name, node.declaration.id.start);
24711
- }
24712
-
24714
+ if (node.declaration.type === "VariableDeclaration")
24715
+ { this.checkVariableExport(exports, node.declaration.declarations); }
24716
+ else
24717
+ { this.checkExport(exports, node.declaration.id.name, node.declaration.id.start); }
24713
24718
  node.specifiers = [];
24714
24719
  node.source = null;
24715
- } else {
24716
- // export { x, y as z } [from '...']
24720
+ } else { // export { x, y as z } [from '...']
24717
24721
  node.declaration = null;
24718
24722
  node.specifiers = this.parseExportSpecifiers(exports);
24719
-
24720
24723
  if (this.eatContextual("from")) {
24721
- if (this.type !== tt.string) {
24722
- this.unexpected();
24723
- }
24724
-
24724
+ if (this.type !== tt.string) { this.unexpected(); }
24725
24725
  node.source = this.parseExprAtom();
24726
24726
 
24727
24727
  if (this.type === this.assertToken) {
24728
24728
  this.next();
24729
24729
  const assertions = this.parseImportAssertions();
24730
-
24731
24730
  if (assertions) {
24732
24731
  node.assertions = assertions;
24733
24732
  }
@@ -24736,52 +24735,47 @@ function importAssertions(Parser) {
24736
24735
  for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
24737
24736
  // check for keywords used as local names
24738
24737
  var spec = list[i];
24739
- this.checkUnreserved(spec.local); // check if export is defined
24740
24738
 
24739
+ this.checkUnreserved(spec.local);
24740
+ // check if export is defined
24741
24741
  this.checkLocalExport(spec.local);
24742
24742
  }
24743
24743
 
24744
24744
  node.source = null;
24745
24745
  }
24746
-
24747
24746
  this.semicolon();
24748
24747
  }
24749
-
24750
- return this.finishNode(node, "ExportNamedDeclaration");
24748
+ return this.finishNode(node, "ExportNamedDeclaration")
24751
24749
  }
24752
24750
 
24753
24751
  parseImport(node) {
24754
- this.next(); // import '...'
24755
-
24752
+ this.next();
24753
+ // import '...'
24756
24754
  if (this.type === tt.string) {
24757
24755
  node.specifiers = [];
24758
24756
  node.source = this.parseExprAtom();
24759
24757
  } else {
24760
24758
  node.specifiers = this.parseImportSpecifiers();
24761
24759
  this.expectContextual("from");
24762
- node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();
24760
+ node.source =
24761
+ this.type === tt.string ? this.parseExprAtom() : this.unexpected();
24763
24762
  }
24764
24763
 
24765
24764
  if (this.type === this.assertToken) {
24766
24765
  this.next();
24767
24766
  const assertions = this.parseImportAssertions();
24768
-
24769
24767
  if (assertions) {
24770
24768
  node.assertions = assertions;
24771
24769
  }
24772
24770
  }
24773
-
24774
24771
  this.semicolon();
24775
24772
  return this.finishNode(node, "ImportDeclaration");
24776
24773
  }
24777
24774
 
24778
24775
  parseImportAssertions() {
24779
24776
  this._eat(tt.braceL);
24780
-
24781
24777
  const attrs = this.parseAssertEntries();
24782
-
24783
24778
  this._eat(tt.braceR);
24784
-
24785
24779
  return attrs;
24786
24780
  }
24787
24781
 
@@ -24794,38 +24788,40 @@ function importAssertions(Parser) {
24794
24788
  break;
24795
24789
  }
24796
24790
 
24797
- const node = this.startNode(); // parse AssertionKey : IdentifierName, StringLiteral
24791
+ const node = this.startNode();
24798
24792
 
24793
+ // parse AssertionKey : IdentifierName, StringLiteral
24799
24794
  let assertionKeyNode;
24800
-
24801
24795
  if (this.type === tt.string) {
24802
24796
  assertionKeyNode = this.parseLiteral(this.value);
24803
24797
  } else {
24804
24798
  assertionKeyNode = this.parseIdent(true);
24805
24799
  }
24806
-
24807
24800
  this.next();
24808
- node.key = assertionKeyNode; // check if we already have an entry for an attribute
24801
+ node.key = assertionKeyNode;
24802
+
24803
+ // check if we already have an entry for an attribute
24809
24804
  // if a duplicate entry is found, throw an error
24810
24805
  // for now this logic will come into play only when someone declares `type` twice
24811
-
24812
24806
  if (attrNames.has(node.key.name)) {
24813
24807
  this.raise(this.pos, "Duplicated key in assertions");
24814
24808
  }
24815
-
24816
24809
  attrNames.add(node.key.name);
24817
24810
 
24818
24811
  if (this.type !== tt.string) {
24819
- this.raise(this.pos, "Only string is supported as an assertion value");
24812
+ this.raise(
24813
+ this.pos,
24814
+ "Only string is supported as an assertion value"
24815
+ );
24820
24816
  }
24821
24817
 
24822
24818
  node.value = this.parseLiteral(this.value);
24819
+
24823
24820
  attrs.push(this.finishNode(node, "ImportAttribute"));
24824
24821
  } while (this.eat(tt.comma));
24825
24822
 
24826
24823
  return attrs;
24827
24824
  }
24828
-
24829
24825
  };
24830
24826
  }
24831
24827
 
@@ -24882,14 +24878,12 @@ const getOnwarn = (config) => {
24882
24878
  : defaultOnWarn;
24883
24879
  };
24884
24880
  const getAcorn = (config) => ({
24885
- allowAwaitOutsideFunction: true,
24886
24881
  ecmaVersion: 'latest',
24887
- preserveParens: false,
24888
24882
  sourceType: 'module',
24889
24883
  ...config.acorn
24890
24884
  });
24891
24885
  const getAcornInjectPlugins = (config) => [
24892
- importAssertions_1,
24886
+ importAssertions,
24893
24887
  ...ensureArray$1(config.acornInjectPlugins)
24894
24888
  ];
24895
24889
  const getCache = (config) => config.cache?.cache || config.cache;
@@ -24956,7 +24950,7 @@ const getModuleContext = (config, context) => {
24956
24950
  for (const [key, moduleContext] of Object.entries(configModuleContext)) {
24957
24951
  contextByModuleId[node_path.resolve(key)] = moduleContext;
24958
24952
  }
24959
- return id => contextByModuleId[id] || context;
24953
+ return id => contextByModuleId[id] ?? context;
24960
24954
  }
24961
24955
  return () => context;
24962
24956
  };