svelte-jsx icon indicating copy to clipboard operation
svelte-jsx copied to clipboard

Adjacent JSX elements must be wrapped in an enclosing tag

Open theoparis opened this issue 4 years ago • 1 comments

Hi there. I've been looking for a working svelte testing solution, and so far svelte-jester is broken with ESM. Then I came across this and I set this up with jest and babel with preset-env. However, it gave the following error upon running jest:

Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? (10:0)

It runs fine with Vite though, so its not a issue with my code. I'm not sure how to disable this specific error.

This is my babel configuration:

{
  "presets": [
    ["@babel/preset-env", { "targets": { "node": "current" } }],
    ["@babel/preset-typescript"]
  ],
  "plugins": [
    "babel-plugin-transform-vite-meta-env",
    [
      "@babel/plugin-transform-react-jsx",
      { "runtime": "automatic", "importSource": "svelte-jsx" }
    ]
  ]
}

theoparis avatar Nov 21 '21 01:11 theoparis

What’s the code?

This is likely unrelated to this package, but a difference in how Babel and esbuild handle JSX. In particular, esbuild would probably be wrong, because JSX is a React thing, and the maintainers there treat Babel as the reference implementation.

wooorm avatar Nov 21 '21 08:11 wooorm