Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.

feat: update to uglify-es - #63

Merged
michael-ciniawsky merged 15 commits into
webpack-contrib:masterfrom
Hartorn:master
Jul 5, 2017
Merged

feat: update to uglify-es#63
michael-ciniawsky merged 15 commits into
webpack-contrib:masterfrom
Hartorn:master

Conversation

@Hartorn

@Hartorn Hartorn commented Jun 30, 2017

Copy link
Copy Markdown
Contributor

@michael-ciniawsky @hulkish @graingert : Here is the new PR.

This PR is about moving to uglify-es (following of #55, due to messy chained rebase/push-force, etc...)

Here is a quick sum up of the modifications, please ask for precisions if needed.

  • Uglify now expose a single high level function minify(code, options), which go through all the steps of minification (parse, compress, mangle, output)
  • it does not throw errors anymore, so the try-catch is not needed (test if there is an error key in the return of the function)
  • it is possible to get the warnings in the result also, so it is not needed anymore to mingle with AST_NODE warn_function
  • it is possible to give a filter for comments, so we can hook on that for exporting comments
  • it is possible to give a preamble in the output, so we can use that for the banner thing (License file, comments, ...)

Basically, we do not need to use any other function than minify from uglify, it is mainly about giving proper options, handle the source maps and output.

I did not had time to update the docs, I will do in the next days.

TODO :

[ ] Update the documentation
[ ] Add new test for the new functionnalities

@Hartorn

Hartorn commented Jun 30, 2017

Copy link
Copy Markdown
Contributor Author

@hulkish Honestly, I'm not so familiar with unit testing like this. I corrected the existing ones (only the configuration given to the plugin). I might need help on this, if anyone wants to lend a hand :)

@michael-ciniawsky

michael-ciniawsky commented Jun 30, 2017

Copy link
Copy Markdown
Member

I take care of the docs in #61 after this PR :)

cc @hulkish for Unit testing

@michael-ciniawsky michael-ciniawsky added this to the 1.0.0 milestone Jun 30, 2017
@hulkish

hulkish commented Jun 30, 2017

Copy link
Copy Markdown
Contributor

@Hartorn sure, you wanna give me access to your fork and ill add the test.

@hulkish

hulkish commented Jun 30, 2017

Copy link
Copy Markdown
Contributor

@Hartorn Nvm, I see you've already included your updates to the tests: https://github.com/webpack-contrib/uglifyjs-webpack-plugin/pull/63/files

This looks good to me, 👍 🌮

@Hartorn

Hartorn commented Jun 30, 2017

Copy link
Copy Markdown
Contributor Author

@hulkish @michael-ciniawsky Already invited you both to my fork, maybe it will be useful.

I pushed the modifications to the package-lock, did not pay attention the repo was in npm 5.
Build should be all good

@hulkish I thought you were talking about adding new cases for uglify-es options.
I might still need to add a check on source map (the one inside uglifyOptions must be ignored, we only care about the one in options).
Thanks for checking :) 👍

Comment thread src/index.js Outdated
warnings,
parse: parse || {},
compress: compress || {},
/* eslint-disable no-undefined */

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eslint-disable-next-line

@michael-ciniawsky michael-ciniawsky left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to find a way to avoid the options nesting

Comment thread test/all-options.test.js
return `License information can be found in ${licenseFile}`;
},
},
uglifyOptions: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible to keep the individual options in the top level e.g via filter() ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt like they were too many options to keep them at top level. (https://github.com/mishoo/UglifyJS2/tree/harmony#minify-options-structure)
That way, I thought it was easier to understand what's coming from the plugin, or what's coming from UglifyJs, and so easier to read the docs according to the need.

@michael-ciniawsky michael-ciniawsky Jun 30, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm.. I basically agree 😛, but uglifyOptions is too verbose (but no better idea atm, just complaining :D). What's your opinion on removing warningFilters && extractComments ? 🙃 What is especially the usecase for warningFilters?

@Hartorn Hartorn Jun 30, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warningFilters : I think it can be used by some people to filter for example on node_modules and still see warnings about their code, maybe to check dead code presence, or optimisation.

extractComment: It is for copyright/license reason I think => that way, the file you load is still small, plus a preamble redirecting to another file containing all the copyrights/licenses.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright

Comment thread src/index.js Outdated
parse: parse || {},
compress: compress || {},
// eslint-disable-next-line no-undefined
mangle: mangle === undefined || mangle === null ? true : mangle,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mangle == null is idiomatic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@graingert I don't understand this. What you mean is that I should not test mangle === null but only mangle === undefined ? true : mangle ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mangle === undefined || mangle === null is the same as mangle == null

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thks for the explanation.

@michael-ciniawsky

Copy link
Copy Markdown
Member

What are the uglifyOptions defaults atm => new UglifyJSPlugin() ?

@graingert

graingert commented Jul 5, 2017 via email

Copy link
Copy Markdown

@michael-ciniawsky
michael-ciniawsky merged commit 1d62560 into webpack-contrib:master Jul 5, 2017
@michael-ciniawsky

Copy link
Copy Markdown
Member

⚠️ Please wait with the next beta release I quickly finish the docs PR :)

@joshwiens

Copy link
Copy Markdown
Contributor

@jdalton @graingert ...

screen shot 2017-07-05 at 10 06 13 pm

@joshwiens

joshwiens commented Jul 6, 2017

Copy link
Copy Markdown
Contributor

For all involved, this is staying on a beta tag at minimum, until the test suite is reliable. I personally wouldn't have merged this yet given Tobias should have looked at it & we didn't answer the performance question though I do understand everyones desire to get this in master.

@Hartorn - Please see my comment in #67

This was referenced Jul 6, 2017
openjck added a commit to mozilla/experiments-viewer that referenced this pull request Jul 18, 2017
The latest version of striptags is causing the build task to fail
because it uses ES6, which is not supported by the version of Uglify
that Webpack is using.

As soon as [1] is published to a main release and Webpack updates to
use that release, we should be able to upgrade striptags to the latest
version.

[1] webpack-contrib/uglifyjs-webpack-plugin#63
@michael-ciniawsky michael-ciniawsky removed this from the 2.0.0 milestone Oct 29, 2017
@openjck

openjck commented Feb 23, 2018

Copy link
Copy Markdown

This hasn't been released yet, has it?

edit: Apologies. Answered my own question. Yes, it has been released.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants