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

Does not work together with the new Backbone 1.1.1

Open xoss opened this issue 11 years ago • 10 comments

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'

xoss avatar Feb 19 '14 16:02 xoss

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.

gkatsev avatar Feb 19 '14 16:02 gkatsev

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

xoss avatar Feb 19 '14 16:02 xoss

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.

xoss avatar Feb 19 '14 16:02 xoss

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 avatar Feb 19 '14 16:02 gkatsev

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

gkatsev avatar Feb 19 '14 17:02 gkatsev

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.

xoss avatar Feb 20 '14 09:02 xoss

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

gkatsev avatar Feb 20 '14 14:02 gkatsev

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.

xoss avatar Feb 20 '14 14:02 xoss

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 avatar Apr 23 '14 09:04 darky

Although would be better to support it in backbone-nested

darky avatar Apr 23 '14 09:04 darky