Skip to content
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

Add support for mangling properties with a name cache #1977

Closed
marvinhagemeister opened this issue Feb 1, 2022 · 1 comment
Closed

Add support for mangling properties with a name cache #1977

marvinhagemeister opened this issue Feb 1, 2022 · 1 comment

Comments

@marvinhagemeister
Copy link

With property name mangling being added in 47773fc I was looking into if we could replace our terser build setup with esbuild for Preact. In our current setup we use the name cache feature of terser to mangle property names in a consistent way for our core library and addons that interface with each other. Without consistent mangling the names would not match up and it would break the code.

This features is currently missing as indicated in the docs for mangling for esbuild. I'm curious if it would be possible to add some sort of name mapping to esbuild similar to the name cache feature in terser.

Here is an example of the name cache in our build: https://github.com/preactjs/preact/blob/1b6fbc723020f66b74581e9eea067f74380eb1f9/mangle.json#L28-L77

Terser doc: https://terser.org/docs/cli-usage#cli-mangling-property-names-mangle-props

@evanw
Copy link
Owner

evanw commented Feb 2, 2022

Yes, this sounds reasonable to add. Right now I'm trying to figure out how the JS and Go APIs should work.

I could make it a file name, but that relies on the file system which means it wouldn't work in the browser. That would also be somewhat problematic from a determinism standpoint as it's essentially a database but multiple concurrent API calls could write to it in different orders, causing nondeterministic builds.

Making it an input map and an output map to each API call would let it work in the browser and would avoid nondeterminism issues with multiple concurrent API calls, but would mean the map wouldn't automatically be updated for every incremental build when in incremental build mode.

Right now I'm leaning toward the second option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants