Deprecated Babel preset for stage 0 plugins that provides migration guidelines to explicit plugin configurations
80
Build a small module that turns source text into a compact AST summary while conditionally enabling modern syntax support based on feature flags.
const config = settings?.theme ?? "light"; export default config; with features ["optional-chains"], return topLevelTypes as ["VariableDeclaration", "ExportDefaultDeclaration"] and identifiers as ["config", "settings", "theme"], all in source order. @testconst View = () => <section><h1>{title}</h1></section>; with features ["jsx"], include the JSX-bearing statement in topLevelTypes and list identifiers ["View", "title"], preserving first appearance order. @testinterface User { id: number } const id: number = 1; with features ["typescript"], ignore type-only declarations in the summary so topLevelTypes is ["VariableDeclaration"] and identifiers is ["id"]. @test@generates
export type FeatureFlag = "optional-chains" | "jsx" | "typescript";
export interface ParseOptions {
features?: FeatureFlag[];
sourceType?: "module" | "script";
}
export interface AstSummary {
topLevelTypes: string[];
identifiers: string[];
}
export function buildAstSummary(code: string, options?: ParseOptions): AstSummary;Identifiers should be reported in the order first encountered during parsing and should exclude any that are only present in type positions.
Parses JavaScript/TypeScript source text with configurable plugin flags.
Install with Tessl CLI
npx tessl i tessl/npm-babel--preset-stage-0docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10