-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Precompiled JSX shouldn't preserve spaces #23030
Comments
Wanted to take a stab at this, but I'm unable to reproduce this issue. The spaces are not present for me and everything works as expected with the provided reproduction. Tested on my mac, linux and windows machine. This is what the emitted file looks like (removed the inline sourcemap comment for readability): import { jsxTemplate as _jsxTemplate } from "@mary/jsx/jsx-runtime";
const $$_tpl_1 = [
"<div><h1>Hello world</h1></div>"
];
const result = _jsxTemplate($$_tpl_1);
console.log(result.value); |
Ooh, so I decided to look into this some more and this seems to be only happening when tabs are being used for indentations instead of spaces. I wasn't sure how I'd get to the emitted code so I'm making use of the import { transpile } from "https://deno.land/x/emit/mod.ts";
const url = new URL("./mod.tsx", import.meta.url);
const result = await transpile(url, {
compilerOptions: {
jsx: "precompile",
jsxImportSource: "@mary/jsx",
},
});
console.log(result.get(url.href)); TabsSpacesWith spaces it works fine as expected |
Good catch, I missed that with the tabs. Only tried spaces. Can confirm that using tabs for indentation reproduces the issue. |
@mary-ext FYI you can see the emitted output from Deno by running |
Version: Deno 1.41.3
Using this example code, with
jsr:@mary/jsx
to do JSX serialization...When the
precompile
JSX option is used, the resulting serialization retains the whitespace information from the source code:It should match what
react-jsx
has:Not just for stylistic reasons but also because it means that switching between the two transforms could lead to broken website styling due to unexpected whitespace.
The text was updated successfully, but these errors were encountered: