【发布时间】:2017-06-01 06:01:27
【问题描述】:
我有以下webpack.config.ts:
var webpack = require( 'webpack' );
var path = require( 'path' );
module.exports = {
entry: [
'./api/bin/www.ts'
],
output: {
path: path.resolve( __dirname, './dist/api' ),
filename: 'index.js'
},
module: {
loaders: [
{ test: /\.ts$/, loader: 'awesome-typescript-loader' },
{ test: /\.json$/, loader: 'json-loader' }
]
},
resolve: {
extensions: [ '', '.js', '.ts' ]
},
target: 'node',
node: {
console: true,
fs: 'empty',
net: 'empty',
tls: 'empty'
}
};
当我运行 webpack 时,我收到关于依赖项的警告:
WARNING in ./~/express/lib/view.js
Critical dependencies:
78:29-56 the request of a dependency is an expression
@ ./~/express/lib/view.js 78:29-56
我从这里开始的快递服务器只不过是一个Hello World 示例,并且功能应该如此,但我担心这个警告。
我的 googlefu 没有透露任何可行的解决方案。我见过这个问题的一个特定实例,但解决方案是通过不显示来绕过警告。
【问题讨论】:
-
能否将view.js的代码包含进来?
-
尝试使用 webpack-node-externals 插件npmjs.com/package/webpack-node-externals
-
@leo 这不是我的仓库中的文件,它只是通过快递包含的,我想当我 di
import * from express -
我真的很困惑。 OP 说该文件是“webpack.config.*ts*”(强调我的),但我看到的所有其他内容都说这应该是一个 .js 文件,实际上它的语法似乎与 JavaScript 文件更一致。这只是一个错字吗?
-
@Everettss 太糟糕了,您没有提供该提示作为答案...哈哈。