CtrlK
BlogDocsLog inGet started
Tessl Logo

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

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

80

1.21x
Overview
Eval results
Files

task.mdevals/scenario-2/

Source Transform Runner

A minimal interface for compiling JavaScript and TypeScript source text and files through the dependency's compiler entry points to deliver transformed code, source maps, and metadata for downstream tooling.

Capabilities

Inline compilation

  • Given source const greet = (name?: string) => name ?? "hi"; and options using @babel/preset-env (targeting Node 14) plus @babel/preset-typescript with sourceMaps: "inline" and filename: "virtual.ts", returns code with type syntax stripped, nullish coalescing rewritten for the target, and an inline source map comment that references virtual.ts. @test
  • When sourceMaps is truthy, the returned object contains the generated code, parsed source map data, and compiler metadata. @test

File compilation

  • Compiling fixtures/sample.ts with the same presets/plugins applies the transforms, resolves cwd and filename into the source map paths, and yields code that mirrors the inline behavior. @test
  • Files outside the allowed extensions set (.js, .jsx, .ts, .tsx) are rejected with a clear error. @test

Callback mode

  • A callback-driven file compile entry point accepts an error-first callback; compiler failures surface the underlying message, and successful callbacks receive the same shape as the async result. @test

Implementation

@generates

API

export interface CompileOptions {
  presets?: Array<string | [string, Record<string, unknown>]>;
  plugins?: Array<string | [string, Record<string, unknown>]>;
  sourceMaps?: boolean | "inline";
  cwd?: string;
  filename?: string;
  extensions?: string[];
}

export interface CompileOutput {
  code: string;
  map?: object | null;
  metadata?: Record<string, unknown>;
}

export function compileString(source: string, options?: CompileOptions): Promise<CompileOutput>;

export function compileFile(filePath: string, options?: CompileOptions): Promise<CompileOutput>;

export function compileFileSync(filePath: string, options?: CompileOptions): CompileOutput;

export function compileFileWithCallback(
  filePath: string,
  options: CompileOptions | undefined,
  callback: (error: Error | null, result?: CompileOutput) => void
): void;

Dependencies { .dependencies }

@babel/core { .dependency }

Exposes the compiler entry points used to transform source strings and files, returning code, source maps, and metadata.

Install with Tessl CLI

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

tile.json