@uni-ku/bundle-optimizer
Version:
uni-app 分包优化插件化实现
1,124 lines (1,118 loc) • 507 kB
JavaScript
//#region rolldown:runtime
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) {
__defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
}
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
//#endregion
let node_fs = require("node:fs");
node_fs = __toESM(node_fs);
let node_process = require("node:process");
node_process = __toESM(node_process);
let chalk = require("chalk");
chalk = __toESM(chalk);
let node_path = require("node:path");
node_path = __toESM(node_path);
let node_buffer = require("node:buffer");
let node_util_types = require("node:util/types");
let _vue_compiler_sfc = require("@vue/compiler-sfc");
let _dcloudio_uni_cli_shared = require("@dcloudio/uni-cli-shared");
//#region package.json
var name = "@uni-ku/bundle-optimizer";
//#endregion
//#region src/common/Logger.ts
var LogLevel = /* @__PURE__ */ function(LogLevel$1) {
LogLevel$1["DEBUG"] = "DEBUG";
LogLevel$1["INFO"] = "INFO";
LogLevel$1["WARN"] = "WARN";
LogLevel$1["ERROR"] = "ERROR";
return LogLevel$1;
}(LogLevel || {});
var Logger = class {
level;
context;
/** TODO: 可以使用其他的 debug 日志库 */
Debugger = null;
/** 全局兜底:是否是隐式log */
isImplicit;
onLog;
constructor(level = LogLevel.INFO, context = "Plugin", isImplicit = false) {
this.level = level;
this.context = context;
this.isImplicit = isImplicit;
}
log(level, message, isImplicit) {
if (this.shouldLog(level)) {
const coloredMessage = this.getColoredMessage(level, message);
this.onLog?.(this.context, level, message, Date.now());
if (isImplicit ?? this.isImplicit) {} else {
const c = 69;
const colorCode = `\u001B[3${c < 8 ? c : `8;5;${c}`};1m`;
console.log(` ${(0, chalk.default)(`${colorCode}${this.context}`)} ${coloredMessage}`);
}
}
}
shouldLog(level) {
const levels = [
LogLevel.DEBUG,
LogLevel.INFO,
LogLevel.WARN,
LogLevel.ERROR
];
return levels.indexOf(level) >= levels.indexOf(this.level);
}
getColoredMessage(level, message) {
switch (level) {
case LogLevel.DEBUG: return chalk.default.blue(`[${level}] ${message}`);
case LogLevel.INFO: return chalk.default.green(`[${level}] ${message}`);
case LogLevel.WARN: return chalk.default.yellow(`[${level}] ${message}`);
case LogLevel.ERROR: return chalk.default.red(`[${level}] ${message}`);
default: return message;
}
}
debug(message, isImplicit) {
this.log(LogLevel.DEBUG, message, isImplicit);
}
info(message, isImplicit) {
this.log(LogLevel.INFO, message, isImplicit);
}
warn(message, isImplicit) {
this.log(LogLevel.WARN, message, isImplicit);
}
error(message, isImplicit) {
this.log(LogLevel.ERROR, message, isImplicit);
}
};
const logger = new Logger(LogLevel.INFO, "uni-ku:bundle-optimizer");
//#endregion
//#region src/common/ParseOptions.ts
var ParseOptions = class {
options;
constructor(options) {
this.options = options;
}
get enable() {
const { enable: origin = true } = this.options;
return typeof origin === "boolean" ? {
"optimization": origin,
"async-component": origin,
"async-import": origin
} : {
"optimization": origin.optimization ?? true,
"async-component": origin["async-component"] ?? true,
"async-import": origin["async-import"] ?? true
};
}
get logger() {
const { logger: origin = false } = this.options;
const _ = [
"optimization",
"async-component",
"async-import"
];
const temp = typeof origin === "boolean" ? origin ? _ : false : origin;
return Object.fromEntries(_.map((item) => [item, (temp || []).includes(item)]));
}
};
//#endregion
//#region src/constants.ts
/**
* `js`|`jsx`|`ts`|`uts`|`tsx`|`mjs`|`json`
* @description json 文件会被处理成 js 模块
*/
const EXTNAME_JS_RE = /\.(js|jsx|ts|uts|tsx|mjs|json)$/;
/** 文件后缀 */
const EXT_RE = /\.\w+$/;
/**
* 项目根路径
*
* // TODO: 后续自实现项目根路径的查找
*/
const ROOT_DIR = node_process.default.env.VITE_ROOT_DIR;
if (!ROOT_DIR) throw new Error("`ROOT_DIR` is not defined");
/**
* Uniapp 业务源码入口
*/
const UNI_INPUT_DIR = node_process.default.env.UNI_INPUT_DIR;
if (!UNI_INPUT_DIR) throw new Error("`UNI_INPUT_DIR` is not defined");
if (!`${UNI_INPUT_DIR}/`.startsWith(ROOT_DIR)) throw new Error("`UNI_INPUT_DIR` need startsWith `ROOT_DIR`");
/**
* Uniapp 输出目录
*/
const UNI_OUTPUT_DIR = node_process.default.env.UNI_OUTPUT_DIR;
if (!UNI_OUTPUT_DIR) throw new Error("`UNI_OUTPUT_DIR` is not defined");
const pathDiff = diffStrings(ROOT_DIR, UNI_INPUT_DIR);
/**
* uniapp 业务源码路径与项目根路径的差异
*/
const UNI_SRC_DIFF_PATH = !pathDiff.diffA && !pathDiff.suffix && pathDiff.prefix === ROOT_DIR ? pathDiff.diffB : "";
//#endregion
//#region node_modules/.pnpm/@babel+parser@7.28.5/node_modules/@babel/parser/lib/index.js
var require_lib = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
function _objectWithoutPropertiesLoose(r, e) {
if (null == r) return {};
var t = {};
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
if (-1 !== e.indexOf(n)) continue;
t[n] = r[n];
}
return t;
}
var Position = class {
constructor(line, col, index) {
this.line = void 0;
this.column = void 0;
this.index = void 0;
this.line = line;
this.column = col;
this.index = index;
}
};
var SourceLocation = class {
constructor(start, end) {
this.start = void 0;
this.end = void 0;
this.filename = void 0;
this.identifierName = void 0;
this.start = start;
this.end = end;
}
};
function createPositionWithColumnOffset(position, columnOffset) {
const { line, column, index } = position;
return new Position(line, column + columnOffset, index + columnOffset);
}
const code = "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
var ModuleErrors = {
ImportMetaOutsideModule: {
message: `import.meta may appear only with 'sourceType: "module"'`,
code
},
ImportOutsideModule: {
message: `'import' and 'export' may appear only with 'sourceType: "module"'`,
code
}
};
const NodeDescriptions = {
ArrayPattern: "array destructuring pattern",
AssignmentExpression: "assignment expression",
AssignmentPattern: "assignment expression",
ArrowFunctionExpression: "arrow function expression",
ConditionalExpression: "conditional expression",
CatchClause: "catch clause",
ForOfStatement: "for-of statement",
ForInStatement: "for-in statement",
ForStatement: "for-loop",
FormalParameters: "function parameter list",
Identifier: "identifier",
ImportSpecifier: "import specifier",
ImportDefaultSpecifier: "import default specifier",
ImportNamespaceSpecifier: "import namespace specifier",
ObjectPattern: "object destructuring pattern",
ParenthesizedExpression: "parenthesized expression",
RestElement: "rest element",
UpdateExpression: {
true: "prefix operation",
false: "postfix operation"
},
VariableDeclarator: "variable declaration",
YieldExpression: "yield expression"
};
const toNodeDescription = (node) => node.type === "UpdateExpression" ? NodeDescriptions.UpdateExpression[`${node.prefix}`] : NodeDescriptions[node.type];
var StandardErrors = {
AccessorIsGenerator: ({ kind }) => `A ${kind}ter cannot be a generator.`,
ArgumentsInClass: "'arguments' is only allowed in functions and class methods.",
AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block.",
AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function.",
AwaitBindingIdentifierInStaticBlock: "Can not use 'await' as identifier inside a static block.",
AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.",
AwaitUsingNotInAsyncContext: "'await using' is only allowed within async functions and at the top levels of modules.",
AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.",
BadGetterArity: "A 'get' accessor must not have any formal parameters.",
BadSetterArity: "A 'set' accessor must have exactly one formal parameter.",
BadSetterRestParameter: "A 'set' accessor function argument must not be a rest parameter.",
ConstructorClassField: "Classes may not have a field named 'constructor'.",
ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.",
ConstructorIsAccessor: "Class constructor may not be an accessor.",
ConstructorIsAsync: "Constructor can't be an async function.",
ConstructorIsGenerator: "Constructor can't be a generator.",
DeclarationMissingInitializer: ({ kind }) => `Missing initializer in ${kind} declaration.`,
DecoratorArgumentsOutsideParentheses: "Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.",
DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.",
DecoratorsBeforeAfterExport: "Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.",
DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",
DecoratorExportClass: "Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.",
DecoratorSemicolon: "Decorators must not be followed by a semicolon.",
DecoratorStaticBlock: "Decorators can't be used with a static block.",
DeferImportRequiresNamespace: "Only `import defer * as x from \"./module\"` is valid.",
DeletePrivateField: "Deleting a private field is not allowed.",
DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
DuplicateConstructor: "Duplicate constructor in the same class.",
DuplicateDefaultExport: "Only one default export allowed per module.",
DuplicateExport: ({ exportName }) => `\`${exportName}\` has already been exported. Exported identifiers must be unique.`,
DuplicateProto: "Redefinition of __proto__ property.",
DuplicateRegExpFlags: "Duplicate regular expression flag.",
ElementAfterRest: "Rest element must be last element.",
EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
ExportBindingIsString: ({ localName, exportName }) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`,
ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
ForInOfLoopInitializer: ({ type }) => `'${type === "ForInStatement" ? "for-in" : "for-of"}' loop variable declaration may not have an initializer.`,
ForInUsing: "For-in loop may not start with 'using' declaration.",
ForOfAsync: "The left-hand side of a for-of loop may not be 'async'.",
ForOfLet: "The left-hand side of a for-of loop may not start with 'let'.",
GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block.",
IllegalBreakContinue: ({ type }) => `Unsyntactic ${type === "BreakStatement" ? "break" : "continue"}.`,
IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.",
IllegalReturn: "'return' outside of function.",
ImportAttributesUseAssert: "The `assert` keyword in import attributes is deprecated and it has been replaced by the `with` keyword. You can enable the `deprecatedImportAssert` parser plugin to suppress this error.",
ImportBindingIsString: ({ importName }) => `A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${importName}" as foo }\`?`,
ImportCallArity: `\`import()\` requires exactly one or two arguments.`,
ImportCallNotNewExpression: "Cannot use new with import(...).",
ImportCallSpreadArgument: "`...` is not allowed in `import()`.",
ImportJSONBindingNotDefault: "A JSON module can only be imported with `default`.",
ImportReflectionHasAssertion: "`import module x` cannot have assertions.",
ImportReflectionNotBinding: "Only `import module x from \"./module\"` is valid.",
IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.",
InvalidBigIntLiteral: "Invalid BigIntLiteral.",
InvalidCodePoint: "Code point out of bounds.",
InvalidCoverDiscardElement: "'void' must be followed by an expression when not used in a binding position.",
InvalidCoverInitializedName: "Invalid shorthand property initializer.",
InvalidDecimal: "Invalid decimal.",
InvalidDigit: ({ radix }) => `Expected number in radix ${radix}.`,
InvalidEscapeSequence: "Bad character escape sequence.",
InvalidEscapeSequenceTemplate: "Invalid escape sequence in template.",
InvalidEscapedReservedWord: ({ reservedWord }) => `Escape sequence in keyword ${reservedWord}.`,
InvalidIdentifier: ({ identifierName }) => `Invalid identifier ${identifierName}.`,
InvalidLhs: ({ ancestor }) => `Invalid left-hand side in ${toNodeDescription(ancestor)}.`,
InvalidLhsBinding: ({ ancestor }) => `Binding invalid left-hand side in ${toNodeDescription(ancestor)}.`,
InvalidLhsOptionalChaining: ({ ancestor }) => `Invalid optional chaining in the left-hand side of ${toNodeDescription(ancestor)}.`,
InvalidNumber: "Invalid number.",
InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'.",
InvalidOrUnexpectedToken: ({ unexpected }) => `Unexpected character '${unexpected}'.`,
InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern.",
InvalidPrivateFieldResolution: ({ identifierName }) => `Private name #${identifierName} is not defined.`,
InvalidPropertyBindingPattern: "Binding member expression.",
InvalidRecordProperty: "Only properties and spread elements are allowed in record definitions.",
InvalidRestAssignmentPattern: "Invalid rest operator's argument.",
LabelRedeclaration: ({ labelName }) => `Label '${labelName}' is already declared.`,
LetInLexicalBinding: "'let' is disallowed as a lexically bound name.",
LineTerminatorBeforeArrow: "No line break is allowed before '=>'.",
MalformedRegExpFlags: "Invalid regular expression flag.",
MissingClassName: "A class name is required.",
MissingEqInAssignment: "Only '=' operator can be used for specifying default value.",
MissingSemicolon: "Missing semicolon.",
MissingPlugin: ({ missingPlugin }) => `This experimental syntax requires enabling the parser plugin: ${missingPlugin.map((name$1) => JSON.stringify(name$1)).join(", ")}.`,
MissingOneOfPlugins: ({ missingPlugin }) => `This experimental syntax requires enabling one of the following parser plugin(s): ${missingPlugin.map((name$1) => JSON.stringify(name$1)).join(", ")}.`,
MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX.",
MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators.",
ModuleAttributeDifferentFromType: "The only accepted module attribute is `type`.",
ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values.",
ModuleAttributesWithDuplicateKeys: ({ key }) => `Duplicate key "${key}" is not allowed in module attributes.`,
ModuleExportNameHasLoneSurrogate: ({ surrogateCharCode }) => `An export name cannot include a lone surrogate, found '\\u${surrogateCharCode.toString(16)}'.`,
ModuleExportUndefined: ({ localName }) => `Export '${localName}' is not defined.`,
MultipleDefaultsInSwitch: "Multiple default clauses.",
NewlineAfterThrow: "Illegal newline after throw.",
NoCatchOrFinally: "Missing catch or finally clause.",
NumberIdentifier: "Identifier directly after number.",
NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",
ObsoleteAwaitStar: "'await*' has been removed from the async functions proposal. Use Promise.all() instead.",
OptionalChainingNoNew: "Constructors in/after an Optional Chain are not allowed.",
OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain.",
OverrideOnConstructor: "'override' modifier cannot appear on a constructor declaration.",
ParamDupe: "Argument name clash.",
PatternHasAccessor: "Object pattern can't contain getter or setter.",
PatternHasMethod: "Object pattern can't contain methods.",
PrivateInExpectedIn: ({ identifierName }) => `Private names are only allowed in property accesses (\`obj.#${identifierName}\`) or in \`in\` expressions (\`#${identifierName} in obj\`).`,
PrivateNameRedeclaration: ({ identifierName }) => `Duplicate private name #${identifierName}.`,
RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
RecordNoProto: "'__proto__' is not allowed in Record expressions.",
RestTrailingComma: "Unexpected trailing comma after rest element.",
SloppyFunction: "In non-strict mode code, functions can only be declared at top level or inside a block.",
SloppyFunctionAnnexB: "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.",
SourcePhaseImportRequiresDefault: "Only `import source x from \"./module\"` is valid.",
StaticPrototype: "Classes may not have static property named prototype.",
SuperNotAllowed: "`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?",
SuperPrivateField: "Private fields can't be accessed on super.",
TrailingDecorator: "Decorators must be attached to a class element.",
TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",
TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",
UnexpectedArgumentPlaceholder: "Unexpected argument placeholder.",
UnexpectedAwaitAfterPipelineBody: "Unexpected \"await\" after pipeline body; await must have parentheses in minimal proposal.",
UnexpectedDigitAfterHash: "Unexpected digit after hash token.",
UnexpectedImportExport: "'import' and 'export' may only appear at the top level.",
UnexpectedKeyword: ({ keyword }) => `Unexpected keyword '${keyword}'.`,
UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration.",
UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context.",
UnexpectedNewTarget: "`new.target` can only be used in functions or class properties.",
UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits.",
UnexpectedPrivateField: "Unexpected private name.",
UnexpectedReservedWord: ({ reservedWord }) => `Unexpected reserved word '${reservedWord}'.`,
UnexpectedSuper: "'super' is only allowed in object methods and classes.",
UnexpectedToken: ({ expected, unexpected }) => `Unexpected token${unexpected ? ` '${unexpected}'.` : ""}${expected ? `, expected "${expected}"` : ""}`,
UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
UnexpectedUsingDeclaration: "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement.",
UnexpectedVoidPattern: "Unexpected void binding.",
UnsupportedBind: "Binding should be performed on object property.",
UnsupportedDecoratorExport: "A decorated export must export a class declaration.",
UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
UnsupportedImport: "`import` can only be used in `import()` or `import.meta`.",
UnsupportedMetaProperty: ({ target, onlyValidPropertyName }) => `The only valid meta property for ${target} is ${target}.${onlyValidPropertyName}.`,
UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters.",
UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties.",
UnsupportedSuper: "'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",
UnterminatedComment: "Unterminated comment.",
UnterminatedRegExp: "Unterminated regular expression.",
UnterminatedString: "Unterminated string constant.",
UnterminatedTemplate: "Unterminated template.",
UsingDeclarationExport: "Using declaration cannot be exported.",
UsingDeclarationHasBindingPattern: "Using declaration cannot have destructuring patterns.",
VarRedeclaration: ({ identifierName }) => `Identifier '${identifierName}' has already been declared.`,
VoidPatternCatchClauseParam: "A void binding can not be the catch clause parameter. Use `try { ... } catch { ... }` if you want to discard the caught error.",
VoidPatternInitializer: "A void binding may not have an initializer.",
YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator.",
YieldInParameter: "Yield expression is not allowed in formal parameters.",
YieldNotInGeneratorFunction: "'yield' is only allowed within generator functions.",
ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0."
};
var StrictModeErrors = {
StrictDelete: "Deleting local variable in strict mode.",
StrictEvalArguments: ({ referenceName }) => `Assigning to '${referenceName}' in strict mode.`,
StrictEvalArgumentsBinding: ({ bindingName }) => `Binding '${bindingName}' in strict mode.`,
StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block.",
StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'.",
StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode.",
StrictWith: "'with' in strict mode."
};
var ParseExpressionErrors = {
ParseExpressionEmptyInput: "Unexpected parseExpression() input: The input is empty or contains only comments.",
ParseExpressionExpectsEOF: ({ unexpected }) => `Unexpected parseExpression() input: The input should contain exactly one expression, but the first expression is followed by the unexpected character \`${String.fromCodePoint(unexpected)}\`.`
};
const UnparenthesizedPipeBodyDescriptions = new Set([
"ArrowFunctionExpression",
"AssignmentExpression",
"ConditionalExpression",
"YieldExpression"
]);
var PipelineOperatorErrors = Object.assign({
PipeBodyIsTighter: "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.",
PipeTopicRequiresHackPipes: "Topic reference is used, but the pipelineOperator plugin was not passed a \"proposal\": \"hack\" or \"smart\" option.",
PipeTopicUnbound: "Topic reference is unbound; it must be inside a pipe body.",
PipeTopicUnconfiguredToken: ({ token }) => `Invalid topic token ${token}. In order to use ${token} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${token}" }.`,
PipeTopicUnused: "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.",
PipeUnparenthesizedBody: ({ type }) => `Hack-style pipe body cannot be an unparenthesized ${toNodeDescription({ type })}; please wrap it in parentheses.`
}, {
PipelineBodyNoArrow: "Unexpected arrow \"=>\" after pipeline body; arrow function in pipeline body must be parenthesized.",
PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression.",
PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression.",
PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference.",
PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
PrimaryTopicRequiresSmartPipeline: "Topic reference is used, but the pipelineOperator plugin was not passed a \"proposal\": \"hack\" or \"smart\" option."
});
const _excluded = ["message"];
function defineHidden(obj, key, value) {
Object.defineProperty(obj, key, {
enumerable: false,
configurable: true,
value
});
}
function toParseErrorConstructor({ toMessage, code, reasonCode, syntaxPlugin }) {
const hasMissingPlugin = reasonCode === "MissingPlugin" || reasonCode === "MissingOneOfPlugins";
{
const oldReasonCodes = {
AccessorCannotDeclareThisParameter: "AccesorCannotDeclareThisParameter",
AccessorCannotHaveTypeParameters: "AccesorCannotHaveTypeParameters",
ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference: "ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference",
SetAccessorCannotHaveOptionalParameter: "SetAccesorCannotHaveOptionalParameter",
SetAccessorCannotHaveRestParameter: "SetAccesorCannotHaveRestParameter",
SetAccessorCannotHaveReturnType: "SetAccesorCannotHaveReturnType"
};
if (oldReasonCodes[reasonCode]) reasonCode = oldReasonCodes[reasonCode];
}
return function constructor(loc, details) {
const error = /* @__PURE__ */ new SyntaxError();
error.code = code;
error.reasonCode = reasonCode;
error.loc = loc;
error.pos = loc.index;
error.syntaxPlugin = syntaxPlugin;
if (hasMissingPlugin) error.missingPlugin = details.missingPlugin;
defineHidden(error, "clone", function clone(overrides = {}) {
var _overrides$loc;
const { line, column, index } = (_overrides$loc = overrides.loc) != null ? _overrides$loc : loc;
return constructor(new Position(line, column, index), Object.assign({}, details, overrides.details));
});
defineHidden(error, "details", details);
Object.defineProperty(error, "message", {
configurable: true,
get() {
const message = `${toMessage(details)} (${loc.line}:${loc.column})`;
this.message = message;
return message;
},
set(value) {
Object.defineProperty(this, "message", {
value,
writable: true
});
}
});
return error;
};
}
function ParseErrorEnum(argument, syntaxPlugin) {
if (Array.isArray(argument)) return (parseErrorTemplates) => ParseErrorEnum(parseErrorTemplates, argument[0]);
const ParseErrorConstructors = {};
for (const reasonCode of Object.keys(argument)) {
const template = argument[reasonCode];
const _ref = typeof template === "string" ? { message: () => template } : typeof template === "function" ? { message: template } : template, { message } = _ref, rest = _objectWithoutPropertiesLoose(_ref, _excluded);
const toMessage = typeof message === "string" ? () => message : message;
ParseErrorConstructors[reasonCode] = toParseErrorConstructor(Object.assign({
code: "BABEL_PARSER_SYNTAX_ERROR",
reasonCode,
toMessage
}, syntaxPlugin ? { syntaxPlugin } : {}, rest));
}
return ParseErrorConstructors;
}
const Errors = Object.assign({}, ParseErrorEnum(ModuleErrors), ParseErrorEnum(StandardErrors), ParseErrorEnum(StrictModeErrors), ParseErrorEnum(ParseExpressionErrors), ParseErrorEnum`pipelineOperator`(PipelineOperatorErrors));
function createDefaultOptions() {
return {
sourceType: "script",
sourceFilename: void 0,
startIndex: 0,
startColumn: 0,
startLine: 1,
allowAwaitOutsideFunction: false,
allowReturnOutsideFunction: false,
allowNewTargetOutsideFunction: false,
allowImportExportEverywhere: false,
allowSuperOutsideMethod: false,
allowUndeclaredExports: false,
allowYieldOutsideFunction: false,
plugins: [],
strictMode: void 0,
ranges: false,
tokens: false,
createImportExpressions: false,
createParenthesizedExpressions: false,
errorRecovery: false,
attachComment: true,
annexB: true
};
}
function getOptions(opts) {
const options = createDefaultOptions();
if (opts == null) return options;
if (opts.annexB != null && opts.annexB !== false) throw new Error("The `annexB` option can only be set to `false`.");
for (const key of Object.keys(options)) if (opts[key] != null) options[key] = opts[key];
if (options.startLine === 1) {
if (opts.startIndex == null && options.startColumn > 0) options.startIndex = options.startColumn;
else if (opts.startColumn == null && options.startIndex > 0) options.startColumn = options.startIndex;
} else if (opts.startColumn == null || opts.startIndex == null) {
if (opts.startIndex != null) throw new Error("With a `startLine > 1` you must also specify `startIndex` and `startColumn`.");
}
if (options.sourceType === "commonjs") {
if (opts.allowAwaitOutsideFunction != null) throw new Error("The `allowAwaitOutsideFunction` option cannot be used with `sourceType: 'commonjs'`.");
if (opts.allowReturnOutsideFunction != null) throw new Error("`sourceType: 'commonjs'` implies `allowReturnOutsideFunction: true`, please remove the `allowReturnOutsideFunction` option or use `sourceType: 'script'`.");
if (opts.allowNewTargetOutsideFunction != null) throw new Error("`sourceType: 'commonjs'` implies `allowNewTargetOutsideFunction: true`, please remove the `allowNewTargetOutsideFunction` option or use `sourceType: 'script'`.");
}
return options;
}
const { defineProperty } = Object;
const toUnenumerable = (object, key) => {
if (object) defineProperty(object, key, {
enumerable: false,
value: object[key]
});
};
function toESTreeLocation(node) {
toUnenumerable(node.loc.start, "index");
toUnenumerable(node.loc.end, "index");
return node;
}
var estree = (superClass) => class ESTreeParserMixin extends superClass {
parse() {
const file = toESTreeLocation(super.parse());
if (this.optionFlags & 256) file.tokens = file.tokens.map(toESTreeLocation);
return file;
}
parseRegExpLiteral({ pattern, flags }) {
let regex = null;
try {
regex = new RegExp(pattern, flags);
} catch (_) {}
const node = this.estreeParseLiteral(regex);
node.regex = {
pattern,
flags
};
return node;
}
parseBigIntLiteral(value) {
let bigInt;
try {
bigInt = BigInt(value);
} catch (_unused) {
bigInt = null;
}
const node = this.estreeParseLiteral(bigInt);
node.bigint = String(node.value || value);
return node;
}
parseDecimalLiteral(value) {
const node = this.estreeParseLiteral(null);
node.decimal = String(node.value || value);
return node;
}
estreeParseLiteral(value) {
return this.parseLiteral(value, "Literal");
}
parseStringLiteral(value) {
return this.estreeParseLiteral(value);
}
parseNumericLiteral(value) {
return this.estreeParseLiteral(value);
}
parseNullLiteral() {
return this.estreeParseLiteral(null);
}
parseBooleanLiteral(value) {
return this.estreeParseLiteral(value);
}
estreeParseChainExpression(node, endLoc) {
const chain = this.startNodeAtNode(node);
chain.expression = node;
return this.finishNodeAt(chain, "ChainExpression", endLoc);
}
directiveToStmt(directive) {
const expression = directive.value;
delete directive.value;
this.castNodeTo(expression, "Literal");
expression.raw = expression.extra.raw;
expression.value = expression.extra.expressionValue;
const stmt = this.castNodeTo(directive, "ExpressionStatement");
stmt.expression = expression;
stmt.directive = expression.extra.rawValue;
delete expression.extra;
return stmt;
}
fillOptionalPropertiesForTSESLint(node) {}
cloneEstreeStringLiteral(node) {
const { start, end, loc, range, raw, value } = node;
const cloned = Object.create(node.constructor.prototype);
cloned.type = "Literal";
cloned.start = start;
cloned.end = end;
cloned.loc = loc;
cloned.range = range;
cloned.raw = raw;
cloned.value = value;
return cloned;
}
initFunction(node, isAsync) {
super.initFunction(node, isAsync);
node.expression = false;
}
checkDeclaration(node) {
if (node != null && this.isObjectProperty(node)) this.checkDeclaration(node.value);
else super.checkDeclaration(node);
}
getObjectOrClassMethodParams(method) {
return method.value.params;
}
isValidDirective(stmt) {
var _stmt$expression$extr;
return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && !((_stmt$expression$extr = stmt.expression.extra) != null && _stmt$expression$extr.parenthesized);
}
parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
super.parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse);
node.body = node.directives.map((d) => this.directiveToStmt(d)).concat(node.body);
delete node.directives;
}
parsePrivateName() {
const node = super.parsePrivateName();
if (!this.getPluginOption("estree", "classFeatures")) return node;
return this.convertPrivateNameToPrivateIdentifier(node);
}
convertPrivateNameToPrivateIdentifier(node) {
const name$1 = super.getPrivateNameSV(node);
delete node.id;
node.name = name$1;
return this.castNodeTo(node, "PrivateIdentifier");
}
isPrivateName(node) {
if (!this.getPluginOption("estree", "classFeatures")) return super.isPrivateName(node);
return node.type === "PrivateIdentifier";
}
getPrivateNameSV(node) {
if (!this.getPluginOption("estree", "classFeatures")) return super.getPrivateNameSV(node);
return node.name;
}
parseLiteral(value, type) {
const node = super.parseLiteral(value, type);
node.raw = node.extra.raw;
delete node.extra;
return node;
}
parseFunctionBody(node, allowExpression, isMethod = false) {
super.parseFunctionBody(node, allowExpression, isMethod);
node.expression = node.body.type !== "BlockStatement";
}
parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
let funcNode = this.startNode();
funcNode.kind = node.kind;
funcNode = super.parseMethod(funcNode, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
delete funcNode.kind;
const { typeParameters } = node;
if (typeParameters) {
delete node.typeParameters;
funcNode.typeParameters = typeParameters;
this.resetStartLocationFromNode(funcNode, typeParameters);
}
node.value = this.castNodeTo(funcNode, "FunctionExpression");
if (type === "ClassPrivateMethod") node.computed = false;
if (type === "ObjectMethod") {
if (node.kind === "method") node.kind = "init";
node.shorthand = false;
return this.finishNode(node, "Property");
} else return this.finishNode(node, "MethodDefinition");
}
nameIsConstructor(key) {
if (key.type === "Literal") return key.value === "constructor";
return super.nameIsConstructor(key);
}
parseClassProperty(...args) {
const propertyNode = super.parseClassProperty(...args);
if (!this.getPluginOption("estree", "classFeatures")) return propertyNode;
this.castNodeTo(propertyNode, "PropertyDefinition");
return propertyNode;
}
parseClassPrivateProperty(...args) {
const propertyNode = super.parseClassPrivateProperty(...args);
if (!this.getPluginOption("estree", "classFeatures")) return propertyNode;
this.castNodeTo(propertyNode, "PropertyDefinition");
propertyNode.computed = false;
return propertyNode;
}
parseClassAccessorProperty(node) {
const accessorPropertyNode = super.parseClassAccessorProperty(node);
if (!this.getPluginOption("estree", "classFeatures")) return accessorPropertyNode;
if (accessorPropertyNode.abstract && this.hasPlugin("typescript")) {
delete accessorPropertyNode.abstract;
this.castNodeTo(accessorPropertyNode, "TSAbstractAccessorProperty");
} else this.castNodeTo(accessorPropertyNode, "AccessorProperty");
return accessorPropertyNode;
}
parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) {
const node = super.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors);
if (node) {
node.kind = "init";
this.castNodeTo(node, "Property");
}
return node;
}
finishObjectProperty(node) {
node.kind = "init";
return this.finishNode(node, "Property");
}
isValidLVal(type, disallowCallExpression, isUnparenthesizedInAssign, binding) {
return type === "Property" ? "value" : super.isValidLVal(type, disallowCallExpression, isUnparenthesizedInAssign, binding);
}
isAssignable(node, isBinding) {
if (node != null && this.isObjectProperty(node)) return this.isAssignable(node.value, isBinding);
return super.isAssignable(node, isBinding);
}
toAssignable(node, isLHS = false) {
if (node != null && this.isObjectProperty(node)) {
const { key, value } = node;
if (this.isPrivateName(key)) this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start);
this.toAssignable(value, isLHS);
} else super.toAssignable(node, isLHS);
}
toAssignableObjectExpressionProp(prop, isLast, isLHS) {
if (prop.type === "Property" && (prop.kind === "get" || prop.kind === "set")) this.raise(Errors.PatternHasAccessor, prop.key);
else if (prop.type === "Property" && prop.method) this.raise(Errors.PatternHasMethod, prop.key);
else super.toAssignableObjectExpressionProp(prop, isLast, isLHS);
}
finishCallExpression(unfinished, optional) {
const node = super.finishCallExpression(unfinished, optional);
if (node.callee.type === "Import") {
var _ref;
this.castNodeTo(node, "ImportExpression");
node.source = node.arguments[0];
node.options = (_ref = node.arguments[1]) != null ? _ref : null;
var _ref2;
node.attributes = (_ref2 = node.arguments[1]) != null ? _ref2 : null;
delete node.arguments;
delete node.callee;
} else if (node.type === "OptionalCallExpression") this.castNodeTo(node, "CallExpression");
else node.optional = false;
return node;
}
toReferencedArguments(node) {
if (node.type === "ImportExpression") return;
super.toReferencedArguments(node);
}
parseExport(unfinished, decorators) {
const exportStartLoc = this.state.lastTokStartLoc;
const node = super.parseExport(unfinished, decorators);
switch (node.type) {
case "ExportAllDeclaration":
node.exported = null;
break;
case "ExportNamedDeclaration": if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier") {
this.castNodeTo(node, "ExportAllDeclaration");
node.exported = node.specifiers[0].exported;
delete node.specifiers;
}
case "ExportDefaultDeclaration":
{
var _declaration$decorato;
const { declaration } = node;
if ((declaration == null ? void 0 : declaration.type) === "ClassDeclaration" && ((_declaration$decorato = declaration.decorators) == null ? void 0 : _declaration$decorato.length) > 0 && declaration.start === node.start) this.resetStartLocation(node, exportStartLoc);
}
break;
}
return node;
}
stopParseSubscript(base, state) {
const node = super.stopParseSubscript(base, state);
if (state.optionalChainMember) return this.estreeParseChainExpression(node, base.loc.end);
return node;
}
parseMember(base, startLoc, state, computed, optional) {
const node = super.parseMember(base, startLoc, state, computed, optional);
if (node.type === "OptionalMemberExpression") this.castNodeTo(node, "MemberExpression");
else node.optional = false;
return node;
}
isOptionalMemberExpression(node) {
if (node.type === "ChainExpression") return node.expression.type === "MemberExpression";
return super.isOptionalMemberExpression(node);
}
hasPropertyAsPrivateName(node) {
if (node.type === "ChainExpression") node = node.expression;
return super.hasPropertyAsPrivateName(node);
}
isObjectProperty(node) {
return node.type === "Property" && node.kind === "init" && !node.method;
}
isObjectMethod(node) {
return node.type === "Property" && (node.method || node.kind === "get" || node.kind === "set");
}
castNodeTo(node, type) {
const result = super.castNodeTo(node, type);
this.fillOptionalPropertiesForTSESLint(result);
return result;
}
cloneIdentifier(node) {
const cloned = super.cloneIdentifier(node);
this.fillOptionalPropertiesForTSESLint(cloned);
return cloned;
}
cloneStringLiteral(node) {
if (node.type === "Literal") return this.cloneEstreeStringLiteral(node);
return super.cloneStringLiteral(node);
}
finishNodeAt(node, type, endLoc) {
return toESTreeLocation(super.finishNodeAt(node, type, endLoc));
}
finishNode(node, type) {
const result = super.finishNode(node, type);
this.fillOptionalPropertiesForTSESLint(result);
return result;
}
resetStartLocation(node, startLoc) {
super.resetStartLocation(node, startLoc);
toESTreeLocation(node);
}
resetEndLocation(node, endLoc = this.state.lastTokEndLoc) {
super.resetEndLocation(node, endLoc);
toESTreeLocation(node);
}
};
var TokContext = class {
constructor(token, preserveSpace) {
this.token = void 0;
this.preserveSpace = void 0;
this.token = token;
this.preserveSpace = !!preserveSpace;
}
};
const types = {
brace: new TokContext("{"),
j_oTag: new TokContext("<tag"),
j_cTag: new TokContext("</tag"),
j_expr: new TokContext("<tag>...</tag>", true)
};
types.template = new TokContext("`", true);
const beforeExpr = true;
const startsExpr = true;
const isLoop = true;
const isAssign = true;
const prefix = true;
const postfix = true;
var ExportedTokenType = class {
constructor(label, conf = {}) {
this.label = void 0;
this.keyword = void 0;
this.beforeExpr = void 0;
this.startsExpr = void 0;
this.rightAssociative = void 0;
this.isLoop = void 0;
this.isAssign = void 0;
this.prefix = void 0;
this.postfix = void 0;
this.binop = void 0;
this.label = label;
this.keyword = conf.keyword;
this.beforeExpr = !!conf.beforeExpr;
this.startsExpr = !!conf.startsExpr;
this.rightAssociative = !!conf.rightAssociative;
this.isLoop = !!conf.isLoop;
this.isAssign = !!conf.isAssign;
this.prefix = !!conf.prefix;
this.postfix = !!conf.postfix;
this.binop = conf.binop != null ? conf.binop : null;
this.updateContext = null;
}
};
const keywords$1 = /* @__PURE__ */ new Map();
function createKeyword(name$1, options = {}) {
options.keyword = name$1;
const token = createToken(name$1, options);
keywords$1.set(name$1, token);
return token;
}
function createBinop(name$1, binop) {
return createToken(name$1, {
beforeExpr,
binop
});
}
let tokenTypeCounter = -1;
const tokenTypes = [];
const tokenLabels = [];
const tokenBinops = [];
const tokenBeforeExprs = [];
const tokenStartsExprs = [];
const tokenPrefixes = [];
function createToken(name$1, options = {}) {
var _options$binop, _options$beforeExpr, _options$startsExpr, _options$prefix;
++tokenTypeCounter;
tokenLabels.push(name$1);
tokenBinops.push((_options$binop = options.binop) != null ? _options$binop : -1);
tokenBeforeExprs.push((_options$beforeExpr = options.beforeExpr) != null ? _options$beforeExpr : false);
tokenStartsExprs.push((_options$startsExpr = options.startsExpr) != null ? _options$startsExpr : false);
tokenPrefixes.push((_options$prefix = options.prefix) != null ? _options$prefix : false);
tokenTypes.push(new ExportedTokenType(name$1, options));
return tokenTypeCounter;
}
function createKeywordLike(name$1, options = {}) {
var _options$binop2, _options$beforeExpr2, _options$startsExpr2, _options$prefix2;
++tokenTypeCounter;
keywords$1.set(name$1, tokenTypeCounter);
tokenLabels.push(name$1);
tokenBinops.push((_options$binop2 = options.binop) != null ? _options$binop2 : -1);
tokenBeforeExprs.push((_options$beforeExpr2 = options.beforeExpr) != null ? _options$beforeExpr2 : false);
tokenStartsExprs.push((_options$startsExpr2 = options.startsExpr) != null ? _options$startsExpr2 : false);
tokenPrefixes.push((_options$prefix2 = options.prefix) != null ? _options$prefix2 : false);
tokenTypes.push(new ExportedTokenType("name", options));
return tokenTypeCounter;
}
const tt = {
bracketL: createToken("[", {
beforeExpr,
startsExpr
}),
bracketHashL: createToken("#[", {
beforeExpr,
startsExpr
}),
bracketBarL: createToken("[|", {
beforeExpr,
startsExpr
}),
bracketR: createToken("]"),
bracketBarR: createToken("|]"),
braceL: createToken("{", {
beforeExpr,
startsExpr
}),
braceBarL: createToken("{|", {
beforeExpr,
startsExpr
}),
braceHashL: createToken("#{", {
beforeExpr,
startsExpr
}),
braceR: createToken("}"),
braceBarR: createToken("|}"),
parenL: createToken("(", {
beforeExpr,
startsExpr
}),
parenR: createToken(")"),
comma: createToken(",", { beforeExpr }),
semi: createToken(";", { beforeExpr }),
colon: createToken(":", { beforeExpr }),
doubleColon: createToken("::", { beforeExpr }),
dot: createToken("."),
question: createToken("?", { beforeExpr }),
questionDot: createToken("?."),
arrow: createToken("=>", { beforeExpr }),
template: createToken("template"),
ellipsis: createToken("...", { beforeExpr }),
backQuote: createToken("`", { startsExpr }),
dollarBraceL: createToken("${", {
beforeExpr,
startsExpr
}),
templateTail: createToken("...`", { startsExpr }),
templateNonTail: createToken("...${", {
beforeExpr,
startsExpr
}),
at: createToken("@"),
hash: createToken("#", { startsExpr }),
interpreterDirective: createToken("#!..."),
eq: createToken("=", {
beforeExpr,
isAssign
}),
assign: createToken("_=", {
beforeExpr,
isAssign
}),
slashAssign: createToken("_=", {
beforeExpr,
isAssign
}),
xorAssign: createToken("_=", {
beforeExpr,
isAssign
}),
moduloAssign: createToken("_=", {
beforeExpr,
isAssign
}),
incDec: createToken("++/--", {
prefix,
postfix,
startsExpr
}),
bang: createToken("!", {
beforeExpr,
prefix,
startsExpr
}),
tilde: createToken("~", {
beforeExpr,
prefix,
startsExpr
}),
doubleCaret: createToken("^^", { startsExpr }),
doubleAt: createToken("@@", { startsExpr }),
pipeline: createBinop("|>", 0),
nullishCoalescing: createBinop("??", 1),
logicalOR: createBinop("||", 1),
logicalAND: createBinop("&&", 2),
bitwiseOR: createBinop("|", 3),
bitwiseXOR: createBinop("^", 4),
bitwiseAND: createBinop("&", 5),
equality: createBinop("==/!=/===/!==", 6),
lt: createBinop("</>/<=/>=", 7),
gt: createBinop("</>/<=/>=", 7),
relational: createBinop("</>/<=/>=", 7),
bitShift: createBinop("<</>>/>>>", 8),
bitShiftL: createBinop("<</>>/>>>", 8),
bitShiftR: createBinop("<</>>/>>>", 8),
plusMin: createToken("+/-", {
beforeExpr,
binop: 9,
prefix,
startsExpr
}),
modulo: createToken("%", {
binop: 10,
startsExpr
}),
star: createToken("*", { binop: 10 }),
slash: createBinop("/", 10),
exponent: createToken("**", {
beforeExpr,
binop: 11,
rightAssociative: true
}),
_in: createKeyword("in", {
beforeExpr,
binop: 7
}),
_instanceof: createKeyword("instanceof", {
beforeExpr,
binop: 7
}),
_break: createKeyword("break"),
_case: createKeyword("case", { beforeExpr }),
_catch: createKeyword("catch"),
_continue: createKeyword("continue"),
_debugger: createKeyword("debugger"),
_default: createKeyword("default", { beforeExpr }),
_else: createKeyword("else", { beforeExpr }),
_finally: createKeyword("finally"),
_function: createKeyword("function", { startsExpr }),
_if: createKeyword("if"),
_return: createKeyword("return", { beforeExpr }),
_switch: createKeyword("switch"),
_throw: createKeyword("throw", {
beforeExpr,
prefix,
startsExpr
}),
_try: createKeyword("try"),
_var: createKeyword("var"),
_const: createKeyword("const"),
_with: createKeyword("with"),
_new: createKeyword("new", {
beforeExpr,
startsExpr
}),
_this: createKeyword("this", { startsExpr }),
_super: createKeyword("super", { startsExpr }),
_class: createKeyword("class", { startsExpr }),
_extends: createKeyword("extends", { beforeExpr }),
_export: createKeyword("export"),
_import: createKeyword("import", { startsExpr }),
_null: createKeyword("null", { startsExpr }),
_true: createKeyword("true", { startsExpr }),
_false: createKeyword("false", { startsExpr }),
_typeof: createKeyword("typeof", {
beforeExpr,
prefix,
startsExpr