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
[Feature request] nameCache and __MANGLE_PROP__ overlap #1527
Comments
I notice you're talking about chunks, so I assume you're using webpack. Webpack doesn't use the nameCache option, which is why mangling properties doesn't work across chunks. But it may be possible if you disable parallelism in terser-webpack-plugin. |
There's something that Terser and the bundler plugins can do together, which is to provide a pre-step to gather all properties, and create a name cache, and then use it in parallel. However, this will take some time to perform and most likely it's not worth it. Simply disabling parallelism would be faster. |
@fabiosantoscode I have parallel turned off, but it still does not work for MANGLE_PROP usage - only for protected members across main bundle and async chunk |
Ok, I understand now. Terser finds all annotated properties, but it doesn't store them in nameCache for subsequent runs. This might not be possible to fix completely. Consider this example: In chunk 1, you have a property |
There is no second chunk. Just these 2 Also - it seems that @MANGLE_PROP usage would mangle all occurrences of the specific prop - not just on the object where it is in use. This is not obvious from the docs. const x = { const x = { Both occurrences of y - not just the first one - get mangled. This is not just the first one. console.log({ |
Bug report or Feature request?
Feature request
Information
nameCache option can be used to fix protected problem across async chunk and main bundle - same mangling should be in place
when MANGLE_PROP is in use in main bundle - make use of nameCache to also cover the mangled property name(s) so they can be safely used in async chunk - replaced accordingly
The text was updated successfully, but these errors were encountered: