@rollup/wasm-node 4.11.0 → 4.12.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,22 +1,22 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.11.0
4
- Thu, 15 Feb 2024 06:09:01 GMT - commit 90ad652b745c5fe7167d92b4ad671cc387577a99
3
+ Rollup.js v4.12.1
4
+ Wed, 06 Mar 2024 06:02:59 GMT - commit f44dac3170a671b0978afa3af43818617904f544
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, logInvalidAnnotation, logRedeclarationError, logDuplicateArgumentNameError, logIllegalImportReassignment, logModuleLevelDirective, logConstVariableReassignError, logMissingExport, logCannotCallNamespace, logEval, LOGLEVEL_INFO, logFirstSideEffect, locate, logThisIsUndefined, logImportAttributeIsInvalid, logImportOptionsAreInvalid, error, logSyntheticNamedExportsNeedNamespaceExport, logMissingEntryExport, logInvalidFormatForTopLevelAwait, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, logModuleParseError, parseAstAsync, logCircularReexport, 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, relativeId, LOGLEVEL_DEBUG, logUnknownOption, printQuotedStringList, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, 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, 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, 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, relativeId, LOGLEVEL_DEBUG, logUnknownOption, printQuotedStringList, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, 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, 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
+ import { parseAsync, xxhashBase64Url, xxhashBase36, xxhashBase16 } from '../../native.js';
13
14
  import process$1, { env as env$1 } from 'node:process';
14
15
  import { performance } from 'node:perf_hooks';
15
- import { xxhashBase64Url, xxhashBase36, xxhashBase16 } from '../../native.js';
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.11.0";
19
+ var version = "4.12.1";
20
20
 
21
21
  const comma = ','.charCodeAt(0);
22
22
  const semicolon = ';'.charCodeAt(0);
@@ -4617,13 +4617,83 @@ function getMemberReturnExpressionWhenCalled(members, memberName) {
4617
4617
  return [members[memberName].returns, false];
4618
4618
  }
4619
4619
 
