@@ -32,8 +32,8 @@ class EmberApp {
32
32
let distPath = path . resolve ( options . distPath ) ;
33
33
let config = this . readPackageJSON ( distPath ) ;
34
34
35
- this . appFilePath = config . appFile ;
36
- this . vendorFilePath = config . vendorFile ;
35
+ this . appFilePaths = config . appFiles ;
36
+ this . vendorFilePaths = config . vendorFiles ;
37
37
this . moduleWhitelist = config . moduleWhitelist ;
38
38
this . hostWhitelist = config . hostWhitelist ;
39
39
this . appConfig = config . appConfig ;
@@ -128,21 +128,26 @@ class EmberApp {
128
128
*/
129
129
loadAppFiles ( ) {
130
130
let sandbox = this . sandbox ;
131
- let appFilePath = this . appFilePath ;
132
- let vendorFilePath = this . vendorFilePath ;
131
+ let appFilePaths = this . appFilePaths ;
132
+ let vendorFilePaths = this . vendorFilePaths ;
133
133
134
134
sandbox . eval ( 'sourceMapSupport.install(Error);' ) ;
135
135
136
- let appFile = fs . readFileSync ( appFilePath , 'utf8' ) ;
137
- let vendorFile = fs . readFileSync ( vendorFilePath , 'utf8' ) ;
136
+ debug ( "evaluating app and vendor files" ) ;
138
137
139
- debug ( "evaluating app; app=%s; vendor=%s" , appFilePath , vendorFilePath ) ;
140
-
141
- sandbox . eval ( vendorFile , vendorFilePath ) ;
138
+ vendorFilePaths . forEach ( function ( vendorFilePath ) {
139
+ debug ( "evaluating vendor file %s" , vendorFilePath ) ;
140
+ let vendorFile = fs . readFileSync ( vendorFilePath , 'utf8' ) ;
141
+ sandbox . eval ( vendorFile , vendorFilePath ) ;
142
+ } ) ;
142
143
debug ( "vendor file evaluated" ) ;
143
144
144
- sandbox . eval ( appFile , appFilePath ) ;
145
- debug ( "app file evaluated" ) ;
145
+ appFilePaths . forEach ( function ( appFilePath ) {
146
+ debug ( "evaluating app file %s" , appFilePath ) ;
147
+ let appFile = fs . readFileSync ( appFilePath , 'utf8' ) ;
148
+ sandbox . eval ( appFile , appFilePath ) ;
149
+ } ) ;
150
+ debug ( "app files evaluated" ) ;
146
151
}
147
152
148
153
/**
@@ -153,7 +158,6 @@ class EmberApp {
153
158
*/
154
159
createEmberApp ( ) {
155
160
let sandbox = this . sandbox ;
156
- let appFilePath = this . appFilePath ;
157
161
158
162
// Retrieve the application factory from within the sandbox
159
163
let AppFactory = sandbox . run ( function ( ctx ) {
@@ -162,7 +166,7 @@ class EmberApp {
162
166
163
167
// If the application factory couldn't be found, throw an error
164
168
if ( ! AppFactory || typeof AppFactory [ 'default' ] !== 'function' ) {
165
- throw new Error ( 'Failed to load Ember app from ' + appFilePath + ' , make sure it was built for FastBoot with the `ember fastboot:build` command.') ;
169
+ throw new Error ( 'Failed to load Ember app from app.js , make sure it was built for FastBoot with the `ember fastboot:build` command.' ) ;
166
170
}
167
171
168
172
// Otherwise, return a new `Ember.Application` instance
@@ -349,9 +353,33 @@ class EmberApp {
349
353
throw new Error ( `${ pkgPath } was malformed or did not contain a manifest. Ensure that you have a compatible version of ember-cli-fastboot.` ) ;
350
354
}
351
355
356
+ var appFiles = [ ] ;
357
+ if ( manifest . appFiles ) {
358
+ debug ( "reading array of app file paths from manifest" ) ;
359
+ manifest . appFiles . forEach ( function ( appFile ) {
360
+ appFiles . push ( path . join ( distPath , appFile ) ) ;
361
+ } ) ;
362
+ } else if ( manifest . appFile ) {
363
+ // TODO : remove after Fastboot 1.0
364
+ debug ( "reading app file path from manifest" ) ;
365
+ appFiles = [ path . join ( distPath , manifest . appFile ) ] ;
366
+ }
367
+
368
+ var vendorFiles = [ ] ;
369
+ if ( manifest . vendorFiles ) {
370
+ debug ( "reading array of vendor file paths from manifest" ) ;
371
+ manifest . vendorFiles . forEach ( function ( vendorFile ) {
372
+ vendorFiles . push ( path . join ( distPath , vendorFile ) ) ;
373
+ } ) ;
374
+ } else if ( manifest . vendorFile ) {
375
+ // TODO : remove after Fastboot 1.0
376
+ debug ( "reading vendor file path from manifest" ) ;
377
+ vendorFiles = [ path . join ( distPath , manifest . vendorFile ) ] ;
378
+ }
379
+
352
380
return {
353
- appFile : path . join ( distPath , manifest . appFile ) ,
354
- vendorFile : path . join ( distPath , manifest . vendorFile ) ,
381
+ appFiles : appFiles ,
382
+ vendorFiles : vendorFiles ,
355
383
htmlFile : path . join ( distPath , manifest . htmlFile ) ,
356
384
moduleWhitelist : pkg . fastboot . moduleWhitelist ,
357
385
hostWhitelist : pkg . fastboot . hostWhitelist ,
0 commit comments