-
Notifications
You must be signed in to change notification settings - Fork 14
/
denali-build.js
37 lines (32 loc) · 1.21 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
const path = require('path');
const chalk = require('chalk');
const { exec } = require('child_process');
const { AddonBuilder, ui } = require('@denali-js/cli');
module.exports = class DenaliBuilder extends AddonBuilder {
processSelf(tree, dir) {
tree = this.transpileTree(tree, dir);
return tree;
}
transpileTree(tree, dir) {
// Lazy load these to avoid needing them as a full dep (this way we can keep them as devDeps)
const { typescript: Typescript } = require('broccoli-typescript-compiler');
const Funnel = require('broccoli-funnel');
const MergeTree = require('broccoli-merge-trees');
let tsconfig = require(path.join(dir, 'tsconfig.json'));
tsconfig.baseUrl = __dirname;
let transpiledTS = new Typescript(tree, {
tsconfig,
throwOnError: false,
workingPath: __dirname,
annotation: 'compile typescript'
});
transpiledTS.setDiagnosticWriter((message) => {
ui.warn(chalk.bold(`==> [denali] Typescript compilation errors: `));
ui.warn(message);
});
let withoutTS = new Funnel(tree, {
exclude: [ '**/*.ts' ]
});
return new MergeTree([ withoutTS, transpiledTS ], { overwrite: true, annotation: 'merge typescript output' });
}
};