1 | import Compiler from "./compiler";
|
2 | import DiagnosticsHandler from "./diagnostics-handler";
|
3 | import { toAbsolutePath } from "./fs/path-utils";
|
4 | import { BroccoliPlugin, heimdall } from "./helpers";
|
5 | import normalizeOptions from "./normalize-options";
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | export function typescript(inputNode, options) {
|
24 | return new TypescriptCompiler(inputNode, options);
|
25 | }
|
26 |
|
27 |
|
28 |
|
29 | export class TypescriptCompiler extends BroccoliPlugin {
|
30 | constructor(inputNode, options) {
|
31 | super([inputNode], {
|
32 | annotation: options && options.annotation,
|
33 | name: "broccoli-typescript-compiler",
|
34 | persistentOutput: true,
|
35 | });
|
36 | const normalizedOptions = normalizeOptions(options || {});
|
37 | this.options = normalizedOptions;
|
38 | this.diagnosticHandler = new DiagnosticsHandler(normalizedOptions);
|
39 | }
|
40 | build() {
|
41 | const token = heimdall.start("TypeScript:compile");
|
42 | let compiler = this.compiler;
|
43 | if (!compiler) {
|
44 | compiler = this.compiler = new Compiler(toAbsolutePath(this.inputPaths[0]), toAbsolutePath(this.outputPath), this.options, this.diagnosticHandler);
|
45 | }
|
46 | compiler.compile();
|
47 | heimdall.stop(token);
|
48 | }
|
49 | setDiagnosticWriter(write) {
|
50 | this.diagnosticHandler.setWrite(write);
|
51 | }
|
52 | }
|
53 |
|
\ | No newline at end of file |