mirror of
https://github.com/denoland/deno.git
synced 2024-11-14 16:33:45 -05:00
cf5a39a361
This PR removes op_cache and refactors how Deno interacts with TS compiler. Ultimate goal is to completely sandbox TS compiler worker; it should operate on simple request -> response basis. With this commit TS compiler no longer caches compiled sources as they are generated but rather collects all sources and sends them back to Rust when compilation is done. Additionally "Diagnostic" and its children got refactored to use "Deserialize" trait instead of manually implementing JSON deserialization.
37 lines
875 B
TypeScript
37 lines
875 B
TypeScript
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import { sendAsync } from "./dispatch_json.ts";
|
|
import { DiagnosticItem } from "../diagnostics.ts";
|
|
|
|
interface CompileRequest {
|
|
rootName: string;
|
|
sources?: Record<string, string>;
|
|
options?: string;
|
|
bundle: boolean;
|
|
}
|
|
|
|
interface CompileResponse {
|
|
diagnostics: DiagnosticItem[];
|
|
output?: string;
|
|
emitMap?: Record<string, Record<string, string>>;
|
|
}
|
|
|
|
export function compile(request: CompileRequest): Promise<CompileResponse> {
|
|
return sendAsync("op_compile", request);
|
|
}
|
|
|
|
interface TranspileRequest {
|
|
sources: Record<string, string>;
|
|
options?: string;
|
|
}
|
|
|
|
export interface TranspileOnlyResult {
|
|
source: string;
|
|
map?: string;
|
|
}
|
|
|
|
export function transpile(
|
|
request: TranspileRequest
|
|
): Promise<Record<string, TranspileOnlyResult>> {
|
|
return sendAsync("op_transpile", request);
|
|
}
|