rollup 4.13.2 → 4.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.13.2
4
- Thu, 28 Mar 2024 14:13:03 GMT - commit b379a592234416a2084918b0eea4c81865a1579f
3
+ Rollup.js v4.14.1
4
+ Sun, 07 Apr 2024 07:35:08 GMT - commit 0b665c31833525c923c0fc20f43ebfca748c6670
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
8
8
  Released under the MIT License.
9
9
  */
10
- import { normalize, getImportPath, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, Program as Program$1, logRedeclarationError, CatchClause as CatchClause$1, logDuplicateArgumentNameError, CallExpression as CallExpression$1, logIllegalImportReassignment, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, Property as Property$1, logConstVariableReassignError, ExpressionStatement as ExpressionStatement$1, ArrowFunctionExpression as ArrowFunctionExpression$1, logMissingExport, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logParseError, logModuleParseError, error, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, Identifier as Identifier$1, logThisIsUndefined, getReadStringFunction, convertString, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logSyntheticNamedExportsNeedNamespaceExport, logMissingEntryExport, logInvalidFormatForTopLevelAwait, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, logCircularReexport, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logMissingNodeBuiltins, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, isAbsolute as isAbsolute$1, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logChunkInvalid, logInvalidOption, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logCannotAssignModuleToChunk, logAnonymousPluginCache, logDuplicatePluginName, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logUnknownOption, printQuotedStringList, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, relativeId, logBadLoader, logExternalModulesCannotBeTransformedToModules, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, logFileNameConflict, logAssetNotFinalisedForFileName, logChunkNotGeneratedForFileName, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidFunctionPluginHook, logInvalidAddonPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_TREESHAKE_MODULESIDEEFFECTS, URL_TREESHAKE, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_AMD_BASEPATH, logInvalidExportOptionValue, warnDeprecation, URL_OUTPUT_INTEROP, URL_OUTPUT_MANUALCHUNKS, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_GENERATEDCODE, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
10
+ import { normalize, getImportPath, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, Program as Program$1, logRedeclarationError, CatchClause as CatchClause$1, logDuplicateArgumentNameError, CallExpression as CallExpression$1, BLANK, logIllegalImportReassignment, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, Property as Property$1, logConstVariableReassignError, ExpressionStatement as ExpressionStatement$1, ArrowFunctionExpression as ArrowFunctionExpression$1, logMissingExport, EMPTY_SET, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logParseError, logModuleParseError, error, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, Identifier as Identifier$1, logThisIsUndefined, getReadStringFunction, convertString, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, EMPTY_OBJECT, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logSyntheticNamedExportsNeedNamespaceExport, logMissingEntryExport, logInvalidFormatForTopLevelAwait, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, logCircularReexport, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logMissingNodeBuiltins, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, isAbsolute as isAbsolute$1, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logChunkInvalid, logInvalidOption, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logCannotAssignModuleToChunk, logAnonymousPluginCache, logDuplicatePluginName, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logUnknownOption, printQuotedStringList, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, relativeId, logBadLoader, logExternalModulesCannotBeTransformedToModules, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, logFileNameConflict, logAssetNotFinalisedForFileName, logChunkNotGeneratedForFileName, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidFunctionPluginHook, logInvalidAddonPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_TREESHAKE_MODULESIDEEFFECTS, URL_TREESHAKE, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_AMD_BASEPATH, logInvalidExportOptionValue, warnDeprecation, URL_OUTPUT_INTEROP, URL_OUTPUT_MANUALCHUNKS, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_GENERATEDCODE, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
11
11
  import { relative, dirname, basename, extname, resolve as resolve$1 } from 'node:path';
12
12
  import require$$0$1, { win32, posix, isAbsolute, resolve } from 'path';
13
13
  import { parseAsync, xxhashBase64Url, xxhashBase36, xxhashBase16 } from '../../native.js';
@@ -16,7 +16,7 @@ import { performance } from 'node:perf_hooks';
16
16
  import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
17
17
  import * as tty from 'tty';
18
18
 
19
- var version = "4.13.2";
19
+ var version = "4.14.1";
20
20
 
21
21
  const comma = ','.charCodeAt(0);
22
22
  const semicolon = ';'.charCodeAt(0);
@@ -1349,21 +1349,29 @@ class MagicString {
1349
1349
  if (searchValue.global) {
1350
1350
  const matches = matchAll(searchValue, this.original);
1351
1351
  matches.forEach((match) => {
1352
- if (match.index != null)
1352
+ if (match.index != null) {
1353
+ const replacement = getReplacement(match, this.original);
1354
+ if (replacement !== match[0]) {
1355
+ this.overwrite(
1356
+ match.index,
1357
+ match.index + match[0].length,
1358
+ replacement
1359
+ );
1360
+ }
1361
+ }
1362
+ });
1363
+ } else {
1364
+ const match = this.original.match(searchValue);
1365
+ if (match && match.index != null) {
1366
+ const replacement = getReplacement(match, this.original);
1367
+ if (replacement !== match[0]) {
1353
1368
  this.overwrite(
1354
1369
  match.index,
1355
1370
  match.index + match[0].length,
1356
- getReplacement(match, this.original),
1371
+ replacement
1357
1372
  );
1358
- });
1359
- } else {
1360
- const match = this.original.match(searchValue);
1361
- if (match && match.index != null)
1362
- this.overwrite(
1363
- match.index,
1364
- match.index + match[0].length,
1365
- getReplacement(match, this.original),
1366
- );
1373
+ }
1374
+ }
1367
1375
  }
1368
1376
  return this;
1369
1377
  }
