我有以下内容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没有透露任何可通过的解决方案.我已经看到了这个问题的一个特定实例,但解决方案是通过不显示它来绕过警告.
使用webpack-node-externals.
const nodeExternals = require('webpack-node-externals'); { target: 'node', externals: [nodeExternals()], }
https://www.npmjs.com/package/webpack-node-externals