Typescript with Babylonjs built with Webpack error: Duplicate identifier 'BABYLON'
Typescript with Babylonjs built with Webpack error: Duplicate identifier 'BABYLON'
我正在开发一款名为 density wars 的 webgl RTS 游戏,但我遇到了很多如下错误:
ERROR in [default] /Users/nikos/PhpstormProjects/Density-Wars/babylonjs.d.ts:1:15
Duplicate identifier 'BABYLON'.
在我打字稿的入口点我这样做:
/// <reference path="./gameUnits/Core.ts" />
/// <reference path="./utils/UnitCommand.ts" />
/// <reference path="./utils/Formations.ts" />
/// <reference path="./User.ts" />
declare function require(module: string):any
require('../style.css');
var BABYLON = require('babylonjs');
webpack.config:
module.exports = {
context: __dirname + "/lib",
entry: {
main: [
"./game.ts"
]
},
output: {
path: __dirname + "/dist",
filename: "density-wars.js"
},
devtool: "source-map",
module: {
loaders: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader'
},
{ test: /\.css$/, loader: "style-loader!css-loader" }
]
},
resolve: {
// you can now require('file') instead of require('file.js')
extensions: ['', '.js', '.json']
}
}
Duplicate identifier 'BABYLON'
因为你的代码 var BABYLON = require('babylonjs');
。在没有根级别 import
或 export
的情况下,该文件对 global 命名空间有贡献,因此您有多个 var BABYLON
声明。
修复
使用 import BABYLON = require('babylonjs');
或至少 export
具有 var BABYLON
.
的文件中的内容
更多https://basarat.gitbooks.io/typescript/content/docs/project/modules.html
我正在开发一款名为 density wars 的 webgl RTS 游戏,但我遇到了很多如下错误:
ERROR in [default] /Users/nikos/PhpstormProjects/Density-Wars/babylonjs.d.ts:1:15
Duplicate identifier 'BABYLON'.
在我打字稿的入口点我这样做:
/// <reference path="./gameUnits/Core.ts" />
/// <reference path="./utils/UnitCommand.ts" />
/// <reference path="./utils/Formations.ts" />
/// <reference path="./User.ts" />
declare function require(module: string):any
require('../style.css');
var BABYLON = require('babylonjs');
webpack.config:
module.exports = {
context: __dirname + "/lib",
entry: {
main: [
"./game.ts"
]
},
output: {
path: __dirname + "/dist",
filename: "density-wars.js"
},
devtool: "source-map",
module: {
loaders: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader'
},
{ test: /\.css$/, loader: "style-loader!css-loader" }
]
},
resolve: {
// you can now require('file') instead of require('file.js')
extensions: ['', '.js', '.json']
}
}
Duplicate identifier 'BABYLON'
因为你的代码 var BABYLON = require('babylonjs');
。在没有根级别 import
或 export
的情况下,该文件对 global 命名空间有贡献,因此您有多个 var BABYLON
声明。
修复
使用 import BABYLON = require('babylonjs');
或至少 export
具有 var BABYLON
.
更多https://basarat.gitbooks.io/typescript/content/docs/project/modules.html