Allow private class members to be mangled #12176
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Openlayers classes use an underscore suffix convention to mark class members as private. These are undocumented implementation details and presumably unsafe for code outside the class to rely on.
Allowing javascript minimisation to change these names gives 5% bundle size reduction to the library.
See terser docs on mangling property names and mange options.
Before/after size comparisons.
For common examples bundle:
After
gzip -9
:And for legacy bundle:
I've not exhaustively tested all examples, but from grep for
'_ '
onlyexamples/custom-interactions.js
touches properties with an underscore suffix, and it's its own class.This might be considered an api change, as it has some potential to break library users (if they're not building from the module sources themselves, and are poking around class internals), so may be worth a specific version bump of some kind.
Motivation for proposing this, is have been using this exact build setup when importing and building
ol
and having the same behaviour upstream makes the guarantee it'll work going forwards a bit stronger.