Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uglifyjs-webpack-plugin@^0.4.6 and uglifyjs-webpack-plugin@^1.1.0 both in use #3973

Closed
3 tasks done
thijsfranck opened this issue Dec 1, 2017 · 2 comments
Closed
3 tasks done
Labels
!deprecated-label:bug Deprecated label - Use #bug instead

Comments

@thijsfranck
Copy link

thijsfranck commented Dec 1, 2017

  • I have checked the superset logs for python stacktraces and included it here as text if any
  • I have reproduced the issue with at least the latest released version of superset
  • I have checked the issue tracker for the same issue and I haven't found one similar

Superset version

commit 84a7730 - master branch

Expected results

Compile javascript containing ES6 constructs successfully using uglifyjs-webpack-plugin^1.1.2

Actual results

UglifyJs produces the following errors:

`ERROR in dashboard.ec6c8da707d118e14e39.entry.js from UglifyJs Unexpected token: punc (.) [dashboard.ec6c8da707d118e14e39.entry.js:266806,11]

ERROR in explore.4ffc79b5c4308af98750.entry.js from UglifyJs Unexpected token: punc (.) explore.4ffc79b5c4308af98750.entry.js:266286,11]`

Steps to reproduce

The first error is being caused by this line of code:

if (new.target == ConceptRegistry) {

The second error is being caused by this line of code (it's actually the same):

if (new.target == ConceptRegistry) {

This code runs just fine, but the uglification script is having some trouble with it. I expect this is because this syntax was only introduced recently (ES6). The uglification plugin version 1.0.0 and up should support this. The latest version of superset has version 1.1.0 configured. In my problem solving process, I have upgraded this to version 1.1.2 to see if this changes things (it does not). Thus, the package.json is set up as follows:

devdependencies{ "uglifyjs-webpack-plugin": "^1.1.2" }

However, in the yarn.lock file I am finding this:

uglifyjs-webpack-plugin@^0.4.6:
version "0.4.6"
resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-0.4.6.tgz#b951f4abb6bd617e66f63eb891498e391763e309"
dependencies:
source-map "^0.5.6"
uglify-js "^2.8.29"
webpack-sources "^1.0.1"

uglifyjs-webpack-plugin@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.1.2.tgz#8a9abc238d01a33daaf86fa9a84c7ebc1e67b0f9"
dependencies:
cacache "^10.0.0"
find-cache-dir "^1.0.0"
schema-utils "^0.3.0"
source-map "^0.6.1"
uglify-es "^3.2.0"
webpack-sources "^1.0.1"
worker-farm "^1.4.1"

So, there is a dependency to the new version of the uglification plugin, which supports my syntax, and an older version which does not. Since I am seeing errors, I am guessing the latter one is used at the moment. I have not yet found the configuration setting that is managing this. Is this behaviour intentional, or is this a bug? Where can I find the additional configuration that I am currently still missing?

@rhunwicks
Copy link
Contributor

Our attempt to build the JavaScript assets is failing with:

ERROR in dashboard.e12007b38f5d226a9398.entry.js from UglifyJs
Unexpected token: keyword (const) [dashboard.e12007b38f5d226a9398.entry.js:250449,7]

ERROR in explore.b068173a7061b4b69f89.entry.js from UglifyJs
Unexpected token: keyword (const) [explore.b068173a7061b4b69f89.entry.js:250450,7]

https://stackoverflow.com/questions/42375468/uglify-syntaxerror-unexpected-token-punc/46294198#46294198 explains that the installed "uglifyjs-webpack-plugin": "^1.1.0", from package.json won't get used.

We solved the problem by removing the embedded Webpack version prior to running the build:

rm -rf ./node_modules/webpack/node_modules/uglifyjs-webpack-plugin
npm run prod

Once the desired "uglifyjs-webpack-plugin": "^1.1.0", was being used we had to update the webpack.config.js to match the config requirements for the later package:

const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

if (process.env.NODE_ENV === 'production') {
  // Using settings suggested in https://github.com/webpack/webpack/issues/537
  const UJSplugin = new UglifyJsPlugin({
    uglifyOptions: {
      ecma: 8,
      compress:  {
        warnings: false
      },
    },
    sourceMap: true,
    parallel: 4
  });
  config.plugins.push(UJSplugin);
}

@kristw kristw added the !deprecated-label:bug Deprecated label - Use #bug instead label Dec 24, 2018
@kristw
Copy link
Contributor

kristw commented Dec 24, 2018

Fixed by #5983

@kristw kristw closed this as completed Dec 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
!deprecated-label:bug Deprecated label - Use #bug instead
Projects
None yet
Development

No branches or pull requests

3 participants