0
我有我的JSPM Build
以下配置使用打字稿編譯:JSPM Builder:如何依賴其他模塊?
var Builder = require('jspm').Builder;
var builder = new Builder('.');
builder.reset();
builder.loadConfig('./jspm.conf.js')
.then(function() {
builder.config({
defaultJSExtensions: false,
transpiler: "typescript",
typescriptOptions: {
"module": "system",
"experimentalDecorators": true,
"resolveAmbientRefs": true
},
packages: {
"source": {
"main": "app/index",
"defaultExtension": "ts",
"meta": {
"*.ts": {
"loader": "ts"
},
"*.css": {
"loader": "css"
}
}
}
},
packageConfigPaths: [
"npm:@*/*.json",
"npm:*.json",
"github:*/*.json"
],
meta: {
"three": {
"format": "global",
"exports": "THREE"
},
"three-firstpersoncontrols": {
"deps": "three"
}
},
map: {
"three": "github:mrdoob/[email protected]/build/three.js",
"three-firstpersoncontrols": "github:mrdoob/[email protected]/examples/js/controls/FirstPersonControls.js"
}
});
var promises = new Array();
promises.push(builder.buildStatic('source', './build/js/app.min.js', {
sourceMaps: false,
minify: true,
mangle: false
}));
return Promise.all(promises);
})
.then(function() {
cb();
})
.catch(function(err) {
console.log('Build Failed. Error Message: ', err);
});
我試圖用含有例如功能單獨的文件一起使用THREE.js
庫FirstPersonControls
。路徑在map
部分中定義,並且這些都工作得很好。
捆綁後,我得到的消息是THREE.FirstPersonControls is not a contructor
。目前我的猜測是,單獨模塊three-firstpersoncontrols
不依賴於全局THREE
變量,因此無法調用構造函數THREE.FirstPersonControls
。
所以我的問題是:
如何讓這些單獨的模塊依賴我的全球THREE
模塊上構建?