Skip to content

swc minifier breaks escaped unicode #11098

@stormslowly

Description

@stormslowly

Describe the bug

JSON.parse('{"bug": " \\"\\\\uD83D\\\\uDC49\\""}')

after swc minified, throw runtime error as

Uncaught SyntaxError: Unexpected token '�', "{"bug": " \"\�\�\""}" is not valid JSON

Input code

JSON.parse('{"bug": " \\"\\\\uD83D\\\\uDC49\\""}')

Config

Link to the code that reproduces this issue

https://play.swc.rs/?version=1.13.5&code=H4sIAAAAAAAAA%2FMK9vfTK0gsKk7VUK9WSipNV7JSUFKIiVGKAYJSFwtjFwjD2cQSKKhUq64JACfeS8kyAAAA&config=H4sIAAAAAAAAA11Puw7CUAjd%2BxUNs6uLm3Fx8SNuKjW3ua8ANW2a%2FruQvtQNzhOmqq6h4wYu9aSjLjgIUnLhjqEgsRJCPZ4WsjhipF2siPDwI1GIxyTOUJCxIDfki8DCzlsOoea88RrCLceISf6KxNELxTKQz6sZok%2B%2BHb%2FbmxwtysytC4xLSbUWQczPPuDxm91jmWqLOXUMu9LzY9NuVxx1hlTzB3dfn5orAQAA

SWC Info output

No response

Expected behavior

minfied code should executable·

Actual behavior

Uncaught SyntaxError: Unexpected token '�', "{"bug": " \"\�\�\""}" is not valid JSON

Version

1.13.5

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions