[]previous and next page

compileAsync

Compiles a module without blocking the event loop: the Rust implementation runs on a worker thread of the process and the promise settles with what compile would have returned or thrown.

Compiles a module without blocking the event loop: the Rust implementation runs on a worker thread of the process and the promise settles with what compile would have returned or thrown. With the WebAssembly build or the TypeScript implementation the work runs on the calling thread, after the current turn.

Import#

ts
import { compileAsync } from "@shadow-js/compiler";

Signature#

ts
async function compileAsync(
  source: string,
  options?: CompileOptions,
): Promise<CompileResult>

Parameters#

Name Description
source Module text to compile.
options What to generate and how; see CompileOptions.

Returns#

A promise of the result; it rejects with a CompileError where compile throws.

Examples#

ts
import { compileAsync } from "@shadow-js/compiler";

const result = await compileAsync("export const A = () => <b>x</b>;");
console.log(result.transformed); // true