Skip to content

Commit

Permalink
docs: update usage with react
Browse files Browse the repository at this point in the history
  • Loading branch information
hansSchall committed Sep 1, 2024
1 parent d577208 commit 44a6c0a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"deno.enable": true,
"cSpell.words": [
"compat",
"lockfiles",
"polyfilling",
"prefresh"
Expand Down
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,21 @@ This import map can be used to polyfill `node:` or do the same as `undeclared_np

Those imports wont be touched.

## Usage with React (coming soon)
## Usage with React

Currently React is unsupported.

1. `react-dom` does some extremely ugly things with cjs exports (like exporting inside an if statement ...). For this
reason it cannot be transformed to ESM correctly, but this is not the only problem.
2. The Deno LSP has problems with React, too. This time it is about missing JSXRuntime types...

I personally only use Preact, so this is not top priority.

Until this is supported out of the box you should be able to use the Preact configuration, it will use the React
compatibility layer. Read more: https://preactjs.com/guide/v10/switching-to-preact
Until this is supported out of the box you could use the Preact configuration. If you are doing this, all react imports
are redirected to preact and the whole application is run with the react compatibility layer... (this works without any
problems 🤯) Read more: https://preactjs.com/guide/v10/switching-to-preact.

If you have experience with Vite plugins and import resolving you should be able to get React working natively.
If you really need React, please file an issue.

## Usage with Preact

Expand Down Expand Up @@ -226,7 +233,7 @@ And your `deno.json`:

```json
"compilerOptions": {
"jsx": "automatic",
"jsx": "react-jsx",
"jsxImportSource": "preact",
}
```
Expand Down Expand Up @@ -281,6 +288,10 @@ Deno.stat = (...args) =>
});
```

### React does not work (and maybe more packages that do ugly things with exports)

See [Usage with React](#usage-with-react)

## Acknowledgements

[esbuild_deno_loader](https://github.com/lucacasonato/esbuild_deno_loader) does essentially the same for esbuild. The
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deno-plc/vite-plugin-deno",
"version": "2.0.2",
"version": "2.0.3",
"exports": "./mod.ts",
"fmt": {
"indentWidth": 4,
Expand Down

0 comments on commit 44a6c0a

Please sign in to comment.