我有一个用TypeScript编写的OS项目,我正在向webpack迁移,
但是,由于此错误,我无法构建项目
ERROR in ./src/store/GigaStore.ts
Module not found: Error: Cannot resolve module 'flux/utils' in /home/erfangc/GigaGrid/src/store
@ ./src/store/GigaStore.ts 11:16-37
项目位于此处 https://github.com/erfangc/GigaGrid/tree/webpack
以下是我为达到这一点所做的工作:
ts-loader
flux/utils
的行是:import FluxUtils = require('flux/utils');
resolve.alias
flux/utils: 'ABSOLUTE_PATH'
部分
node_modules
下存在肯定文件,我依赖的其他库似乎捆绑得很好
非常感谢任何帮助...
webpack.config.js
从repo再现
module.exports = {
entry: "./src/index.ts",
output: {
path: "./dist",
libraryTarget: "umd",
library: "GigaGrid",
filename: "giga-grid.js"
},
resolve: {
extensions: ['', 'webpack.js', '.web.js', 'js', '.ts', '.tsx']
},
module: {
loaders: [
{
test: /\.tsx?$/, loader: "ts-loader"
},
{
test: /\.css$/, loader: "style-loader!css-loader"
},
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/font-woff"
}, {
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/font-woff"
}, {
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/octet-stream"
}, {
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: "file"
}, {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=image/svg+xml"
}
]
},
externals: {
"react": {
commonjs: 'react',
commonjs2: 'react',
amd: 'react',
root: 'React'
},
"react-dom": {
commonjs: 'react-dom',
commonjs2: 'react-dom',
amd: 'react-dom',
root: 'ReactDOM'
}
}
};
答案 0 :(得分:2)
您的resolve.extensions
部分中有错误打印。 js
文件的扩展名必须以点开头:
resolve: {
extensions: ['', 'webpack.js', '.web.js', '.js', '.ts', '.tsx']
},
因此,js模块无法解决。