@@ -30,8 +30,6 @@ function getVersionChecker(context) {
30
30
return checker ;
31
31
}
32
32
33
-
34
-
35
33
/*
36
34
* Main entrypoint for the Ember CLI addon.
37
35
*/
@@ -62,10 +60,11 @@ module.exports = {
62
60
* See: https://ember-cli.com/user-guide/#integration
63
61
*/
64
62
included ( app ) {
65
-
66
63
let assetRev = this . project . addons . find ( addon => addon . name === 'broccoli-asset-rev' ) ;
67
- if ( assetRev && ! assetRev . supportsFastboot ) {
68
- throw new SilentError ( "This version of ember-cli-fastboot requires a newer version of broccoli-asset-rev" ) ;
64
+ if ( assetRev && ! assetRev . supportsFastboot ) {
65
+ throw new SilentError (
66
+ 'This version of ember-cli-fastboot requires a newer version of broccoli-asset-rev'
67
+ ) ;
69
68
}
70
69
71
70
// set autoRun to false since we will conditionally include creating app when app files
@@ -91,8 +90,8 @@ module.exports = {
91
90
*/
92
91
importTransforms ( ) {
93
92
return {
94
- fastbootShim : fastbootTransform
95
- }
93
+ fastbootShim : fastbootTransform ,
94
+ } ;
96
95
} ,
97
96
98
97
/**
@@ -102,16 +101,15 @@ module.exports = {
102
101
*/
103
102
contentFor ( type , config , contents ) {
104
103
if ( type === 'body' ) {
105
- return " <!-- EMBER_CLI_FASTBOOT_BODY -->" ;
104
+ return ' <!-- EMBER_CLI_FASTBOOT_BODY -->' ;
106
105
}
107
106
108
107
if ( type === 'head' ) {
109
- return " <!-- EMBER_CLI_FASTBOOT_TITLE --><!-- EMBER_CLI_FASTBOOT_HEAD -->" ;
108
+ return ' <!-- EMBER_CLI_FASTBOOT_TITLE --><!-- EMBER_CLI_FASTBOOT_HEAD -->' ;
110
109
}
111
110
112
111
if ( type === 'app-boot' ) {
113
- const isModuleUnification = this . _isModuleUnification ( ) ;
114
- return fastbootAppBoot ( config . modulePrefix , JSON . stringify ( config . APP || { } ) , isModuleUnification ) ;
112
+ return fastbootAppBoot ( config . modulePrefix , JSON . stringify ( config . APP || { } ) ) ;
115
113
}
116
114
117
115
// if the fastboot addon is installed, we overwrite the config-module so that the config can be read
@@ -121,10 +119,10 @@ module.exports = {
121
119
const appConfigModule = `${ config . modulePrefix } ` ;
122
120
contents . splice ( 0 , contents . length ) ;
123
121
contents . push (
124
- ' if (typeof FastBoot !== \ 'undefined\ ') {' ,
125
- ' return FastBoot.config(\'' + appConfigModule + '\');' ,
122
+ " if (typeof FastBoot !== 'undefined') {" ,
123
+ " return FastBoot.config('" + appConfigModule + "');" ,
126
124
'} else {' ,
127
- originalContents ,
125
+ originalContents ,
128
126
'}'
129
127
) ;
130
128
return ;
@@ -144,7 +142,7 @@ module.exports = {
144
142
} ,
145
143
146
144
_processAddons ( addons , fastbootTrees ) {
147
- addons . forEach ( ( addon ) => {
145
+ addons . forEach ( addon => {
148
146
this . _processAddon ( addon , fastbootTrees ) ;
149
147
} ) ;
150
148
} ,
@@ -177,7 +175,6 @@ module.exports = {
177
175
*/
178
176
_getFastbootTree ( ) {
179
177
const appName = this . _name ;
180
- const isModuleUnification = this . _isModuleUnification ( ) ;
181
178
182
179
let fastbootTrees = [ ] ;
183
180
@@ -192,22 +189,22 @@ module.exports = {
192
189
193
190
// transpile the fastboot JS tree
194
191
let mergedFastBootTree = new MergeTrees ( fastbootTrees , {
195
- overwrite : true
192
+ overwrite : true ,
196
193
} ) ;
197
194
198
195
let funneledFastbootTrees = new Funnel ( mergedFastBootTree , {
199
- destDir : appName
196
+ destDir : appName ,
200
197
} ) ;
201
198
const processExtraTree = p . preprocessJs ( funneledFastbootTrees , '/' , this . _name , {
202
- registry : this . _appRegistry
199
+ registry : this . _appRegistry ,
203
200
} ) ;
204
201
205
202
// FastBoot app factory module
206
203
const writeFile = require ( 'broccoli-file-creator' ) ;
207
- let appFactoryModuleTree = writeFile ( " app-factory.js" , fastbootAppFactoryModule ( appName , this . _isModuleUnification ( ) ) ) ;
204
+ let appFactoryModuleTree = writeFile ( ' app-factory.js' , fastbootAppFactoryModule ( appName ) ) ;
208
205
209
206
let newProcessExtraTree = new MergeTrees ( [ processExtraTree , appFactoryModuleTree ] , {
210
- overwrite : true
207
+ overwrite : true ,
211
208
} ) ;
212
209
213
210
function stripLeadingSlash ( filePath ) {
@@ -216,7 +213,7 @@ module.exports = {
216
213
217
214
let appFilePath = stripLeadingSlash ( this . app . options . outputPaths . app . js ) ;
218
215
let finalFastbootTree = new Concat ( newProcessExtraTree , {
219
- outputFile : appFilePath . replace ( / \. j s $ / , '-fastboot.js' )
216
+ outputFile : appFilePath . replace ( / \. j s $ / , '-fastboot.js' ) ,
220
217
} ) ;
221
218
222
219
return finalFastbootTree ;
@@ -235,7 +232,7 @@ module.exports = {
235
232
let fastbootConfigTree = this . _buildFastbootConfigTree ( newTree ) ;
236
233
237
234
// Merge the package.json with the existing tree
238
- return new MergeTrees ( [ newTree , fastbootConfigTree ] , { overwrite : true } ) ;
235
+ return new MergeTrees ( [ newTree , fastbootConfigTree ] , { overwrite : true } ) ;
239
236
} ,
240
237
241
238
/**
@@ -251,7 +248,7 @@ module.exports = {
251
248
252
249
if ( config instanceof Array ) {
253
250
let copy = [ ] ;
254
- for ( let i = 0 ; i < config . length ; i ++ ) {
251
+ for ( let i = 0 ; i < config . length ; i ++ ) {
255
252
copy [ i ] = this . _cloneConfigObject ( config [ i ] ) ;
256
253
}
257
254
@@ -305,7 +302,7 @@ module.exports = {
305
302
outputPaths : this . app . options . outputPaths ,
306
303
ui : this . ui ,
307
304
fastbootAppConfig : fastbootAppConfig ,
308
- appConfig : appConfig
305
+ appConfig : appConfig ,
309
306
} ) ;
310
307
} ,
311
308
@@ -318,26 +315,25 @@ module.exports = {
318
315
// that version contains API to hook fastboot into ember-cli
319
316
320
317
app . use ( ( req , resp , next ) => {
321
- const fastbootQueryParam = ( req . query . hasOwnProperty ( 'fastboot' ) && req . query . fastboot === 'false' ) ? false : true ;
318
+ const fastbootQueryParam =
319
+ req . query . hasOwnProperty ( 'fastboot' ) && req . query . fastboot === 'false' ? false : true ;
322
320
const enableFastBootServe = ! process . env . FASTBOOT_DISABLED && fastbootQueryParam ;
323
321
324
322
if ( req . serveUrl && enableFastBootServe ) {
325
323
// if it is a base page request, then have fastboot serve the base page
326
324
if ( ! this . fastboot ) {
327
325
const broccoliHeader = req . headers [ 'x-broccoli' ] ;
328
326
const outputPath = broccoliHeader [ 'outputPath' ] ;
329
- const fastbootOptions = Object . assign (
330
- { } ,
331
- this . fastbootOptions ,
332
- { distPath : outputPath }
333
- ) ;
327
+ const fastbootOptions = Object . assign ( { } , this . fastbootOptions , {
328
+ distPath : outputPath ,
329
+ } ) ;
334
330
335
331
this . ui . writeLine ( chalk . green ( 'App is being served by FastBoot' ) ) ;
336
332
this . fastboot = new FastBoot ( fastbootOptions ) ;
337
333
}
338
334
339
335
let fastbootMiddleware = FastBootExpressMiddleware ( {
340
- fastboot : this . fastboot
336
+ fastboot : this . fastboot ,
341
337
} ) ;
342
338
343
339
fastbootMiddleware ( req , resp , next ) ;
@@ -356,7 +352,7 @@ module.exports = {
356
352
// in sandbox.
357
353
this . ui . writeLine ( chalk . blue ( 'Reloading FastBoot...' ) ) ;
358
354
this . fastboot . reload ( {
359
- distPath : result . directory
355
+ distPath : result . directory ,
360
356
} ) ;
361
357
}
362
358
} ,
@@ -378,10 +374,6 @@ module.exports = {
378
374
return checker . for ( 'ember' , 'bower' ) ;
379
375
} ,
380
376
381
- _isModuleUnification ( ) {
382
- return ( typeof this . project . isModuleUnification === 'function' ) && this . project . isModuleUnification ( ) ;
383
- } ,
384
-
385
377
/**
386
378
* Reads FastBoot configuration from application's `config/fastboot.js` file if present,
387
379
* otherwise returns empty object.
@@ -398,5 +390,5 @@ module.exports = {
398
390
return require ( configPath ) ( environment ) ;
399
391
}
400
392
return { } ;
401
- }
393
+ } ,
402
394
} ;
0 commit comments