@@ -10,17 +10,17 @@ var Project = require('ember-cli/lib/models/project');
10
10
11
11
module . exports = Angular2App ;
12
12
13
- function Angular2App ( defaults , options , additionalPaths ) {
13
+ function Angular2App ( defaults , options ) {
14
14
this . _initProject ( ) ;
15
15
this . _notifyAddonIncluded ( ) ;
16
16
this . options = options ;
17
- this . additionalPaths = additionalPaths || [ ] ;
18
17
}
19
18
20
19
Angular2App . prototype . toTree = function ( ) {
21
20
var sourceDir = 'src' ;
22
21
23
22
var sourceTree = new Funnel ( 'src' , {
23
+ include : [ '*.ts' , '**/*.ts' , '**/*.d.ts' ] ,
24
24
destDir : 'src'
25
25
} ) ;
26
26
@@ -41,33 +41,31 @@ Angular2App.prototype.toTree = function() {
41
41
'angular2/bundles/upgrade.dev.js'
42
42
] ;
43
43
44
-
45
-
46
44
if ( this . options && this . options . vendorNpmFiles ) {
47
45
vendorNpmFiles = vendorNpmFiles . concat ( this . options . vendorNpmFiles ) ;
48
46
}
49
47
50
48
var tsconfig = JSON . parse ( fs . readFileSync ( 'src/tsconfig.json' , 'utf-8' ) ) ;
51
- var tsConfigCompilerOptions = tsconfig . compilerOptions ;
52
-
53
-
54
- // TODO(i): why do we need these additional paths? remove?
55
- tsConfigCompilerOptions . rootFilePaths = this . additionalPaths . map ( function ( name ) {
56
- return path . join ( process . cwd ( ) , sourceDir , name )
57
- } ) ;
58
-
59
- // TODO(i): kill rootFilePaths in broccoli-typescript and use tsconfig.json#files instead
60
- tsConfigCompilerOptions . rootFilePaths = tsConfigCompilerOptions . rootFilePaths .
61
- concat ( tsconfig . files . map ( function ( p ) {
62
- // TODO(i): this is a hack - for some reason we need to prefix all paths with srcDir because
63
- // tsc's "rootDir" doesn't take effect when resolving "files" paths
64
- return path . join ( sourceDir , p ) ;
65
- } ) ) ;
49
+ // Add all spec files to files. We need this because spec files are their own entry
50
+ // point.
51
+ fs . readdirSync ( sourceDir ) . forEach ( function addPathRecursive ( name ) {
52
+ const filePath = path . join ( sourceDir , name ) ;
53
+ if ( filePath . match ( / \. s p e c \. [ j t ] s $ / ) ) {
54
+ tsconfig . files . push ( name ) ;
55
+ } else if ( fs . statSync ( filePath ) . isDirectory ( ) ) {
56
+ // Recursively call this function with the full sub-path.
57
+ fs . readdirSync ( filePath ) . forEach ( function ( n ) {
58
+ addPathRecursive ( path . join ( name , n ) ) ;
59
+ } ) ;
60
+ }
61
+ } ) ;
66
62
63
+ // Because the tsconfig does not include the source directory, add this as the first path
64
+ // element.
65
+ tsconfig . files = tsconfig . files . map ( name => path . join ( sourceDir , name ) ) ;
67
66
68
67
var srcAndTypingsTree = mergeTrees ( [ sourceTree , typingsTree ] ) ;
69
-
70
- var tsTree = compileWithTypescript ( srcAndTypingsTree , tsConfigCompilerOptions ) ;
68
+ var tsTree = new compileWithTypescript ( srcAndTypingsTree , tsconfig ) ;
71
69
72
70
tsTree = new Funnel ( tsTree , {
73
71
srcDir : 'src' ,
@@ -113,10 +111,10 @@ Angular2App.prototype.toTree = function() {
113
111
jsTree ,
114
112
this . index ( ) ,
115
113
vendorNpmTree ,
116
- thirdPartyJs
114
+ thirdPartyJs ,
117
115
] , { overwrite : true } ) ;
118
116
119
- return mergeTrees ( [ merged , new SwManifest ( merged ) ] ) ;
117
+ return mergeTrees ( [ merged , new SwManifest ( [ merged ] ) ] ) ;
120
118
} ;
121
119
122
120
/**
0 commit comments