Skip to content
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

Optimizer generates javascript with errors #3

Open
huafu opened this issue May 21, 2013 · 1 comment
Open

Optimizer generates javascript with errors #3

huafu opened this issue May 21, 2013 · 1 comment

Comments

@huafu
Copy link

huafu commented May 21, 2013

I have an application using your plugin, and all works fine until I uses the --optimize options while running brunch build.
Other scripts compile correctly while optimizing, I got the ember debug lines in the console, but it's telling me there is an unexpected = in the template.js file:

Uncaught SyntaxError: Unexpected token = templates.js:1
DEBUG: ------------------------------- vendor.js:5
DEBUG: Ember.VERSION : 1.0.0-rc.3 vendor.js:5
DEBUG: Handlebars.VERSION : 1.0.0-rc.3 vendor.js:5
DEBUG: jQuery.VERSION : 1.9.1 vendor.js:5
DEBUG: ------------------------------- vendor.js:5
Uncaught Error: Cannot find module "templates/application"

Here is my config:

    templates:
      precompile: true
      root: 'templates'
      defaultExtension: 'hbs'
      joinTo: 'javascripts/templates.js' : /^app/

And I can see in this javascript, after reformatting it for better reading, where is the unexpected = (in fact there is not only one, but many):

window.require.register("templates/application", function (exports, require, module) {
    Ember.TEMPLATES[= application] = Ember.Handlebars.template(function anonymous(Handlebars, depth0, helpers, partials, data) {
        this.compilerInfo = [2, '>=1.0-rc.3'];
        helpers = helpers || Ember.Handlebars.helpers;
        data = data || {};
        var buffer = '', stack1, hashTypes, helperMissing = helpers.helperMissing, escapeExpression = this.escapeExpression, self = this;

        function program1(depth0, data) {
            var stack1, hashTypes, options;
            hashTypes = {};
            options = {hash:{}, contexts:[depth0], types:[= STRING], hashTypes:hashTypes, data:data};
            data.buffer.push(escapeExpression(((stack1 = helpers.render), stack1 ? stack1.call(depth0, "left-panel", options) : helperMissing.call(depth0, "render", "left-panel", options))))
        }

So as you can see there are problematic = first in Ember.TEMPLATES[= application] (where also application should be surrounded by quotes but isn't), and then in types:[= STRING] (which I can find in any "program" function created).

Feel free to ask for more information(s) to debug if needed.

@huafu
Copy link
Author

huafu commented May 21, 2013

Just tested with precompile: no and got the same error (except the type:[= STRING]since it's not precompiled of course). Sounds like only the first template got compiled into

window.require.register("templates/application", function(exports, require, module)
{
  Ember.TEMPLATES[=application] = Ember.Handlebars.compile(...

where it should be, as the following ones:

window.require.register("templates/application", function(exports, require, module
{
  Ember.TEMPLATES['application'] = Ember.Handlebars.compile(...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant