0

我有一个用 TypeScript 编写的操作系统项目,我正在迁移到 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'
        }
    }
};
4

1 回答 1

2

你的resolve.extensions部分有印刷错误。文件的扩展名js必须以点开头:

resolve: {
    extensions: ['', 'webpack.js', '.web.js', '.js', '.ts', '.tsx']
},

所以,js模块无法解析。

于 2016-03-20T14:54:38.330 回答