-
Notifications
You must be signed in to change notification settings - Fork 2
/
denali-build.js
38 lines (33 loc) · 1.16 KB
/
denali-build.js
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
38
const path = require('path');
const chalk = require('chalk');
const { AddonBuilder, ui } = require(`@denali-js/cli`);
const Funnel = require('broccoli-funnel');
const MergeTree = require('broccoli-merge-trees');
const { typescript: Typescript } = require('broccoli-typescript-compiler');
module.exports = class DenaliTypescriptBuilder extends AddonBuilder {
processSelf(tree, dir) {
return this.transpileTree(tree, dir);
}
processParent(tree, dir) {
return this.transpileTree(tree, dir);
}
transpileTree(tree, dir) {
let tsconfig = require(path.join(dir, 'tsconfig.json'));
tsconfig.baseUrl = dir;
let transpiledTS = new Typescript(tree, {
tsconfig,
workingPath: dir,
annotation: 'compile typescript'
});
transpiledTS.setDiagnosticWriter((message) => {
if (this.parentBuilder) {
ui.warn(chalk.bold(`==> [${ this.parentBuilder.pkg.name }] Typescript compilation errors: `));
}
ui.warn(message);
});
let withoutTS = new Funnel(tree, {
exclude: [ '**/*.ts' ]
});
return new MergeTree([ withoutTS, transpiledTS ], { overwrite: true, annotation: 'merge typescript output' });
}
};