backbone-super icon indicating copy to clipboard operation
backbone-super copied to clipboard

Let backbone-super to provide modified Backbone

Open jifeon opened this issue 10 years ago • 9 comments

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

jifeon avatar Jan 21 '15 21:01 jifeon

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/

michaelBenin avatar Jan 21 '15 21:01 michaelBenin

@lukasolson thoughts?

michaelBenin avatar Jan 21 '15 21:01 michaelBenin

@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...

jifeon avatar Jan 21 '15 22:01 jifeon

Another thing: providing Backbone does not broke anything and the people who wants to include it just once will be able to do it

jifeon avatar Jan 21 '15 22:01 jifeon

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);

rachel-carvalho avatar Jan 21 '15 22:01 rachel-carvalho

+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 avatar Jan 22 '15 09:01 apsavin

@apsavin how are you using backbone-super?

michaelBenin avatar Jan 22 '15 16:01 michaelBenin

@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 avatar Jan 22 '15 16:01 michaelBenin

@michaelBenin now with requirejs, 2 years ago I just placed it after Backbone in configuration file of assets compile tool.

apsavin avatar Jan 22 '15 17:01 apsavin