Express Webpack Critical Dependency Error

What is the current behavior?
The express server still starts up and the callback prints “server running”, but I get this error in the terminal when I build webpack.

Critical dependencies: 78:29-56 the request of a dependency is an expression

module.exports = {
  ...
  module: {
    exprContextCritical: false,
  }
}

The above config can suppress the error, but I’d rather not do that in case something breaks further down the line.

If the current behavior is a bug, please provide the steps to reproduce.

import * as Express from 'express';

const app = Express().listen(3000, () => console.log("server running"));
var path = require("path")

module.exports = {
  entry: {
    "server": "./server/server.ts"
  },
  target: "node",
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "bundle.js",
    publicPath: "/public/"
  },
  module: {
    loaders: [
      {
        test: /\.ts(x?)$/,
        exclude: /node_modules/,
        loader: "ts-loader"
      }, {
        test: /\.js(x?)$/,
        exclude: /node_modules/,
        loader: "babel-loader"
      }, {
        test: /\.json$/,
        loader: "json-loader"
      }, {
        test: /\.scss$/,
        exclude: /node_modules/,
        loaders: ["style-loader", "css-loader", "postcss-loader", "sass-loader"]
      }, {
        test: /\.css$/,
        loader: ["style-loader", "css-loader", "postcss-loader"]
      }, {
        test: /\.(jpe?g|gif|png|svg)$/i,
        loader: 'url-loader?limit=10000'
      }
    ]
  }
}

What is the expected behavior?
No Critical Dependency Error

**Please mention other relevant information such as the browser version, Node.js version,

Node --version // v6.9.1
webpack@1.13.3 

Author: Fantashit

1 thought on “Express Webpack Critical Dependency Error

Comments are closed.