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

Removed the 'crypto' dependency #2478

Merged
merged 2 commits into from
Nov 15, 2022
Merged

Removed the 'crypto' dependency #2478

merged 2 commits into from
Nov 15, 2022

Conversation

3bl3gamer
Copy link
Contributor

The crypto module brings a huge amount of code to the browser build and it's removal reduces the build size by 400 KiB or by 25%.

The crypto.randomBytes Generates cryptographically strong pseudorandom data. That strength is not needed since these hex strings are used only as ids/classes in the generated HTML.

This change may cause test fails for some users, but this can be fixed by stubbing Math.random.

Another option would be to generate sequential IDs:

let lastId = -1
export default function genStringId() {
  lastId += 1
  return lastId+''
}

This won't cause problems with tests but may reveal the amount of e-mails generated by some application (if used on the server side).

@3bl3gamer
Copy link
Contributor Author

3bl3gamer commented Jun 6, 2022

BundleAnalyzerPlugin output for comparison. Before:

before

After:

after

@iRyusa
Copy link
Member

iRyusa commented Jul 8, 2022

I'll try to get this in 4.13.1

@iRyusa
Copy link
Member

iRyusa commented Aug 2, 2022

@3bl3gamer Can you resolve those conflicts i'd like to release this next week ?

@3bl3gamer
Copy link
Contributor Author

@iRyusa sorry for the delay, resolved.

@F21
Copy link

F21 commented Oct 11, 2022

Any chance this can be merged soon?

@iRyusa iRyusa merged commit e03c580 into mjmlio:master Nov 15, 2022
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

Successfully merging this pull request may close these issues.

3 participants