1

I'm using NestJS. In production minimize will set to true. When I run build. The source code after build not work like development mode, all route not map, this function map to other function...

This is my code.

module.exports = {
  target: 'node',
  optimization: { 
    minimize: true <-- HERE
  },
  node: {
    __dirname: false,
    __filename: false,
  },
  module: {
    rules: [
      {
        test: /.tsx?$/,
        use: 'ts-loader',
        exclude: /node_modules/,
      },
    ],
  },
  resolve: {
    extensions: ['.tsx', '.ts', '.js'],
  },
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'server.js',
  },
};

Any help?

Binh Ho
  • 3,690
  • 1
  • 31
  • 31

1 Answers1

1

Looks like you found your answer on the GitHub issue, but for the sake of anyone finding this problem in a search, the problem is with Webpack and how it renames classes when running in production mode with minimize. Quote from Kamil

Webpack automatically transforms the names of classes/functions in the production mode. I'd recommend looking at this chapter: https://webpack.js.org/configuration/mode/ and disabling minimize option.

Jay McDoniel
  • 57,339
  • 7
  • 135
  • 147