cljs.js sourcemap support throws on non-latin1 characters
Description
In cljs.js/append-source-map we encode the source-map string in base64 without escaping non-latin1 characters. In Chrome, this throws the error: "DOMException: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range."
New patch adding js/encodeURIComponent and fixed args to string/replace
Matthew Huebert
August 14, 2017 at 12:02 PM
After further use of source-mapping with files that contain unicode values, I discovered two bugs in my previous patch: we need to apply js/encodeURIComponent to the string first, and string/replace should have been passed a function as a second argument.
In cljs.js/append-source-map we encode the source-map string in base64 without escaping non-latin1 characters. In Chrome, this throws the error: "DOMException: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range."
Source: https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/js.cljs#L152
The problem & a couple of solutions are explained here: https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem