-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 handlebars-runtime in production. #675
Conversation
👍 |
Actually. Now that I think about it, we are precompiling the templates all the time (since #574) so I think we should just use runtime all the time.... |
@rjackson The problem is when you need to use There were a few solutions suggested in that thread but no resolution. I'd be happy to look at implementation if there is consensus on the right path there. Also, these tests failed due to timeouts. |
I'm working on implementing inline template compilation now (for Ember), will extract into a plugin that can be reused here once that is done. 👍 for now, and thank you for the reminder from #574. |
@rjackson <3 |
👍 |
@rjackson Awesome, that will be great |
IMO it would be great to have this changed now and then switch to using the runtime in dev and test as well once the inline precompiler is ready. I guess it depends on how far along that is, though. |
Agree with @xtian. Let's ship a better prod and I'll PR an update to dev once my inline template precompiler is done (hopefully later in the weekend). Robert Jackson -- twitter: rwjblue
|
Use handlebars-runtime in production.
I use I'm using ember-i18n and ember-easyForm. Both of those require Handlebars.compile to be available. Can I override this change somewhere to include the full handlebars in my apps? /cc @rjackson |
@mattbeedle you should be able to just app.import the library if you need it |
Cool, thx. I was adding the import at the bottom of the Brocfile, but moving it to the top fixed the issue for me. |
@mattbeedle Can you please show us where and how you placed the new import? The following workaround does work, but is ugly as "you know where." |
After a bit debugging, I think to have pinpointed the issue (in production). But during evaluation in the client, when Ember.Handlebars is being setup, the Handlebars is still only the runtime library. And again later in the evaluation window.Handlebars is overwritten with the complete library, but Ember.HandleBars is not (naturally). So, is it possible to override/remove an import except for the following hack? function replaceHandlebarsRuntime(app) {
var index = app.legacyFilesToAppend.indexOf('vendor/handlebars/handlebars.runtime.js');
if(index) {
app.legacyFilesToAppend[index] = 'vendor/handlebars/handlebars.js';
}
}
replaceHandlebarsRuntime(app); |
I've toyed around with precompiling ember-i18n language files as well. Mostly because it removes the need for the full handlebars in production: https://github.com/tdegrunt/broccoli-ember-i18n-precompile @DiMarcello - Your trick was the only thing which actually worked. |
HI I encountered the same issue, unfortunately @tdegrunt solution was too opinionated for my need, and using the full Handlebar library in prod was not an option. So I ended up writing something very similar than the Grunt task I used before switching to ember-cli https://github.com/alexBaizeau/broccoli-i18n-precompile. I hope it helps. I am using it at the moment. |
👍 Would love to see .compile since many of our templates are one liners that really don't need an extra file. |
+1 on |
@alvincrespo do you realize how many extra bytes the compiler is compared to pre-compiling the templates? |
Ember is based on convention. Being able to glance at an Ember app, and know exactly where things live is invaluable.
Opting into using full handlebars is possible (and pretty simple), but definitely discouraged. |
On precompilation and convention: I've tried my hands on a sort of convention here. The plugin only takes care of the pre-compilation, it doesn't tell you:
@rwjblue You wrote you had a inline template compiler? |
I still get an error if I try to remove following workaround:
Any update on this? CLI 0.1.9. Ember 1.9.1. |
@kuzirashi - That is not how to update a vendored asset. See http://www.ember-cli.com/#customizing-a-built-in-asset for details. |
@rwjblue Thanks, I've changed this code. To clarify - has this something to do with my plugins which require full version of Handlebars? |
No description provided.