-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use latest visit API #71
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/*globals Ember, URL*/ | ||
export default { | ||
name: "dom-helper-patches", | ||
|
||
initialize: function(App) { | ||
// TODO: remove me | ||
Ember.HTMLBars.DOMHelper.prototype.protocolForURL = function(url) { | ||
var protocol = URL.parse(url).protocol; | ||
return (protocol == null) ? ':' : protocol; | ||
}; | ||
|
||
// TODO: remove me https://github.com/tildeio/htmlbars/pull/425 | ||
Ember.HTMLBars.DOMHelper.prototype.parseHTML = function(html) { | ||
return this.document.createRawHTMLSection(html); | ||
}; | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,32 @@ | ||
/* jshint node: true */ | ||
'use strict'; | ||
|
||
var Funnel = require('broccoli-funnel'); | ||
|
||
// Expose the an factory for the creating the `Application` object | ||
// with the proper config at a known path, so that the server does | ||
// not have to disover the app's module prefix ("my-app"). | ||
// | ||
// The module defined here is prefixed with a `~` to make it less | ||
// likely to collide with user code, since it is not possible to | ||
// define a module with a name like this in the file system. | ||
function fastbootAppModule(prefix) { | ||
return [ | ||
"", | ||
"define('~fastboot/app-factory', ['{{MODULE_PREFIX}}/app', '{{MODULE_PREFIX}}/config/environment'], function(App, config) {", | ||
" App = App['default'];", | ||
" config = config['default'];", | ||
"", | ||
" return {", | ||
" 'default': function() {", | ||
" return App.create(config.APP);", | ||
" }", | ||
" };", | ||
"});", | ||
"" | ||
].join("\n").replace(/\{\{MODULE_PREFIX\}\}/g, prefix); | ||
} | ||
|
||
module.exports = { | ||
name: 'ember-cli-fastboot', | ||
|
||
|
@@ -11,6 +37,30 @@ module.exports = { | |
}; | ||
}, | ||
|
||
included: function(app) { | ||
if (process.env.EMBER_CLI_FASTBOOT) { | ||
process.env.EMBER_CLI_FASTBOOT_APP_NAME = app.name; | ||
app.options.autoRun = false; | ||
} | ||
|
||
// We serve the index.html from fastboot-dist, so this has to apply to both builds | ||
app.options.storeConfigInMeta = false; | ||
}, | ||
|
||
config: function(/* environment, appConfig */) { | ||
// do nothing unless running `ember fastboot` command | ||
if (!process.env.EMBER_CLI_FASTBOOT) { return {}; } | ||
|
||
return { | ||
EmberENV: { | ||
FEATURES: { 'ember-application-visit': true } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I initially avoided doing this because feature flags were not being merged. Which meant that if you had a feature flag set in the consuming apps This may be fixed now with current ember-cli, but I'd love it if you could confirm. The easiest way to test would be to make a throw away app, set some features in it, run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, from what I read, the whole thing is deep merged with lodash. I will confirm! |
||
}, | ||
APP: { | ||
autoboot: false | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. both of these works |
||
}; | ||
}, | ||
|
||
contentFor: function(type, config) { | ||
// do nothing unless running `ember fastboot` command | ||
if (!process.env.EMBER_CLI_FASTBOOT) { return; } | ||
|
@@ -23,17 +73,28 @@ module.exports = { | |
return "<!-- EMBER_CLI_FASTBOOT_TITLE -->"; | ||
} | ||
|
||
if (type === 'vendor-prefix') { | ||
return '// Added from ember-cli-fastboot \n' + | ||
'EmberENV.FEATURES = EmberENV.FEATURES || {};\n' + | ||
'EmberENV.FEATURES["ember-application-visit"] = true;\n'; | ||
if (type === 'app-boot') { | ||
return fastbootAppModule(config.modulePrefix); | ||
} | ||
}, | ||
|
||
included: function() { | ||
treeForApp: function(tree) { | ||
if (process.env.EMBER_CLI_FASTBOOT) { | ||
this.app.options.storeConfigInMeta = false; | ||
process.env.EMBER_CLI_FASTBOOT_APP_NAME = this.app.name; | ||
return new Funnel(tree, { | ||
annotation: 'Funnel: Remove browser-only initializers', | ||
exclude: [ | ||
'initializers/browser/*', | ||
'instance-initializers/browser/*' | ||
] | ||
}); | ||
} else { | ||
return new Funnel(tree, { | ||
annotation: 'Funnel: Remove server-only initializers', | ||
exclude: [ | ||
'initializers/server/*', | ||
'instance-initializers/server/*' | ||
] | ||
}); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rwjblue @stefanpenner how does that look? with this I could complete remove the By the way, if this works out for us, we might want to move it into the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 - This looks great to me! I don't see a way to completely generalize this, but we can chat about that further in a separate issue... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it just work if we move this code to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @chancancode - Ya, we could come up with something that could work (I misread initially as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll leave that for another time, probably until someone asks for it :P (if you are reading this, you might just want to PR it 😉) |
||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
var RSVP = require('rsvp'); | ||
var path = require('path'); | ||
var runCommand = require('ember-cli/tests/helpers/run-command'); | ||
var emberCommand = path.join('.', 'node_modules', 'ember-cli', 'bin', 'ember'); | ||
|
||
module.exports = function runServer(callback, options) { | ||
options = options || { }; | ||
|
@@ -12,7 +13,7 @@ module.exports = function runServer(callback, options) { | |
} | ||
|
||
var args = [ | ||
path.join('.', 'node_modules', 'ember-cli', 'bin', 'ember'), | ||
emberCommand, | ||
'fastboot', | ||
'--port', options.port | ||
]; | ||
|
@@ -36,7 +37,10 @@ module.exports = function runServer(callback, options) { | |
args.push(commandOptions); | ||
|
||
return new RSVP.Promise(function(resolve, reject) { | ||
runCommand.apply(null, args) | ||
runCommand.call(null, emberCommand, 'build') // build 'dist' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this reflects a real-world problem: you need to now run Unfortunately, it is not easy to refactor the set up to produce both builds in a single command (it relies on a global ENV variable, among other things). So I just added a new |
||
.then(function() { | ||
return runCommand.apply(null, args); | ||
}) | ||
.then(function() { | ||
throw new Error('The server should not have exited successfully.'); | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwjblue turns out removing this is not as easy as I thought – contrary to the documentation (see "Uses"), these options can't actually be set through the
config
hook :( (It makes sense, mutating these build options at a random time during build probably has the same problem as settingautoboot
during boot 😉)@stefanpenner can you c/d? If that's true I can (eventually) send a doc PR