Skip to content

Commit 88fab39

Browse files
author
Robert Jackson
authored
Added support for embroider build and current build (#702)
Added support for embroider build and current build
2 parents dff28c1 + c468059 commit 88fab39

File tree

3 files changed

+16
-252
lines changed

3 files changed

+16
-252
lines changed

index.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -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(/\.js$/, '-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
};

lib/utilities/fastboot-app-module.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = function fastbootAppModule(prefix, configAppAsString, isModuleU
1212
return [
1313
"",
1414
"if (typeof FastBoot === 'undefined') {",
15-
" if (!runningTests) {",
15+
" if (typeof runningTests === 'undefined') {",
1616
" require('{{MODULE_PREFIX}}/" + appSuffix + "')['default'].create({{CONFIG_APP}});",
1717
" }",
1818
"}",

0 commit comments

Comments
 (0)