toastdotdev / toast

The best place to stack your JAM. Toast is a Jamstack framework
153 stars 13 forks source link

Add preact/jsx-runtime alias #67

Closed talves closed 3 years ago

talves commented 3 years ago

Allow for automatic jsx transform (react/jsx-runtime) react component libraries to alias to the preact/jsx-runtime.

export function Hello() {
    return <div>Hello</div>;
}

compiles to:

import { jsx } from "react/jsx-runtime";
export function Hello() {
  return /*#__PURE__*/jsx ("div", {
    children: "Hello"
  });
}

The alternative to the automatic is classic which uses React.createElement and this is currently handled with the react: "preact/compat" alias.

compiles to:

import React from "react";
export function Hello() {
  return /*#__PURE__*/React.createElement("div", null, "Hello");
}