Skip to content

oxc_codegen: support printing StringLiteral using StringLiteral#raw #10214

@xu-cheng

Description

@xu-cheng

I need to make oxc_codegen crate to output original input (i.e., raw) for StringLiteral. The reason is that I want to have the following js code:

const foo = "\x3chead\x3e\x3c/head\x3e\x3cbody\x3e\x3c/body\x3e";

Currently, oxc_codegen will instead generate the following code:

const foo = `<head></head><body></body>`;

This would break HTML if I embed the generated js inline inside a <script> element.

Previously, I can set StringLiteral#lossy as true to workaround this issue. But this attribute has since been removed in v0.62.0.

Metadata

Metadata

Assignees

Labels

P-highPriority - High

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions