-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
fix(mangler): keep exported symbols for top_level: true
#7927
base: main
Are you sure you want to change the base?
fix(mangler): keep exported symbols for top_level: true
#7927
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
CodSpeed Performance ReportMerging #7927 will not alter performanceComparing Summary
|
@ Boshen, what's the right way to fix this one? we probably need access to ModuleRecord in this mangler to check what's exported/not right? |
41aa4a0
to
c2a99eb
Compare
top_level: true
I made the exported symbols to be not mangled. I made a function that iterates over the top-level statements to collect the exported symbols. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terser's toplevel
option seems different to our top_level
, is there an existing option in another minifier? Or perhaps we should never mangle top level symbols, as it doesn't make sense.
we probably need access to ModuleRecord in this mangler to check what's exported/not right? Code may have been changed a lot after minfication, I think it's best to recollect them. Probably need something better to get some code reuse. |
}) | ||
.map(|id| (id.name.to_compact_str(), id.symbol_id())) | ||
.collect() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The best approach is to have a symbol flag for the exports 🤔 but there aren't any...
Is it different? export const foo = ''
const bar = ''
export { bar } terser outputs /*
option:
{
module: false,
mangle: { toplevel: true }
}
*/
export const foo="";const o="";export{o as bar};
/*
option:
{
module: false,
mangle: { toplevel: false }
}
*/
export const foo="";const bar="";export{bar};
Both:
works for me. |
I'm not going to work on a fix for a while so feel free to fix it if anyone wants to work on it.Exported symbols are now not mangled.