Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ function getVersionChecker(context) {
return checker;
}


function stripLeadingSlash(filePath) {
return filePath.replace(/^\//, '');
}

/*
* Main entrypoint for the Ember CLI addon.
Expand Down Expand Up @@ -106,11 +108,6 @@ module.exports = {
return "<!-- EMBER_CLI_FASTBOOT_TITLE --><!-- EMBER_CLI_FASTBOOT_HEAD -->";
}

if (type === 'app-boot') {
const isModuleUnification = (typeof this.project.isModuleUnification === 'function') && this.project.isModuleUnification();
return fastbootAppModule(config.modulePrefix, JSON.stringify(config.APP || {}), isModuleUnification);
}

// if the fastboot addon is installed, we overwrite the config-module so that the config can be read
// from meta tag/directly for browser build and from Fastboot config for fastboot target.
if (type === 'config-module') {
Expand Down Expand Up @@ -196,10 +193,6 @@ module.exports = {
registry: this._appRegistry
});

function stripLeadingSlash(filePath) {
return filePath.replace(/^\//, '');
}

let appFilePath = stripLeadingSlash(this.app.options.outputPaths.app.js);
let finalFastbootTree = new Concat(processExtraTree, {
outputFile: appFilePath.replace(/\.js$/, '-fastboot.js')
Expand Down Expand Up @@ -334,6 +327,8 @@ module.exports = {
},

postBuild(result) {
let appFilePath = stripLeadingSlash(this.app.options.outputPaths.app.js);
this._appendAppBoot(result.directory, appFilePath);
if (this.fastboot) {
// should we reload fastboot if there are only css changes? Seems it maynot be needed.
// TODO(future): we can do a smarter reload here by running fs-tree-diff on files loaded
Expand Down Expand Up @@ -361,4 +356,14 @@ module.exports = {

return checker.for('ember', 'bower');
},

_appendAppBoot(appDir, appFilePath) {
let env = this.app.env;
let config = this.project.config(env);
const isModuleUnification = (typeof this.project.isModuleUnification === 'function') && this.project.isModuleUnification();
const appBoot = fastbootAppModule(config.modulePrefix, JSON.stringify(config.APP || {}), isModuleUnification);

appFilePath = path.resolve(appDir, appFilePath);
fs.appendFileSync(appFilePath, appBoot);
}
};
2 changes: 1 addition & 1 deletion lib/utilities/fastboot-app-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function fastbootAppModule(prefix, configAppAsString, isModuleU
return [
"",
"if (typeof FastBoot === 'undefined') {",
" if (!runningTests) {",
" if (typeof runningTests === 'undefined') {",
" require('{{MODULE_PREFIX}}/" + appSuffix + "')['default'].create({{CONFIG_APP}});",
" }",
"}",
Expand Down
Loading