package js_ast

Import Path
	github.com/evanw/esbuild/internal/js_ast (on go.dev)

Dependency Relation
	imports 5 packages, and imported by 9 packages

Involved Source Files js_ast.go
Package-Level Type Names (total 126, in which 123 are exported)
/* sort exporteds by: | */
Binding Binding Default *Expr "constructor(public x: boolean) {}" TSDecorators []Expr
Binding Binding DefaultValue *Expr
func OpCode.BinaryAssignTarget() AssignTarget func OpCode.UnaryAssignTarget() AssignTarget const AssignTargetNone const AssignTargetReplace const AssignTargetUpdate
ApproximateLineCount int32 CharFreq *CharFreq Directive string // Does not include TypeScript-specific syntax ExportStarImportRecords []uint32 ExportsRef Ref HasLazyExport bool This is a list of CommonJS features. When a file uses CommonJS features, it's not a candidate for "flat bundling" and must be wrapped in its own closure. Hashbang string This is a list of ES6 features. They are ranges instead of booleans so that they can be used in log messages. Check to see if "Len > 0". // Does not include TypeScript-specific syntax or "import()" These are stored at the AST level instead of on individual AST nodes so they can be manipulated efficiently without a full AST traversal ModuleRef Ref ModuleScope *Scope NamedExports map[string]NamedExport These are used when bundling. They are filled in during the parser pass since we already have to traverse the AST then anyway and the parser pass is conveniently fully parallelized. NestedScopeSlotCounts SlotCounts Parts []Part SourceMapComment Span Symbols []Symbol TopLevelAwaitKeyword logger.Range TopLevelSymbolToParts map[Ref][]uint32 URLForCSS string UsesExportsRef bool UsesModuleRef bool WrapperRef Ref (*T) HasCommonJSFeatures() bool (*T) HasESMFeatures() bool (*T) UsesCommonJSExports() bool func github.com/evanw/esbuild/internal/cache.(*JSCache).Parse(log logger.Log, source logger.Source, options js_parser.Options) (AST, bool) func github.com/evanw/esbuild/internal/js_parser.LazyExportAST(log logger.Log, source logger.Source, options js_parser.Options, expr Expr, apiCall string) AST func github.com/evanw/esbuild/internal/js_parser.Parse(log logger.Log, source logger.Source, options js_parser.Options) (result AST, ok bool) func github.com/evanw/esbuild/internal/js_printer.Print(tree AST, symbols SymbolMap, r renamer.Renamer, options js_printer.Options) js_printer.PrintResult
This interface is never called. Its purpose is to encode a variant type in Go's type system. *BArray *BIdentifier *BMissing *BObject
HasSpread bool IsSingleLine bool Items []ArrayBinding *T : B
Ref Ref *T : B
Data B Loc logger.Loc
*T : B
IsSingleLine bool Properties []PropertyBinding *T : B
Body []Stmt Value *Expr
Binding *Binding Body []Stmt Loc logger.Loc
This is a histogram of character frequencies for minification (*T) Compile() NameMinifier (*T) Include(other *CharFreq) (*T) Scan(text string, delta int32) func (*CharFreq).Include(other *CharFreq)
Alias string AliasLoc logger.Loc Name LocRef This is the original name of the symbol stored in "Name". It's needed for "SExportClause" statements such as this: export {foo as bar} from 'path' In this case both "foo" and "bar" are aliases because it's a re-export. We need to preserve both aliases in case the symbol is renamed. In this example, "foo" is "OriginalName" and "bar" is "Alias".
Loc logger.Loc Text string
Binding Binding Value *Expr
IsTopLevel bool Ref Ref
This interface is never called. Its purpose is to encode a variant type in Go's type system. *EArray *EArrow *EAwait *EBigInt *EBinary *EBoolean *ECall *EClass *EDot *EFunction *EIdentifier *EIf *EImport *EImportIdentifier *EImportMeta *EIndex *EJSXElement *EMissing *ENew *ENewTarget *ENull *ENumber *EObject *EPrivateIdentifier *ERegExp *ERequire *ERequireResolve *ESpread *EString *ESuper *ETemplate *EThis *EUnary *EUndefined *EYield
CommaAfterSpread logger.Loc IsParenthesized bool IsSingleLine bool Items []Expr *T : E
Args []Arg Body FnBody HasRestArg bool IsAsync bool // Use shorthand if true and "Body" is a single return statement *T : E
Value Expr *T : E
Value string *T : E
Left Expr Op OpCode Right Expr *T : E
Value bool *T : E
Args []Expr True if there is a comment containing "@__PURE__" or "#__PURE__" preceding this call expression. This is an annotation used for tree shaking, and means that the call can be removed if it's unused. It does not mean the call is pure (e.g. it may still return something different if called twice). Note that the arguments are not considered to be part of the call. If the call itself is removed due to this annotation, the arguments must remain if they have side effects. IsDirectEval bool OptionalChain OptionalChain Target Expr (*T) HasSameFlagsAs(b *ECall) bool *T : E func (*ECall).HasSameFlagsAs(b *ECall) bool
Class Class *T : E
If true, this property access is a function that, when called, can be unwrapped if the resulting value is unused. Unwrapping means discarding the call target but keeping any arguments with side effects. If true, this property access is known to be free of side-effects. That means it can be removed if the resulting value isn't used. Name string NameLoc logger.Loc OptionalChain OptionalChain Target Expr (*T) HasSameFlagsAs(b *EDot) bool *T : E func (*EDot).HasSameFlagsAs(b *EDot) bool
Fn Fn *T : E
If true, this identifier represents a function that, when called, can be unwrapped if the resulting value is unused. Unwrapping means discarding the call target but keeping any arguments with side effects. If true, this identifier is known to not have a side effect (i.e. to not throw an exception) when referenced. If false, this identifier may or may not have side effects when referenced. This is used to allow the removal of known globals such as "Object" if they aren't used. If we're inside a "with" statement, this identifier may be a property access. In that case it would be incorrect to remove this identifier since the property access may be a getter or setter with side effects. Ref Ref *T : E
No Expr Test Expr Yes Expr *T : E
Expr Expr ImportRecordIndex ast.Index32 Comments inside "import()" expressions have special meaning for Webpack. Preserving comments inside these expressions makes it possible to use esbuild as a TypeScript-to-JavaScript frontend for Webpack to improve performance. We intentionally do not interpret these comments in esbuild because esbuild is not Webpack. But we do preserve them since doing so is harmless, easy to maintain, and useful to people. See the Webpack docs for more info: https://webpack.js.org/api/module-methods/#magic-comments. *T : E
This is similar to an EIdentifier but it represents a reference to an ES6 import item. Depending on how the code is linked, the file containing this EImportIdentifier may or may not be in the same module group as the file it was imported from. If it's the same module group than we can just merge the import item symbol with the corresponding symbol that was imported, effectively renaming them to be the same thing and statically binding them together. But if it's a different module group, then the import must be dynamically evaluated using a property access off the corresponding namespace symbol, which represents the result of a require() call. It's stored as a separate type so it's not easy to confuse with a plain identifier. For example, it'd be bad if code trying to convert "{x: x}" into "{x}" shorthand syntax wasn't aware that the "x" in this case is actually "{x: importedNamespace.x}". This separate type forces code to opt-in to doing this instead of opt-out. Ref Ref If true, this was originally an identifier expression such as "foo". If false, this could potentially have been a member access expression such as "ns.foo" off of an imported namespace object. *T : E
*T : E
Index Expr OptionalChain OptionalChain Target Expr (*T) HasSameFlagsAs(b *EIndex) bool *T : E func (*EIndex).HasSameFlagsAs(b *EIndex) bool
Children []Expr Properties []Property Tag *Expr *T : E
*T : E
Args []Expr True if there is a comment containing "@__PURE__" or "#__PURE__" preceding this call expression. See the comment inside ECall for more details. Target Expr *T : E
*T : E
*T : E
Value float64 *T : E
Loc logger.Loc Name []uint16 Ref Ref Value *Expr
CommaAfterSpread logger.Loc IsParenthesized bool IsSingleLine bool Properties []Property *T : E
This is similar to EIdentifier but it represents class-private fields and methods. It can be used where computed properties can be used, such as EIndex and Property. Ref Ref *T : E
Value string *T : E
ImportRecordIndex uint32 *T : E
ImportRecordIndex uint32 *T : E
Value Expr *T : E
This is used for both strings and no-substitution template literals to reduce the number of cases that need to be checked for string optimization code LegacyOctalLoc logger.Loc PreferTemplate bool Value []uint16 *T : E
*T : E
Head []uint16 // This is only filled out for tagged template literals LegacyOctalLoc logger.Loc Parts []TemplatePart Tag *Expr *T : E
*T : E
Op OpCode Value Expr *T : E
*T : E
Loc logger.Loc Although this alias name starts off as being the same as the statement's namespace symbol, it may diverge if the namespace symbol name is minified. The original alias name is preserved here to avoid this scenario.
Data E Loc logger.Loc func Assign(a Expr, b Expr) Expr func JoinAllWithComma(all []Expr) Expr func JoinWithComma(a Expr, b Expr) Expr func JoinWithLeftAssociativeOp(op OpCode, a Expr, b Expr) Expr func MaybeSimplifyNot(expr Expr) (Expr, bool) func Not(expr Expr) Expr func github.com/evanw/esbuild/internal/cache.(*JSONCache).Parse(log logger.Log, source logger.Source, options js_parser.JSONOptions) (Expr, bool) func github.com/evanw/esbuild/internal/js_parser.ParseJSON(log logger.Log, source logger.Source, options js_parser.JSONOptions) (result Expr, ok bool) func Assign(a Expr, b Expr) Expr func Assign(a Expr, b Expr) Expr func AssignStmt(a Expr, b Expr) Stmt func AssignStmt(a Expr, b Expr) Stmt func IsBooleanValue(a Expr) bool func IsNumericValue(a Expr) bool func IsOptionalChain(value Expr) bool func IsStringValue(a Expr) bool func JoinAllWithComma(all []Expr) Expr func JoinWithComma(a Expr, b Expr) Expr func JoinWithComma(a Expr, b Expr) Expr func JoinWithLeftAssociativeOp(op OpCode, a Expr, b Expr) Expr func JoinWithLeftAssociativeOp(op OpCode, a Expr, b Expr) Expr func MaybeSimplifyNot(expr Expr) (Expr, bool) func Not(expr Expr) Expr func github.com/evanw/esbuild/internal/js_parser.LazyExportAST(log logger.Log, source logger.Source, options js_parser.Options, expr Expr, apiCall string) AST
Expr *Expr Stmt *Stmt
IsStar bool Value *Expr *T : E
Loc logger.Loc Stmts []Stmt
Args []Arg ArgumentsRef Ref Body FnBody HasIfScope bool HasRestArg bool IsAsync bool IsGenerator bool This is true if the function is a method Name *LocRef OpenParenLoc logger.Loc
Loc logger.Loc Stmts []Stmt
const ImportItemGenerated const ImportItemMissing const ImportItemNone
const LAdd const LAssign const LBitwiseAnd const LBitwiseOr const LBitwiseXor const LCall const LComma const LCompare const LConditional const LEquals const LExponentiation const LLogicalAnd const LLogicalOr const LLowest const LMember const LMultiply const LNew const LNullishCoalescing const LPostfix const LPrefix const LShift const LSpread const LYield
const LocalConst const LocalLet const LocalVar
Loc logger.Loc Ref Ref
AliasLoc logger.Loc Ref Ref
Alias string AliasLoc logger.Loc ImportRecordIndex uint32 It's useful to flag exported imports because if they are in a TypeScript file, we can't tell if they are a type or a value. Parts within this file that use this import NamespaceRef Ref
(*T) NumberToMinifiedName(i int) string func (*CharFreq).Compile() NameMinifier func github.com/evanw/esbuild/internal/renamer.(*MinifyRenamer).AssignNamesByFrequency(minifier *NameMinifier) var DefaultNameMinifier
Alias string NamespaceRef Ref
( T) BinaryAssignTarget() AssignTarget ( T) IsLeftAssociative() bool ( T) IsPrefix() bool ( T) IsRightAssociative() bool ( T) IsShortCircuit() bool ( T) UnaryAssignTarget() AssignTarget func JoinWithLeftAssociativeOp(op OpCode, a Expr, b Expr) Expr const BinOpAdd const BinOpAddAssign const BinOpAssign const BinOpBitwiseAnd const BinOpBitwiseAndAssign const BinOpBitwiseOr const BinOpBitwiseOrAssign const BinOpBitwiseXor const BinOpBitwiseXorAssign const BinOpComma const BinOpDiv const BinOpDivAssign const BinOpGe const BinOpGt const BinOpIn const BinOpInstanceof const BinOpLe const BinOpLogicalAnd const BinOpLogicalAndAssign const BinOpLogicalOr const BinOpLogicalOrAssign const BinOpLooseEq const BinOpLooseNe const BinOpLt const BinOpMul const BinOpMulAssign const BinOpNullishCoalescing const BinOpNullishCoalescingAssign const BinOpPow const BinOpPowAssign const BinOpRem const BinOpRemAssign const BinOpShl const BinOpShlAssign const BinOpShr const BinOpShrAssign const BinOpStrictEq const BinOpStrictNe const BinOpSub const BinOpSubAssign const BinOpUShr const BinOpUShrAssign const UnOpCpl const UnOpDelete const UnOpNeg const UnOpNot const UnOpPos const UnOpPostDec const UnOpPostInc const UnOpPreDec const UnOpPreInc const UnOpTypeof const UnOpVoid
const OptionalChainContinue const OptionalChainNone const OptionalChainStart
Each file is made up of multiple parts, and each part consists of one or more top-level statements. Parts are used for tree shaking and code splitting analysis. Individual parts of a file can be discarded by tree shaking and can be assigned to separate chunks (i.e. output files) by code splitting. If true, this part can be removed if none of the declared symbols are used. If the file containing this part is imported, then all parts that don't have this flag enabled must be included. All symbols that are declared in this part. Note that a given symbol may have multiple declarations, and so may end up being declared in multiple parts (e.g. multiple "var" declarations with the same name). Also note that this list isn't deduplicated and may contain duplicates. This is used for generated parts that we don't want to be present if they aren't needed. This enables tree shaking for these parts even if global tree shaking isn't enabled. Each is an index into the file-level import record list If true, this is the automatically-generated part for this file's ES6 exports. It may hold the "var exports = {};" statement and also the "__export(exports, { ... })" call to initialize the getters. The indices of the other parts in this file that are needed if this part is needed. Scopes []*Scope Stmts []Stmt An estimate of the number of uses of all symbols used within this part.
This is used when parsing a pattern that uses default values: [a = 1] = []; ({a = 1} = {}); It's also used for class fields: class Foo { a = 1 } IsComputed bool IsMethod bool IsStatic bool Key Expr Kind PropertyKind TSDecorators []Expr This is omitted for class fields WasShorthand bool
DefaultValue *Expr IsComputed bool IsSpread bool Key Expr Value Binding
const PropertyGet const PropertyNormal const PropertySet const PropertySpread
Files are parsed in parallel for speed. We want to allow each parser to generate symbol IDs that won't conflict with each other. We also want to be able to quickly merge symbol tables from all files into one giant symbol table. We can accomplish both goals by giving each symbol ID two parts: an outer index that is unique to the parser goroutine, and an inner index that increments as the parser generates new symbol IDs. Then a symbol map can be an array of arrays indexed first by outer index, then by inner index. The maps can be merged quickly by creating a single outer array containing all inner arrays from all parsed files. InnerIndex uint32 OuterIndex uint32 func FollowSymbols(symbols SymbolMap, ref Ref) Ref func MergeSymbols(symbols SymbolMap, old Ref, new Ref) Ref func FollowSymbols(symbols SymbolMap, ref Ref) Ref func MergeSymbols(symbols SymbolMap, old Ref, new Ref) Ref func MergeSymbols(symbols SymbolMap, old Ref, new Ref) Ref func SymbolMap.Get(ref Ref) *Symbol func github.com/evanw/esbuild/internal/renamer.(*MinifyRenamer).AccumulateSymbolCount(ref Ref, count uint32) func github.com/evanw/esbuild/internal/renamer.(*MinifyRenamer).AccumulateSymbolUseCounts(symbolUses map[Ref]SymbolUse, stableSourceIndices []uint32) func github.com/evanw/esbuild/internal/renamer.(*MinifyRenamer).NameForSymbol(ref Ref) string func github.com/evanw/esbuild/internal/renamer.(*NumberRenamer).AddTopLevelSymbol(ref Ref) func github.com/evanw/esbuild/internal/renamer.(*NumberRenamer).NameForSymbol(ref Ref) string func github.com/evanw/esbuild/internal/renamer.Renamer.NameForSymbol(ref Ref) string var InvalidRef
This interface is never called. Its purpose is to encode a variant type in Go's type system. *SBlock *SBreak *SClass *SComment *SContinue *SDebugger *SDirective *SDoWhile *SEmpty *SEnum *SExportClause *SExportDefault *SExportEquals *SExportFrom *SExportStar *SExpr *SFor *SForIn *SForOf *SFunction *SIf *SImport *SLabel *SLazyExport *SLocal *SNamespace *SReturn *SSwitch *SThrow *STry *STypeScript *SWhile *SWith
Stmts []Stmt *T : S
Label *LocRef *T : S
Class Class IsExport bool *T : S
Text string *T : S
Label *LocRef *T : S
Children []*Scope If a scope contains a direct eval() expression, then none of the symbols inside that scope can be renamed. We conservatively assume that the evaluated code might reference anything that it has access to. This is to help forbid "arguments" inside class body scopes Generated []Ref Kind ScopeKind This is used to store the ref of the label symbol for ScopeLabel scopes. LabelStmtIsLoop bool Members map[string]ScopeMember Parent *Scope StrictMode StrictModeKind (*T) RecursiveSetStrictMode(kind StrictModeKind) func github.com/evanw/esbuild/internal/renamer.AssignNestedScopeSlots(moduleScope *Scope, symbols []Symbol) (slotCounts SlotCounts) func github.com/evanw/esbuild/internal/renamer.ComputeReservedNames(moduleScopes []*Scope, symbols SymbolMap) map[string]uint32 func github.com/evanw/esbuild/internal/renamer.(*NumberRenamer).AssignNamesByScope(nestedScopes map[uint32][]*Scope)
( T) StopsHoisting() bool const ScopeBlock const ScopeClassBody const ScopeClassName const ScopeEntry const ScopeFunctionArgs const ScopeFunctionBody const ScopeLabel const ScopeWith
Loc logger.Loc Ref Ref
*T : S
LegacyOctalLoc logger.Loc Value []uint16 *T : S
Body Stmt Test Expr *T : S
*T : S
Arg Ref IsExport bool Name LocRef Values []EnumValue *T : S
IsSingleLine bool Items []ClauseItem *T : S
DefaultName LocRef // May be a SFunction or SClass *T : S
This is an "export = value;" statement in TypeScript Value Expr *T : S
ImportRecordIndex uint32 IsSingleLine bool Items []ClauseItem NamespaceRef Ref *T : S
Alias *ExportStarAlias ImportRecordIndex uint32 NamespaceRef Ref *T : S
This is set to true for automatically-generated expressions that should not affect tree shaking. For example, calling a function from the runtime that doesn't have externally-visible side effects. Value Expr *T : S
Body Stmt // May be a SConst, SLet, SVar, or SExpr Test *Expr Update *Expr *T : S
Body Stmt // May be a SConst, SLet, SVar, or SExpr Value Expr *T : S
Body Stmt // May be a SConst, SLet, SVar, or SExpr IsAwait bool Value Expr *T : S
Fn Fn IsExport bool *T : S
No *Stmt Test Expr Yes Stmt *T : S
This object represents all of these types of import statements: import 'path' import {item1, item2} from 'path' import * as ns from 'path' import defaultItem, {item1, item2} from 'path' import defaultItem, * as ns from 'path' Many parts are optional and can be combined in different ways. The only restriction is that you cannot have both a clause and a star namespace. DefaultName *LocRef ImportRecordIndex uint32 IsSingleLine bool Items *[]ClauseItem If this is a star import: This is a Ref for the namespace symbol. The Loc for the symbol is StarLoc. Otherwise: This is an auto-generated Ref for the namespace representing the imported file. In this case StarLoc is nil. The NamespaceRef is used when converting this module to a CommonJS module. StarNameLoc *logger.Loc *T : S
Name LocRef Stmt Stmt *T : S
The decision of whether to export an expression using "module.exports" or "export default" is deferred until linking using this statement kind Value Expr *T : S
Decls []Decl IsExport bool Kind LocalKind The TypeScript compiler doesn't generate code for "import foo = bar" statements where the import is never used. *T : S
(*T) UnionMax(b SlotCounts) func github.com/evanw/esbuild/internal/renamer.AssignNestedScopeSlots(moduleScope *Scope, symbols []Symbol) (slotCounts SlotCounts) func (*SlotCounts).UnionMax(b SlotCounts) func github.com/evanw/esbuild/internal/renamer.NewMinifyRenamer(symbols SymbolMap, firstTopLevelSlots SlotCounts, reservedNames map[string]uint32) *renamer.MinifyRenamer
func (*Symbol).SlotNamespace() SlotNamespace const SlotDefault const SlotLabel const SlotMustNotBeRenamed const SlotPrivateName
Arg Ref IsExport bool Name LocRef Stmts []Stmt *T : S
Range logger.Range Text string
Value *Expr *T : S
BodyLoc logger.Loc Cases []Case Test Expr *T : S
Value Expr *T : S
Data S Loc logger.Loc func AssignStmt(a Expr, b Expr) Stmt func IsSuperCall(stmt Stmt) bool
func (*Scope).RecursiveSetStrictMode(kind StrictModeKind) const ExplicitStrictMode const ImplicitStrictModeClass const ImplicitStrictModeExport const ImplicitStrictModeImport const ImplicitStrictModeTopLevelAwait const SloppyMode
Body []Stmt BodyLoc logger.Loc Catch *Catch Finally *Finally *T : S
This is a stand-in for a TypeScript type declaration *T : S
Body Stmt Test Expr *T : S
Body Stmt BodyLoc logger.Loc Value Expr *T : S
Note: the order of values in this struct matters to reduce struct size. This is for generating cross-chunk imports and exports for code splitting. We automatically generate import items for property accesses off of namespace imports. This lets us remove the expensive namespace imports while bundling in many cases, replacing them with a cheap import item instead: import * as ns from 'path' ns.foo() That can often be replaced by this, which avoids needing the namespace: import {foo} from 'path' foo() However, if the import is actually missing then we don't want to report a compile-time error like we do for real import items. This status lets us avoid this. We also need to be able to replace such import items with undefined, which this status is also used for. Kind SymbolKind Used by the parser for single pass parsing. Symbols that have been merged form a linked-list where the last link is the symbol to use. This link is an invalid ref if it's the last link. If this isn't invalid, you need to FollowSymbols to get the real one. Certain symbols must not be renamed or minified. For example, the "arguments" variable is declared by the runtime for every function. Renaming can also break any identifier used inside a "with" statement. This is used for symbols that represent items in the import clause of an ES6 import statement. These should always be referenced by EImportIdentifier instead of an EIdentifier. When this is present, the expression should be printed as a property access off the namespace instead of as a bare identifier. For correctness, this must be stored on the symbol instead of indirectly associated with the Ref for the symbol somehow. In ES6 "flat bundling" mode, re-exported symbols are collapsed using MergeSymbols() and renamed symbols from other files that end up at this symbol must be able to tell if it has a namespace alias. This is used for minification. Symbols that are declared in sibling scopes can share a name. A good heuristic (from Google Closure Compiler) is to assign names to symbols from sibling scopes in declaration order. That way local variable names are reused in each global function like this, which improves gzip compression: function x(a, b) { ... } function y(a, b, c) { ... } The parser fills this in for symbols inside nested scopes. There are three slot namespaces: regular symbols, label symbols, and private symbols. This is the name that came from the parser. Printed names may be renamed during minification or to avoid name collisions. Do not use the original name during printing. An estimate of the number of uses of this symbol. This is used to detect whether a symbol is used or not. For example, TypeScript imports that are unused must be removed because they are probably type-only imports. This is an estimate and may not be completely accurate due to oversights in the code. But it should always be non-zero when the symbol is used. (*T) SlotNamespace() SlotNamespace func SymbolMap.Get(ref Ref) *Symbol func github.com/evanw/esbuild/internal/renamer.AssignNestedScopeSlots(moduleScope *Scope, symbols []Symbol) (slotCounts SlotCounts)
This could be represented as a "map[Ref]Symbol" but a two-level array was more efficient in profiles. This appears to be because it doesn't involve a hash. This representation also makes it trivial to quickly merge symbol maps from multiple files together. Each file only generates symbols in a single inner array, so you can join the maps together by just make a single outer array containing all of the inner arrays. See the comment on "Ref" for more detail. ( T) Get(ref Ref) *Symbol func NewSymbolMap(sourceCount int) SymbolMap func FollowAllSymbols(symbols SymbolMap) func FollowSymbols(symbols SymbolMap, ref Ref) Ref func MergeSymbols(symbols SymbolMap, old Ref, new Ref) Ref func github.com/evanw/esbuild/internal/js_printer.Print(tree AST, symbols SymbolMap, r renamer.Renamer, options js_printer.Options) js_printer.PrintResult func github.com/evanw/esbuild/internal/renamer.ComputeReservedNames(moduleScopes []*Scope, symbols SymbolMap) map[string]uint32 func github.com/evanw/esbuild/internal/renamer.NewMinifyRenamer(symbols SymbolMap, firstTopLevelSlots SlotCounts, reservedNames map[string]uint32) *renamer.MinifyRenamer func github.com/evanw/esbuild/internal/renamer.NewNoOpRenamer(symbols SymbolMap) renamer.Renamer func github.com/evanw/esbuild/internal/renamer.NewNumberRenamer(symbols SymbolMap, reservedNames map[string]uint32) *renamer.NumberRenamer
CountEstimate uint32 IsAssigned bool func github.com/evanw/esbuild/internal/renamer.(*MinifyRenamer).AccumulateSymbolUseCounts(symbolUses map[Ref]SymbolUse, stableSourceIndices []uint32)
Tail []uint16 TailLoc logger.Loc // This is only filled out for tagged template literals Value Expr
Package-Level Functions (total 18, all are exported)
Use this before calling "FollowSymbols" from separate threads to avoid concurrent map update hazards. In Go, mutating a map is not threadsafe but reading from a map is. Calling "FollowAllSymbols" first ensures that all mutation is done up front.
Returns the canonical ref that represents the ref for the provided symbol. This may not be the provided ref if the symbol has been merged with another symbol.
For readability, the names of certain automatically-generated symbols are derived from the file name. For example, instead of the CommonJS wrapper for a file being called something like "require273" it can be called something like "require_react" instead. This function generates the part of these identifiers that's specific to the file path. It can take both an absolute path (OS-specific) and a path in the source code (OS-independent). Note that these generated names do not at all relate to the correctness of the code as far as avoiding symbol name collisions. These names still go through the renaming logic that all other symbols go through to avoid name collisions.
The goal of this function is to "rotate" the AST if it's possible to use the left-associative property of the operator to avoid unnecessary parentheses. When using this, make absolutely sure that the operator is actually associative. For example, the "-" operator is not associative for floating-point numbers.
The given "expr" argument should be the operand of a "!" prefix operator (i.e. the "x" in "!x"). This returns a simplified expression for the whole operator (i.e. the "!x") if it can be simplified, or false if not. It's separate from "Not()" above to avoid allocation on failure in case that is undesired.
Makes "old" point to "new" by joining the linked lists for the two symbols together. That way "FollowSymbols" on both "old" and "new" will result in the same ref.
Wraps the provided expression in the "!" prefix operator. The expression will potentially be simplified to avoid generating unnecessary extra "!" operators. For example, calling this with "!!x" will return "!x" instead of returning "!!!x".
Package-Level Variables (total 3, all are exported)
Package-Level Constants (total 133, all are exported)
Left-associative
If you add a new token, remember to add it to "OpTable" too
Right-associative
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
Non-associative
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
The linker doesn't report import/export mismatch errors
The printer will replace this import with "undefined"
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
"a?.b.c" => ".c" is OptionalChainContinue "(a?.b).c" => ".c" is OptionalChainNone
The scopes below stop hoisted variables from extending into parent scopes
This is the special "arguments" variable inside functions
There's a weird special case where catch variables declared using a simple identifier (i.e. not a binding pattern) block hoisted variables instead of becoming an error: var e = 0; try { throw 1 } catch (e) { print(e) // 1 var e = 2 print(e) // 2 } print(e) // 0 (since the hoisting stops at the catch block boundary) However, other forms are still a syntax error: try {} catch (e) { let e } try {} catch ({e}) { var e } This symbol is for handling this weird special case.
Classes can merge with TypeScript namespaces.
Assigning to a "const" symbol will throw a TypeError at runtime
Generator and async functions are not hoisted, but still have special properties such as being able to overwrite previous functions with the same name
This has special merging behavior. You're allowed to re-declare these symbols more than once in the same scope. These symbols are also hoisted out of the scope they are declared in to the closest containing function or module scope. These are the symbols with this kind: - Function arguments - Function statements - Variables declared using "var"
In TypeScript, imports are allowed to silently collide with symbols within the module. Presumably this is because the imports may be type-only.
Labels are in their own namespace
This annotates all other symbols that don't have special behavior.
A class-private identifier (i.e. "#foo").
TypeScript enums can merge with TypeScript namespaces and other TypeScript enums.
TypeScript namespaces can merge with classes, functions, TypeScript enums, and other TypeScript namespaces.
An unbound symbol is one that isn't declared in the file it's referenced in. For example, using "window" without declaring it will be unbound.
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
Prefix
Postfix update
If you add a new token, remember to add it to "OpTable" too
Prefix update
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too
If you add a new token, remember to add it to "OpTable" too