【发布时间】:2014-03-13 08:52:37
【问题描述】:
是否可以在 RequireJS 中以不同的名称使用相同的模块? (最感兴趣的是优化版)
示例
我依赖一个依赖于lodash 的 AMD 兼容库。我的代码中已经有underscore,我希望该库使用它而不是lodash。
我当然不想修改库的源代码。于是我修改了require.js的配置:
paths: {
'underscore': 'vendor/underscore', // that's for my code
...
'lodash': 'vendor/underscore', // that's for the new library
}
现在在尝试构建时,r.js 抛出了不幸的问题:
The following modules share the same URL.
This could be a misconfiguration if that URL only has one anonymous module in it:
/.../underscore.js: lodash, underscore
有没有办法以 2 个或多个不同的名称注册同一个模块?
【问题讨论】: