2020-03-08 08:09:22 -04:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
|
|
|
import { sendAsync } from "./dispatch_json.ts";
|
2020-05-05 12:23:15 -04:00
|
|
|
import { DiagnosticItem } from "../diagnostics.ts";
|
2020-03-08 08:09:22 -04:00
|
|
|
|
|
|
|
interface CompileRequest {
|
|
|
|
rootName: string;
|
|
|
|
sources?: Record<string, string>;
|
|
|
|
options?: string;
|
|
|
|
bundle: boolean;
|
|
|
|
}
|
|
|
|
|
2020-05-05 12:23:15 -04:00
|
|
|
interface CompileResponse {
|
|
|
|
diagnostics: DiagnosticItem[];
|
|
|
|
output?: string;
|
|
|
|
emitMap?: Record<string, Record<string, string>>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function compile(request: CompileRequest): Promise<CompileResponse> {
|
2020-03-08 08:09:22 -04:00
|
|
|
return sendAsync("op_compile", request);
|
|
|
|
}
|
|
|
|
|
|
|
|
interface TranspileRequest {
|
|
|
|
sources: Record<string, string>;
|
|
|
|
options?: string;
|
|
|
|
}
|
|
|
|
|
2020-05-05 12:23:15 -04:00
|
|
|
export interface TranspileOnlyResult {
|
|
|
|
source: string;
|
|
|
|
map?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function transpile(
|
|
|
|
request: TranspileRequest
|
|
|
|
): Promise<Record<string, TranspileOnlyResult>> {
|
2020-03-08 08:09:22 -04:00
|
|
|
return sendAsync("op_transpile", request);
|
|
|
|
}
|