summaryrefslogtreecommitdiff
path: root/cli/js/ops/runtime_compiler.ts
blob: 671585118df6f907c63fac031b548224053b97d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { sendAsync } from "./dispatch_json.ts";
import type { 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);
}