refactor(ts): remove op_cache (#5071)

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.
This commit is contained in:
Bartek Iwańczuk 2020-05-05 18:23:15 +02:00 committed by GitHub
parent e574437922
commit cf5a39a361
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 348 additions and 503 deletions

View file

@ -38,15 +38,3 @@ export function getAsset(name: string): string {
const sourceCodeBytes = core.dispatch(opId, encoder.encode(name));
return decoder.decode(sourceCodeBytes!);
}
export function cache(
extension: string,
moduleId: string,
contents: string
): void {
sendSync("op_cache", {
extension,
moduleId,
contents,
});
}

View file

@ -1,6 +1,7 @@
// 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;
@ -9,7 +10,13 @@ interface CompileRequest {
bundle: boolean;
}
export function compile(request: CompileRequest): Promise<string> {
interface CompileResponse {
diagnostics: DiagnosticItem[];
output?: string;
emitMap?: Record<string, Record<string, string>>;
}
export function compile(request: CompileRequest): Promise<CompileResponse> {
return sendAsync("op_compile", request);
}
@ -18,6 +25,13 @@ interface TranspileRequest {
options?: string;
}
export function transpile(request: TranspileRequest): Promise<string> {
export interface TranspileOnlyResult {
source: string;
map?: string;
}
export function transpile(
request: TranspileRequest
): Promise<Record<string, TranspileOnlyResult>> {
return sendAsync("op_transpile", request);
}