Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single quotes in template literal are escaped wrong when compress is enabled #8228

Closed
smvv opened this issue Nov 6, 2023 · 1 comment · Fixed by #8248
Closed

Single quotes in template literal are escaped wrong when compress is enabled #8228

smvv opened this issue Nov 6, 2023 · 1 comment · Fixed by #8248
Assignees
Labels
Milestone

Comments

@smvv
Copy link
Contributor

smvv commented Nov 6, 2023

Describe the bug

I looked for related bug reports first and this bug seems related to #1488.

Note: the bug does not happen when compress is false.

Input code

export const a = `You\'ll`
export const b = 'You\'ll'

Config

{
"sourceMaps": true,
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": true,
      "decorators": true
    },
    "target": "es2017",
    "loose": false,
    "transform": {
      "react": {
        "runtime": "automatic"
      }
    },
    "externalHelpers": true,
    "keepClassNames": false,
    "minify": {
      "compress": true
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.3.96&code=H4sIAAAAAAAAA0utKMgvKlFIzs8rLlFIVLBVSIjML41Rz8lJ4EpFlkoCSqlDpdQBxGxW3DUAAAA%3D&config=H4sIAAAAAAAAA31VvY7bMAze8xSB5hvaDlega4GiS%2FsKgiJRjq6yaIhULsEh717Kdi6JI2ez%2BPGfH%2BmPjSIs2cIfM5D6seVc4GWz3ao3svL8kE95DCYT5M%2B3SOiU2BxFovg0ANkcBlYvF5TpeONrFDmwmA1jvkQZgfOEKza5A67ugL59%2Bfp9dqUiIoGIvYkEF91sEnnM%2FW0%2BGYzlG0EVlcShr9bKFMbecLBqhs930eHIkJOJvyEOkOkudfUPYPgZDdFf0wMtculDCv50m4jFfshAdJ%2BLlFd6SLywn7GM77Tol8h3iBGk1HVEG9IhMXRT0kvHFmOUqYI%2BmNzwUjM1ORC2QlSwMDg9ZByaeHKBA0rXGqgD47RFBw0oZLAcDtAyk1hilkjKa9Qzwg52petGMi6s4WBiMdyICcdxJJJtw%2BseA7H2JbVaOIErPZjAublLy%2BB1Bi45Pdq9YUgrM6lk07ayLT2y7arhhU9r1v6pZUheKMunBi671qoyQSdN1SH4RmdrZyBzaE0zgysWamdtK50ZXmkfBQcavBeuNFzTe2C7bwWt1wh9A5D5Gt9i1QTozy1cwetCPIF%2FSZXcJtisIfdnv47Sqd9hfBKgB96je6Igo2Bch7NcieOwjpfkQKgBrqlSaAQej4AsAKOO4%2B1%2B4Iash3jUXcTd9UzcX%2BDNfIVVj66MWz%2F%2Fcuogp%2F%2FBq7oqXc7tmOHm%2FB%2F4%2B2x5vgYAAA%3D%3D

SWC Info output

No response

Expected behavior

export const a = "You'll";  // or `You\'ll`;
export const b = 'You\'ll';

Actual behavior

with compress: true, swc returns:

export const a = "You\\'ll";
export const b = 'You\'ll';

with compress: false, swc returns:

export const a = `You\'ll`;
export const b = 'You\'ll';

Version

1.3.96

Additional context

This bug report looks related to escaping

`''`

. Could that be related?

@smvv smvv added the C-bug label Nov 6, 2023
@kdy1 kdy1 added this to the Planned milestone Nov 7, 2023
@kdy1 kdy1 self-assigned this Nov 7, 2023
@kdy1 kdy1 closed this as completed in #8248 Nov 9, 2023
kdy1 added a commit that referenced this issue Nov 9, 2023
@kdy1 kdy1 modified the milestones: Planned, v1.3.98 Nov 21, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Dec 21, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Dec 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants