From 13d68c8d73380f4ba9378dd9b80eed695f23497e Mon Sep 17 00:00:00 2001 From: Tom Wayson Date: Fri, 17 Nov 2017 13:53:30 -0800 Subject: [PATCH 1/2] allow reading sandboxGlobals from app's config/environment --- CHANGELOG.md | 7 ++++++- index.js | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d78fdfd38..af91e3edc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # ember-cli-fastboot changelog +## Unreleased + +### Added +* allow reading sandboxGlobals from app's config/environment + ## 1.1.0 -* Bumping `fastboot-express-middleware` to 1.1.0 \ No newline at end of file +* Bumping `fastboot-express-middleware` to 1.1.0 diff --git a/index.js b/index.js index 261b18a59..4ade7cb79 100644 --- a/index.js +++ b/index.js @@ -292,6 +292,8 @@ module.exports = { serverMiddleware(options) { let emberCliVersion = this._getEmberCliVersion(); let app = options.app; + let appConfig = this._getHostAppConfig(); + let fastbootConfig = appConfig.fastboot; if (emberCliVersion.gte('2.12.0-beta.1')) { // only run the middleware when ember-cli version for app is above 2.12.0-beta.1 since @@ -310,7 +312,8 @@ module.exports = { // and custom sandbox class this.ui.writeLine(chalk.green('App is being served by FastBoot')); this.fastboot = new FastBoot({ - distPath: outputPath + distPath: outputPath, + sandboxGlobals: fastbootConfig && fastbootConfig.sandboxGlobals }); } From 87904ae7db3cebb42fbc64fbbdbb7fbd9f433476 Mon Sep 17 00:00:00 2001 From: Tom Wayson Date: Fri, 17 Nov 2017 14:35:18 -0800 Subject: [PATCH 2/2] allow passing of sandbox to FastBoot constructor from config environment --- index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 4ade7cb79..58550b12f 100644 --- a/index.js +++ b/index.js @@ -293,7 +293,6 @@ module.exports = { let emberCliVersion = this._getEmberCliVersion(); let app = options.app; let appConfig = this._getHostAppConfig(); - let fastbootConfig = appConfig.fastboot; if (emberCliVersion.gte('2.12.0-beta.1')) { // only run the middleware when ember-cli version for app is above 2.12.0-beta.1 since @@ -308,12 +307,12 @@ module.exports = { if (req.serveUrl && enableFastBootServe) { // if it is a base page request, then have fastboot serve the base page if (!this.fastboot) { - // TODO(future): make this configurable for allowing apps to pass sandboxGlobals - // and custom sandbox class + let fastbootConfig = appConfig.fastboot || {}; this.ui.writeLine(chalk.green('App is being served by FastBoot')); this.fastboot = new FastBoot({ distPath: outputPath, - sandboxGlobals: fastbootConfig && fastbootConfig.sandboxGlobals + sandbox: fastbootConfig.sandbox, + sandboxGlobals: fastbootConfig.sandboxGlobals }); }