@@ -9,8 +9,9 @@ const FastBootExpressMiddleware = require('fastboot-express-middleware');
99const FastBoot = require ( 'fastboot' ) ;
1010const chalk = require ( 'chalk' ) ;
1111
12- const fastbootAppModule = require ( './lib/utilities/fastboot-app-module ' ) ;
12+ const fastbootAppBoot = require ( './lib/utilities/fastboot-app-boot ' ) ;
1313const FastBootConfig = require ( './lib/broccoli/fastboot-config' ) ;
14+ const fastbootAppFactoryModule = require ( './lib/utilities/fastboot-app-factory-module' ) ;
1415const migrateInitializers = require ( './lib/build-utilities/migrate-initializers' ) ;
1516const SilentError = require ( 'silent-error' ) ;
1617
@@ -107,8 +108,8 @@ module.exports = {
107108 }
108109
109110 if ( type === 'app-boot' ) {
110- const isModuleUnification = ( typeof this . project . isModuleUnification === 'function' ) && this . project . isModuleUnification ( ) ;
111- return fastbootAppModule ( config . modulePrefix , JSON . stringify ( config . APP || { } ) , isModuleUnification ) ;
111+ const isModuleUnification = this . _isModuleUnification ( ) ;
112+ return fastbootAppBoot ( config . modulePrefix , JSON . stringify ( config . APP || { } ) , isModuleUnification ) ;
112113 }
113114
114115 // if the fastboot addon is installed, we overwrite the config-module so that the config can be read
@@ -174,10 +175,11 @@ module.exports = {
174175 */
175176 _getFastbootTree ( ) {
176177 const appName = this . _name ;
178+ const isModuleUnification = this . _isModuleUnification ( ) ;
177179
178180 let fastbootTrees = [ ] ;
179- this . _processAddons ( this . project . addons , fastbootTrees ) ;
180181
182+ this . _processAddons ( this . project . addons , fastbootTrees ) ;
181183 // check the parent containing the fastboot directory
182184 const projectFastbootPath = path . join ( this . project . root , 'fastboot' ) ;
183185 if ( this . existsSync ( projectFastbootPath ) ) {
@@ -189,19 +191,28 @@ module.exports = {
189191 let mergedFastBootTree = new MergeTrees ( fastbootTrees , {
190192 overwrite : true
191193 } ) ;
194+
192195 let funneledFastbootTrees = new Funnel ( mergedFastBootTree , {
193196 destDir : appName
194197 } ) ;
195198 const processExtraTree = p . preprocessJs ( funneledFastbootTrees , '/' , this . _name , {
196199 registry : this . _appRegistry
197200 } ) ;
198201
202+ // FastBoot app factory module
203+ const writeFile = require ( 'broccoli-file-creator' ) ;
204+ let appFactoryModuleTree = writeFile ( "app-factory.js" , fastbootAppFactoryModule ( appName , this . _isModuleUnification ( ) ) ) ;
205+
206+ let newProcessExtraTree = new MergeTrees ( [ processExtraTree , appFactoryModuleTree ] , {
207+ overwrite : true
208+ } ) ;
209+
199210 function stripLeadingSlash ( filePath ) {
200211 return filePath . replace ( / ^ \/ / , '' ) ;
201212 }
202213
203214 let appFilePath = stripLeadingSlash ( this . app . options . outputPaths . app . js ) ;
204- let finalFastbootTree = new Concat ( processExtraTree , {
215+ let finalFastbootTree = new Concat ( newProcessExtraTree , {
205216 outputFile : appFilePath . replace ( / \. j s $ / , '-fastboot.js' )
206217 } ) ;
207218
@@ -362,4 +373,8 @@ module.exports = {
362373
363374 return checker . for ( 'ember' , 'bower' ) ;
364375 } ,
376+
377+ _isModuleUnification ( ) {
378+ return ( typeof this . project . isModuleUnification === 'function' ) && this . project . isModuleUnification ( ) ;
379+ }
365380} ;
0 commit comments