PaulUithol / Backbone-relational

Get and set relations (one-to-one, one-to-many, many-to-one) for Backbone models
http://backbonerelational.org
MIT License
2.34k stars 330 forks source link

Export extended Backbone object #559

Closed chaudeco closed 8 years ago

chaudeco commented 8 years ago

In order to use ES6 module syntax, we need to return the extended Backbone object.

Then, we'll be able to import this extended Backbone object in other projects: import Relational from 'Backbone-relational'

bpatram commented 8 years ago

Could you merge the latest master branch commit into your PR?

bpatram commented 8 years ago

I'd really like to see Backbone Relational export only it's own objects instead of Backbone + RelationalModel, etc, etc. This of course would be a breaking change, but I feel makes sense to do. Thoughts anyone?

philfreo commented 8 years ago

BBR would still be modifying the main Backbone object I assume?

bpatram commented 8 years ago

@philfreo Yes, but I'd like to keep all the BBR objects within their own namespace.

So the following changes would happen:

(I think that covers everything)

So then the library would export only Backbone.Relational

philfreo commented 8 years ago

Aha, yeah that makes sense as long as the upgrade path is well documented like this

bpatram commented 8 years ago

@chaudeco Do you think you could make those changes, or should I take over from here? I'm hoping to get these updates pushed out sooner than later.

jeremymlane commented 8 years ago

Any updates on this PR?

PaulUithol commented 8 years ago

As for upgrade path, would it make sense to mark the old syntax deprecated, but ship with a shim for 1 or 2 versions?

jeremymlane commented 8 years ago

@PaulUithol As much as I wish the answer to that was no, that's probably the right thing to do.

bpatram commented 8 years ago

Yes, a shim would be in order to make migration easier. I'm unsure of the best way to implementation for it right now.

I'm hoping to break up the current code base into separate modules (this issue was the first step) as well as introduce a build system (most likely gulp) to make the amd+cjs+umd bundle (most likely rollup). With that in place, having a compat bundle which would export in the same way as before in the Backbone namespace would be trivial.