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

feat: update to uglify-es #63

Merged
merged 15 commits into from
Jul 5, 2017
Merged

feat: update to uglify-es #63

merged 15 commits into from
Jul 5, 2017

Conversation

Hartorn
Copy link
Contributor

@Hartorn Hartorn commented Jun 30, 2017

@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
Copy link
Contributor Author

Hartorn commented Jun 30, 2017

@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
Copy link
Member

michael-ciniawsky commented Jun 30, 2017

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
Copy link
Contributor

hulkish commented Jun 30, 2017

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

@hulkish
Copy link
Contributor

hulkish commented Jun 30, 2017

@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
Copy link
Contributor Author

Hartorn commented Jun 30, 2017

@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 :) 👍

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

Choose a reason for hiding this comment

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

eslint-disable-next-line

Copy link
Member

@michael-ciniawsky michael-ciniawsky left a comment

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

@@ -33,6 +27,14 @@ describe('when applied with all options', () => {
return `License information can be found in ${licenseFile}`;
},
},
uglifyOptions: {
Copy link
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
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.

Copy link
Member

@michael-ciniawsky michael-ciniawsky Jun 30, 2017

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?

Copy link
Contributor Author

@Hartorn Hartorn Jun 30, 2017

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
Member

Choose a reason for hiding this comment

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

Alright

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

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
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 ?

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
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
Member

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

@graingert
Copy link

graingert commented Jul 5, 2017 via email

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

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

@joshwiens
Copy link
Member

@jdalton @graingert ...

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

@joshwiens
Copy link
Member

joshwiens commented Jul 6, 2017

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
Copy link

openjck commented Feb 23, 2018

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