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

Improve JSX transform using tsconfig jsx precompile for server side rendering #6878

Open
neves opened this issue Nov 3, 2023 · 0 comments
Open
Labels
performance An issue with performance

Comments

@neves
Copy link

neves commented Nov 3, 2023

What is the problem this feature would solve?

It's all explained here https://deno.com/blog/v1.38#fastest-jsx-transform but the idea is to implement this faster and memory efficient jsx transform. Example:

{
  "compilerOptions": {
    "jsx": "precompile",
    "jsxImportSource": "custom"
  }
}
// input
const a = (
  <div className="greeting">
    <a href={link}>
      Hello <b>{name}!</b>
    </a>
  </div>
);

// output
import { jsxAttr, jsxEscape, jsxTemplate } from "custom/jsx-runtime";

const tpl = [
  '<div class="greeting"><a ',
  ">hello <b>",
  "!</b></a></div>"
];
const a = jsxTemplate(tpl, jsxAttr("href", link), jsxEscape(name));

custom/jsx-runtime can easily be implemented as:

export const jsxTemplate = String.raw
export const jsxEscape = Bun.escapeHTML
export const jsxAttr = (name, value) => ` ${name}="${value}"`

What is the feature you are proposing to solve the problem?

It's all explained here https://deno.com/blog/v1.38#fastest-jsx-transform

What alternatives have you considered?

No response

@neves neves added the enhancement New feature or request label Nov 3, 2023
@Electroid Electroid changed the title Fast(est) JSX transform like Deno 1.38.0 using tsconfig jsx precompile for server side rendering Improve JSX transform using tsconfig jsx precompile for server side rendering Nov 4, 2023
@Electroid Electroid added performance An issue with performance and removed enhancement New feature or request labels Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance An issue with performance
Projects
None yet
Development

No branches or pull requests

2 participants