Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Embroider Support: Moved app factory module out of fastboot-app-module
* Cleaned up fastboot-app-module. * Added Fastboot-app-factory-plugin to insert app factory module as part of <app>-fastboot.js * This clean up ensures fastboot specific App-factory code is not shipped to browsers.
- Loading branch information
1 parent
538adf8
commit c2f3c9c
Showing
4 changed files
with
64 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* eslint-env node */ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const fs = require('fs'); | ||
const Plugin = require('broccoli-plugin'); | ||
const fastbootAppFactoryModule = require('../utilities/fastboot-app-factory-module'); | ||
|
||
module.exports = class FastBootAppFactory extends Plugin { | ||
constructor(inputNode, options) { | ||
super([inputNode], { | ||
annotation: 'Generate: FastBoot app-factory module', | ||
persistentOutput: true | ||
}); | ||
this.appName = options.appName; | ||
this.isModuleUnification = options.isModuleUnification; | ||
} | ||
|
||
build() { | ||
let outputPath = path.join(this.outputPath, 'app-factory.js'); | ||
let content = fastbootAppFactoryModule(this.appName, this.isModuleUnification); | ||
fs.writeFileSync(outputPath, content); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict' | ||
|
||
// Added as app boot code to app.js that allows booting of the application | ||
// in browser. This code is injected during app-boot type of contentFor hook for ember-cli. | ||
module.exports = function fastbootAppBoot(prefix, configAppAsString, isModuleUnification) { | ||
var appSuffix = isModuleUnification ? "src/main" : "app"; | ||
return [ | ||
"", | ||
"if (typeof FastBoot === 'undefined') {", | ||
" if (!runningTests) {", | ||
" require('{{MODULE_PREFIX}}/" + appSuffix + "')['default'].create({{CONFIG_APP}});", | ||
" }", | ||
"}", | ||
"" | ||
].join("\n").replace(/\{\{MODULE_PREFIX\}\}/g, prefix).replace(/\{\{CONFIG_APP\}\}/g, configAppAsString); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters