afeld / backbone-nested

A plugin to make Backbone.js keep track of nested attributes - looking for maintainers! https://github.com/afeld/backbone-nested/issues/157
https://afeld.github.com/backbone-nested/
MIT License
444 stars 83 forks source link

Does not work together with the new Backbone 1.1.1 #114

Open xoss opened 10 years ago

xoss commented 10 years ago

Since Backbone 1.1.1, Backbone is AMD compatible. This, unfortunately, led to a not working backbone nested model, in case js has been concatinated and minified for production. Chrome yields: 'Uncaught Error: Backbone is not defined'

gkatsev commented 10 years ago

Yeah, I wish that backbone didn't release it as 1.1.1. It should not be a patch version bump. Minor at least. We'll take a look.

xoss commented 10 years ago

Couldn't you just limit the use of Backbone to <= 1.1.0 in bower.json as a HOTFIX?

xoss commented 10 years ago

Just for the record: I totally agree with you, that the AMD compatibility is a huge change and should not be reflected by a minor version bump.

gkatsev commented 10 years ago

Unfortunately, that project is not interested in semver. Interestingly enough, the tests pass just fine. Though, that's probably because the tests don't use AMD.

gkatsev commented 10 years ago

It seems to work for me. See https://gist.github.com/gkatsev/9096687

xoss commented 10 years ago

So far, so good, ya. The problems occurs when you start to concat and minify the js to one single main.js file with requirejs. Even if you define a shim for backbone-nested-model, somehow Backbone does not get defined in the global namespace and is therefore not defined for Backbone.NestedModel. I didn't get into much research. As a hotfix I downgraded to Backbone 1.1.0, but maybe today I get the chance to dig a little deeper.

gkatsev commented 10 years ago

I wonder if the AMD stuff get mangled and thus become useless. Could you post your minified versions to something like jsbin or jsfiddle?

xoss commented 10 years ago

Checkout https://github.com/xoss/backbone-nested-model-AMD Run

  1. bower install
  2. grunt serve => Works just fine
  3. grunt serve:dist => Not working

Replace "backbone":"1.1.1." by "backbone":"1.1.0" in bower.json. Run the same procedure. 3. => works as well.

darky commented 10 years ago

You can use new feature in requirejs - wrapShim to resolve this problem for build Or simplify use shim in requirejs for non-build version

darky commented 10 years ago

Although would be better to support it in backbone-nested