denoland / deno_emit

Transpile and bundle JavaScript and TypeScript under Deno and Deno Deploy
https://jsr.io/@deno/emit
MIT License
225 stars 23 forks source link

fix: Escape reserved JSON characters before bundling into JS file #84

Closed kamilogorek closed 1 year ago

kamilogorek commented 1 year ago

Fixes https://github.com/denoland/deno/issues/14012 and removes unnecessary line-ending from the processed output, as before the trimming, it always ended up looking like this:

__default = JSON.parse(`{"foo": "bar"}
`);

Escaping is done using https://docs.rs/escape8259/ and verified correctness with the https://www.rfc-editor.org/rfc/rfc8259 itself. I didn't see a point vendoring such a small library, but if necessary, we can do that.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

kamilogorek commented 1 year ago

cc @dsherret @bartlomieju

kamilogorek commented 1 year ago

Can I ask for actions reapproval?

bartlomieju commented 1 year ago

@kamilogorek done

kamilogorek commented 1 year ago

Uh, did deno lint and deno fmt but forgot that it also consists of rust code and didn't run rust fmt 🙄

kamilogorek commented 1 year ago
deno lint && deno fmt && deno test -A && cargo fmt && cargo test

Should be good now

bartlomieju commented 1 year ago

@kamilogorek Windows CI is still not happy

kamilogorek commented 1 year ago

Updated. I didnt pull EOL from deno_std/fs nor use isWindows from deno_std/_util/os as it's a simple oneliner, and for pulling whole dep for one tests sounds redundant. We also need Raw.string anyway, so deno_std/fs/EOL couldn't be used directly.