我为我的项目使用 RequireJS 2.2.0,配置如下:
require.config({
baseUrl: "Scripts/js/kendo",
paths: {
"kendo.datepicker.min": "kendo.datepicker.min",
"jquery-ui": "../../lib/jquery-ui.min",
"modules": "../../modules",
"colorpicker": "../../lib/colorpicker",
"eye": "../../lib/eye",
"layout": "../../lib/layout",
"utils": "../../lib/utils",
"oraclemaps": "../../lib/oraclemapsv2"
},
shim: {
"kendo.datepicker.min": ["oraclemaps"],
"jquery-ui": ["oraclemaps"],
"colorpicker": ["jquery-ui"],
"eye": ["colorpicker"],
"layout": ["eye"],
"utils": ["layout"]
}
});
oraclemaps
是一个包含 jQuery 的第三方库。我使用他们的版本,所以我在 shim 中定义了 Kendo 和 jQuery-UI 依赖项。oraclemaps 有一个jquery-ui, colorpicker, eye, layout, and utils
按上述顺序需要的组件。我也在 shim 中定义了这一点。应用程序运行良好。
现在问题出在优化器上。使用配置,我得到一个错误oraclemapsv2.js has more than one anonymous define
。我用谷歌搜索了它,我发现这是一个问题(包含在 oraclemaps 中)。运行应用程序会导致mismatched anonymous define() module
.
我尝试将 oraclemaps 放入exclude/excludeShallow
并在 HTML 中加载它,但我得到了Script error for "jquery", needed by: jquery-ui, kendo.core.min
.
这是我的优化器配置:
({
baseUrl: "../js/kendo",
paths: {
"kendo.datepicker.min": "kendo.datepicker.min",
"jquery-ui": "../../lib/jquery-ui.min",
"modules": "../../modules",
"colorpicker": "../../lib/colorpicker",
"eye": "../../lib/eye",
"layout": "../../lib/layout",
"utils": "../../lib/utils",
"oraclemaps": "../../lib/oraclemapsv2"
},
shim: {
"kendo.datepicker.min": ["oraclemaps"],
"jquery-ui": ["oraclemaps"],
"colorpicker": ["jquery-ui"],
"eye": ["colorpicker"],
"layout": ["eye"],
"utils": ["layout"]
},
include: ["../../lib/require.min"],
exclude: ["oraclemaps"],
name: "../../app",
out: "../build/app-built.js"
})
我应该怎么办?有任何想法吗?