1
+ var path = require ( 'path' ) ;
1
2
var Concat = require ( 'broccoli-concat' ) ;
2
3
var configReplace = require ( './broccoli-config-replace' ) ;
3
4
var compileWithTypescript = require ( './broccoli-typescript' ) . default ;
4
5
var fs = require ( 'fs' ) ;
6
+ var glob = require ( 'glob' ) ;
5
7
var Funnel = require ( 'broccoli-funnel' ) ;
6
8
var mergeTrees = require ( 'broccoli-merge-trees' ) ;
7
9
var Project = require ( 'ember-cli/lib/models/project' ) ;
@@ -32,7 +34,25 @@ Angular2App.prototype.toTree = function() {
32
34
vendorNpmFiles = vendorNpmFiles . concat ( this . options . vendorNpmFiles ) ;
33
35
}
34
36
35
- var tsConfigCompilerOptions = JSON . parse ( fs . readFileSync ( 'src/tsconfig.json' , 'utf-8' ) ) . compilerOptions ;
37
+ var tsConfig = JSON . parse ( fs . readFileSync ( 'tsconfig.json' , 'utf-8' ) ) ;
38
+ var tsConfigCompilerOptions = tsConfig . compilerOptions ;
39
+
40
+ // `rootFilesPath` is used by the broccoli-typescript to add files to the compilation.
41
+ // It is _not_ part of the `tsconfig.json` spec, so it won't be found in
42
+ // tsConfigCompilerOptions. This adds the typings manually to the compilation step.
43
+ // We pass in all files except those that matches excluded paths.
44
+ var exclude = tsConfig . exclude || [ ] ;
45
+ var files = glob . sync ( '**/*.ts' ) ;
46
+ tsConfigCompilerOptions . rootFilePaths = files
47
+ . filter ( function ( x ) {
48
+ // Remove those who start with paths in the tsconfig exclude list.
49
+ return ! exclude . some ( function ( y ) { return x . startsWith ( y ) ; } ) ;
50
+ } )
51
+ . map ( ( function ( x ) {
52
+ // Map them around the current working directory.
53
+ return path . join ( process . cwd ( ) , x ) ;
54
+ } ) ) ;
55
+
36
56
var tsTree = compileWithTypescript ( sourceTree , tsConfigCompilerOptions ) ;
37
57
var tsSrcTree = new Funnel ( sourceTree , {
38
58
include : [ '**/*.ts' ] ,
@@ -46,7 +66,7 @@ Angular2App.prototype.toTree = function() {
46
66
47
67
var assetTree = new Funnel ( sourceTree , {
48
68
include : [ '**/*.*' ] ,
49
- exclude : [ '**/*.ts' , '**/*.js' , 'src/tsconfig.json' ] ,
69
+ exclude : [ '**/*.ts' , '**/*.js' ] ,
50
70
allowEmpty : true
51
71
} ) ;
52
72
0 commit comments