Webpack和Express - 严重依赖关系警告 [英] Webpack and Express - Critical Dependencies Warning
问题描述
我有以下 webpack.config.ts
:
var webpack = require('webpack');
var path = require('path');
module.exports = {
条目:[
'./api/bin/www.ts'
],
输出:{
path:path.resolve(__dirname,'./dist/api'),
filename:'index.js'
},
module:{
装载机:[
{test:/\tsts/,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时,我收到关于依赖关系的警告:
警告in ./~/express/lib/view.js
严重依赖关系:
78:29-56依赖关系的请求是一个表达式
@ ./~/express/lib/view.js 78:29-56
我从这开始的快递服务器不过是一个 Hello World
example和函数,应该,但我担心这个警告。 / p>
我的googlefu没有透露任何可行的解决方案。我已经看到这个问题的一个特殊实例,但解决方案是绕过不显示的警告。
使用webpack- node-externals。
const nodeExternals = require('webpack-node-externals');
{
target:'node',
externals:[nodeExternals()],
}
https:// www。 npmjs.com/package/webpack-node-externals
I have the following 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'
}
};
When I run webpack I get a warning about a dependency:
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
The express server I start with this is no more than a Hello World
example and functions as should but I am concerned about this warning.
My googlefu hasn't revealed any passable solutions. I have seen one particular instance of this problem but the solutions were to bypass the warning by not showing it.
Use webpack-node-externals.
const nodeExternals = require('webpack-node-externals');
{
target: 'node',
externals: [nodeExternals()],
}
https://www.npmjs.com/package/webpack-node-externals
这篇关于Webpack和Express - 严重依赖关系警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!