backbone-super
backbone-super copied to clipboard
Let backbone-super to provide modified Backbone
Inspired by #39
maybe backbone-super should just provide modified Backbone? Than you will be able to write like this:
var Backbone = require('backbone-super');
It's not far from reality because backbone-super does not provide anything by itself, it just replace the extend method of Backbone so you can use either backbone or replaced backbone. And it would be very strange and ambiguous if require('backbone') will provide replaced version. And writing require('backbone-super') will clearly indicate version of backbone you are using
Personally I would prefer requiring it once in my entry point with browserify because I would like to explicitly modify Backbone rather than replace it.
See other popular backbone plugins:
https://github.com/thedersen/backbone.validation#using-server-validation http://backbonerelational.org/
@lukasolson thoughts?
@jifeon One problem I see with this is that it would be a bit weird to combine with other Backbone extension libraries (I have a project that's not yet using Browserify, where I use backbone-hotkeys, which replaces Backbone.View and backbone-paginator, which adds a new type of Collection to Backbone).
@rachel-carvalho @michaelBenin I'am using RequireJS in projects I'm involved in, and if backbone-super provided Backbone I would use map config option
map: {
'*': {
'backbone': 'path/to/backbone-super'
},
'backbone-super': {
'backbone': 'path/to/real/backbone'
}
}
But in any case the fact that backbone-super has a side effect hurts me...
Another thing: providing Backbone does not broke anything and the people who wants to include it just once will be able to do it
But in any case the fact that backbone-super has a side effect hurts me...
That's what bothered me too... That's why I preferred the idea of exporting a setup function to which we would explicitly pass Backbone. Like
var Backbone = require('backbone');
require('backbone-super')(Backbone);
+1 for exporting Backbone. -1 for exporting a setup function, because Backbone is a dependency of backbone-super and I don't want to create yet another module which depends both on backbone-super and backbone just to call a setup function
@apsavin how are you using backbone-super?
@jifeon can you elaborate on "But in any case the fact that backbone-super has a side effect hurts me..."
What's the side effect specifically? Is it something specific to requirejs?
@michaelBenin now with requirejs, 2 years ago I just placed it after Backbone in configuration file of assets compile tool.