summaryrefslogtreecommitdiff
path: root/cli/js/compiler_api.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-03-08 13:09:22 +0100
committerGitHub <noreply@github.com>2020-03-08 13:09:22 +0100
commit1b6f8318750d319d689f7eeef9e7e1f2e56b94a6 (patch)
treeb2e182b77cfbcd25ee893113de9f61509e16e787 /cli/js/compiler_api.ts
parentb9037c86ed8d1d55a59a1c1298fa12bbfcae6873 (diff)
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
Diffstat (limited to 'cli/js/compiler_api.ts')
-rw-r--r--cli/js/compiler_api.ts17
1 files changed, 10 insertions, 7 deletions
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<string, string>,
options?: CompilerOptions
): Promise<Record<string, TranspileOnlyResult>> {
@@ -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<string, string>,
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<string, string>,
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);
}