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

minify: Unnecessary escaping in string literal templates #8496

Closed
Themezv opened this issue Jan 11, 2024 · 2 comments · Fixed by #8510
Closed

minify: Unnecessary escaping in string literal templates #8496

Themezv opened this issue Jan 11, 2024 · 2 comments · Fixed by #8510
Assignees
Labels
Milestone

Comments

@Themezv
Copy link
Contributor

Themezv commented Jan 11, 2024

Describe the bug

Starts from version 1.3.98

dollar symbol in substitutional string to literal template is unnecessary escaped.

Input code

export const strWithDollar = `$login`;

export const use = `${strWithDollar}`; // expected: "$login" without \\

Config

{
    "jsc": {
        "parser": {
            "syntax": "ecmascript",
            "jsx": false
        },
        "loose": true,
        "minify": {
            "mangle": false,
            "compress": {
              "arguments": false,
              "arrows": true,
              "booleans": true,
              "booleans_as_integers": false,
              "collapse_vars": true,
              "comparisons": true,
              "computed_props": true,
              "conditionals": true,
              "dead_code": true,
              "directives": true,
              "drop_console": false,
              "drop_debugger": true,
              "evaluate": true,
              "expression": false,
              "hoist_funs": false,
              "hoist_props": true,
              "hoist_vars": false,
              "if_return": true,
              "join_vars": true,
              "keep_classnames": false,
              "keep_fargs": true,
              "keep_fnames": false,
              "keep_infinity": false,
              "loops": true,
              "negate_iife": true,
              "properties": true,
              "reduce_funcs": false,
              "reduce_vars": false,
              "side_effects": true,
              "switches": true,
              "typeofs": true,
              "unsafe": false,
              "unsafe_arrows": false,
              "unsafe_comps": false,
              "unsafe_Function": false,
              "unsafe_math": false,
              "unsafe_symbols": false,
              "unsafe_methods": false,
              "unsafe_proto": false,
              "unsafe_regexp": false,
              "unsafe_undefined": false,
              "unused": true,
              "const_to_let": true,
              "pristine_globals": true
            }
        }
    },
    "module": {
      "type": "es6"
    },
    "minify": true,
    "isModule": true,
    "env": {
        "targets": {
            "chrome": 109
        },
        "coreJs": "3.21",
        "mode": "usage"
    }
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.3.98&code=H4sIAAAAAAAAA0utKMgvKlFIzs8rLlEoLikKzyzJcMnPyUksUrBVSFDJyU%2FPzEuw5uJKRVZXWpwKlq1G0VCbYK2gr68AVJmaXJKaYqWgBNGupFAOVJNfWqIQE8PFBQAYdvvmcQAAAA%3D%3D&config=H4sIAAAAAAAAA42VwW7bMAyG73mKwudhWDugwPYAOwzYMwiKRDnKLNEQqTRBkXcvrdhNvET2ckrITySjnxTfN0%2FyafZkmp9P7%2BVHMfQ6EaSZrdjpFFkfxd6ACZpM8j03X%2BbMngbA6Y7g03G%2BMk2HSCAEpww35uCjd6f7lEHHtoMp4j%2B5DIY%2BAdHdMfHp1OYAkenx2UIkfKO7UkbvFrEDHVf9SpPykaGFVE9lsOt0T6AOOlUjDv9GJ09YTzogmcGqPmG%2FQEXr2WOUWmqMBW2VQXsvxQT4BIb9AeohpAYJEQlrAk2QhW1u29JRDyPBQXdZc7UWOBaZ5R9V8%2BzQEyuXY12EC7J4cxdkFOlxFO9UAs4p1mLs0cdFnf8CyL11mijqAPVMhXPSx8uR3H9E8dHJfPGpSslU1m8lQiviKO9dVaHhViGxr3dLApsNDAqZerEjtCgAeQsKnJPurCajN89mVy%2BGTz2gq7qli7Sr9%2FTFrT7fj0VqGNlV6JfcCi%2B198gFzbs1hk5hi91qygC8Q7uKibCMa1CS1%2B%2FYr1E5WpA2BLsAZiru2rMmw8moOuB6H8oASw7Vdri9Pn8z7LyZfxu3UxPQ5vKSTbuktEnZdvTazNFpW12LaDz9mQLcWCEe5ruVZaCB71dWY3YJw3D6%2BduPh5vTYILfw8Hm%2B9eX55u9O1Re6sykWxgr3Zw%2FAMcCWo%2FeBwAA

SWC Info output

No response

Expected behavior

export const strWithDollar = $login;
export const use = $login;

Actual behavior

export const strWithDollar = $login;
export const use = \\$login;

Version

1.3.98

Additional context

Can be related: #8475

@Themezv Themezv added the C-bug label Jan 11, 2024
@Themezv
Copy link
Contributor Author

Themezv commented Jan 11, 2024

Probably duplicates #8407

@kdy1 kdy1 added this to the Planned milestone Jan 14, 2024
@kdy1 kdy1 self-assigned this Jan 16, 2024
kdy1 added a commit that referenced this issue Jan 19, 2024
kdy1 added a commit that referenced this issue Jan 19, 2024
**Related issue:**

 - Closes #8475
 - #8496 (Fixed by #8510)
@kdy1 kdy1 modified the milestones: Planned, v1.3.105 Jan 21, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented Feb 20, 2024

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 Feb 20, 2024
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