Ember + RequireJS: Ember does not recognize handlebars


#1

So the issue is that Ember tries to initialize before RequireJS even get’s to the initialization stage.

I get this error:

Ember Handlebars requires Handlebars 1.0.0-rc.3 or greater. Include a SCRIPT tag in the HTML HEAD linking to the Handlebars file before you link to Ember.

And my version of Handlebars is rc.4.

This is my config:

ember: {
      deps: ["jquery", "handlebars"],
      exports: "Ember",
}

Handlebars is initialized on the window object.


#2

Why initializing Handlebars on the window object when using requireJS?

Had this problem before, this is my current setup (boot.js) which works (cut out some other modules like bootstrap for demonstration…):

require.config({
        Ember: "Js/Lib/ember-1.0.0-rc.3",
        Handlebars: "Js/Lib/handlebars-1.0.0-rc.3",
        jQuery: "Js/Lib/jquery-1.9.1"
    },
shim: {
    jQuery: {
        exports: "$"
    },
    Ember: {
        deps: ["Handlebars"],
        exports: "Ember"
    }
}
});

require([
    "Ember",
    "Handlebars",
    "jQuery",
], function(Ember, Handlebars, $) {

Hope this helps!


#3

Looks like it was an Ember bug. See here: https://github.com/emberjs/ember.js/issues/2288

Fixed now.