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

Support publishing with JSX #24

Open
lucacasonato opened this issue Feb 28, 2024 · 5 comments
Open

Support publishing with JSX #24

lucacasonato opened this issue Feb 28, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@lucacasonato
Copy link
Member

lucacasonato commented Feb 28, 2024

To publish with JSX, we need to take the JSX relevant config options from tsconfig.json / deno.json and put them into the source files via pragmas.

For example, when publishing this index.jsx file with this deno.json file:

import { renderToString } from "npm:preact-render-to-string";
console.log(renderToString(<div>jsx</div>));
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "npm:preact"
  }
}

emit this before publish:

/** @jsxRuntime automatic *//** @jsxImportSource npm:preact */
import { renderToString } from "npm:preact-render-to-string";
console.log(renderToString(<div>jsx</div>));
@lucacasonato lucacasonato added the bug Something isn't working label Feb 28, 2024
@bartlomieju
Copy link
Contributor

@lucacasonato @dsherret I'm a bit confused by this issue. I thought that we only consider the first encountered directive like that - ie. different directives in different files will override each other. I assume that this situation can't be hit because we're gonna pull the directive value from the config file and it's essentially the first one loaded that will actually have effect. Is this correct?

@lucacasonato
Copy link
Member Author

No - directives are per file.

@lucacasonato
Copy link
Member Author

For now we can just add a warning if your publish contains a .jsx / .tsx file saying that .jsx / .tsx are not supported yet, linking to this issue.

@bartlomieju
Copy link
Contributor

PR adding a warning: denoland/deno#22631

@nestarz
Copy link

nestarz commented Mar 1, 2024

To support React JSX I think this issue should be resolved so JSR published React+JSX modules works also in Deno, right ?

denoland/deno#18203

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Ready
Development

No branches or pull requests

3 participants