Skip to content

extra spaces in jsx #4

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

Closed
jeetiss opened this issue Dec 24, 2022 · 2 comments
Closed

extra spaces in jsx #4

jeetiss opened this issue Dec 24, 2022 · 2 comments
Labels
💪 phase/solved Post is done

Comments

@jeetiss
Copy link
Contributor

jeetiss commented Dec 24, 2022

Steps to reproduce

transpile next code with estree-util-build-jsx

const a = () => (
  <>
    <div>text</div>
    <div>
      text
    </div>
    <div>
      text{" "}
    </div>
  </>
)

Expected behavior

const a = () =>
  React.createElement(
    React.Fragment,
    null,
    React.createElement("div", null, "text"),
    React.createElement("div", null, "text"),
    React.createElement("div", null, "text", " ")
  );

Actual behavior

const a = () =>
  React.createElement(
    React.Fragment,
    null,
    React.createElement("div", null, "text"),
    React.createElement("div", null, " text"),
    React.createElement("div", null, " text", " ")
  );

typescript, babel, swc work as expected, but this project adds extra leading spaces

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Dec 24, 2022
@jeetiss jeetiss mentioned this issue Dec 24, 2022
5 tasks
@wooorm
Copy link
Member

wooorm commented Dec 24, 2022

Why should this project do things differently than babel, esbuild, typescript, swc?

@jeetiss
Copy link
Contributor Author

jeetiss commented Dec 24, 2022

Babel and typescript don't add spaces in this case (don't have exp with esbuild and swc)

check the repl

EDIT:

swc trims leading spaces too.

@wooorm wooorm closed this as completed in 1a8b9d3 Dec 26, 2022
@wooorm wooorm added the 💪 phase/solved Post is done label Dec 26, 2022
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Dec 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 phase/solved Post is done
Development

No branches or pull requests

2 participants