@@ -1395,7 +1403,9 @@ class MagicString {
1395
1403
  index !== -1;
1396
1404
  index = original.indexOf(string, index + stringLength)
1397
1405
  ) {
1398
- this.overwrite(index, index + stringLength, replacement);
1406
+ const previous = original.slice(index, index + stringLength);
1407
+ if (previous !== replacement)
1408
+ this.overwrite(index, index + stringLength, replacement);
1399
1409
  }
1400
1410
 
1401
1411
  return this;
@@ -2016,15 +2026,6 @@ class ExternalVariable extends Variable {
2016
2026
  }
2017
2027
  }
2018
2028
 
2019
- const BLANK = Object.freeze(Object.create(null));
2020
- const EMPTY_OBJECT = Object.freeze({});
2021
- const EMPTY_ARRAY = Object.freeze([]);
2022
- const EMPTY_SET = Object.freeze(new (class extends Set {
2023
- add() {
2024
- throw new Error('Cannot add to empty set');
2025
- }
2026
- })());
2027
-
2028
2029
  function cacheObjectGetters(object, getterProperties) {
2029
2030
  for (const property of getterProperties) {
2030
2031
  const propertyGetter = Object.getOwnPropertyDescriptor(object, property).get;
@@ -7284,13 +7285,7 @@ class GlobalVariable extends Variable {
7284
7285
  }
7285
7286
  }
7286
7287
 
7287
- const tdzVariableKinds = {
7288
- __proto__: null,
7289
- class: true,
7290
- const: true,
7291
- let: true,
7292
- var: true
7293
- };
7288
+ const tdzVariableKinds = new Set(['class', 'const', 'let', 'var', 'using', 'await using']);
7294
7289
  class Identifier extends NodeBase {
7295
7290
  constructor() {
7296
7291
  super(...arguments);
@@ -7336,6 +7331,8 @@ class Identifier extends NodeBase {
7336
7331
  }
7337
7332
  case 'let':
7338
7333
  case 'const':
7334
+ case 'using':
7335
+ case 'await using':
7339
7336
  case 'class': {
7340
7337
  variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
7341
7338
  break;
@@ -7418,7 +7415,7 @@ class Identifier extends NodeBase {
7418
7415
  return cachedTdzAccess;
7419
7416
  if (!(this.variable instanceof LocalVariable &&
7420
7417
  this.variable.kind &&
7421
- this.variable.kind in tdzVariableKinds &&
7418
+ tdzVariableKinds.has(this.variable.kind) &&
7422
7419
  // we ignore possible TDZs due to circular module dependencies as
7423
7420
  // otherwise we get many false positives
7424
7421
  this.variable.module === this.scope.context.module)) {
@@ -7927,15 +7924,12 @@ class FunctionBase extends NodeBase {
7927
7924
  }
7928
7925
  parseNode(esTreeNode) {
7929
7926
  const { body, params } = esTreeNode;
7930
- const parameters = (this.params = []);
7931
7927
  const { scope } = this;
7932
7928
  const { bodyScope, context } = scope;
7933
7929
  // We need to ensure that parameters are declared before the body is parsed
7934
7930
  // so that the scope already knows all parameters and can detect conflicts
7935
7931
  // when parsing the body.
7936
- for (const parameter of params) {
7937
- parameters.push(new (context.getNodeConstructor(parameter.type))(this, scope).parseNode(parameter));
7938
- }
7932
+ const parameters = (this.params = params.map((parameter) => new (context.getNodeConstructor(parameter.type))(this, scope).parseNode(parameter)));
7939
7933
  scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
7940
7934
  this.body = new (context.getNodeConstructor(body.type))(this, bodyScope).parseNode(body);
7941
7935
  return super.parseNode(esTreeNode);
@@ -10357,7 +10351,8 @@ function isReassignedExportsMember(variable, exportNamesByVariable) {
10357
10351
  }
10358
10352
 
10359
10353
  class VariableDeclarator extends NodeBase {
10360
- declareDeclarator(kind) {
10354
+ declareDeclarator(kind, isUsingDeclaration) {
10355
+ this.isUsingDeclaration = isUsingDeclaration;
10361
10356
  this.id.declare(kind, this.init || UNDEFINED_EXPRESSION);
10362
10357
  }
10363
10358
  deoptimizePath(path) {
@@ -10368,7 +10363,7 @@ class VariableDeclarator extends NodeBase {
10368
10363
  this.applyDeoptimizations();
10369
10364
  const initEffect = this.init?.hasEffects(context);
10370
10365
  this.id.markDeclarationReached();
10371
- return initEffect || this.id.hasEffects(context);
10366
+ return initEffect || this.id.hasEffects(context) || this.isUsingDeclaration;
10372
10367
  }
10373
10368
  include(context, includeChildrenRecursively) {
10374
10369
  const { deoptimized, id, init } = this;
@@ -10387,7 +10382,7 @@ class VariableDeclarator extends NodeBase {
10387
10382
  render(code, options) {
10388
10383
  const { exportNamesByVariable, snippets: { _, getPropertyAccess } } = options;
10389
10384
  const { end, id, init, start } = this;
10390
- const renderId = id.included;
10385
+ const renderId = id.included || this.isUsingDeclaration;
10391
10386
  if (renderId) {
10392
10387
  id.render(code, options);
10393
10388
  }
@@ -12064,15 +12059,17 @@ class VariableDeclaration extends NodeBase {
12064
12059
  }
12065
12060
  initialise() {
12066
12061
  super.initialise();
12062
+ this.isUsingDeclaration = this.kind === 'await using' || this.kind === 'using';
12067
12063
  for (const declarator of this.declarations) {
12068
- declarator.declareDeclarator(this.kind);
12064
+ declarator.declareDeclarator(this.kind, this.isUsingDeclaration);
12069
12065
  }
12070
12066
  }
12071
12067
  removeAnnotations(code) {
12072
12068
  this.declarations[0].removeAnnotations(code);
12073
12069
  }
12074
12070
  render(code, options, nodeRenderOptions = BLANK) {
12075
- if (areAllDeclarationsIncludedAndNotExported(this.declarations, options.exportNamesByVariable)) {
12071
+ if (this.isUsingDeclaration ||
12072
+ areAllDeclarationsIncludedAndNotExported(this.declarations, options.exportNamesByVariable)) {
12076
12073
  for (const declarator of this.declarations) {
12077
12074
  declarator.render(code, options);
12078
12075
  }
@@ -12398,18 +12395,18 @@ const nodeConstructors$1 = [
12398
12395
  ];
12399
12396
  const bufferParsers = [
12400
12397
  function panicError(node, position, buffer, readString) {
12401
- node.message = convertString(position, buffer, readString);
12398
+ node.message = convertString(buffer[position], buffer, readString);
12402
12399
  },
12403
12400
  function parseError(node, position, buffer, readString) {
12404
- node.message = convertString(position, buffer, readString);
12401
+ node.message = convertString(buffer[position], buffer, readString);
12405
12402
  },
12406
12403
  function arrayExpression(node, position, buffer, readString) {
12407
12404
  const { scope } = node;
12408
- node.elements = convertNodeList(node, scope, position, buffer, readString);
12405
+ node.elements = convertNodeList(node, scope, buffer[position], buffer, readString);
12409
12406
  },
12410
12407
  function arrayPattern(node, position, buffer, readString) {
12411
12408
  const { scope } = node;
12412
- node.elements = convertNodeList(node, scope, position, buffer, readString);
12409
+ node.elements = convertNodeList(node, scope, buffer[position], buffer, readString);
12413
12410
  },
12414
12411
  function arrowFunctionExpression(node, position, buffer, readString) {
12415
12412
  const { scope } = node;
@@ -12417,36 +12414,36 @@ const bufferParsers = [
12417
12414
  node.async = (flags & 1) === 1;
12418
12415
  node.expression = (flags & 2) === 2;
12419
12416
  node.generator = (flags & 4) === 4;
12420
- const parameters = (node.params = convertNodeList(node, scope, buffer[position + 1], buffer, readString));
12421
- scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
12422
- node.body = convertNode(node, scope.bodyScope, buffer[position + 2], buffer, readString);
12423
- const annotations = (node.annotations = convertAnnotations(position + 3, buffer));
12417
+ const annotations = (node.annotations = convertAnnotations(buffer[position + 1], buffer));
12424
12418
  node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
12419
+ const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer, readString));
12420
+ scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
12421
+ node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer, readString);
12425
12422
  },
12426
12423
  function assignmentExpression(node, position, buffer, readString) {
12427
12424
  const { scope } = node;
12428
12425
  node.operator = FIXED_STRINGS[buffer[position]];
12429
- node.right = convertNode(node, scope, buffer[position + 1], buffer, readString);
12430
- node.left = convertNode(node, scope, position + 2, buffer, readString);
12426
+ node.left = convertNode(node, scope, buffer[position + 1], buffer, readString);
12427
+ node.right = convertNode(node, scope, buffer[position + 2], buffer, readString);
12431
12428
  },
12432
12429
  function assignmentPattern(node, position, buffer, readString) {
12433
12430
  const { scope } = node;
12434
- node.right = convertNode(node, scope, buffer[position], buffer, readString);
12435
- node.left = convertNode(node, scope, position + 1, buffer, readString);
12431
+ node.left = convertNode(node, scope, buffer[position], buffer, readString);
12432
+ node.right = convertNode(node, scope, buffer[position + 1], buffer, readString);
12436
12433
  },
12437
12434
  function awaitExpression(node, position, buffer, readString) {
12438
12435
  const { scope } = node;
12439
- node.argument = convertNode(node, scope, position, buffer, readString);
12436
+ node.argument = convertNode(node, scope, buffer[position], buffer, readString);
12440
12437
  },
12441
12438
  function binaryExpression(node, position, buffer, readString) {
12442
12439
  const { scope } = node;
12443
12440
  node.operator = FIXED_STRINGS[buffer[position]];
12444
- node.right = convertNode(node, scope, buffer[position + 1], buffer, readString);
12445
- node.left = convertNode(node, scope, position + 2, buffer, readString);
12441
+ node.left = convertNode(node, scope, buffer[position + 1], buffer, readString);
12442
+ node.right = convertNode(node, scope, buffer[position + 2], buffer, readString);
12446
12443
  },
12447
12444
  function blockStatement(node, position, buffer, readString) {
12448
12445
  const { scope } = node;
12449
- node.body = convertNodeList(node, scope, position, buffer, readString);
12446
+ node.body = convertNodeList(node, scope, buffer[position], buffer, readString);
12450
12447
  },
12451
12448
  function breakStatement(node, position, buffer, readString) {
12452
12449
  const { scope } = node;
@@ -12458,9 +12455,9 @@ const bufferParsers = [
12458
12455
  const { scope } = node;
12459
12456
  const flags = buffer[position];
12460
12457
  node.optional = (flags & 1) === 1;
12461
- node.callee = convertNode(node, scope, buffer[position + 1], buffer, readString);
12462
- node.arguments = convertNodeList(node, scope, buffer[position + 2], buffer, readString);
12463
- node.annotations = convertAnnotations(position + 3, buffer);
12458
+ node.annotations = convertAnnotations(buffer[position + 1], buffer);
12459
+ node.callee = convertNode(node, scope, buffer[position + 2], buffer, readString);
12460
+ node.arguments = convertNodeList(node, scope, buffer[position + 3], buffer, readString);
12464
12461
  },
12465
12462
  function catchClause(node, position, buffer, readString) {
12466
12463
  const { scope } = node;
@@ -12474,15 +12471,18 @@ const bufferParsers = [
12474
12471
  },
12475
12472
  function chainExpression(node, position, buffer, readString) {
12476
12473
  const { scope } = node;
12477
- node.expression = convertNode(node, scope, position, buffer, readString);
12474
+ node.expression = convertNode(node, scope, buffer[position], buffer, readString);
12478
12475
  },
12479
12476
  function classBody(node, position, buffer, readString) {
12480
12477
  const { scope } = node;
12481
- const length = buffer[position];
12478
+ const bodyPosition = buffer[position];
12482
12479
  const body = (node.body = []);
12483
- for (let index = 0; index < length; index++) {
12484
- const nodePosition = buffer[position + 1 + index];
12485
- body.push(convertNode(node, (buffer[nodePosition + 3] & 1) === 0 ? scope.instanceScope : scope, nodePosition, buffer, readString));
12480
+ if (bodyPosition) {
12481
+ const length = buffer[bodyPosition];
12482
+ for (let index = 0; index < length; index++) {
12483
+ const nodePosition = buffer[bodyPosition + 1 + index];
12484
+ body.push(convertNode(node, (buffer[nodePosition + 3] & 1) === 0 ? scope.instanceScope : scope, nodePosition, buffer, readString));
12485
+ }
12486
12486
  }
12487
12487
  },
12488
12488
  function classDeclaration(node, position, buffer, readString) {
@@ -12512,9 +12512,9 @@ const bufferParsers = [
12512
12512
  },
12513
12513
  function conditionalExpression(node, position, buffer, readString) {
12514
12514
  const { scope } = node;
12515
- node.consequent = convertNode(node, scope, buffer[position], buffer, readString);
12516
- node.alternate = convertNode(node, scope, buffer[position + 1], buffer, readString);
12517
- node.test = convertNode(node, scope, position + 2, buffer, readString);
12515
+ node.test = convertNode(node, scope, buffer[position], buffer, readString);
12516
+ node.consequent = convertNode(node, scope, buffer[position + 1], buffer, readString);
12517
+ node.alternate = convertNode(node, scope, buffer[position + 2], buffer, readString);
12518
12518
  },
12519
12519
  function continueStatement(node, position, buffer, readString) {
12520
12520
  const { scope } = node;
@@ -12525,13 +12525,13 @@ const bufferParsers = [
12525
12525
  function debuggerStatement() { },
12526
12526
  function directive(node, position, buffer, readString) {
12527
12527
  const { scope } = node;
12528
- node.expression = convertNode(node, scope, buffer[position], buffer, readString);
12529
- node.directive = convertString(position + 1, buffer, readString);
12528
+ node.directive = convertString(buffer[position], buffer, readString);
12529
+ node.expression = convertNode(node, scope, buffer[position + 1], buffer, readString);
12530
12530
  },
12531
12531
  function doWhileStatement(node, position, buffer, readString) {
12532
12532
  const { scope } = node;
12533
- node.test = convertNode(node, scope, buffer[position], buffer, readString);
12534
- node.body = convertNode(node, scope, position + 1, buffer, readString);
12533
+ node.body = convertNode(node, scope, buffer[position], buffer, readString);
12534
+ node.test = convertNode(node, scope, buffer[position + 1], buffer, readString);
12535
12535
  },
12536
12536
  function emptyStatement() { },
12537
12537
  function exportAllDeclaration(node, position, buffer, readString) {
@@ -12546,25 +12546,25 @@ const bufferParsers = [
12546
12546
  },
12547
12547
  function exportDefaultDeclaration(node, position, buffer, readString) {
12548
12548
  const { scope } = node;
12549
- node.declaration = convertNode(node, scope, position, buffer, readString);
12549
+ node.declaration = convertNode(node, scope, buffer[position], buffer, readString);
12550
12550
  },
12551
12551
  function exportNamedDeclaration(node, position, buffer, readString) {
12552
12552
  const { scope } = node;
12553
- const sourcePosition = buffer[position];
12553
+ node.specifiers = convertNodeList(node, scope, buffer[position], buffer, readString);
12554
+ const sourcePosition = buffer[position + 1];
12554
12555
  node.source =
12555
12556
  sourcePosition === 0 ? null : convertNode(node, scope, sourcePosition, buffer, readString);
12556
- node.attributes = convertNodeList(node, scope, buffer[position + 1], buffer, readString);
12557
- const declarationPosition = buffer[position + 2];
12557
+ node.attributes = convertNodeList(node, scope, buffer[position + 2], buffer, readString);
12558
+ const declarationPosition = buffer[position + 3];
12558
12559
  node.declaration =
12559
12560
  declarationPosition === 0
12560
12561
  ? null
12561
12562
  : convertNode(node, scope, declarationPosition, buffer, readString);
12562
- node.specifiers = convertNodeList(node, scope, position + 3, buffer, readString);
12563
12563
  },
12564
12564
  function exportSpecifier(node, position, buffer, readString) {
12565
12565
  const { scope } = node;
12566
- const exportedPosition = buffer[position];
12567
- node.local = convertNode(node, scope, position + 1, buffer, readString);
12566
+ node.local = convertNode(node, scope, buffer[position], buffer, readString);
12567
+ const exportedPosition = buffer[position + 1];
12568
12568
  node.exported =
12569
12569
  exportedPosition === 0
12570
12570
  ? node.local
@@ -12572,21 +12572,21 @@ const bufferParsers = [
12572
12572
  },
12573
12573
  function expressionStatement(node, position, buffer, readString) {
12574
12574
  const { scope } = node;
12575
- node.expression = convertNode(node, scope, position, buffer, readString);
12575
+ node.expression = convertNode(node, scope, buffer[position], buffer, readString);
12576
12576
  },
12577
12577
  function forInStatement(node, position, buffer, readString) {
12578
12578
  const { scope } = node;
12579
- node.right = convertNode(node, scope, buffer[position], buffer, readString);
12580
- node.body = convertNode(node, scope, buffer[position + 1], buffer, readString);
12581
- node.left = convertNode(node, scope, position + 2, buffer, readString);
12579
+ node.left = convertNode(node, scope, buffer[position], buffer, readString);
12580
+ node.right = convertNode(node, scope, buffer[position + 1], buffer, readString);
12581
+ node.body = convertNode(node, scope, buffer[position + 2], buffer, readString);
12582
12582
  },
12583
12583
  function forOfStatement(node, position, buffer, readString) {
12584
12584
  const { scope } = node;
12585
12585
  const flags = buffer[position];
12586
12586
  node.await = (flags & 1) === 1;
12587
- node.right = convertNode(node, scope, buffer[position + 1], buffer, readString);
12588
- node.body = convertNode(node, scope, buffer[position + 2], buffer, readString);
12589
- node.left = convertNode(node, scope, position + 3, buffer, readString);
12587
+ node.left = convertNode(node, scope, buffer[position + 1], buffer, readString);
12588
+ node.right = convertNode(node, scope, buffer[position + 2], buffer, readString);
12589
+ node.body = convertNode(node, scope, buffer[position + 3], buffer, readString);
12590
12590
  },
12591
12591
  function forStatement(node, position, buffer, readString) {
12592
12592
  const { scope } = node;
@@ -12606,70 +12606,70 @@ const bufferParsers = [
12606
12606
  const flags = buffer[position];
12607
12607
  node.async = (flags & 1) === 1;
12608
12608
  node.generator = (flags & 2) === 2;
12609
- const idPosition = buffer[position + 1];
12609
+ const annotations = (node.annotations = convertAnnotations(buffer[position + 1], buffer));
12610
+ node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
12611
+ const idPosition = buffer[position + 2];
12610
12612
  node.id =
12611
12613
  idPosition === 0
12612
12614
  ? null
12613
12615
  : convertNode(node, scope.parent, idPosition, buffer, readString);
12614
- const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer, readString));
12616
+ const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer, readString));
12615
12617
  scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
12616
- node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer, readString);
12617
- const annotations = (node.annotations = convertAnnotations(position + 4, buffer));
12618
- node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
12618
+ node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer, readString);
12619
12619
  },
12620
12620
  function functionExpression(node, position, buffer, readString) {
12621
12621
  const { scope } = node;
12622
12622
  const flags = buffer[position];
12623
12623
  node.async = (flags & 1) === 1;
12624
12624
  node.generator = (flags & 2) === 2;
12625
- const idPosition = buffer[position + 1];
12625
+ const annotations = (node.annotations = convertAnnotations(buffer[position + 1], buffer));
12626
+ node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
12627
+ const idPosition = buffer[position + 2];
12626
12628
  node.id =
12627
12629
  idPosition === 0 ? null : convertNode(node, node.idScope, idPosition, buffer, readString);
12628
- const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer, readString));
12630
+ const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer, readString));
12629
12631
  scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
12630
- node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer, readString);
12631
- const annotations = (node.annotations = convertAnnotations(position + 4, buffer));
12632
- node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
12632
+ node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer, readString);
12633
12633
  },
12634
12634
  function identifier(node, position, buffer, readString) {
12635
- node.name = convertString(position, buffer, readString);
12635
+ node.name = convertString(buffer[position], buffer, readString);
12636
12636
  },
12637
12637
  function ifStatement(node, position, buffer, readString) {
12638
12638
  const { scope } = node;
12639
- node.consequent = convertNode(node, (node.consequentScope = new TrackingScope(scope)), buffer[position], buffer, readString);
12640
- const alternatePosition = buffer[position + 1];
12639
+ node.test = convertNode(node, scope, buffer[position], buffer, readString);
12640
+ node.consequent = convertNode(node, (node.consequentScope = new TrackingScope(scope)), buffer[position + 1], buffer, readString);
12641
+ const alternatePosition = buffer[position + 2];
12641
12642
  node.alternate =
12642
12643
  alternatePosition === 0
12643
12644
  ? null
12644
12645
  : convertNode(node, (node.alternateScope = new TrackingScope(scope)), alternatePosition, buffer, readString);
12645
- node.test = convertNode(node, scope, position + 2, buffer, readString);
12646
12646
  },
12647
12647
  function importAttribute(node, position, buffer, readString) {
12648
12648
  const { scope } = node;
12649
- node.value = convertNode(node, scope, buffer[position], buffer, readString);
12650
- node.key = convertNode(node, scope, position + 1, buffer, readString);
12649
+ node.key = convertNode(node, scope, buffer[position], buffer, readString);
12650
+ node.value = convertNode(node, scope, buffer[position + 1], buffer, readString);
12651
12651
  },
12652
12652
  function importDeclaration(node, position, buffer, readString) {
12653
12653
  const { scope } = node;
12654
- node.source = convertNode(node, scope, buffer[position], buffer, readString);
12655
- node.attributes = convertNodeList(node, scope, buffer[position + 1], buffer, readString);
12656
- node.specifiers = convertNodeList(node, scope, position + 2, buffer, readString);
12654
+ node.specifiers = convertNodeList(node, scope, buffer[position], buffer, readString);
12655
+ node.source = convertNode(node, scope, buffer[position + 1], buffer, readString);
12656
+ node.attributes = convertNodeList(node, scope, buffer[position + 2], buffer, readString);
12657
12657
  },
12658
12658
  function importDefaultSpecifier(node, position, buffer, readString) {
12659
12659
  const { scope } = node;
12660
- node.local = convertNode(node, scope, position, buffer, readString);
12660
+ node.local = convertNode(node, scope, buffer[position], buffer, readString);
12661
12661
  },
12662
12662
  function importExpression(node, position, buffer, readString) {
12663
12663
  const { scope } = node;
12664
- const optionsPosition = buffer[position];
12664
+ node.source = convertNode(node, scope, buffer[position], buffer, readString);
12665
+ node.sourceAstNode = convertNode$1(buffer[position], buffer, readString);
12666
+ const optionsPosition = buffer[position + 1];
12665
12667
  node.options =
12666
12668
  optionsPosition === 0 ? null : convertNode(node, scope, optionsPosition, buffer, readString);
12667
- node.source = convertNode(node, scope, position + 1, buffer, readString);
12668
- node.sourceAstNode = convertNode$1(position + 1, buffer, readString);
12669
12669
  },
12670
12670
  function importNamespaceSpecifier(node, position, buffer, readString) {
12671
12671
  const { scope } = node;
12672
- node.local = convertNode(node, scope, position, buffer, readString);
12672
+ node.local = convertNode(node, scope, buffer[position], buffer, readString);
12673
12673
  },
12674
12674
  function importSpecifier(node, position, buffer, readString) {
12675
12675
  const { scope } = node;
@@ -12682,12 +12682,12 @@ const bufferParsers = [
12682
12682
  },
12683
12683
  function labeledStatement(node, position, buffer, readString) {
12684
12684
  const { scope } = node;
12685
- node.body = convertNode(node, scope, buffer[position], buffer, readString);
12686
- node.label = convertNode(node, scope, position + 1, buffer, readString);
12685
+ node.label = convertNode(node, scope, buffer[position], buffer, readString);
12686
+ node.body = convertNode(node, scope, buffer[position + 1], buffer, readString);
12687
12687
  },
12688
12688
  function literalBigInt(node, position, buffer, readString) {
12689
- node.raw = convertString(buffer[position], buffer, readString);
12690
- const bigint = (node.bigint = convertString(position + 1, buffer, readString));
12689
+ const bigint = (node.bigint = convertString(buffer[position], buffer, readString));
12690
+ node.raw = convertString(buffer[position + 1], buffer, readString);
12691
12691
  node.value = BigInt(bigint);
12692
12692
  },
12693
12693
  function literalBoolean(node, position, buffer) {
@@ -12704,66 +12704,66 @@ const bufferParsers = [
12704
12704
  node.value = new DataView(buffer.buffer).getFloat64((position + 1) << 2, true);
12705
12705
  },
12706
12706
  function literalRegExp(node, position, buffer, readString) {
12707
- const pattern = convertString(buffer[position], buffer, readString);
12708
- const flags = convertString(position + 1, buffer, readString);
12707
+ const flags = convertString(buffer[position], buffer, readString);
12708
+ const pattern = convertString(buffer[position + 1], buffer, readString);
12709
12709
  node.raw = `/${pattern}/${flags}`;
12710
12710
  node.regex = { flags, pattern };
12711
12711
  node.value = new RegExp(pattern, flags);
12712
12712
  },
12713
12713
  function literalString(node, position, buffer, readString) {
12714
- const rawPosition = buffer[position];
12714
+ node.value = convertString(buffer[position], buffer, readString);
12715
+ const rawPosition = buffer[position + 1];
12715
12716
  node.raw = rawPosition === 0 ? undefined : convertString(rawPosition, buffer, readString);
12716
- node.value = convertString(position + 1, buffer, readString);
12717
12717
  },
12718
12718
  function logicalExpression(node, position, buffer, readString) {
12719
12719
  const { scope } = node;
12720
12720
  node.operator = FIXED_STRINGS[buffer[position]];
12721
- node.right = convertNode(node, scope, buffer[position + 1], buffer, readString);
12722
- node.left = convertNode(node, scope, position + 2, buffer, readString);
12721
+ node.left = convertNode(node, scope, buffer[position + 1], buffer, readString);
12722
+ node.right = convertNode(node, scope, buffer[position + 2], buffer, readString);
12723
12723
  },
12724
12724
  function memberExpression(node, position, buffer, readString) {
12725
12725
  const { scope } = node;
12726
12726
  const flags = buffer[position];
12727
12727
  node.computed = (flags & 1) === 1;
12728
12728
  node.optional = (flags & 2) === 2;
12729
- node.property = convertNode(node, scope, buffer[position + 1], buffer, readString);
12730
- node.object = convertNode(node, scope, position + 2, buffer, readString);
12729
+ node.object = convertNode(node, scope, buffer[position + 1], buffer, readString);
12730
+ node.property = convertNode(node, scope, buffer[position + 2], buffer, readString);
12731
12731
  },
12732
12732
  function metaProperty(node, position, buffer, readString) {
12733
12733
  const { scope } = node;
12734
- node.property = convertNode(node, scope, buffer[position], buffer, readString);
12735
- node.meta = convertNode(node, scope, position + 1, buffer, readString);
12734
+ node.meta = convertNode(node, scope, buffer[position], buffer, readString);
12735
+ node.property = convertNode(node, scope, buffer[position + 1], buffer, readString);
12736
12736
  },
12737
12737
  function methodDefinition(node, position, buffer, readString) {
12738
12738
  const { scope } = node;
12739
12739
  const flags = buffer[position];
12740
12740
  node.static = (flags & 1) === 1;
12741
12741
  node.computed = (flags & 2) === 2;
12742
- node.value = convertNode(node, scope, buffer[position + 1], buffer, readString);
12743
- node.kind = FIXED_STRINGS[buffer[position + 2]];
12744
- node.key = convertNode(node, scope, position + 3, buffer, readString);
12742
+ node.key = convertNode(node, scope, buffer[position + 1], buffer, readString);
12743
+ node.value = convertNode(node, scope, buffer[position + 2], buffer, readString);
12744
+ node.kind = FIXED_STRINGS[buffer[position + 3]];
12745
12745
  },
12746
12746
  function newExpression(node, position, buffer, readString) {
12747
12747
  const { scope } = node;
12748
- node.callee = convertNode(node, scope, buffer[position], buffer, readString);
12749
- node.arguments = convertNodeList(node, scope, buffer[position + 1], buffer, readString);
12750
- node.annotations = convertAnnotations(position + 2, buffer);
12748
+ node.annotations = convertAnnotations(buffer[position], buffer);
12749
+ node.callee = convertNode(node, scope, buffer[position + 1], buffer, readString);
12750
+ node.arguments = convertNodeList(node, scope, buffer[position + 2], buffer, readString);
12751
12751
  },
12752
12752
  function objectExpression(node, position, buffer, readString) {
12753
12753
  const { scope } = node;
12754
- node.properties = convertNodeList(node, scope, position, buffer, readString);
12754
+ node.properties = convertNodeList(node, scope, buffer[position], buffer, readString);
12755
12755
  },
12756
12756
  function objectPattern(node, position, buffer, readString) {
12757
12757
  const { scope } = node;
12758
- node.properties = convertNodeList(node, scope, position, buffer, readString);
12758
+ node.properties = convertNodeList(node, scope, buffer[position], buffer, readString);
12759
12759
  },
12760
12760
  function privateIdentifier(node, position, buffer, readString) {
12761
- node.name = convertString(position, buffer, readString);
12761
+ node.name = convertString(buffer[position], buffer, readString);
12762
12762
  },
12763
12763
  function program(node, position, buffer, readString) {
12764
12764
  const { scope } = node;
12765
- node.invalidAnnotations = convertAnnotations(buffer[position], buffer);
12766
- node.body = convertNodeList(node, scope, position + 1, buffer, readString);
12765
+ node.body = convertNodeList(node, scope, buffer[position], buffer, readString);
12766
+ node.invalidAnnotations = convertAnnotations(buffer[position + 1], buffer);
12767
12767
  },
12768
12768
  function property(node, position, buffer, readString) {
12769
12769
  const { scope } = node;
@@ -12782,14 +12782,14 @@ const bufferParsers = [
12782
12782
  const flags = buffer[position];
12783
12783
  node.static = (flags & 1) === 1;
12784
12784
  node.computed = (flags & 2) === 2;
12785
- const valuePosition = buffer[position + 1];
12785
+ node.key = convertNode(node, scope, buffer[position + 1], buffer, readString);
12786
+ const valuePosition = buffer[position + 2];
12786
12787
  node.value =
12787
12788
  valuePosition === 0 ? null : convertNode(node, scope, valuePosition, buffer, readString);
12788
- node.key = convertNode(node, scope, position + 2, buffer, readString);
12789
12789
  },
12790
12790
  function restElement(node, position, buffer, readString) {
12791
12791
  const { scope } = node;
12792
- node.argument = convertNode(node, scope, position, buffer, readString);
12792
+ node.argument = convertNode(node, scope, buffer[position], buffer, readString);
12793
12793
  },
12794
12794
  function returnStatement(node, position, buffer, readString) {
12795
12795
  const { scope } = node;
@@ -12801,15 +12801,15 @@ const bufferParsers = [
12801
12801
  },
12802
12802
  function sequenceExpression(node, position, buffer, readString) {
12803
12803
  const { scope } = node;
12804
- node.expressions = convertNodeList(node, scope, position, buffer, readString);
12804
+ node.expressions = convertNodeList(node, scope, buffer[position], buffer, readString);
12805
12805
  },
12806
12806
  function spreadElement(node, position, buffer, readString) {
12807
12807
  const { scope } = node;
12808
- node.argument = convertNode(node, scope, position, buffer, readString);
12808
+ node.argument = convertNode(node, scope, buffer[position], buffer, readString);
12809
12809
  },
12810
12810
  function staticBlock(node, position, buffer, readString) {
12811
12811
  const { scope } = node;
12812
- node.body = convertNodeList(node, scope, position, buffer, readString);
12812
+ node.body = convertNodeList(node, scope, buffer[position], buffer, readString);
12813
12813
  },
12814
12814
  function superElement() { },
12815
12815
  function switchCase(node, position, buffer, readString) {
@@ -12821,72 +12821,72 @@ const bufferParsers = [
12821
12821
  },
12822
12822
  function switchStatement(node, position, buffer, readString) {
12823
12823
  const { scope } = node;
12824
- node.cases = convertNodeList(node, scope, buffer[position], buffer, readString);
12825
- node.discriminant = convertNode(node, node.parentScope, position + 1, buffer, readString);
12824
+ node.discriminant = convertNode(node, node.parentScope, buffer[position], buffer, readString);
12825
+ node.cases = convertNodeList(node, scope, buffer[position + 1], buffer, readString);
12826
12826
  },
12827
12827
  function taggedTemplateExpression(node, position, buffer, readString) {
12828
12828
  const { scope } = node;
12829
- node.quasi = convertNode(node, scope, buffer[position], buffer, readString);
12830
- node.tag = convertNode(node, scope, position + 1, buffer, readString);
12829
+ node.tag = convertNode(node, scope, buffer[position], buffer, readString);
12830
+ node.quasi = convertNode(node, scope, buffer[position + 1], buffer, readString);
12831
12831
  },
12832
12832
  function templateElement(node, position, buffer, readString) {
12833
12833
  const flags = buffer[position];
12834
12834
  node.tail = (flags & 1) === 1;
12835
12835
  const cookedPosition = buffer[position + 1];
12836
12836
  const cooked = cookedPosition === 0 ? undefined : convertString(cookedPosition, buffer, readString);
12837
- const raw = convertString(position + 2, buffer, readString);
12837
+ const raw = convertString(buffer[position + 2], buffer, readString);
12838
12838
  node.value = { cooked, raw };
12839
12839
  },
12840
12840
  function templateLiteral(node, position, buffer, readString) {
12841
12841
  const { scope } = node;
12842
- node.expressions = convertNodeList(node, scope, buffer[position], buffer, readString);
12843
- node.quasis = convertNodeList(node, scope, position + 1, buffer, readString);
12842
+ node.quasis = convertNodeList(node, scope, buffer[position], buffer, readString);
12843
+ node.expressions = convertNodeList(node, scope, buffer[position + 1], buffer, readString);
12844
12844
  },
12845
12845
  function thisExpression() { },
12846
12846
  function throwStatement(node, position, buffer, readString) {
12847
12847
  const { scope } = node;
12848
- node.argument = convertNode(node, scope, position, buffer, readString);
12848
+ node.argument = convertNode(node, scope, buffer[position], buffer, readString);
12849
12849
  },
12850
12850
  function tryStatement(node, position, buffer, readString) {
12851
12851
  const { scope } = node;
12852
- const handlerPosition = buffer[position];
12852
+ node.block = convertNode(node, scope, buffer[position], buffer, readString);
12853
+ const handlerPosition = buffer[position + 1];
12853
12854
  node.handler =
12854
12855
  handlerPosition === 0 ? null : convertNode(node, scope, handlerPosition, buffer, readString);
12855
- const finalizerPosition = buffer[position + 1];
12856
+ const finalizerPosition = buffer[position + 2];
12856
12857
  node.finalizer =
12857
12858
  finalizerPosition === 0
12858
12859
  ? null
12859
12860
  : convertNode(node, scope, finalizerPosition, buffer, readString);
12860
- node.block = convertNode(node, scope, position + 2, buffer, readString);
12861
12861
  },
12862
12862
  function unaryExpression(node, position, buffer, readString) {
12863
12863
  const { scope } = node;
12864
12864
  node.operator = FIXED_STRINGS[buffer[position]];
12865
- node.argument = convertNode(node, scope, position + 1, buffer, readString);
12865
+ node.argument = convertNode(node, scope, buffer[position + 1], buffer, readString);
12866
12866
  },
12867
12867
  function updateExpression(node, position, buffer, readString) {
12868
12868
  const { scope } = node;
12869
12869
  const flags = buffer[position];
12870
12870
  node.prefix = (flags & 1) === 1;
12871
12871
  node.operator = FIXED_STRINGS[buffer[position + 1]];
12872
- node.argument = convertNode(node, scope, position + 2, buffer, readString);
12872
+ node.argument = convertNode(node, scope, buffer[position + 2], buffer, readString);
12873
12873
  },
12874
12874
  function variableDeclaration(node, position, buffer, readString) {
12875
12875
  const { scope } = node;
12876
12876
  node.kind = FIXED_STRINGS[buffer[position]];
12877
- node.declarations = convertNodeList(node, scope, position + 1, buffer, readString);
12877
+ node.declarations = convertNodeList(node, scope, buffer[position + 1], buffer, readString);
12878
12878
  },
12879
12879
  function variableDeclarator(node, position, buffer, readString) {
12880
12880
  const { scope } = node;
12881
- const initPosition = buffer[position];
12881
+ node.id = convertNode(node, scope, buffer[position], buffer, readString);
12882
+ const initPosition = buffer[position + 1];
12882
12883
  node.init =
12883
12884
  initPosition === 0 ? null : convertNode(node, scope, initPosition, buffer, readString);
12884
- node.id = convertNode(node, scope, position + 1, buffer, readString);
12885
12885
  },
12886
12886
  function whileStatement(node, position, buffer, readString) {
12887
12887
  const { scope } = node;
12888
- node.body = convertNode(node, scope, buffer[position], buffer, readString);
12889
- node.test = convertNode(node, scope, position + 1, buffer, readString);
12888
+ node.test = convertNode(node, scope, buffer[position], buffer, readString);
12889
+ node.body = convertNode(node, scope, buffer[position + 1], buffer, readString);
12890
12890
  },
12891
12891
  function yieldExpression(node, position, buffer, readString) {
12892
12892
  const { scope } = node;
@@ -12916,6 +12916,8 @@ function convertNode(parent, parentScope, position, buffer, readString) {
12916
12916
  return node;
12917
12917
  }
12918
12918
  function convertNodeList(parent, parentScope, position, buffer, readString) {
12919
+ if (position === 0)
12920
+ return EMPTY_ARRAY;
12919
12921
  const length = buffer[position++];
12920
12922
  const list = [];
12921
12923
  for (let index = 0; index < length; index++) {
@@ -20716,6 +20718,19 @@ function handleError(error, recover = false) {
20716
20718
  if (error.stack) {
20717
20719
  outputLines.push(dim(error.stack?.replace(`${nameSection}${error.message}\n`, '')));
20718
20720
  }
20721
+ // ES2022: Error.prototype.cause is optional
20722
+ if (error.cause) {
20723
+ let cause = error.cause;
20724
+ const causeErrorLines = [];
20725
+ let indent = '';
20726
+ while (cause) {
20727
+ indent += ' ';
20728
+ const message = cause.stack || cause;
20729
+ causeErrorLines.push(...`[cause] ${message}`.split('\n').map(line => indent + line));
20730
+ cause = cause.cause;
20731
+ }
20732
+ outputLines.push(dim(causeErrorLines.join('\n')));
20733
+ }
20719
20734
  outputLines.push('', '');
20720
20735
  stderr(outputLines.join('\n'));
20721
20736
  if (!recover)