我已经安装了 proxyquire 并且我的 ajax.test.tsx 文件包含以下代码,只有 2 行
import * as proxyquire from 'proxyquire';
proxyquire.noCallThru();
我的 webpack 代码如下
module.exports = {
entry: {
"book.service": './src/book.service.ts',
"ajax.test": './src/ajax.test.tsx'
},
output: {
filename: "[name].js",
path: __dirname + "/dist"
},
devtool: "source-map",
watch: true,
resolve: {
extensions: [".tsx", ".tsx", ".js", ".json", ".ts", '.d.ts']
},
module: {
rules: [
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
]
},
externals: {
'react/lib/ExecutionEnvironment': true,
'react/addons': true,
'react/lib/ReactContext': 'window'
}
};
我已经安装了 proxyquire 和 @types/proxyquire。当我运行 webpack 命令时,它会抛出以下错误
WARNING in ./~/proxyquire/lib/proxyquire.js
require.extensions is not supported by webpack. Use a loader instead.
@ ./~/proxyquire/index.js 3:17-44
@ ./src/ajax.test.tsx
ERROR in ./~/proxyquire/lib/proxyquire.js
Module not found: Error: Can't resolve 'module' in '***\node_modules\pr
oxyquire\lib'