-
Notifications
You must be signed in to change notification settings - Fork 284
Split grunt copy task into copy and uglify to minify JS files #74
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
Conversation
|
r=me |
|
Before I land this on our branch, @redmunds would you guys take this patch upstream? |
|
I won't pretend to understand it all, but it looks good. |
|
@humphd Thanks for asking. Seems like more granularity would be nice to have. @jasonsanjose @peterflynn @nethip Any reason we wouldn't want this in Brackets? |
|
@humphd Is this more aggressive than the Uglify2 task that Brackets currently runs on its main source in the It's worrisome that QuickView gets broken when subjected to this... How sure are you that other features don't have subtler problems? I think I'd want to get to the bottom of what's going wrong with QuickView first, to feel confident it wouldn't cause more widespread breakage. |
|
This is separate from the requirejs build step, since a bunch of thirdparty stuff (CodeMirror, extensions, require.js itself, ...) get copied over to I share your concerns are other subtle issues, which is why I didn't bother doing this PR against upstream. I can try playing with uglify's options a bit more, and see if I can fix the QuickView code. Before I bothered, I wanted to see if you'd take it at all. |
|
I did some digging, and it's function hoisting that's causing QuickView to break. This fixes things: uglify: {
options: {
mangle: false,
compress: {
hoist_funs: false |
|
This also exposed an issue in xorigin.js, which I've done a PR for upstream adobe#10683 |
|
Are there other possible transformations Uglify is doing that could break other parts of Brackets? Is there anything that enumerates all the settings that are on by default? It seems safest to run Uglify in the same bare-minimum mode (concat only) that Brackets applies to the non-thirdparty stuff... but does that make it not a win for you guys? I.e. is stripping comments, whitespace, etc. important for page load or is gzipping the concat-only result good enough? |
|
The list of compressor options, with info about defaults is documented here https://github.com/mishoo/UglifyJS2#compressor-options. I did a test, and by simply copying (what happens now for I think that it's unlikely to be beneficial for the Brackets-proper case, so I've altered my patch so that we can use a |
|
r+ |
|
OK, I've turned off uglify's name mangling and compression--it's just doing whitespace packing and concatenation now. This is still good. In later bugs it would be good to figure out how much of uglify's compression stuff we can safely turn on, but that can happen over time. I've also reworked things so that |
|
@redmunds Yes! Fine granularity is definently good. But I doubt the We are also tracking another PR adobe#10219 which will further compress the |
Previously, the grunt build was just copying things from the source tree, which left a lot of JS unminified (i.e., anything in an extension or not in the requirejs build step). This splits the copy process across two tasks, one of which copies, then the second uglfiies things in dist.
I had to do one hack I don't love, but I'm not sure how to fix it. The code for the QuickView extension's main.js breaks when you minify it. I could try and track that down, but it won't save enough space to worry about, so I just skip it (i.e., copy but don't minify).