Reputation: 905
I'm trying to install backbone.marionette
from NPM with the JSPM for client dependency resolving. A simple operation with the following command in commandprompt:
jspm install marionette=npm:backbone.marionette
All dependencies - except jQuery is automatically downloaded and installed. But I get a runtime error:
Can't call Deferred of undefined.
I was looking into the code, and i found that the problem was in the backbone source code line 9, 10 and 11
} else if (typeof exports !== 'undefined') {
var _ = require("underscore");
factory(root, exports, _);
When running under traceurJS
, the factory-method
is called from here, and it is clear, that the last argument $
, is left out. When I look in the backbone sourcecode on github, the same lines look like this:
} else if (typeof exports !== 'undefined') {
var _ = require('underscore'), $;
try { $ = require('jquery'); } catch(e) {}
factory(root, exports, _, $);
Here the jQuery dependency is added with option (try/catch). I have to add here, that the NPM version is marked with the same version as GitHub - 1.1.2.
Why the difference? It seems as if this has been a problem for some time as of, there is published a few workarounds like adding this in code:
$ = require('jquery');
Backbone = require('backbone');
Backbone.$ = $
I don't like this, although it works, because its a workaround, and it seems as if it's not existing.
Upvotes: 39
Views: 748