Closed samccone closed 10 years ago
I like this in theory. Backbone won't ever specify jQuery as a dependency, but it is absolutely a dependency of Marionette.
With that said, there's been a ton of heated discussion over this in the past. Before we act, we should understand why people were so fervently against us specifying jQuery as a dependency of Marionette, and make sure we're not breaking anything by doing it.
The most important things to consider are CommonJS/AMD builds.
If anyone is replacing jquery with something like zepto, they can just alias it. It's the same thing as replacing underscore with lodash.
So I dug through old issues (this is the most important one) and determined that the main reason we removed jQuery from the npm dependencies is because nowhere do we have require('jquery');
in the source.
If we choose to add it back as a dependency, then it only makes sense that we also add in that line of code.
I think this is a really good idea. Firstly, Backbone doesn't depend on jQuery at all. So much so that they recently abstracted all of the jQuery-dependent code in helpers to ease your transition away from using it. And they've infamously neglected to include it as a dependency in the package.json, much to the annoyance of CommonJS users everywhere.
However, Marionette does depend on jQuery. Very much so, in fact, and it is highly unlikely that this will change anytime soon.
Because of this, I think we should make the step to add:
Marionette.$ = require('jquery');
within Marionette, and then specify it as a dependency.
@wbinnssmith, I'd like to get your thoughts on this change.
Two questions:
@jasonLaster as it is right now, I think it's very difficult for react people to integrate. In 2.3, along with this jquery requirement, I think we can separate out all of our DOM interaction to 9 methods (plus Deferred), detailed at the end of https://github.com/marionettejs/backbone.marionette/issues/980#issuecomment-51868548 (Marionette.DOM
?) that people can override to use different engines. With that, we'd be like Backbone, where the default implementation requires jQuery, but, unlike Backbone, we could make the project work out of the box and not confuse people
If we agree that this is a major change – it sounds like one to me – then we can close this issue and add it to #1796. The discussion can continue in this thread even after its closed.
What do y'all think?
Mmk, well, I think it's breaking. And I don't want to piss anyone off by releasing this in 2.3, so I vote that we wait until v3 at the earliest. I've moved this to #1796, and I'm closing the issue in the meantime.
The conversation can continue here.
We can also drop
Backbone.$.Deferred
this change means that once again jquery is a dep of marionette, except for the fact that every where that we are going to use $ we will use Marionette.$