Question

How to implement lodash with new version of BB 1.1.1 or 1.1.2, which has AMD wrapper? And how to exports Backbone into global scope, with requirejs?

1.1.0 - without amd wrapper, works good. Thnk's.

Was it helpful?

Solution 2

Having this in your config should work:

paths: {
    underscore: <path to lodash>,
    backbone: <path to backbone>,
    jquery: <path to jquery>
}

You must use a version of lodash that is compatible with Backbone. This is the one created with lodash backbone when you use the CLI. You do not need shims of any of these. Defining underscore so that it points to lodash will make Backbone use lodash.

OTHER TIPS

If you have libraries that depend on lodash explicitly, such as lodash-template-loader, you will need to use this:

paths: {
    lodash: <path to lodash>,
    ....
},
map: {
  "*": {
    "underscore": "lodash"
  }
}

At that point, any dependency on underscore will load lodash instead, and the template loader will work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top