mirror of
https://github.com/denoland/deno.git
synced 2025-07-24 13:44:08 +00:00
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:
parent
e574437922
commit
cf5a39a361
16 changed files with 348 additions and 503 deletions
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue