closure-compiler icon indicating copy to clipboard operation
closure-compiler copied to clipboard

Re-add Minification Mapping Input Suggestion

Open tommywilkinson opened this issue 1 year ago • 5 comments

Looks like this ability used to be in the compiler, but was removed long ago. A piece of the functionality was re-added for #433, but not the piece allowing for an input mapping to use as a starting point.

It's a very common practice for website to use hashed file names to allow browsers to cache unchanged portions of scripts, especially as a part of a webpack bundle, which allows only certain portions of the bundle to need to get re-downloaded by users in the new version.

However, if you're using Closure Compiler as a minifier (perhaps via the webpack plugin), the instability of the minification will mean that all chunk contents will likely change every build, even if there were no real changes to the contents of some of the chunks.

In an ideal world, we'd be able to give Closure the minification map of the previous build, which it could then use as a "suggestion" for the current mapping. If there's a big enough upside, it can choose to re-map any or all of the identifiers. This means that for cases where there's no upside to re-mapping, Closure could choose stability, perhaps allowing more of those chunks to have unchanged contents.

The main pitch here is to make minification slightly less "chaotic" (in the sense that small changes anywhere within the scope can lead to big output differences everywhere) for cases where there is little-to-no upside.

tommywilkinson avatar Jun 07 '23 00:06 tommywilkinson