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

vanjs-jsx Fragment missing #324

Open
thednp opened this issue May 18, 2024 · 6 comments
Open

vanjs-jsx Fragment missing #324

thednp opened this issue May 18, 2024 · 6 comments

Comments

@thednp
Copy link

thednp commented May 18, 2024

Hi @Tao-VanJS, I'm getting this error:

Uncaught SyntaxError:
The requested module '/node_modules/.vite/deps/vanjs-jsx_jsx-dev-runtime.js?v=6fa83af3'
does not provide an export named 'Fragment' 

Perhaps including something in compileOptions or the jsx-runtime would fix this? Let me try and let you know later ;)

Btw, I'm using the default bare example converted to JSX

import "./app.css";
import van from "vanjs-core";
import vanjsLogo from "./vanjs.svg";
import viteLogo from "/vite.svg";
import { Counter } from "./counter";
const app = document.getElementById("app")!;

const App = () => {
  return (
    <>
      <div className="flex flex-row gap-3">

        <a href="https://vitejs.dev" target="_blank">
          <img src={viteLogo} className="logo w-3 h-auto" alt="Vite logo" />
        </a>
        <a href="https://vanjs.org" target="_blank">
          <img src={vanjsLogo} className="logo vanilla w-3 h-auto" alt="VanJS logo" />
        </a>
      </div>

      <Counter />
      <p className="read-the-docs">Click on the Vite and VanJS logos to learn more</p>
    </>

  );
};

van.add(app, <App />);
@Tao-VanJS
Copy link
Member

@cqh963852, could you take a look at this?

@thednp
Copy link
Author

thednp commented May 18, 2024

@cqh963852 sorry to bother you, I believe you need to export something like this

// vanjs-jsx/src/index.js
import van from "vanjs-core";
export function createState(v) {
    return van.state(v);
}

export const Fragment = (props) => props.children; // <<<<<<<<<<<<< THIS

export { default as createElement, default as jsx, default as jsxDEV } from "./createElement";

Another option would be something like Solid has implemented with "jsx": "preserve" and not rely on React's usage of className and htmlFor. But that's just an opinion, we might want to accommodate both React devs and new comers. @Tao-VanJS thoughts?

damienflament added a commit to damienflament/van that referenced this issue May 22, 2024
@cqh963852
Copy link
Contributor

"jsx": "preserve"

solidjs has its own babel transform.

I tend to fork the react's compiler to do this work.

@cqh963852
Copy link
Contributor

className and htmlFor

I can understand your expectation.

Do you mean it to be more like writing html?

<label for="xxx" />
<div class="xxx" />

@cqh963852
Copy link
Contributor

cqh963852 commented May 24, 2024

A react compiler example

image

react compiler does not implement the build time reconcile part

@cqh963852
Copy link
Contributor

cqh963852 commented May 24, 2024

A solidjs example

image

Personally, I don't like the For tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants