Improve internal tree-shaking and lazy load md5#1812
Merged
larabr merged 6 commits intoopenpgpjs:mainfrom Nov 25, 2024
Merged
Conversation
Every submodule under the 'crypto' directory was exported-imported even if a handful of functions where actually needed. We now only export entire modules behind default exports if it makes sense for readability and if the different submodules would be imported together anyway (e.g. `cipherMode` exports are all needed by the SEIPD class). We've also dropped exports that are not used outside of the crypto modules, e.g. pkcs5 helpers.
Used by old, legacy messages only
The existing md5 module brought in the util module, which messed up the chunking structure in the lightweight build; inlining those functions is an option, but the noble-hashes code is also more modern and readable.
To avoid issues with the lightweight build: for now it works fine, but it could mess up chunking in the future, and it already results in a circular import.
Import single functions instead of entire lib.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
See commits for details.
The improved internal tree-shaking for crypto functions helps with unused code elimination; also, md5 can be lazily load as it's used by legacy messages only. This is the impact on the lightweight build before and after the changes:
Open spoiler