Getting Invalid JS from USER_JSPRE_PLACEHOLDER

Unity version 2021.2.13f1

I’m using the js-sha512 library attached. When I run standalone tests for WebGL, I’m getting the error:

Unable to parse Build/PlayerWithTests.framework.js! The file is corrupt, or compression was misconfigured? (check Content-Encoding HTTP Response Header on web server)

Checking the console, I’m getting an error

Uncaught SyntaxError: Invalid left-hand side in assignment

When I look at the code in the PlayerWithTests.framework.js source file, I noticed the minified JS script I added has been modified with

Module["USER_JSPRE_PLACEHOLDER"]="USER_JSPRE_PLACEHOLDER";

For example, in my sha512.min.jspre script, this snippet

g=§_DISCOURSE_HOISTED_CODE_0_§th^~§_DISCOURSE_HOISTED_CODE_0_§sh

Was turned into:

g=Module["USER_JSPRE_PLACEHOLDER"] = "USER_JSPRE_PLACEHOLDER";th^~Module["USER_JSPRE_PLACEHOLDER"] = "USER_JSPRE_PLACEHOLDER";sh

7929217–1012723–sha512.min.js (17.5 KB)

Still getting this issue, seems there is an incorrect replacement.

Our recommendation would be to use the un-minified js-sha512 library as a prejs in Unity and have Unity perform the minification with the non-development build.