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.

Error when Uglifying with Webpack 4

See original GitHub issue

Superagent Version: 4.0.0-beta.5 Webpack Version: 4.19.1 UglifyJS Webpack Plugin: 2.0.1

Appears to have an issue when running a production build in Webpack 4 with UglifyJS.

ERROR in bundle.js from UglifyJs Unexpected token: name (root) [./node_modules/superagent/lib/client.js:5,0]...

Possibly an issue with using the reserved keyword ‘root’.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
TotooriaHyperioncommented, Dec 25, 2018

No, you are wrong it’s not a problem of Uglify plugin.

It’s because many people use webpack this way:

      {
        test: /\.tsx?$/,
        loader: "ts-loader",
        exclude: /node_modules/,
        options: {
          configFile: path.resolve(__dirname, "../../src/tsconfig.json"),
        },
      },

so the const/let etc… will not be transpiled to es5.

add a rule:

      {
        test: /\.jsx?$/,
        loader: "ts-loader",
        include: /(autobind-decorator)|(superagent)/,
        options: {
          configFile: path.resolve(__dirname, "../../src/tsconfig.json"),
          transpileOnly: true,
        },
      },

will fix this problem.

Situation1: People usually use webpack to bundle with loaders exclude file in node_modules Situation2: Some package don’t provide es5 version, or use module: es6version in package.json

Situation1 + Situation2 = the code send to uglify plugin would be es6 version, causing this problem.

0reactions
sergej-scommented, Nov 5, 2018

@djizco Hi! How did you solve the issue? What do you mean of switching to ES5 version?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when Uglifying with Webpack 4 · Issue #1415 - GitHub
Appears to have an issue when running a production build in Webpack 4 with UglifyJS. ERROR in bundle.js from UglifyJs Unexpected token: name...
Read more >
Webpack 4 and Uglify Plugin (TypeError: Cannot read ...
Setting mode to production in Webpack v4 should do enough optimisations, so there's no need to specifically require the Uglify plugin.
Read more >
UglifyjsWebpackPlugin | webpack
This plugin uses uglify-js to minify your JavaScript. ... Custom logic for extract comments const { error, map, code, warnings } = require('uglify-module') ......
Read more >
uglify-js - npm
UglifyJS is a JavaScript parser, minifier, compressor and beautifier toolkit. Note: uglify-js supports JavaScript and most language features in ...
Read more >
uglifyjs-webpack-plugin - npm.io
webpack.config.js module.exports = { optimization: { minimizer: [ new UglifyJsPlugin({ chunkFilter: (chunk) => { // Exclude uglification for the `vendor` ...
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