GoogleChromeLabs / proxx

A game of proximity
https://proxx.app
Apache License 2.0
1.31k stars 124 forks source link

Reduced size with terser #438

Closed ZaneHannanAU closed 5 years ago

ZaneHannanAU commented 5 years ago

Relies on https://github.com/TrySound/rollup-plugin-terser/pull/33 at current due to single use stuff. Removed, inlined instead.

mangle-props (from uglifyjs/terser) could reasonably reduce the bundle size by a few KiB -- though that's not certain...

description from uglify-js:

    --mangle-props [options]    Mangle properties/specify mangler options:
                                `builtins`  Mangle property names that overlaps
                                            with standard JavaScript globals.
                                `debug`  Add debug prefix and suffix.
                                `domprops`  Mangle property names that overlaps
                                            with DOM properties.
                                `keep_quoted`  Only mangle unquoted properties.
                                `regex`  Only mangle matched property names.
                                `reserved`  List of names that should not be mangled.

Similarly duplicated on options.mangle.properties: https://github.com/mishoo/UglifyJS2/blob/master/README.md#minify-options

Should (realistically) reduce size.

googlebot commented 5 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

ZaneHannanAU commented 5 years ago

I signed it!

googlebot commented 5 years ago

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

ZaneHannanAU commented 5 years ago

Currently is totally broken, hrmm...

May make my own terser thing and test...

ZaneHannanAU commented 5 years ago

Currently it seems that require runs into a 404 after deploying; please offer help...

surma commented 5 years ago

Your minifier settings mangled our AMD loader, specifically this line. It renames require to Y in this case. Any idea how to prevent that?

ZaneHannanAU commented 5 years ago

In that case, probably with reserved: [ "require" ]. Tried it and it still isn't working though.

ZaneHannanAU commented 5 years ago

Still broken, but only slightly less so. I'll continue when I get back on my laptop soon.

ZaneHannanAU commented 5 years ago

For the time being, being very lighthanded on it and using only properties that are either constants (allcaps, snake case) or internal functions (__awaiter) and state.

ZaneHannanAU commented 5 years ago

If we can whitelist more properties, that would be very nice; thank you.

ZaneHannanAU commented 5 years ago

I should probably have the name cache automatically output to lib/name-cache.json rather than manually updating lib/name-cache.js but for the time being it should be fine...

... famous last words.

ZaneHannanAU commented 5 years ago

... Should probably only keep certain properties (eg width, height, mines) in the name cache but uh... hrmm.

ZaneHannanAU commented 5 years ago

For the time being, I believe this is ready to check over again. It uses a regex of white-listed properties, so currently doesn't cause any notable errors...

okay wat

so now I'm seeing errors on the info screen?

ZaneHannanAU commented 5 years ago

Errors about undefined and so on

May be renaming of dot and stuff...

surma commented 5 years ago

Gonna be honest, this seems like a lot of work to save 1kB.

ZaneHannanAU commented 5 years ago

Yeah, it is. It gets hard and whitelisting properties becomes difficult. Not to mention that I have no idea how the errors that came up have come up.