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-1/

Preparsed AST Export Rewriter

Transforms an existing Babel-format AST of an ES module without reparsing the source. Rewrites logging, promotes an anonymous default export into a named handler, and returns generated code (and an optional source map) derived from the provided tree. When inserting or reusing logging helpers, default to a module specifier of "reporter" unless overridden.

Capabilities

Rewrites console logging

  • Given an AST for const msg = "hi"; console.log(msg); export default () => msg;, the emitted code uses reporter.log(msg) instead of console.log(msg) while leaving other statements intact, adding a single default import for the reporter module when none exists. @test

Names and re-exports the default handler

  • When the default export is an anonymous function, emit code that declares export const handler = <original default export> and export default handler; while preserving the original function body. @test

Avoids duplicate reporter import

  • If the AST already includes import reporter from "reporter";, the transformed code reuses the existing import and still rewrites log calls without adding a second import. @test

Emits source map when requested

  • When called with includeSourceMap: true and filename: "example.js" plus the AST described above, returns a non-null map whose file is "example.js" and whose mappings align with the transformed output length. @test

Implementation

@generates

API

export interface TransformResult {
  code: string;
  map?: object | null;
}

export interface TransformOptions {
  filename?: string;
  reporterModule?: string;
  includeSourceMap?: boolean;
}

export async function transformPreparsedModule(
  ast: object,
  sourceCode?: string,
  options?: TransformOptions
): Promise<TransformResult>;

Dependencies { .dependencies }

@babel/core { .dependency }

Runs a plugin pipeline against an existing AST and emits code and source maps without reparsing the input.

Version

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