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.

有帮助吗?

解决方案 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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top