4620
- const keys = {
4620
+ // This file is generated by scripts/generate-ast-converters.js.
4621
+ // Do not edit this file directly.
4622
+ const childNodeKeys = {
4623
+ ArrayExpression: ['elements'],
4624
+ ArrayPattern: ['elements'],
4625
+ ArrowFunctionExpression: ['params', 'body'],
4626
+ AssignmentExpression: ['left', 'right'],
4627
+ AssignmentPattern: ['left', 'right'],
4628
+ AwaitExpression: ['argument'],
4629
+ BinaryExpression: ['left', 'right'],
4630
+ BlockStatement: ['body'],
4631
+ BreakStatement: ['label'],
4632
+ CallExpression: ['callee', 'arguments'],
4633
+ CatchClause: ['param', 'body'],
4634
+ ChainExpression: ['expression'],
4635
+ ClassBody: ['body'],
4636
+ ClassDeclaration: ['id', 'superClass', 'body'],
4637
+ ClassExpression: ['id', 'superClass', 'body'],
4638
+ ConditionalExpression: ['test', 'consequent', 'alternate'],
4639
+ ContinueStatement: ['label'],
4640
+ DebuggerStatement: [],
4641
+ DoWhileStatement: ['body', 'test'],
4642
+ EmptyStatement: [],
4643
+ ExportAllDeclaration: ['exported', 'source', 'attributes'],
4644
+ ExportDefaultDeclaration: ['declaration'],
4645
+ ExportNamedDeclaration: ['specifiers', 'source', 'attributes', 'declaration'],
4646
+ ExportSpecifier: ['local', 'exported'],
4647
+ ExpressionStatement: ['expression'],
4648
+ ForInStatement: ['left', 'right', 'body'],
4649
+ ForOfStatement: ['left', 'right', 'body'],
4650
+ ForStatement: ['init', 'test', 'update', 'body'],
4651
+ FunctionDeclaration: ['id', 'params', 'body'],
4652
+ FunctionExpression: ['id', 'params', 'body'],
4653
+ Identifier: [],
4654
+ IfStatement: ['test', 'consequent', 'alternate'],
4655
+ ImportAttribute: ['key', 'value'],
4656
+ ImportDeclaration: ['specifiers', 'source', 'attributes'],
4657
+ ImportDefaultSpecifier: ['local'],
4658
+ ImportExpression: ['source', 'options'],
4659
+ ImportNamespaceSpecifier: ['local'],
4660
+ ImportSpecifier: ['imported', 'local'],
4661
+ LabeledStatement: ['label', 'body'],
4621
4662
  Literal: [],
4622
- Program: ['body']
4663
+ LogicalExpression: ['left', 'right'],
4664
+ MemberExpression: ['object', 'property'],
4665
+ MetaProperty: ['meta', 'property'],
4666
+ MethodDefinition: ['key', 'value'],
4667
+ NewExpression: ['callee', 'arguments'],
4668
+ ObjectExpression: ['properties'],
4669
+ ObjectPattern: ['properties'],
4670
+ PanicError: [],
4671
+ ParseError: [],
4672
+ PrivateIdentifier: [],
4673
+ Program: ['body'],
4674
+ Property: ['key', 'value'],
4675
+ PropertyDefinition: ['key', 'value'],
4676
+ RestElement: ['argument'],
4677
+ ReturnStatement: ['argument'],
4678
+ SequenceExpression: ['expressions'],
4679
+ SpreadElement: ['argument'],
4680
+ StaticBlock: ['body'],
4681
+ Super: [],
4682
+ SwitchCase: ['test', 'consequent'],
4683
+ SwitchStatement: ['discriminant', 'cases'],
4684
+ TaggedTemplateExpression: ['tag', 'quasi'],
4685
+ TemplateElement: [],
4686
+ TemplateLiteral: ['quasis', 'expressions'],
4687
+ ThisExpression: [],
4688
+ ThrowStatement: ['argument'],
4689
+ TryStatement: ['block', 'handler', 'finalizer'],
4690
+ UnaryExpression: ['argument'],
4691
+ UpdateExpression: ['argument'],
4692
+ VariableDeclaration: ['declarations'],
4693
+ VariableDeclarator: ['id', 'init'],
4694
+ WhileStatement: ['test', 'body'],
4695
+ YieldExpression: ['argument']
4623
4696
  };
4624
- function createKeysForNode(esTreeNode) {
4625
- return Object.keys(esTreeNode).filter(key => typeof esTreeNode[key] === 'object' && key.charCodeAt(0) !== 95 /* _ */);
4626
- }
4627
4697
 
4628
4698
  const INCLUDE_PARAMETERS = 'variables';
4629
4699
  class NodeBase extends ExpressionEntity {
@@ -4639,22 +4709,11 @@ class NodeBase extends ExpressionEntity {
4639
4709
  set deoptimized(value) {
4640
4710
  this.flags = setFlag(this.flags, 2 /* Flag.deoptimized */, value);
4641
4711
  }
4642
- constructor(esTreeNode, parent, parentScope, keepEsTreeNode = false) {
4712
+ constructor(parent, parentScope) {
4643
4713
  super();
4644
- // Nodes can opt-in to keep the AST if needed during the build pipeline.
4645
- // Avoid true when possible as large AST takes up memory.
4646
- if (keepEsTreeNode) {
4647
- this.esTreeNode = esTreeNode;
4648
- }
4649
- const { type } = esTreeNode;
4650
- keys[type] ||= createKeysForNode(esTreeNode);
4651
4714
  this.parent = parent;
4652
4715
  this.scope = parentScope;
4653
4716
  this.createScope(parentScope);
4654
- this.parseNode(esTreeNode);
4655
- this.initialise();
4656
- this.scope.context.magicString.addSourcemapLocation(this.start);
4657
- this.scope.context.magicString.addSourcemapLocation(this.end);
4658
4717
  }
4659
4718
  addExportedVariables(_variables, _exportNamesByVariable) { }
4660
4719
  /**
@@ -4662,7 +4721,7 @@ class NodeBase extends ExpressionEntity {
4662
4721
  * that require the scopes to be populated with variables.
4663
4722
  */
4664
4723
  bind() {
4665
- for (const key of keys[this.type]) {
4724
+ for (const key of childNodeKeys[this.type]) {
4666
4725
  const value = this[key];
4667
4726
  if (Array.isArray(value)) {
4668
4727
  for (const child of value) {
@@ -4684,7 +4743,7 @@ class NodeBase extends ExpressionEntity {
4684
4743
  hasEffects(context) {
4685
4744
  if (!this.deoptimized)
4686
4745
  this.applyDeoptimizations();
4687
- for (const key of keys[this.type]) {
4746
+ for (const key of childNodeKeys[this.type]) {
4688
4747
  const value = this[key];
4689
4748
  if (value === null)
4690
4749
  continue;
@@ -4707,7 +4766,7 @@ class NodeBase extends ExpressionEntity {
4707
4766
  if (!this.deoptimized)
4708
4767
  this.applyDeoptimizations();
4709
4768
  this.included = true;
4710
- for (const key of keys[this.type]) {
4769
+ for (const key of childNodeKeys[this.type]) {
4711
4770
  const value = this[key];
4712
4771
  if (value === null)
4713
4772
  continue;
@@ -4728,8 +4787,11 @@ class NodeBase extends ExpressionEntity {
4728
4787
  * Override to perform special initialisation steps after the scope is
4729
4788
  * initialised
4730
4789
  */
4731
- initialise() { }
4732
- parseNode(esTreeNode, keepEsTreeNodeKeys) {
4790
+ initialise() {
4791
+ this.scope.context.magicString.addSourcemapLocation(this.start);
4792
+ this.scope.context.magicString.addSourcemapLocation(this.end);
4793
+ }
4794
+ parseNode(esTreeNode) {
4733
4795
  for (const [key, value] of Object.entries(esTreeNode)) {
4734
4796
  // Skip properties defined on the class already.
4735
4797
  // This way, we can override this function to add custom initialisation and then call super.parseNode
@@ -4739,20 +4801,10 @@ class NodeBase extends ExpressionEntity {
4739
4801
  continue;
4740
4802
  if (key.charCodeAt(0) === 95 /* _ */) {
4741
4803
  if (key === ANNOTATION_KEY) {
4742
- const annotations = value;
4743
- this.annotations = annotations;
4744
- if (this.scope.context.options.treeshake.annotations) {
4745
- this.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
4746
- this.annotationPure = annotations.some(comment => comment.type === 'pure');
4747
- }
4804
+ this.annotations = value;
4748
4805
  }
4749
4806
  else if (key === INVALID_ANNOTATION_KEY) {
4750
- for (const { start, end, type } of value) {
4751
- this.scope.context.magicString.remove(start, end);
4752
- if (type === 'pure' || type === 'noSideEffects') {
4753
- this.scope.context.log(LOGLEVEL_WARN, logInvalidAnnotation(this.scope.context.code.slice(start, end), this.scope.context.module.id, type), start);
4754
- }
4755
- }
4807
+ this.invalidAnnotations = value;
4756
4808
  }
4757
4809
  }
4758
4810
  else if (typeof value !== 'object' || value === null) {
@@ -4763,13 +4815,17 @@ class NodeBase extends ExpressionEntity {
4763
4815
  for (const child of value) {
4764
4816
  this[key].push(child === null
4765
4817
  ? null
4766
- : new (this.scope.context.getNodeConstructor(child.type))(child, this, this.scope, keepEsTreeNodeKeys?.includes(key)));
4818
+ : new (this.scope.context.getNodeConstructor(child.type))(this, this.scope).parseNode(child));
4767
4819
  }
4768
4820
  }
4769
4821
  else {
4770
- this[key] = new (this.scope.context.getNodeConstructor(value.type))(value, this, this.scope, keepEsTreeNodeKeys?.includes(key));
4822
+ this[key] = new (this.scope.context.getNodeConstructor(value.type))(this, this.scope).parseNode(value);
4771
4823
  }
4772
4824
  }
4825
+ // extend child keys for unknown node types
4826
+ childNodeKeys[esTreeNode.type] ||= createChildNodeKeysForNode(esTreeNode);
4827
+ this.initialise();
4828
+ return this;
4773
4829
  }
4774
4830
  removeAnnotations(code) {
4775
4831
  if (this.annotations) {
@@ -4779,7 +4835,7 @@ class NodeBase extends ExpressionEntity {
4779
4835
  }
4780
4836
  }
4781
4837
  render(code, options) {
4782
- for (const key of keys[this.type]) {
4838
+ for (const key of childNodeKeys[this.type]) {
4783
4839
  const value = this[key];
4784
4840
  if (value === null)
4785
4841
  continue;
@@ -4806,7 +4862,7 @@ class NodeBase extends ExpressionEntity {
4806
4862
  */
4807
4863
  applyDeoptimizations() {
4808
4864
  this.deoptimized = true;
4809
- for (const key of keys[this.type]) {
4865
+ for (const key of childNodeKeys[this.type]) {
4810
4866
  const value = this[key];
4811
4867
  if (value === null)
4812
4868
  continue;
@@ -4822,6 +4878,9 @@ class NodeBase extends ExpressionEntity {
4822
4878
  this.scope.context.requestTreeshakingPass();
4823
4879
  }
4824
4880
  }
4881
+ function createChildNodeKeysForNode(esTreeNode) {
4882
+ return Object.keys(esTreeNode).filter(key => typeof esTreeNode[key] === 'object' && key.charCodeAt(0) !== 95 /* _ */);
4883
+ }
4825
4884
 
4826
4885
  class SpreadElement extends NodeBase {
4827
4886
  deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
@@ -5574,16 +5633,6 @@ class ArrayPattern extends NodeBase {
5574
5633
  }
5575
5634
  }
5576
5635
 
5577
- const ArrowFunctionExpression$1 = 'ArrowFunctionExpression';
5578
- const BlockStatement$1 = 'BlockStatement';
5579
- const CallExpression$1 = 'CallExpression';
5580
- const CatchClause$1 = 'CatchClause';
5581
- const ExpressionStatement$1 = 'ExpressionStatement';
5582
- const Identifier$1 = 'Identifier';
5583
- const Program$1 = 'Program';
5584
- const Property$1 = 'Property';
5585
- const ReturnStatement$1 = 'ReturnStatement';
5586
-
5587
5636
  class LocalVariable extends Variable {
5588
5637
  constructor(name, declarator, init, context, kind) {
5589
5638
  super(name);
@@ -5728,7 +5777,7 @@ const EMPTY_PATH_TRACKER = new PathTracker();
5728
5777
  const UNKNOWN_DEOPTIMIZED_ENTITY = new Set([UNKNOWN_EXPRESSION]);
5729
5778
  class ParameterVariable extends LocalVariable {
5730
5779
  constructor(name, declarator, context) {
5731
- super(name, declarator, UNKNOWN_EXPRESSION, context, "parameter" /* VariableKind.parameter */);
5780
+ super(name, declarator, UNKNOWN_EXPRESSION, context, 'parameter');
5732
5781
  this.deoptimizationInteractions = [];
5733
5782
  this.deoptimizations = new PathTracker();
5734
5783
  this.deoptimizedFields = new Set();
@@ -5865,7 +5914,7 @@ class Scope {
5865
5914
  const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
5866
5915
  if (existingVariable) {
5867
5916
  const existingKind = existingVariable.kind;
5868
- if (kind === "var" /* VariableKind.var */ && existingKind === "var" /* VariableKind.var */) {
5917
+ if (kind === 'var' && existingKind === 'var') {
5869
5918
  existingVariable.addDeclaration(identifier, init);
5870
5919
  return existingVariable;
5871
5920
  }
@@ -5976,12 +6025,12 @@ class CatchBodyScope extends ChildScope {
5976
6025
  this.parent = parent;
5977
6026
  }
5978
6027
  addDeclaration(identifier, context, init, kind) {
5979
- if (kind === "var" /* VariableKind.var */) {
6028
+ if (kind === 'var') {
5980
6029
  const name = identifier.name;
5981
6030
  const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
5982
6031
  if (existingVariable) {
5983
6032
  const existingKind = existingVariable.kind;
5984
- if (existingKind === "parameter" /* VariableKind.parameter */ &&
6033
+ if (existingKind === 'parameter' &&
5985
6034
  // If this is a destructured parameter, it is forbidden to redeclare
5986
6035
  existingVariable.declarations[0].parent.type === CatchClause$1) {
5987
6036
  // If this is a var with the same name as the catch scope parameter,
@@ -6000,7 +6049,7 @@ class CatchBodyScope extends ChildScope {
6000
6049
  this.addHoistedVariable(name, declaredVariable);
6001
6050
  return declaredVariable;
6002
6051
  }
6003
- if (existingKind === "var" /* VariableKind.var */) {
6052
+ if (existingKind === 'var') {
6004
6053
  existingVariable.addDeclaration(identifier, init);
6005
6054
  return existingVariable;
6006
6055
  }
@@ -6030,10 +6079,8 @@ class FunctionBodyScope extends ChildScope {
6030
6079
  const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
6031
6080
  if (existingVariable) {
6032
6081
  const existingKind = existingVariable.kind;
6033
- if ((kind === "var" /* VariableKind.var */ || kind === "function" /* VariableKind.function */) &&
6034
- (existingKind === "var" /* VariableKind.var */ ||
6035
- existingKind === "function" /* VariableKind.function */ ||
6036
- existingKind === "parameter" /* VariableKind.parameter */)) {
6082
+ if ((kind === 'var' || kind === 'function') &&
6083
+ (existingKind === 'var' || existingKind === 'function' || existingKind === 'parameter')) {
6037
6084
  existingVariable.addDeclaration(identifier, init);
6038
6085
  return existingVariable;
6039
6086
  }
@@ -7254,7 +7301,7 @@ class Identifier extends NodeBase {
7254
7301
  let variable;
7255
7302
  const { treeshake } = this.scope.context.options;
7256
7303
  switch (kind) {
7257
- case "var" /* VariableKind.var */: {
7304
+ case 'var': {
7258
7305
  variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
7259
7306
  if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
7260
7307
  // Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
@@ -7262,18 +7309,18 @@ class Identifier extends NodeBase {
7262
7309
  }
7263
7310
  break;
7264
7311
  }
7265
- case "function" /* VariableKind.function */: {
7312
+ case 'function': {
7266
7313
  // in strict mode, functions are only hoisted within a scope but not across block scopes
7267
7314
  variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
7268
7315
  break;
7269
7316
  }
7270
- case "let" /* VariableKind.let */:
7271
- case "const" /* VariableKind.const */:
7272
- case "class" /* VariableKind.class */: {
7317
+ case 'let':
7318
+ case 'const':
7319
+ case 'class': {
7273
7320
  variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
7274
7321
  break;
7275
7322
  }
7276
- case "parameter" /* VariableKind.parameter */: {
7323
+ case 'parameter': {
7277
7324
  variable = this.scope.addParameterDeclaration(this);
7278
7325
  break;
7279
7326
  }
@@ -7306,7 +7353,7 @@ class Identifier extends NodeBase {
7306
7353
  hasEffects(context) {
7307
7354
  if (!this.deoptimized)
7308
7355
  this.applyDeoptimizations();
7309
- if (this.isPossibleTDZ() && this.variable.kind !== "var" /* VariableKind.var */) {
7356
+ if (this.isPossibleTDZ() && this.variable.kind !== 'var') {
7310
7357
  return true;
7311
7358
  }
7312
7359
  return (this.scope.context.options.treeshake
@@ -7581,12 +7628,12 @@ class BlockScope extends ChildScope {
7581
7628
  super(parent, parent.context);
7582
7629
  }
7583
7630
  addDeclaration(identifier, context, init, kind) {
7584
- if (kind === "var" /* VariableKind.var */) {
7631
+ if (kind === 'var') {
7585
7632
  const name = identifier.name;
7586
7633
  const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
7587
7634
  if (existingVariable) {
7588
- if (existingVariable.kind === "var" /* VariableKind.var */ ||
7589
- (kind === "var" /* VariableKind.var */ && existingVariable.kind === "parameter" /* VariableKind.parameter */)) {
7635
+ if (existingVariable.kind === 'var' ||
7636
+ (kind === 'var' && existingVariable.kind === 'parameter')) {
7590
7637
  existingVariable.addDeclaration(identifier, init);
7591
7638
  return existingVariable;
7592
7639
  }
@@ -7606,6 +7653,7 @@ class BlockScope extends ChildScope {
7606
7653
 
7607
7654
  class ExpressionStatement extends NodeBase {
7608
7655
  initialise() {
7656
+ super.initialise();
7609
7657
  if (this.directive &&
7610
7658
  this.directive !== 'use strict' &&
7611
7659
  this.parent.type === Program$1) {
@@ -7679,6 +7727,7 @@ class BlockStatement extends NodeBase {
7679
7727
  }
7680
7728
  }
7681
7729
  initialise() {
7730
+ super.initialise();
7682
7731
  const firstBodyStatement = this.body[0];
7683
7732
  this.deoptimizeBody =
7684
7733
  firstBodyStatement instanceof ExpressionStatement &&
@@ -7742,6 +7791,12 @@ class FunctionBase extends NodeBase {
7742
7791
  set deoptimizedReturn(value) {
7743
7792
  this.flags = setFlag(this.flags, 512 /* Flag.deoptimizedReturn */, value);
7744
7793
  }
7794
+ get generator() {
7795
+ return isFlagSet(this.flags, 4194304 /* Flag.generator */);
7796
+ }
7797
+ set generator(value) {
7798
+ this.flags = setFlag(this.flags, 4194304 /* Flag.generator */, value);
7799
+ }
7745
7800
  deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
7746
7801
  if (interaction.type === INTERACTION_CALLED) {
7747
7802
  const { parameters } = this.scope;
@@ -7838,12 +7893,17 @@ class FunctionBase extends NodeBase {
7838
7893
  this.scope.includeCallArguments(context, parameters);
7839
7894
  }
7840
7895
  initialise() {
7896
+ super.initialise();
7841
7897
  if (this.body instanceof BlockStatement) {
7842
7898
  this.body.addImplicitReturnExpressionToScope();
7843
7899
  }
7844
7900
  else {
7845
7901
  this.scope.addReturnExpression(this.body);
7846
7902
  }
7903
+ if (this.annotations &&
7904
+ this.scope.context.options.treeshake.annotations) {
7905
+ this.annotationNoSideEffects = this.annotations.some(comment => comment.type === 'noSideEffects');
7906
+ }
7847
7907
  }
7848
7908
  parseNode(esTreeNode) {
7849
7909
  const { body, params } = esTreeNode;
@@ -7854,11 +7914,11 @@ class FunctionBase extends NodeBase {
7854
7914
  // so that the scope already knows all parameters and can detect conflicts
7855
7915
  // when parsing the body.
7856
7916
  for (const parameter of params) {
7857
- parameters.push(new (context.getNodeConstructor(parameter.type))(parameter, this, scope, false));
7917
+ parameters.push(new (context.getNodeConstructor(parameter.type))(this, scope).parseNode(parameter));
7858
7918
  }
7859
- scope.addParameterVariables(parameters.map(parameter => parameter.declare("parameter" /* VariableKind.parameter */, UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
7860
- this.body = new (context.getNodeConstructor(body.type))(body, this, bodyScope);
7861
- super.parseNode(esTreeNode);
7919
+ scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
7920
+ this.body = new (context.getNodeConstructor(body.type))(this, bodyScope).parseNode(body);
7921
+ return super.parseNode(esTreeNode);
7862
7922
  }
7863
7923
  addArgumentToBeDeoptimized(_argument) { }
7864
7924
  applyDeoptimizations() { }
@@ -7870,6 +7930,12 @@ class ArrowFunctionExpression extends FunctionBase {
7870
7930
  super(...arguments);
7871
7931
  this.objectEntity = null;
7872
7932
  }
7933
+ get expression() {
7934
+ return isFlagSet(this.flags, 8388608 /* Flag.expression */);
7935
+ }
7936
+ set expression(value) {
7937
+ this.flags = setFlag(this.flags, 8388608 /* Flag.expression */, value);
7938
+ }
7873
7939
  createScope(parentScope) {
7874
7940
  this.scope = new ReturnValueScope(parentScope, false);
7875
7941
  }
@@ -8028,6 +8094,7 @@ class AssignmentExpression extends NodeBase {
8028
8094
  right.include(context, includeChildrenRecursively);
8029
8095
  }
8030
8096
  initialise() {
8097
+ super.initialise();
8031
8098
  if (this.left instanceof Identifier) {
8032
8099
  const variable = this.scope.variables.get(this.left.name);
8033
8100
  if (variable?.kind === 'const') {
@@ -8122,7 +8189,7 @@ class AssignmentPattern extends NodeBase {
8122
8189
 
8123
8190
  class ArgumentsVariable extends LocalVariable {
8124
8191
  constructor(context) {
8125
- super('arguments', null, UNKNOWN_EXPRESSION, context, "other" /* VariableKind.other */);
8192
+ super('arguments', null, UNKNOWN_EXPRESSION, context, 'other');
8126
8193
  this.deoptimizedArguments = [];
8127
8194
  }
8128
8195
  addArgumentToBeDeoptimized(argument) {
@@ -8245,7 +8312,7 @@ class FunctionNode extends FunctionBase {
8245
8312
  }
8246
8313
  initialise() {
8247
8314
  super.initialise();
8248
- this.id?.declare("function" /* VariableKind.function */, this);
8315
+ this.id?.declare('function', this);
8249
8316
  }
8250
8317
  addArgumentToBeDeoptimized(argument) {
8251
8318
  this.scope.argumentsVariable.addArgumentToBeDeoptimized(argument);
@@ -8442,12 +8509,13 @@ class Literal extends NodeBase {
8442
8509
  }
8443
8510
  }
8444
8511
  initialise() {
8512
+ super.initialise();
8445
8513
  this.members = getLiteralMembersForValue(this.value);
8446
8514
  }
8447
8515
  parseNode(esTreeNode) {
8448
8516
  this.value = esTreeNode.value;
8449
8517
  this.regex = esTreeNode.regex;
8450
- super.parseNode(esTreeNode);
8518
+ return super.parseNode(esTreeNode);
8451
8519
  }
8452
8520
  render(code) {
8453
8521
  if (typeof this.value === 'string') {
@@ -8665,6 +8733,7 @@ class MemberExpression extends NodeBase {
8665
8733
  }
8666
8734
  }
8667
8735
  initialise() {
8736
+ super.initialise();
8668
8737
  this.propertyKey = getResolvablePropertyKey(this);
8669
8738
  this.accessInteraction = { args: [this.object], type: INTERACTION_ACCESSED };
8670
8739
  }
@@ -8944,6 +9013,13 @@ class CallExpression extends CallExpressionBase {
8944
9013
  }
8945
9014
  this.callee.includeCallArguments(context, this.arguments);
8946
9015
  }
9016
+ initialise() {
9017
+ super.initialise();
9018
+ if (this.annotations &&
9019
+ this.scope.context.options.treeshake.annotations) {
9020
+ this.annotationPure = this.annotations.some(comment => comment.type === 'pure');
9021
+ }
9022
+ }
8947
9023
  isSkippedAsOptional(origin) {
8948
9024
  return (this.callee.isSkippedAsOptional?.(origin) ||
8949
9025
  (this.optional &&
@@ -8978,11 +9054,11 @@ class CatchClause extends NodeBase {
8978
9054
  const { body, param, type } = esTreeNode;
8979
9055
  this.type = type;
8980
9056
  if (param) {
8981
- this.param = new (this.scope.context.getNodeConstructor(param.type))(param, this, this.scope);
8982
- this.param.declare("parameter" /* VariableKind.parameter */, UNKNOWN_EXPRESSION);
9057
+ this.param = new (this.scope.context.getNodeConstructor(param.type))(this, this.scope).parseNode(param);
9058
+ this.param.declare('parameter', UNKNOWN_EXPRESSION);
8983
9059
  }
8984
- this.body = new BlockStatement(body, this, this.scope.bodyScope);
8985
- super.parseNode(esTreeNode);
9060
+ this.body = new BlockStatement(this, this.scope.bodyScope).parseNode(body);
9061
+ return super.parseNode(esTreeNode);
8986
9062
  }
8987
9063
  }
8988
9064
  CatchClause.prototype.preventChildBlockScope = true;
@@ -9009,7 +9085,7 @@ class ClassBodyScope extends ChildScope {
9009
9085
  constructor(parent, classNode) {
9010
9086
  const { context } = parent;
9011
9087
  super(parent, context);
9012
- this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, context, "other" /* VariableKind.other */)));
9088
+ this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, context, 'other')));
9013
9089
  this.instanceScope = new ChildScope(this, context);
9014
9090
  this.instanceScope.variables.set('this', new ThisVariable(context));
9015
9091
  }
@@ -9032,9 +9108,9 @@ class ClassBody extends NodeBase {
9032
9108
  parseNode(esTreeNode) {
9033
9109
  const body = (this.body = []);
9034
9110
  for (const definition of esTreeNode.body) {
9035
- body.push(new (this.scope.context.getNodeConstructor(definition.type))(definition, this, definition.static ? this.scope : this.scope.instanceScope));
9111
+ body.push(new (this.scope.context.getNodeConstructor(definition.type))(this, definition.static ? this.scope : this.scope.instanceScope).parseNode(definition));
9036
9112
  }
9037
- super.parseNode(esTreeNode);
9113
+ return super.parseNode(esTreeNode);
9038
9114
  }
9039
9115
  applyDeoptimizations() { }
9040
9116
  }
@@ -9193,7 +9269,8 @@ class ClassNode extends NodeBase {
9193
9269
  }
9194
9270
  }
9195
9271
  initialise() {
9196
- this.id?.declare("class" /* VariableKind.class */, this);
9272
+ super.initialise();
9273
+ this.id?.declare('class', this);
9197
9274
  for (const method of this.body.body) {
9198
9275
  if (method instanceof MethodDefinition && method.kind === 'constructor') {
9199
9276
  this.classConstructor = method;
@@ -9263,9 +9340,9 @@ class ClassDeclaration extends ClassNode {
9263
9340
  }
9264
9341
  parseNode(esTreeNode) {
9265
9342
  if (esTreeNode.id !== null) {
9266
- this.id = new Identifier(esTreeNode.id, this, this.scope.parent);
9343
+ this.id = new Identifier(this, this.scope.parent).parseNode(esTreeNode.id);
9267
9344
  }
9268
- super.parseNode(esTreeNode);
9345
+ return super.parseNode(esTreeNode);
9269
9346
  }
9270
9347
  render(code, options) {
9271
9348
  const { exportNamesByVariable, format, snippets: { _, getPropertyAccess } } = options;
@@ -9505,6 +9582,12 @@ class ContinueStatement extends NodeBase {
9505
9582
  }
9506
9583
  }
9507
9584
 
9585
+ class DebuggerStatement extends NodeBase {
9586
+ hasEffects() {
9587
+ return true;
9588
+ }
9589
+ }
9590
+
9508
9591
  function hasLoopBodyEffects(context, body) {
9509
9592
  const { brokenFlow, hasBreak, hasContinue, ignore } = context;
9510
9593
  const { breaks, continues } = ignore;
@@ -9555,6 +9638,7 @@ class ExportAllDeclaration extends NodeBase {
9555
9638
  return false;
9556
9639
  }
9557
9640
  initialise() {
9641
+ super.initialise();
9558
9642
  this.scope.context.addExport(this);
9559
9643
  }
9560
9644
  render(code, _options, nodeRenderOptions) {
@@ -9573,9 +9657,9 @@ class FunctionDeclaration extends FunctionNode {
9573
9657
  }
9574
9658
  parseNode(esTreeNode) {
9575
9659
  if (esTreeNode.id !== null) {
9576
- this.id = new Identifier(esTreeNode.id, this, this.scope.parent);
9660
+ this.id = new Identifier(this, this.scope.parent).parseNode(esTreeNode.id);
9577
9661
  }
9578
- super.parseNode(esTreeNode);
9662
+ return super.parseNode(esTreeNode);
9579
9663
  }
9580
9664
  }
9581
9665
 
@@ -9600,6 +9684,7 @@ class ExportDefaultDeclaration extends NodeBase {
9600
9684
  }
9601
9685
  }
9602
9686
  initialise() {
9687
+ super.initialise();
9603
9688
  const declaration = this.declaration;
9604
9689
  this.declarationName =
9605
9690
  (declaration.id && declaration.id.name) || this.declaration.name;
@@ -9683,6 +9768,7 @@ class ExportNamedDeclaration extends NodeBase {
9683
9768
  return !!this.declaration?.hasEffects(context);
9684
9769
  }
9685
9770
  initialise() {
9771
+ super.initialise();
9686
9772
  this.scope.context.addExport(this);
9687
9773
  }
9688
9774
  removeAnnotations(code) {
@@ -9728,6 +9814,7 @@ class ForInStatement extends NodeBase {
9728
9814
  includeLoopBody(context, body, includeChildrenRecursively);
9729
9815
  }
9730
9816
  initialise() {
9817
+ super.initialise();
9731
9818
  this.left.setAssignedValue(UNKNOWN_EXPRESSION);
9732
9819
  }
9733
9820
  render(code, options) {
@@ -9772,6 +9859,7 @@ class ForOfStatement extends NodeBase {
9772
9859
  includeLoopBody(context, body, includeChildrenRecursively);
9773
9860
  }
9774
9861
  initialise() {
9862
+ super.initialise();
9775
9863
  this.left.setAssignedValue(UNKNOWN_EXPRESSION);
9776
9864
  }
9777
9865
  render(code, options) {
@@ -9824,9 +9912,9 @@ class FunctionExpression extends FunctionNode {
9824
9912
  }
9825
9913
  parseNode(esTreeNode) {
9826
9914
  if (esTreeNode.id !== null) {
9827
- this.id = new Identifier(esTreeNode.id, this, this.idScope);
9915
+ this.id = new Identifier(this, this.idScope).parseNode(esTreeNode.id);
9828
9916
  }
9829
- super.parseNode(esTreeNode);
9917
+ return super.parseNode(esTreeNode);
9830
9918
  }
9831
9919
  render(code, options, { renderedSurroundingElement } = BLANK) {
9832
9920
  super.render(code, options);
@@ -9893,13 +9981,11 @@ class IfStatement extends NodeBase {
9893
9981
  }
9894
9982
  }
9895
9983
  parseNode(esTreeNode) {
9896
- this.consequentScope = new TrackingScope(this.scope);
9897
- this.consequent = new (this.scope.context.getNodeConstructor(esTreeNode.consequent.type))(esTreeNode.consequent, this, this.consequentScope);
9984
+ this.consequent = new (this.scope.context.getNodeConstructor(esTreeNode.consequent.type))(this, (this.consequentScope = new TrackingScope(this.scope))).parseNode(esTreeNode.consequent);
9898
9985
  if (esTreeNode.alternate) {
9899
- this.alternateScope = new TrackingScope(this.scope);
9900
- this.alternate = new (this.scope.context.getNodeConstructor(esTreeNode.alternate.type))(esTreeNode.alternate, this, this.alternateScope);
9986
+ this.alternate = new (this.scope.context.getNodeConstructor(esTreeNode.alternate.type))(this, (this.alternateScope = new TrackingScope(this.scope))).parseNode(esTreeNode.alternate);
9901
9987
  }
9902
- super.parseNode(esTreeNode);
9988
+ return super.parseNode(esTreeNode);
9903
9989
  }
9904
9990
  render(code, options) {
9905
9991
  const { snippets: { getPropertyAccess } } = options;
@@ -10025,6 +10111,7 @@ class ImportDeclaration extends NodeBase {
10025
10111
  return false;
10026
10112
  }
10027
10113
  initialise() {
10114
+ super.initialise();
10028
10115
  this.scope.context.addImport(this);
10029
10116
  }
10030
10117
  render(code, _options, nodeRenderOptions) {
@@ -10415,11 +10502,12 @@ class ImportExpression extends NodeBase {
10415
10502
  this.source.include(context, includeChildrenRecursively);
10416
10503
  }
10417
10504
  initialise() {
10505
+ super.initialise();
10418
10506
  this.scope.context.addDynamicImport(this);
10419
10507
  }
10420
10508
  parseNode(esTreeNode) {
10421
- // Keep the source AST to be used by renderDynamicImport
10422
- super.parseNode(esTreeNode, ['source']);
10509
+ this.sourceAstNode = esTreeNode.source;
10510
+ return super.parseNode(esTreeNode);
10423
10511
  }
10424
10512
  render(code, options) {
10425
10513
  const { snippets: { _, getDirectReturnFunction, getObject, getPropertyAccess } } = options;
@@ -10896,18 +10984,18 @@ const getGenericImportMetaMechanism = (getUrl) => (property, { chunkId }) => {
10896
10984
  : 'undefined';
10897
10985
  };
10898
10986
  const getFileUrlFromFullPath = (path) => `require('u' + 'rl').pathToFileURL(${path}).href`;
10899
- const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${path}'`);
10987
+ const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${escapeId(path)}'`);
10900
10988
  const getUrlFromDocument = (chunkId, umd = false) => `${umd ? `typeof document === 'undefined' ? location.href : ` : ''}(${DOCUMENT_CURRENT_SCRIPT} && ${DOCUMENT_CURRENT_SCRIPT}.src || new URL('${escapeId(chunkId)}', document.baseURI).href)`;
10901
10989
  const relativeUrlMechanisms = {
10902
10990
  amd: relativePath => {
10903
10991
  if (relativePath[0] !== '.')
10904
10992
  relativePath = './' + relativePath;
10905
- return getResolveUrl(`require.toUrl('${relativePath}'), document.baseURI`);
10993
+ return getResolveUrl(`require.toUrl('${escapeId(relativePath)}'), document.baseURI`);
10906
10994
  },
10907
10995
  cjs: relativePath => `(typeof document === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath)})`,
10908
- es: relativePath => getResolveUrl(`'${relativePath}', import.meta.url`),
10996
+ es: relativePath => getResolveUrl(`'${escapeId(relativePath)}', import.meta.url`),
10909
10997
  iife: relativePath => getRelativeUrlFromDocument(relativePath),
10910
- system: relativePath => getResolveUrl(`'${relativePath}', module.meta.url`),
10998
+ system: relativePath => getResolveUrl(`'${escapeId(relativePath)}', module.meta.url`),
10911
10999
  umd: relativePath => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath, true)})`
10912
11000
  };
10913
11001
  const importMetaMechanisms = {
@@ -10952,11 +11040,16 @@ class NewExpression extends NodeBase {
10952
11040
  this.callee.includeCallArguments(context, this.arguments);
10953
11041
  }
10954
11042
  initialise() {
11043
+ super.initialise();
10955
11044
  this.interaction = {
10956
11045
  args: [null, ...this.arguments],
10957
11046
  type: INTERACTION_CALLED,
10958
11047
  withNew: true
10959
11048
  };
11049
+ if (this.annotations &&
11050
+ this.scope.context.options.treeshake.annotations) {
11051
+ this.annotationPure = this.annotations.some(comment => comment.type === 'pure');
11052
+ }
10960
11053
  }
10961
11054
  render(code, options) {
10962
11055
  this.callee.render(code, options);
@@ -11042,6 +11135,29 @@ class ObjectExpression extends NodeBase {
11042
11135
  }
11043
11136
  }
11044
11137
 
11138
+ class PanicError extends NodeBase {
11139
+ initialise() {
11140
+ const id = this.scope.context.module.id;
11141
+ // This simulates the current nested error structure. We could also just
11142
+ // replace it with a flat error.
11143
+ const parseError = getRollupError(logParseError(this.message));
11144
+ const moduleParseError = logModuleParseError(parseError, id);
11145
+ return error(moduleParseError);
11146
+ }
11147
+ }
11148
+
11149
+ class ParseError extends NodeBase {
11150
+ initialise() {
11151
+ const pos = this.start;
11152
+ const id = this.scope.context.module.id;
11153
+ // This simulates the current nested error structure. We could also just
11154
+ // replace it with a flat error.
11155
+ const parseError = getRollupError(logParseError(this.message, pos));
11156
+ const moduleParseError = logModuleParseError(parseError, id);
11157
+ this.scope.context.error(moduleParseError, pos);
11158
+ }
11159
+ }
11160
+
11045
11161
  class PrivateIdentifier extends NodeBase {
11046
11162
  }
11047
11163
 
@@ -11080,6 +11196,16 @@ class Program extends NodeBase {
11080
11196
  }
11081
11197
  }
11082
11198
  }
11199
+ initialise() {
11200
+ super.initialise();
11201
+ if (this.invalidAnnotations)
11202
+ for (const { start, end, type } of this.invalidAnnotations) {
11203
+ this.scope.context.magicString.remove(start, end);
11204
+ if (type === 'pure' || type === 'noSideEffects') {
11205
+ this.scope.context.log(LOGLEVEL_WARN, logInvalidAnnotation(this.scope.context.code.slice(start, end), this.scope.context.module.id, type), start);
11206
+ }
11207
+ }
11208
+ }
11083
11209
  render(code, options) {
11084
11210
  let start = this.start;
11085
11211
  if (code.original.startsWith('#!')) {
@@ -11198,6 +11324,7 @@ class ReturnStatement extends NodeBase {
11198
11324
  context.brokenFlow = true;
11199
11325
  }
11200
11326
  initialise() {
11327
+ super.initialise();
11201
11328
  this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION);
11202
11329
  }
11203
11330
  render(code, options) {
@@ -11419,6 +11546,7 @@ class SwitchStatement extends NodeBase {
11419
11546
  context.hasBreak = hasBreak;
11420
11547
  }
11421
11548
  initialise() {
11549
+ super.initialise();
11422
11550
  for (let caseIndex = 0; caseIndex < this.cases.length; caseIndex++) {
11423
11551
  if (this.cases[caseIndex].test === null) {
11424
11552
  this.defaultCase = caseIndex;
@@ -11428,8 +11556,8 @@ class SwitchStatement extends NodeBase {
11428
11556
  this.defaultCase = null;
11429
11557
  }
11430
11558
  parseNode(esTreeNode) {
11431
- this.discriminant = new (this.scope.context.getNodeConstructor(esTreeNode.discriminant.type))(esTreeNode.discriminant, this, this.parentScope);
11432
- super.parseNode(esTreeNode);
11559
+ this.discriminant = new (this.scope.context.getNodeConstructor(esTreeNode.discriminant.type))(this, this.parentScope).parseNode(esTreeNode.discriminant);
11560
+ return super.parseNode(esTreeNode);
11433
11561
  }
11434
11562
  render(code, options) {
11435
11563
  this.discriminant.render(code, options);
@@ -11482,6 +11610,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
11482
11610
  }
11483
11611
  }
11484
11612
  initialise() {
11613
+ super.initialise();
11485
11614
  this.args = [UNKNOWN_EXPRESSION, ...this.quasi.expressions];
11486
11615
  this.interaction = {
11487
11616
  args: [
@@ -11527,7 +11656,7 @@ class TemplateElement extends NodeBase {
11527
11656
  }
11528
11657
  parseNode(esTreeNode) {
11529
11658
  this.value = esTreeNode.value;
11530
- super.parseNode(esTreeNode);
11659
+ return super.parseNode(esTreeNode);
11531
11660
  }
11532
11661
  render() { }
11533
11662
  }
@@ -11572,7 +11701,7 @@ class UndefinedVariable extends Variable {
11572
11701
 
11573
11702
  class ExportDefaultVariable extends LocalVariable {
11574
11703
  constructor(name, exportDefaultDeclaration, context) {
11575
- super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context, "other" /* VariableKind.other */);
11704
+ super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context, 'other');
11576
11705
  this.hasId = false;
11577
11706
  this.originalId = null;
11578
11707
  this.originalVariable = null;
@@ -11643,7 +11772,7 @@ class ExportDefaultVariable extends LocalVariable {
11643
11772
  class ModuleScope extends ChildScope {
11644
11773
  constructor(parent, context) {
11645
11774
  super(parent, context);
11646
- this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context, "other" /* VariableKind.other */));
11775
+ this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context, 'other'));
11647
11776
  }
11648
11777
  addDeclaration(identifier, context, init, kind) {
11649
11778
  if (this.context.module.importDescriptions.has(identifier.name)) {
@@ -11701,6 +11830,7 @@ class ThisExpression extends NodeBase {
11701
11830
  }
11702
11831
  }
11703
11832
  initialise() {
11833
+ super.initialise();
11704
11834
  this.alias =
11705
11835
  this.scope.findLexicalBoundary() instanceof ModuleScope
11706
11836
  ? this.scope.context.moduleContext
@@ -11817,15 +11947,6 @@ class UnaryExpression extends NodeBase {
11817
11947
  }
11818
11948
  }
11819
11949
 
11820
- class UnknownNode extends NodeBase {
11821
- hasEffects() {
11822
- return true;
11823
- }
11824
- include(context) {
11825
- super.include(context, true);
11826
- }
11827
- }
11828
-
11829
11950
  class UpdateExpression extends NodeBase {
11830
11951
  hasEffects(context) {
11831
11952
  if (!this.deoptimized)
@@ -11842,6 +11963,7 @@ class UpdateExpression extends NodeBase {
11842
11963
  this.argument.includeAsAssignmentTarget(context, includeChildrenRecursively, true);
11843
11964
  }
11844
11965
  initialise() {
11966
+ super.initialise();
11845
11967
  this.argument.setAssignedValue(UNKNOWN_EXPRESSION);
11846
11968
  }
11847
11969
  render(code, options) {
@@ -11921,6 +12043,7 @@ class VariableDeclaration extends NodeBase {
11921
12043
  }
11922
12044
  }
11923
12045
  initialise() {
12046
+ super.initialise();
11924
12047
  for (const declarator of this.declarations) {
11925
12048
  declarator.declareDeclarator(this.kind);
11926
12049
  }
@@ -12086,6 +12209,711 @@ class YieldExpression extends NodeBase {
12086
12209
  }
12087
12210
  }
12088
12211
 
12212
+ // This file is generated by scripts/generate-ast-converters.js.
12213
+ // Do not edit this file directly.
12214
+ function convertProgram(buffer, parent, parentScope) {
12215
+ return convertNode(parent, parentScope, 0, new Uint32Array(buffer.buffer), getReadStringFunction(buffer));
12216
+ }
12217
+ const nodeTypeStrings = [
12218
+ 'PanicError',
12219
+ 'ParseError',
12220
+ 'ArrayExpression',
12221
+ 'ArrayPattern',
12222
+ 'ArrowFunctionExpression',
12223
+ 'AssignmentExpression',
12224
+ 'AssignmentPattern',
12225
+ 'AwaitExpression',
12226
+ 'BinaryExpression',
12227
+ 'BlockStatement',
12228
+ 'BreakStatement',
12229
+ 'CallExpression',
12230
+ 'CatchClause',
12231
+ 'ChainExpression',
12232
+ 'ClassBody',
12233
+ 'ClassDeclaration',
12234
+ 'ClassExpression',
12235
+ 'ConditionalExpression',
12236
+ 'ContinueStatement',
12237
+ 'DebuggerStatement',
12238
+ 'ExpressionStatement',
12239
+ 'DoWhileStatement',
12240
+ 'EmptyStatement',
12241
+ 'ExportAllDeclaration',
12242
+ 'ExportDefaultDeclaration',
12243
+ 'ExportNamedDeclaration',
12244
+ 'ExportSpecifier',
12245
+ 'ExpressionStatement',
12246
+ 'ForInStatement',
12247
+ 'ForOfStatement',
12248
+ 'ForStatement',
12249
+ 'FunctionDeclaration',
12250
+ 'FunctionExpression',
12251
+ 'Identifier',
12252
+ 'IfStatement',
12253
+ 'ImportAttribute',
12254
+ 'ImportDeclaration',
12255
+ 'ImportDefaultSpecifier',
12256
+ 'ImportExpression',
12257
+ 'ImportNamespaceSpecifier',
12258
+ 'ImportSpecifier',
12259
+ 'LabeledStatement',
12260
+ 'Literal',
12261
+ 'Literal',
12262
+ 'Literal',
12263
+ 'Literal',
12264
+ 'Literal',
12265
+ 'Literal',
12266
+ 'LogicalExpression',
12267
+ 'MemberExpression',
12268
+ 'MetaProperty',
12269
+ 'MethodDefinition',
12270
+ 'NewExpression',
12271
+ 'ObjectExpression',
12272
+ 'ObjectPattern',
12273
+ 'PrivateIdentifier',
12274
+ 'Program',
12275
+ 'Property',
12276
+ 'PropertyDefinition',
12277
+ 'RestElement',
12278
+ 'ReturnStatement',
12279
+ 'SequenceExpression',
12280
+ 'SpreadElement',
12281
+ 'StaticBlock',
12282
+ 'Super',
12283
+ 'SwitchCase',
12284
+ 'SwitchStatement',
12285
+ 'TaggedTemplateExpression',
12286
+ 'TemplateElement',
12287
+ 'TemplateLiteral',
12288
+ 'ThisExpression',
12289
+ 'ThrowStatement',
12290
+ 'TryStatement',
12291
+ 'UnaryExpression',
12292
+ 'UpdateExpression',
12293
+ 'VariableDeclaration',
12294
+ 'VariableDeclarator',
12295
+ 'WhileStatement',
12296
+ 'YieldExpression'
12297
+ ];
12298
+ const nodeConstructors$1 = [
12299
+ PanicError,
12300
+ ParseError,
12301
+ ArrayExpression,
12302
+ ArrayPattern,
12303
+ ArrowFunctionExpression,
12304
+ AssignmentExpression,
12305
+ AssignmentPattern,
12306
+ AwaitExpression,
12307
+ BinaryExpression,
12308
+ BlockStatement,
12309
+ BreakStatement,
12310
+ CallExpression,
12311
+ CatchClause,
12312
+ ChainExpression,
12313
+ ClassBody,
12314
+ ClassDeclaration,
12315
+ ClassExpression,
12316
+ ConditionalExpression,
12317
+ ContinueStatement,
12318
+ DebuggerStatement,
12319
+ ExpressionStatement,
12320
+ DoWhileStatement,
12321
+ EmptyStatement,
12322
+ ExportAllDeclaration,
12323
+ ExportDefaultDeclaration,
12324
+ ExportNamedDeclaration,
12325
+ ExportSpecifier,
12326
+ ExpressionStatement,
12327
+ ForInStatement,
12328
+ ForOfStatement,
12329
+ ForStatement,
12330
+ FunctionDeclaration,
12331
+ FunctionExpression,
12332
+ Identifier,
12333
+ IfStatement,
12334
+ ImportAttribute,
12335
+ ImportDeclaration,
12336
+ ImportDefaultSpecifier,
12337
+ ImportExpression,
12338
+ ImportNamespaceSpecifier,
12339
+ ImportSpecifier,
12340
+ LabeledStatement,
12341
+ Literal,
12342
+ Literal,
12343
+ Literal,
12344
+ Literal,
12345
+ Literal,
12346
+ Literal,
12347
+ LogicalExpression,
12348
+ MemberExpression,
12349
+ MetaProperty,
12350
+ MethodDefinition,
12351
+ NewExpression,
12352
+ ObjectExpression,
12353
+ ObjectPattern,
12354
+ PrivateIdentifier,
12355
+ Program,
12356
+ Property,
12357
+ PropertyDefinition,
12358
+ RestElement,
12359
+ ReturnStatement,
12360
+ SequenceExpression,
12361
+ SpreadElement,
12362
+ StaticBlock,
12363
+ Super,
12364
+ SwitchCase,
12365
+ SwitchStatement,
12366
+ TaggedTemplateExpression,
12367
+ TemplateElement,
12368
+ TemplateLiteral,
12369
+ ThisExpression,
12370
+ ThrowStatement,
12371
+ TryStatement,
12372
+ UnaryExpression,
12373
+ UpdateExpression,
12374
+ VariableDeclaration,
12375
+ VariableDeclarator,
12376
+ WhileStatement,
12377
+ YieldExpression
12378
+ ];
12379
+ const bufferParsers = [
12380
+ function panicError(node, position, buffer, readString) {
12381
+ node.message = convertString(position, buffer, readString);
12382
+ },
12383
+ function parseError(node, position, buffer, readString) {
12384
+ node.message = convertString(position, buffer, readString);
12385
+ },
12386
+ function arrayExpression(node, position, buffer, readString) {
12387
+ const { scope } = node;
12388
+ node.elements = convertNodeList(node, scope, position, buffer, readString);
12389
+ },
12390
+ function arrayPattern(node, position, buffer, readString) {
12391
+ const { scope } = node;
12392
+ node.elements = convertNodeList(node, scope, position, buffer, readString);
12393
+ },
12394
+ function arrowFunctionExpression(node, position, buffer, readString) {
12395
+ const { scope } = node;
12396
+ const flags = buffer[position];
12397
+ node.async = (flags & 1) === 1;
12398
+ node.expression = (flags & 2) === 2;
12399
+ node.generator = (flags & 4) === 4;
12400
+ const parameters = (node.params = convertNodeList(node, scope, buffer[position + 1], buffer, readString));
12401
+ scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
12402
+ node.body = convertNode(node, scope.bodyScope, buffer[position + 2], buffer, readString);
12403
+ const annotations = (node.annotations = convertAnnotations(position + 3, buffer));
12404
+ node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
12405
+ },
12406
+ function assignmentExpression(node, position, buffer, readString) {
12407
+ const { scope } = node;
12408
+ node.operator = FIXED_STRINGS[buffer[position]];
12409
+ node.right = convertNode(node, scope, buffer[position + 1], buffer, readString);
12410
+ node.left = convertNode(node, scope, position + 2, buffer, readString);
12411
+ },
12412
+ function assignmentPattern(node, position, buffer, readString) {
12413
+ const { scope } = node;
12414
+ node.right = convertNode(node, scope, buffer[position], buffer, readString);
12415
+ node.left = convertNode(node, scope, position + 1, buffer, readString);
12416
+ },
12417
+ function awaitExpression(node, position, buffer, readString) {
12418
+ const { scope } = node;
12419
+ node.argument = convertNode(node, scope, position, buffer, readString);
12420
+ },
12421
+ function binaryExpression(node, position, buffer, readString) {
12422
+ const { scope } = node;
12423
+ node.operator = FIXED_STRINGS[buffer[position]];
12424
+ node.right = convertNode(node, scope, buffer[position + 1], buffer, readString);
12425
+ node.left = convertNode(node, scope, position + 2, buffer, readString);
12426
+ },
12427
+ function blockStatement(node, position, buffer, readString) {
12428
+ const { scope } = node;
12429
+ node.body = convertNodeList(node, scope, position, buffer, readString);
12430
+ },
12431
+ function breakStatement(node, position, buffer, readString) {
12432
+ const { scope } = node;
12433
+ const labelPosition = buffer[position];
12434
+ node.label =
12435
+ labelPosition === 0 ? null : convertNode(node, scope, labelPosition, buffer, readString);
12436
+ },
12437
+ function callExpression(node, position, buffer, readString) {
12438
+ const { scope } = node;
12439
+ const flags = buffer[position];
12440
+ node.optional = (flags & 1) === 1;
12441
+ node.callee = convertNode(node, scope, buffer[position + 1], buffer, readString);
12442
+ node.arguments = convertNodeList(node, scope, buffer[position + 2], buffer, readString);
12443
+ node.annotations = convertAnnotations(position + 3, buffer);
12444
+ },
12445
+ function catchClause(node, position, buffer, readString) {
12446
+ const { scope } = node;
12447
+ const parameterPosition = buffer[position];
12448
+ const parameter = (node.param =
12449
+ parameterPosition === 0
12450
+ ? null
12451
+ : convertNode(node, scope, parameterPosition, buffer, readString));
12452
+ parameter?.declare('parameter', UNKNOWN_EXPRESSION);
12453
+ node.body = convertNode(node, scope.bodyScope, buffer[position + 1], buffer, readString);
12454
+ },
12455
+ function chainExpression(node, position, buffer, readString) {
12456
+ const { scope } = node;
12457
+ node.expression = convertNode(node, scope, position, buffer, readString);
12458
+ },
12459
+ function classBody(node, position, buffer, readString) {
12460
+ const { scope } = node;
12461
+ const length = buffer[position];
12462
+ const body = (node.body = []);
12463
+ for (let index = 0; index < length; index++) {
12464
+ const nodePosition = buffer[position + 1 + index];
12465
+ body.push(convertNode(node, (buffer[nodePosition + 3] & 1) === 0 ? scope.instanceScope : scope, nodePosition, buffer, readString));
12466
+ }
12467
+ },
12468
+ function classDeclaration(node, position, buffer, readString) {
12469
+ const { scope } = node;
12470
+ const idPosition = buffer[position];
12471
+ node.id =
12472
+ idPosition === 0
12473
+ ? null
12474
+ : convertNode(node, scope.parent, idPosition, buffer, readString);
12475
+ const superClassPosition = buffer[position + 1];
12476
+ node.superClass =
12477
+ superClassPosition === 0
12478
+ ? null
12479
+ : convertNode(node, scope, superClassPosition, buffer, readString);
12480
+ node.body = convertNode(node, scope, buffer[position + 2], buffer, readString);
12481
+ },
12482
+ function classExpression(node, position, buffer, readString) {
12483
+ const { scope } = node;
12484
+ const idPosition = buffer[position];
12485
+ node.id = idPosition === 0 ? null : convertNode(node, scope, idPosition, buffer, readString);
12486
+ const superClassPosition = buffer[position + 1];
12487
+ node.superClass =
12488
+ superClassPosition === 0
12489
+ ? null
12490
+ : convertNode(node, scope, superClassPosition, buffer, readString);
12491
+ node.body = convertNode(node, scope, buffer[position + 2], buffer, readString);
12492
+ },
12493
+ function conditionalExpression(node, position, buffer, readString) {
12494
+ const { scope } = node;
12495
+ node.consequent = convertNode(node, scope, buffer[position], buffer, readString);
12496
+ node.alternate = convertNode(node, scope, buffer[position + 1], buffer, readString);
12497
+ node.test = convertNode(node, scope, position + 2, buffer, readString);
12498
+ },
12499
+ function continueStatement(node, position, buffer, readString) {
12500
+ const { scope } = node;
12501
+ const labelPosition = buffer[position];
12502
+ node.label =
12503
+ labelPosition === 0 ? null : convertNode(node, scope, labelPosition, buffer, readString);
12504
+ },
12505
+ function debuggerStatement() { },
12506
+ function directive(node, position, buffer, readString) {
12507
+ const { scope } = node;
12508
+ node.expression = convertNode(node, scope, buffer[position], buffer, readString);
12509
+ node.directive = convertString(position + 1, buffer, readString);
12510
+ },
12511
+ function doWhileStatement(node, position, buffer, readString) {
12512
+ const { scope } = node;
12513
+ node.test = convertNode(node, scope, buffer[position], buffer, readString);
12514
+ node.body = convertNode(node, scope, position + 1, buffer, readString);
12515
+ },
12516
+ function emptyStatement() { },
12517
+ function exportAllDeclaration(node, position, buffer, readString) {
12518
+ const { scope } = node;
12519
+ const exportedPosition = buffer[position];
12520
+ node.exported =
12521
+ exportedPosition === 0
12522
+ ? null
12523
+ : convertNode(node, scope, exportedPosition, buffer, readString);
12524
+ node.source = convertNode(node, scope, buffer[position + 1], buffer, readString);
12525
+ node.attributes = convertNodeList(node, scope, buffer[position + 2], buffer, readString);
12526
+ },
12527
+ function exportDefaultDeclaration(node, position, buffer, readString) {
12528
+ const { scope } = node;
12529
+ node.declaration = convertNode(node, scope, position, buffer, readString);
12530
+ },
12531
+ function exportNamedDeclaration(node, position, buffer, readString) {
12532
+ const { scope } = node;
12533
+ const sourcePosition = buffer[position];
12534
+ node.source =
12535
+ sourcePosition === 0 ? null : convertNode(node, scope, sourcePosition, buffer, readString);
12536
+ node.attributes = convertNodeList(node, scope, buffer[position + 1], buffer, readString);
12537
+ const declarationPosition = buffer[position + 2];
12538
+ node.declaration =
12539
+ declarationPosition === 0
12540
+ ? null
12541
+ : convertNode(node, scope, declarationPosition, buffer, readString);
12542
+ node.specifiers = convertNodeList(node, scope, position + 3, buffer, readString);
12543
+ },
12544
+ function exportSpecifier(node, position, buffer, readString) {
12545
+ const { scope } = node;
12546
+ const exportedPosition = buffer[position];
12547
+ node.local = convertNode(node, scope, position + 1, buffer, readString);
12548
+ node.exported =
12549
+ exportedPosition === 0
12550
+ ? node.local
12551
+ : convertNode(node, scope, exportedPosition, buffer, readString);
12552
+ },
12553
+ function expressionStatement(node, position, buffer, readString) {
12554
+ const { scope } = node;
12555
+ node.expression = convertNode(node, scope, position, buffer, readString);
12556
+ },
12557
+ function forInStatement(node, position, buffer, readString) {
12558
+ const { scope } = node;
12559
+ node.right = convertNode(node, scope, buffer[position], buffer, readString);
12560
+ node.body = convertNode(node, scope, buffer[position + 1], buffer, readString);
12561
+ node.left = convertNode(node, scope, position + 2, buffer, readString);
12562
+ },
12563
+ function forOfStatement(node, position, buffer, readString) {
12564
+ const { scope } = node;
12565
+ const flags = buffer[position];
12566
+ node.await = (flags & 1) === 1;
12567
+ node.right = convertNode(node, scope, buffer[position + 1], buffer, readString);
12568
+ node.body = convertNode(node, scope, buffer[position + 2], buffer, readString);
12569
+ node.left = convertNode(node, scope, position + 3, buffer, readString);
12570
+ },
12571
+ function forStatement(node, position, buffer, readString) {
12572
+ const { scope } = node;
12573
+ const initPosition = buffer[position];
12574
+ node.init =
12575
+ initPosition === 0 ? null : convertNode(node, scope, initPosition, buffer, readString);
12576
+ const testPosition = buffer[position + 1];
12577
+ node.test =
12578
+ testPosition === 0 ? null : convertNode(node, scope, testPosition, buffer, readString);
12579
+ const updatePosition = buffer[position + 2];
12580
+ node.update =
12581
+ updatePosition === 0 ? null : convertNode(node, scope, updatePosition, buffer, readString);
12582
+ node.body = convertNode(node, scope, buffer[position + 3], buffer, readString);
12583
+ },
12584
+ function functionDeclaration(node, position, buffer, readString) {
12585
+ const { scope } = node;
12586
+ const flags = buffer[position];
12587
+ node.async = (flags & 1) === 1;
12588
+ node.generator = (flags & 2) === 2;
12589
+ const idPosition = buffer[position + 1];
12590
+ node.id =
12591
+ idPosition === 0
12592
+ ? null
12593
+ : convertNode(node, scope.parent, idPosition, buffer, readString);
12594
+ const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer, readString));
12595
+ scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
12596
+ node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer, readString);
12597
+ const annotations = (node.annotations = convertAnnotations(position + 4, buffer));
12598
+ node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
12599
+ },
12600
+ function functionExpression(node, position, buffer, readString) {
12601
+ const { scope } = node;
12602
+ const flags = buffer[position];
12603
+ node.async = (flags & 1) === 1;
12604
+ node.generator = (flags & 2) === 2;
12605
+ const idPosition = buffer[position + 1];
12606
+ node.id =
12607
+ idPosition === 0 ? null : convertNode(node, node.idScope, idPosition, buffer, readString);
12608
+ const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer, readString));
12609
+ scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
12610
+ node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer, readString);
12611
+ const annotations = (node.annotations = convertAnnotations(position + 4, buffer));
12612
+ node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
12613
+ },
12614
+ function identifier(node, position, buffer, readString) {
12615
+ node.name = convertString(position, buffer, readString);
12616
+ },
12617
+ function ifStatement(node, position, buffer, readString) {
12618
+ const { scope } = node;
12619
+ node.consequent = convertNode(node, (node.consequentScope = new TrackingScope(scope)), buffer[position], buffer, readString);
12620
+ const alternatePosition = buffer[position + 1];
12621
+ node.alternate =
12622
+ alternatePosition === 0
12623
+ ? null
12624
+ : convertNode(node, (node.alternateScope = new TrackingScope(scope)), alternatePosition, buffer, readString);
12625
+ node.test = convertNode(node, scope, position + 2, buffer, readString);
12626
+ },
12627
+ function importAttribute(node, position, buffer, readString) {
12628
+ const { scope } = node;
12629
+ node.value = convertNode(node, scope, buffer[position], buffer, readString);
12630
+ node.key = convertNode(node, scope, position + 1, buffer, readString);
12631
+ },
12632
+ function importDeclaration(node, position, buffer, readString) {
12633
+ const { scope } = node;
12634
+ node.source = convertNode(node, scope, buffer[position], buffer, readString);
12635
+ node.attributes = convertNodeList(node, scope, buffer[position + 1], buffer, readString);
12636
+ node.specifiers = convertNodeList(node, scope, position + 2, buffer, readString);
12637
+ },
12638
+ function importDefaultSpecifier(node, position, buffer, readString) {
12639
+ const { scope } = node;
12640
+ node.local = convertNode(node, scope, position, buffer, readString);
12641
+ },
12642
+ function importExpression(node, position, buffer, readString) {
12643
+ const { scope } = node;
12644
+ const optionsPosition = buffer[position];
12645
+ node.options =
12646
+ optionsPosition === 0 ? null : convertNode(node, scope, optionsPosition, buffer, readString);
12647
+ node.source = convertNode(node, scope, position + 1, buffer, readString);
12648
+ node.sourceAstNode = convertNode$1(position + 1, buffer, readString);
12649
+ },
12650
+ function importNamespaceSpecifier(node, position, buffer, readString) {
12651
+ const { scope } = node;
12652
+ node.local = convertNode(node, scope, position, buffer, readString);
12653
+ },
12654
+ function importSpecifier(node, position, buffer, readString) {
12655
+ const { scope } = node;
12656
+ const importedPosition = buffer[position];
12657
+ node.local = convertNode(node, scope, buffer[position + 1], buffer, readString);
12658
+ node.imported =
12659
+ importedPosition === 0
12660
+ ? node.local
12661
+ : convertNode(node, scope, importedPosition, buffer, readString);
12662
+ },
12663
+ function labeledStatement(node, position, buffer, readString) {
12664
+ const { scope } = node;
12665
+ node.body = convertNode(node, scope, buffer[position], buffer, readString);
12666
+ node.label = convertNode(node, scope, position + 1, buffer, readString);
12667
+ },
12668
+ function literalBigInt(node, position, buffer, readString) {
12669
+ node.raw = convertString(buffer[position], buffer, readString);
12670
+ const bigint = (node.bigint = convertString(position + 1, buffer, readString));
12671
+ node.value = BigInt(bigint);
12672
+ },
12673
+ function literalBoolean(node, position, buffer) {
12674
+ const flags = buffer[position];
12675
+ const value = (node.value = (flags & 1) === 1);
12676
+ node.raw = value ? 'true' : 'false';
12677
+ },
12678
+ function literalNull(node) {
12679
+ node.value = null;
12680
+ },
12681
+ function literalNumber(node, position, buffer, readString) {
12682
+ const rawPosition = buffer[position];
12683
+ node.raw = rawPosition === 0 ? undefined : convertString(rawPosition, buffer, readString);
12684
+ node.value = new DataView(buffer.buffer).getFloat64((position + 1) << 2, true);
12685
+ },
12686
+ function literalRegExp(node, position, buffer, readString) {
12687
+ const pattern = convertString(buffer[position], buffer, readString);
12688
+ const flags = convertString(position + 1, buffer, readString);
12689
+ node.raw = `/${pattern}/${flags}`;
12690
+ node.regex = { flags, pattern };
12691
+ node.value = new RegExp(pattern, flags);
12692
+ },
12693
+ function literalString(node, position, buffer, readString) {
12694
+ const rawPosition = buffer[position];
12695
+ node.raw = rawPosition === 0 ? undefined : convertString(rawPosition, buffer, readString);
12696
+ node.value = convertString(position + 1, buffer, readString);
12697
+ },
12698
+ function logicalExpression(node, position, buffer, readString) {
12699
+ const { scope } = node;
12700
+ node.operator = FIXED_STRINGS[buffer[position]];
12701
+ node.right = convertNode(node, scope, buffer[position + 1], buffer, readString);
12702
+ node.left = convertNode(node, scope, position + 2, buffer, readString);
12703
+ },
12704
+ function memberExpression(node, position, buffer, readString) {
12705
+ const { scope } = node;
12706
+ const flags = buffer[position];
12707
+ node.computed = (flags & 1) === 1;
12708
+ node.optional = (flags & 2) === 2;
12709
+ node.property = convertNode(node, scope, buffer[position + 1], buffer, readString);
12710
+ node.object = convertNode(node, scope, position + 2, buffer, readString);
12711
+ },
12712
+ function metaProperty(node, position, buffer, readString) {
12713
+ const { scope } = node;
12714
+ node.property = convertNode(node, scope, buffer[position], buffer, readString);
12715
+ node.meta = convertNode(node, scope, position + 1, buffer, readString);
12716
+ },
12717
+ function methodDefinition(node, position, buffer, readString) {
12718
+ const { scope } = node;
12719
+ const flags = buffer[position];
12720
+ node.static = (flags & 1) === 1;
12721
+ node.computed = (flags & 2) === 2;
12722
+ node.value = convertNode(node, scope, buffer[position + 1], buffer, readString);
12723
+ node.kind = FIXED_STRINGS[buffer[position + 2]];
12724
+ node.key = convertNode(node, scope, position + 3, buffer, readString);
12725
+ },
12726
+ function newExpression(node, position, buffer, readString) {
12727
+ const { scope } = node;
12728
+ node.callee = convertNode(node, scope, buffer[position], buffer, readString);
12729
+ node.arguments = convertNodeList(node, scope, buffer[position + 1], buffer, readString);
12730
+ node.annotations = convertAnnotations(position + 2, buffer);
12731
+ },
12732
+ function objectExpression(node, position, buffer, readString) {
12733
+ const { scope } = node;
12734
+ node.properties = convertNodeList(node, scope, position, buffer, readString);
12735
+ },
12736
+ function objectPattern(node, position, buffer, readString) {
12737
+ const { scope } = node;
12738
+ node.properties = convertNodeList(node, scope, position, buffer, readString);
12739
+ },
12740
+ function privateIdentifier(node, position, buffer, readString) {
12741
+ node.name = convertString(position, buffer, readString);
12742
+ },
12743
+ function program(node, position, buffer, readString) {
12744
+ const { scope } = node;
12745
+ node.invalidAnnotations = convertAnnotations(buffer[position], buffer);
12746
+ node.body = convertNodeList(node, scope, position + 1, buffer, readString);
12747
+ },
12748
+ function property(node, position, buffer, readString) {
12749
+ const { scope } = node;
12750
+ const flags = buffer[position];
12751
+ node.method = (flags & 1) === 1;
12752
+ node.shorthand = (flags & 2) === 2;
12753
+ node.computed = (flags & 4) === 4;
12754
+ const keyPosition = buffer[position + 1];
12755
+ node.value = convertNode(node, scope, buffer[position + 2], buffer, readString);
12756
+ node.kind = FIXED_STRINGS[buffer[position + 3]];
12757
+ node.key =
12758
+ keyPosition === 0 ? node.value : convertNode(node, scope, keyPosition, buffer, readString);
12759
+ },
12760
+ function propertyDefinition(node, position, buffer, readString) {
12761
+ const { scope } = node;
12762
+ const flags = buffer[position];
12763
+ node.static = (flags & 1) === 1;
12764
+ node.computed = (flags & 2) === 2;
12765
+ const valuePosition = buffer[position + 1];
12766
+ node.value =
12767
+ valuePosition === 0 ? null : convertNode(node, scope, valuePosition, buffer, readString);
12768
+ node.key = convertNode(node, scope, position + 2, buffer, readString);
12769
+ },
12770
+ function restElement(node, position, buffer, readString) {
12771
+ const { scope } = node;
12772
+ node.argument = convertNode(node, scope, position, buffer, readString);
12773
+ },
12774
+ function returnStatement(node, position, buffer, readString) {
12775
+ const { scope } = node;
12776
+ const argumentPosition = buffer[position];
12777
+ node.argument =
12778
+ argumentPosition === 0
12779
+ ? null
12780
+ : convertNode(node, scope, argumentPosition, buffer, readString);
12781
+ },
12782
+ function sequenceExpression(node, position, buffer, readString) {
12783
+ const { scope } = node;
12784
+ node.expressions = convertNodeList(node, scope, position, buffer, readString);
12785
+ },
12786
+ function spreadElement(node, position, buffer, readString) {
12787
+ const { scope } = node;
12788
+ node.argument = convertNode(node, scope, position, buffer, readString);
12789
+ },
12790
+ function staticBlock(node, position, buffer, readString) {
12791
+ const { scope } = node;
12792
+ node.body = convertNodeList(node, scope, position, buffer, readString);
12793
+ },
12794
+ function superElement() { },
12795
+ function switchCase(node, position, buffer, readString) {
12796
+ const { scope } = node;
12797
+ const testPosition = buffer[position];
12798
+ node.test =
12799
+ testPosition === 0 ? null : convertNode(node, scope, testPosition, buffer, readString);
12800
+ node.consequent = convertNodeList(node, scope, buffer[position + 1], buffer, readString);
12801
+ },
12802
+ function switchStatement(node, position, buffer, readString) {
12803
+ const { scope } = node;
12804
+ node.cases = convertNodeList(node, scope, buffer[position], buffer, readString);
12805
+ node.discriminant = convertNode(node, node.parentScope, position + 1, buffer, readString);
12806
+ },
12807
+ function taggedTemplateExpression(node, position, buffer, readString) {
12808
+ const { scope } = node;
12809
+ node.quasi = convertNode(node, scope, buffer[position], buffer, readString);
12810
+ node.tag = convertNode(node, scope, position + 1, buffer, readString);
12811
+ },
12812
+ function templateElement(node, position, buffer, readString) {
12813
+ const flags = buffer[position];
12814
+ node.tail = (flags & 1) === 1;
12815
+ const cookedPosition = buffer[position + 1];
12816
+ const cooked = cookedPosition === 0 ? undefined : convertString(cookedPosition, buffer, readString);
12817
+ const raw = convertString(position + 2, buffer, readString);
12818
+ node.value = { cooked, raw };
12819
+ },
12820
+ function templateLiteral(node, position, buffer, readString) {
12821
+ const { scope } = node;
12822
+ node.expressions = convertNodeList(node, scope, buffer[position], buffer, readString);
12823
+ node.quasis = convertNodeList(node, scope, position + 1, buffer, readString);
12824
+ },
12825
+ function thisExpression() { },
12826
+ function throwStatement(node, position, buffer, readString) {
12827
+ const { scope } = node;
12828
+ node.argument = convertNode(node, scope, position, buffer, readString);
12829
+ },
12830
+ function tryStatement(node, position, buffer, readString) {
12831
+ const { scope } = node;
12832
+ const handlerPosition = buffer[position];
12833
+ node.handler =
12834
+ handlerPosition === 0 ? null : convertNode(node, scope, handlerPosition, buffer, readString);
12835
+ const finalizerPosition = buffer[position + 1];
12836
+ node.finalizer =
12837
+ finalizerPosition === 0
12838
+ ? null
12839
+ : convertNode(node, scope, finalizerPosition, buffer, readString);
12840
+ node.block = convertNode(node, scope, position + 2, buffer, readString);
12841
+ },
12842
+ function unaryExpression(node, position, buffer, readString) {
12843
+ const { scope } = node;
12844
+ node.operator = FIXED_STRINGS[buffer[position]];
12845
+ node.argument = convertNode(node, scope, position + 1, buffer, readString);
12846
+ },
12847
+ function updateExpression(node, position, buffer, readString) {
12848
+ const { scope } = node;
12849
+ const flags = buffer[position];
12850
+ node.prefix = (flags & 1) === 1;
12851
+ node.operator = FIXED_STRINGS[buffer[position + 1]];
12852
+ node.argument = convertNode(node, scope, position + 2, buffer, readString);
12853
+ },
12854
+ function variableDeclaration(node, position, buffer, readString) {
12855
+ const { scope } = node;
12856
+ node.kind = FIXED_STRINGS[buffer[position]];
12857
+ node.declarations = convertNodeList(node, scope, position + 1, buffer, readString);
12858
+ },
12859
+ function variableDeclarator(node, position, buffer, readString) {
12860
+ const { scope } = node;
12861
+ const initPosition = buffer[position];
12862
+ node.init =
12863
+ initPosition === 0 ? null : convertNode(node, scope, initPosition, buffer, readString);
12864
+ node.id = convertNode(node, scope, position + 1, buffer, readString);
12865
+ },
12866
+ function whileStatement(node, position, buffer, readString) {
12867
+ const { scope } = node;
12868
+ node.body = convertNode(node, scope, buffer[position], buffer, readString);
12869
+ node.test = convertNode(node, scope, position + 1, buffer, readString);
12870
+ },
12871
+ function yieldExpression(node, position, buffer, readString) {
12872
+ const { scope } = node;
12873
+ const flags = buffer[position];
12874
+ node.delegate = (flags & 1) === 1;
12875
+ const argumentPosition = buffer[position + 1];
12876
+ node.argument =
12877
+ argumentPosition === 0
12878
+ ? null
12879
+ : convertNode(node, scope, argumentPosition, buffer, readString);
12880
+ }
12881
+ ];
12882
+ function convertNode(parent, parentScope, position, buffer, readString) {
12883
+ const nodeType = buffer[position];
12884
+ const NodeConstructor = nodeConstructors$1[nodeType];
12885
+ /* istanbul ignore if: This should never be executed but is a safeguard against faulty buffers */
12886
+ if (!NodeConstructor) {
12887
+ console.trace();
12888
+ throw new Error(`Unknown node type: ${nodeType}`);
12889
+ }
12890
+ const node = new NodeConstructor(parent, parentScope);
12891
+ node.type = nodeTypeStrings[nodeType];
12892
+ node.start = buffer[position + 1];
12893
+ node.end = buffer[position + 2];
12894
+ bufferParsers[nodeType](node, position + 3, buffer, readString);
12895
+ node.initialise();
12896
+ return node;
12897
+ }
12898
+ function convertNodeList(parent, parentScope, position, buffer, readString) {
12899
+ const length = buffer[position++];
12900
+ const list = [];
12901
+ for (let index = 0; index < length; index++) {
12902
+ const nodePosition = buffer[position++];
12903
+ list.push(nodePosition ? convertNode(parent, parentScope, nodePosition, buffer, readString) : null);
12904
+ }
12905
+ return list;
12906
+ }
12907
+
12908
+ class UnknownNode extends NodeBase {
12909
+ hasEffects() {
12910
+ return true;
12911
+ }
12912
+ include(context) {
12913
+ super.include(context, true);
12914
+ }
12915
+ }
12916
+
12089
12917
  const nodeConstructors = {
12090
12918
  ArrayExpression,
12091
12919
  ArrayPattern,
@@ -12133,6 +12961,8 @@ const nodeConstructors = {
12133
12961
  NewExpression,
12134
12962
  ObjectExpression,
12135
12963
  ObjectPattern,
12964
+ PanicError,
12965
+ ParseError,
12136
12966
  PrivateIdentifier,
12137
12967
  Program,
12138
12968
  Property,
@@ -12487,7 +13317,9 @@ function getAttributesFromImportExpression(node) {
12487
13317
  }
12488
13318
  const getPropertyKey = (property) => {
12489
13319
  const key = property.key;
12490
- return (key && !property.computed && (key.name || key.value));
13320
+ return (key &&
13321
+ !property.computed &&
13322
+ (key.name || key.value));
12491
13323
  };
12492
13324
  function getAttributesFromImportExportDeclaration(attributes) {
12493
13325
  return attributes?.length
@@ -13135,11 +13967,11 @@ class Module {
13135
13967
  return { source, usesTopLevelAwait };
13136
13968
  }
13137
13969
  async setSource({ ast, code, customTransformCache, originalCode, originalSourcemap, resolvedIds, sourcemapChain, transformDependencies, transformFiles, ...moduleOptions }) {
13970
+ timeStart('generate ast', 3);
13138
13971
  if (code.startsWith('#!')) {
13139
13972
  const shebangEndPosition = code.indexOf('\n');
13140
13973
  this.shebang = code.slice(2, shebangEndPosition);
13141
13974
  }
13142
- timeStart('generate ast', 3);
13143
13975
  this.info.code = code;
13144
13976
  this.originalCode = originalCode;
13145
13977
  // We need to call decodedSourcemap on the input in case they were hydrated from json in the cache and don't
@@ -13155,9 +13987,6 @@ class Module {
13155
13987
  this.transformDependencies = transformDependencies;
13156
13988
  this.customTransformCache = customTransformCache;
13157
13989
  this.updateOptions(moduleOptions);
13158
- const moduleAst = ast ?? (await this.tryParseAsync());
13159
- timeEnd('generate ast', 3);
13160
- timeStart('analyze ast', 3);
13161
13990
  this.resolvedIds = resolvedIds ?? Object.create(null);
13162
13991
  // By default, `id` is the file name. Custom resolvers and loaders
13163
13992
  // can change that, but it makes sense to use it for the source file name
@@ -13197,13 +14026,17 @@ class Module {
13197
14026
  };
13198
14027
  this.scope = new ModuleScope(this.graph.scope, this.astContext);
13199
14028
  this.namespace = new NamespaceVariable(this.astContext);
13200
- this.ast = new Program(moduleAst, { context: this.astContext, type: 'Module' }, this.scope);
13201
- // Assign AST directly if has existing one as there's no way to drop it from memory.
13202
- // If cache is enabled, also assign directly as otherwise it takes more CPU and memory to re-compute.
13203
- if (ast || this.options.cache !== false) {
13204
- this.info.ast = moduleAst;
14029
+ const programParent = { context: this.astContext, type: 'Module' };
14030
+ if (ast) {
14031
+ this.ast = new nodeConstructors[ast.type](programParent, this.scope).parseNode(ast);
14032
+ this.info.ast = ast;
13205
14033
  }
13206
14034
  else {
14035
+ // Measuring asynchronous code does not provide reasonable results
14036
+ timeEnd('generate ast', 3);
14037
+ const astBuffer = await parseAsync(code, false);
14038
+ timeStart('generate ast', 3);
14039
+ this.ast = convertProgram(astBuffer, programParent, this.scope);
13207
14040
  // Make lazy and apply LRU cache to not hog the memory
13208
14041
  Object.defineProperty(this.info, 'ast', {
13209
14042
  get: () => {
@@ -13212,13 +14045,23 @@ class Module {
13212
14045
  }
13213
14046
  else {
13214
14047
  const parsedAst = this.tryParse();
14048
+ // If the cache is not disabled, we need to keep the AST in memory
14049
+ // until the end when the cache is generated
14050
+ if (this.options.cache !== false) {
14051
+ Object.defineProperty(this.info, 'ast', {
14052
+ value: parsedAst
14053
+ });
14054
+ return parsedAst;
14055
+ }
14056
+ // Otherwise, we keep it in a small LRU cache to not hog too much
14057
+ // memory but allow the same AST to be requested several times.
13215
14058
  this.graph.astLru.set(fileName, parsedAst);
13216
14059
  return parsedAst;
13217
14060
  }
13218
14061
  }
13219
14062
  });
13220
14063
  }
13221
- timeEnd('analyze ast', 3);
14064
+ timeEnd('generate ast', 3);
13222
14065
  }
13223
14066
  toJSON() {
13224
14067
  return {
@@ -13271,13 +14114,15 @@ class Module {
13271
14114
  }
13272
14115
  }
13273
14116
  addDynamicImport(node) {
13274
- let argument = node.source;
13275
- if (argument instanceof TemplateLiteral) {
13276
- if (argument.quasis.length === 1 && argument.quasis[0].value.cooked) {
14117
+ let argument = node.sourceAstNode;
14118
+ if (argument.type === TemplateLiteral$1) {
14119
+ if (argument.quasis.length === 1 &&
14120
+ typeof argument.quasis[0].value.cooked === 'string') {
13277
14121
  argument = argument.quasis[0].value.cooked;
13278
14122
  }
13279
14123
  }
13280
- else if (argument instanceof Literal && typeof argument.value === 'string') {
14124
+ else if (argument.type === Literal$1 &&
14125
+ typeof argument.value === 'string') {
13281
14126
  argument = argument.value;
13282
14127
  }
13283
14128
  this.dynamicImports.push({ argument, id: null, node, resolution: null });
@@ -13572,14 +14417,6 @@ class Module {
13572
14417
  return this.error(logModuleParseError(error_, this.id), error_.pos);
13573
14418
  }
13574
14419
  }
13575
- async tryParseAsync() {
13576
- try {
13577
- return await parseAstAsync(this.info.code);
13578
- }
13579
- catch (error_) {
13580
- return this.error(logModuleParseError(error_, this.id), error_.pos);
13581
- }
13582
- }
13583
14420
  }
13584
14421
  // if there is a cyclic import in the reexport chain, we should not
13585
14422
  // import from the original module but from the cyclic module to not
@@ -15921,13 +16758,10 @@ function* concatLazy(iterables) {
15921
16758
  *
15922
16759
  * One non-trivial optimization we can apply is that dynamic entries are
15923
16760
  * different from static entries in so far as when a dynamic import occurs,
15924
- * some
15925
- * modules are already in memory. If some of these modules are also
15926
- * dependencies
15927
- * of the dynamic entry, then it does not make sense to create a separate chunk
15928
- * for them. Instead, the dynamic import target can load them from the
15929
- * importing
15930
- * chunk.
16761
+ * some modules are already in memory. If some of these modules are also
16762
+ * dependencies of the dynamic entry, then it does not make sense to create a
16763
+ * separate chunk for them. Instead, the dynamic import target can load them
16764
+ * from the importing chunk.
15931
16765
  *
15932
16766
  * With regard to chunking, if B is implicitly loaded after A, then this can be
15933
16767
  * handled the same way as if there was a dynamic import A => B.
@@ -15936,8 +16770,7 @@ function* concatLazy(iterables) {
15936
16770
  * Assume A -> B (A imports B), A => C (A dynamically imports C) and C -> B.
15937
16771
  * Then the initial algorithm would assign A into the A chunk, C into the C
15938
16772
  * chunk and B into the AC chunk, i.e. the chunk with the dependent entry
15939
- * points
15940
- * A and C.
16773
+ * points A and C.
15941
16774
  * However we know that C can only be loaded from A, so A and its dependency B
15942
16775
  * must already be in memory when C is loaded. So it is enough to create only
15943
16776
  * two chunks A containing [AB] and C containing [C].
@@ -15952,15 +16785,13 @@ function* concatLazy(iterables) {
15952
16785
  * A => D,
15953
16786
  * D -> B, D -> C
15954
16787
  * So without dynamic import optimization, the dependent entry points are
15955
- * A: XY, B: DXY, C: DX, D: D, X: X, Y: Y,
15956
- * so we would for now create six chunks.
16788
+ * A: XY, B: DXY, C: DX, D: D, X: X, Y: Y, so we would for now create six
16789
+ * chunks.
15957
16790
  *
15958
16791
  * Now D is loaded only after A is loaded. But A is loaded if either X is
15959
- * loaded
15960
- * or Y is loaded. So the modules that are already in memory when D is loaded
15961
- * are the intersection of all modules that X depends on with all modules that
15962
- * Y
15963
- * depends on, which in this case are the modules A and B.
16792
+ * loaded or Y is loaded. So the modules that are already in memory when D is
16793
+ * loaded are the intersection of all modules that X depends on with all
16794
+ * modules that Y depends on, which in this case are the modules A and B.
15964
16795
  * We could also say they are all modules that have both X and Y as dependent
15965
16796
  * entry points.
15966
16797
  *
@@ -15969,8 +16800,7 @@ function* concatLazy(iterables) {
15969
16800
  * same chunk.
15970
16801
  *
15971
16802
  * Now let us extend this to the most general case where we have several
15972
- * dynamic
15973
- * importers for one dynamic entry point.
16803
+ * dynamic importers for one dynamic entry point.
15974
16804
  *
15975
16805
  * In the most general form, it works like this:
15976
16806
  * For each dynamic entry point, we have a number of dynamic importers, which
@@ -15983,9 +16813,8 @@ function* concatLazy(iterables) {
15983
16813
  * each dynamic importer.
15984
16814
  *
15985
16815
  * Assuming that A => D and B => D and A has dependent entry points XY and B
15986
- * has
15987
- * dependent entry points YZ, then the modules guaranteed to be in memory are
15988
- * all modules that have at least XYZ as dependent entry points.
16816
+ * has dependent entry points YZ, then the modules guaranteed to be in memory
16817
+ * are all modules that have at least XYZ as dependent entry points.
15989
16818
  * We call XYZ the *dynamically dependent entry points* of D.
15990
16819
  *
15991
16820
  * Now there is one last case to consider: If one of the dynamically dependent
@@ -16012,7 +16841,7 @@ function* concatLazy(iterables) {
16012
16841
  *
16013
16842
  * For efficient operations, we assign each entry a numerical index and
16014
16843
  * represent Sets of Chunks as BigInt values where each chunk corresponds to a
16015
- * bit index. Then thw last two maps can be represented as arrays of BigInt
16844
+ * bit index. Then the last two maps can be represented as arrays of BigInt
16016
16845
  * values.
16017
16846
  *
16018
16847
  * Then we iterate through each dynamic entry. We set the already loaded modules
@@ -17831,7 +18660,6 @@ class ModuleLoader {
17831
18660
  ? source
17832
18661
  : error(logBadLoader(id));
17833
18662
  const code = sourceDescription.code;
17834
- /* eslint-disable-next-line unicorn/number-literal-case */
17835
18663
  if (code.charCodeAt(0) === 65279) {
17836
18664
  sourceDescription.code = code.slice(1);
17837
18665
  }
@@ -18015,9 +18843,7 @@ class ModuleLoader {
18015
18843
  }
18016
18844
  getResolveDynamicImportPromises(module) {
18017
18845
  return module.dynamicImports.map(async (dynamicImport) => {
18018
- const resolvedId = await this.resolveDynamicImport(module, typeof dynamicImport.argument === 'string'
18019
- ? dynamicImport.argument
18020
- : dynamicImport.argument.esTreeNode, module.id, getAttributesFromImportExpression(dynamicImport.node));
18846
+ const resolvedId = await this.resolveDynamicImport(module, dynamicImport.argument, module.id, getAttributesFromImportExpression(dynamicImport.node));
18021
18847
  if (resolvedId && typeof resolvedId === 'object') {
18022
18848
  dynamicImport.id = resolvedId.id;
18023
18849
  }