CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-babel--preset-stage-0

tessl install tessl/npm-babel--preset-stage-0@7.8.0

Deprecated Babel preset for stage 0 plugins that provides migration guidelines to explicit plugin configurations

Agent Success

Agent success rate when using this tile

80%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.21x

Baseline

Agent success rate without this tile

66%

task.mdevals/scenario-2/

AST Emitter with Source Maps

Generate JavaScript from a Babel-format AST while returning a usable source map and optional inline map comment.

Capabilities

Emits code and map for a single file

  • Given an ESTree-compatible/Babel-format AST for const answer = 42; with loc data anchored at line 1, column 0 and sourceName: "input.js", return code === "const answer = 42;" and a source map whose sources contains "input.js", sourcesContent contains the original source string, and the identifier answer maps to the original line 1, column 6. @test

Appends inline source map comment when requested

  • When includeInlineMap: true is provided along with sourceName: "inline.js" and sourceContent: "let value = 7;", return the code string plus a trailing //# sourceMappingURL=data:application/json;base64,... comment that decodes to the same map object returned alongside code. @test

Respects retained line layout

  • When retainLines: true and the AST's top-level loc.start.line is 2 (one blank line before the program), preserve the leading blank line in the emitted code and ensure the first statement still maps to original line 2 in the source map. @test

Implementation

@generates

API

export interface EmitOptions {
  sourceName?: string;
  sourceContent?: string;
  includeInlineMap?: boolean;
  retainLines?: boolean;
}

export interface EmitResult {
  code: string;
  map: object;
}

export function emitWithSourceMap(ast: object, options?: EmitOptions): EmitResult;

Dependencies { .dependencies }

@babel/generator { .dependency }

Generates JavaScript from Babel-format AST nodes with source map support.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@babel/preset-stage-0@7.8.x
tile.json