@@ -29,7 +29,9 @@ function getVersionChecker(context) {
2929 return checker ;
3030}
3131
32-
32+ function stripLeadingSlash ( filePath ) {
33+ return filePath . replace ( / ^ \/ / , '' ) ;
34+ }
3335
3436/*
3537 * Main entrypoint for the Ember CLI addon.
@@ -106,11 +108,6 @@ module.exports = {
106108 return "<!-- EMBER_CLI_FASTBOOT_TITLE --><!-- EMBER_CLI_FASTBOOT_HEAD -->" ;
107109 }
108110
109- 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 ) ;
112- }
113-
114111 // if the fastboot addon is installed, we overwrite the config-module so that the config can be read
115112 // from meta tag/directly for browser build and from Fastboot config for fastboot target.
116113 if ( type === 'config-module' ) {
@@ -196,10 +193,6 @@ module.exports = {
196193 registry : this . _appRegistry
197194 } ) ;
198195
199- function stripLeadingSlash ( filePath ) {
200- return filePath . replace ( / ^ \/ / , '' ) ;
201- }
202-
203196 let appFilePath = stripLeadingSlash ( this . app . options . outputPaths . app . js ) ;
204197 let finalFastbootTree = new Concat ( processExtraTree , {
205198 outputFile : appFilePath . replace ( / \. j s $ / , '-fastboot.js' )
@@ -334,6 +327,8 @@ module.exports = {
334327 } ,
335328
336329 postBuild ( result ) {
330+ let appFilePath = stripLeadingSlash ( this . app . options . outputPaths . app . js ) ;
331+ this . _appendAppBoot ( result . directory , appFilePath ) ;
337332 if ( this . fastboot ) {
338333 // should we reload fastboot if there are only css changes? Seems it maynot be needed.
339334 // TODO(future): we can do a smarter reload here by running fs-tree-diff on files loaded
@@ -361,4 +356,14 @@ module.exports = {
361356
362357 return checker . for ( 'ember' , 'bower' ) ;
363358 } ,
359+
360+ _appendAppBoot ( appDir , appFilePath ) {
361+ let env = this . app . env ;
362+ let config = this . project . config ( env ) ;
363+ const isModuleUnification = ( typeof this . project . isModuleUnification === 'function' ) && this . project . isModuleUnification ( ) ;
364+ const appBoot = fastbootAppModule ( config . modulePrefix , JSON . stringify ( config . APP || { } ) , isModuleUnification ) ;
365+
366+ appFilePath = path . resolve ( appDir , appFilePath ) ;
367+ fs . appendFileSync ( appFilePath , appBoot ) ;
368+ }
364369} ;
0 commit comments