From 1b6f8318750d319d689f7eeef9e7e1f2e56b94a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sun, 8 Mar 2020 13:09:22 +0100 Subject: reorg: move JS ops implementations to cli/js/ops/, part 1 (#4264) Following JS ops were moved to separate files in cli/js/ops directory: - compiler - dispatch_json - dispatch_minimal - errors - fetch - fs_events - os - random - repl - resources - runtime_compiler - runtime - tty --- cli/js/compiler_api.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'cli/js/compiler_api.ts') diff --git a/cli/js/compiler_api.ts b/cli/js/compiler_api.ts index 3638046b6..b7c4e83e8 100644 --- a/cli/js/compiler_api.ts +++ b/cli/js/compiler_api.ts @@ -4,8 +4,8 @@ // compiler within Deno. import { DiagnosticItem } from "./diagnostics.ts"; -import { sendAsync } from "./dispatch_json.ts"; import * as util from "./util.ts"; +import * as runtimeCompilerOps from "./ops/runtime_compiler.ts"; /** A specific subset TypeScript compiler options that can be supported by * the Deno TypeScript compiler. */ @@ -300,7 +300,7 @@ export interface TranspileOnlyResult { * Many of the options related to type checking and emitting * type declaration files will have no impact on the output. */ -export function transpileOnly( +export async function transpileOnly( sources: Record, options?: CompilerOptions ): Promise> { @@ -309,7 +309,8 @@ export function transpileOnly( sources, options: options ? JSON.stringify(options) : undefined }; - return sendAsync("op_transpile", payload).then(result => JSON.parse(result)); + const result = await runtimeCompilerOps.transpile(payload); + return JSON.parse(result); } /** Takes a root module name, any optionally a record set of sources. Resolves @@ -339,7 +340,7 @@ export function transpileOnly( * @param options An optional object of options to send to the compiler. This is * a subset of ts.CompilerOptions which can be supported by Deno. */ -export function compile( +export async function compile( rootName: string, sources?: Record, options?: CompilerOptions @@ -355,7 +356,8 @@ export function compile( sources: !!sources, options }); - return sendAsync("op_compile", payload).then(result => JSON.parse(result)); + const result = await runtimeCompilerOps.compile(payload); + return JSON.parse(result); } /** Takes a root module name, and optionally a record set of sources. Resolves @@ -386,7 +388,7 @@ export function compile( * @param options An optional object of options to send to the compiler. This is * a subset of ts.CompilerOptions which can be supported by Deno. */ -export function bundle( +export async function bundle( rootName: string, sources?: Record, options?: CompilerOptions @@ -402,5 +404,6 @@ export function bundle( sources: !!sources, options }); - return sendAsync("op_compile", payload).then(result => JSON.parse(result)); + const result = await runtimeCompilerOps.compile(payload); + return JSON.parse(result); } -- cgit v1.2.3