Searching around how to fix it, i've seen that is a pretty common problem, but yet with no defenitive solution...
...But i find one post where they said that "lowering the size of the memory allocated at build time did the trick." (Ref. https://answers.unity.com/questions/1577758/webgl-build-error-unity-2018218.html)
Also, i think this can help you undertanding what you're working on...
- https://docs.unity3d.com/Manual/webgl-memory.html
- https://blogs.unity3d.com/2016/09/20/understanding-memory-in-unity-webgl/
- https://blogs.unity3d.com/2016/12/05/unity-webgl-memory-the-unity-heap/?_ga=2.72953425.310398189.1588433213-308107014.1587208625
Not sure if this will help you fix your problem... I tried my best... =C
Also, sorry for the late response... =C