如何使 requirejs 填充模块能够访问未定义的依赖项
How to make requirejs shimmed module able to access a dependency not defined
require.config({
shim:{
"openLayers": {
deps: ["proj4", "css!/libs/ol3/v3.11.2/ol.css"],
},
"jsts": {
// exports:"jsts",
deps: ["libs/jsts/javascript.util.min", "openLayers"]
}
}
}
我的问题是 jsts 库需要在代码中定义 "openLayers" 依赖项。
是否有可能以某种方式在 requirejs 中配置它,或者我必须用 amd define 调用包装 jsts 库?
是否有 grunt 任务可以在需要时进行以下包装?
define(["openLayers"], function (ol) {
//jsts code
});
我用 grunt 任务解决了它:
grunt.loadNpmTasks('grunt-umd');
umd: {
jsts: {
options: {
src: 'wwwroot/libs/jsts/jsts.min.js',
dest: 'wwwroot/libs/jsts/jsts.umd.min.js',
objectToExport: 'jsts',
amdModuleId: 'jsts',
deps: {
'default': ['ol'],
amd: ['openLayers'],
}
}
}
},
require.config({
shim:{
"openLayers": {
deps: ["proj4", "css!/libs/ol3/v3.11.2/ol.css"],
},
"jsts": {
// exports:"jsts",
deps: ["libs/jsts/javascript.util.min", "openLayers"]
}
}
}
我的问题是 jsts 库需要在代码中定义 "openLayers" 依赖项。
是否有可能以某种方式在 requirejs 中配置它,或者我必须用 amd define 调用包装 jsts 库?
是否有 grunt 任务可以在需要时进行以下包装?
define(["openLayers"], function (ol) {
//jsts code
});
我用 grunt 任务解决了它:
grunt.loadNpmTasks('grunt-umd');
umd: {
jsts: {
options: {
src: 'wwwroot/libs/jsts/jsts.min.js',
dest: 'wwwroot/libs/jsts/jsts.umd.min.js',
objectToExport: 'jsts',
amdModuleId: 'jsts',
deps: {
'default': ['ol'],
amd: ['openLayers'],
}
}
}
},