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

[Bug] Extra \r\n in JSXText #9106

Closed
caoccao opened this issue Jun 26, 2024 · 1 comment · Fixed by #9112
Closed

[Bug] Extra \r\n in JSXText #9106

caoccao opened this issue Jun 26, 2024 · 1 comment · Fixed by #9112
Assignees
Labels

Comments

@caoccao
Copy link

caoccao commented Jun 26, 2024

Describe the bug

There are extra \r\ns appearing the JSXText value and raw. That causes the AST mismatch the original source code.

Input code

function test() {
  return (
    <div>
      abc
    </div>
  );
}

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": true
    },
    "target": "es2020",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": false
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.6.5&code=H4sIAAAAAAAAA0srzUsuyczPUyhJLS7R0FSo5uVSUChKLSktylPQALEVFGxSMsvsIEwFhcSkZKioPkxY05qXqxYAMvsHs0gAAAA%3D&config=H4sIAAAAAAAAA1WPSw6DMAxE95wi8roLxKKL3qGHiFKDgvKTHaQixN0b8mu7i9%2FMeJxjEAJWVvAQR3qmIUhipD4nwruL8p0IoLKSFekQ4dbUlS8p0oaZnEWAKGnBmEM8jdNYA2C8Z0x4loaxMqudnvffSuVtIGT%2BN15W6RbT86VxqK1g%2FWvLYv1K3AOWC%2B7wNbWyvhg0P1uyrD0%2F0IfHixcBAAA%3D

SWC Info output

No response

Expected behavior

Both value and raw should be "\n abc\n ".

Here is a screenshot of the AST from https://astexplorer.net/.

image

Actual behavior

Both value and raw are "\n\r\n abc\n\r\n ".

Version

1.6.5

Additional context

No response

@swc-bot
Copy link
Collaborator

swc-bot commented Jul 29, 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 Jul 29, 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