You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I came across this issue where if the source code passed into magic-string contains characters outside of the Latin1 range, e.g. Cyrillic, and the execution context is a browser (works fine in Node), then an error is thrown:
I did some research and found a solution (in the context of a Rollup use case):
constrollupBundle=awaitrollup(inputOptions);const{ code, map }=awaitrollupBundle.generate(outputOptions);// Monkey patch magic-string internals// to support characters outside of the Latin1 range, e.g. Cyrillic.consttoString=map.toString.bind(map);map.toString=()=>unescape(encodeURIComponent(toString()));// Inspired by https://github.com/rollup/rollup/issues/121constcodeWithSourceMap=code+'\n//# sourceMappingURL='+map.toUrl();
thanks! this was actually a long-standing annoyance in the Svelte REPL; had no idea it would be such an easy fix. I had to go into that file today anyway, to remove a deprecated new Buffer(...) call, so I changed this while I was at it: 2177946
I came across this issue where if the source code passed into magic-string contains characters outside of the Latin1 range, e.g. Cyrillic, and the execution context is a browser (works fine in Node), then an error is thrown:
I did some research and found a solution (in the context of a Rollup use case):
Related reading:
magic-string/src/SourceMap.js
Line 3 in 3466b02
I'd be happy to submit a PR incorporating this into magic-string, if there's interest.
The text was updated successfully, but these errors were encountered: