-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat(forge flatten
): add dead code elimination
#2266
Comments
Good catch. |
@gakonst just realized the same is true for non flattened files. When you have a file like:
When I verify this contract it will include |
We'd need to do deeper parsing of the dependency graph for this kind of flattening I think? |
It's probably worth an additional flag as the automatic removal of unused imports may confuse some developers. I believe this would be a valuable feature as we'll see more utility in index files, as shown by protocols in addition to aave. The dependency graph only grows as protocols build across many chains, requiring index files. |
forge flatten
): add dead code elimination
Component
Forge
Describe the feature you would like
When using some libraries, the
--flatten
output will be gigantic as flatten will inline all imports. It would be neat if flatten would detect & remove unused imports.When using re-export index files like here https://github.com/bgd-labs/aave-address-book/blob/main/src/AaveAddressBook.sol that makes it essentially impossible to use in foundry as the generated code will be unusable long.
Additional context
In addition to what i mentioned above i guess it might make sense to even eliminate unused code in the actually imported files. Not sure sure about this though.
The text was updated successfully, but these errors were encountered: