question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: webpack.optimize.UglifyJsPlugin is not a constructor

See original GitHub issue

This is in webpack@4.0.0-beta.0

Do you want to request a feature or report a bug?

bug

What is the current behavior?

TypeError: webpack.optimize.UglifyJsPlugin is not a constructor

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

const webpack = require('webpack');
new webpack.optimize.UglifyJsPlugin()

Also:

$ npm i webpack@4.0.0-beta.0
$ node -e 'console.log(require("webpack").optimize)'

{ AggressiveMergingPlugin: [Getter],
  AggressiveSplittingPlugin: [Getter],
  ChunkModuleIdRangePlugin: [Getter],
  LimitChunkCountPlugin: [Getter],
  MinChunkSizePlugin: [Getter],
  ModuleConcatenationPlugin: [Getter],
  OccurrenceOrderPlugin: [Getter],
  RuntimeChunkPlugin: [Getter],
  SideEffectsFlagPlugin: [Getter],
  SplitChunksPlugin: [Getter] }

What is the expected behavior?

webpack.optimize.UglifyJsPlugin === function

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

❯ node v8.6.0 ❯ npm 5.6.0 ❯ webpack 4.0.0-beta.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:29 (12 by maintainers)

github_iconTop GitHub Comments

41reactions
fregantecommented, Jan 29, 2018

Any docs available for config.optimization.minimize? Google brings up zero results.

Also it’d be nice to include a friendly message about this in webpack itself because plenty of people will be hitting that error.

9reactions
backflipcommented, Feb 7, 2018

I was using an outdated structure, the config needs to be wrapped with uglifyOptions:

optimization: {
  minimizer: [
    new UglifyJSPlugin({
      uglifyOptions: {
        mangle: {
          keep_fnames: true,
        },
      },
    }),
  ],
},

Sorry for spamming.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: webpack.optimize.UglifyJsPlugin is not a constructor
As you may notice that the plugin uglifyjs-webpack-plugin is being deprecated and in the terser-webpack-plugin comes in as replacement.
Read more >
UglifyjsWebpackPlugin | webpack
This plugin uses uglify-js to minify your JavaScript. Requirements. This module requires a minimum of Node v6.9.0 and Webpack v4.0.0. Getting Started.
Read more >
webpack.optimize JavaScript and Node.js code examples
Returns a formatted string of the compilation information (similar to CLI output). DefinePlugin · UglifyJsPlugin · Stats.hasErrors,; Compiler.plugin,; Compiler.
Read more >
DevExtreme Bundler does not work with Webpack 4
UglifyJsPlugin plugin was removed in Webpack 4 is confirmed in the TypeError: webpack.optimize.UglifyJsPlugin is not a constructor GitHub ...
Read more >
uglifyjs-webpack-plugin - npm
UglifyJS plugin for webpack. Latest version: 2.2.0, last published: 3 years ago. Start using uglifyjs-webpack-plugin in your project by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found