denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.04k stars 604 forks source link

Issues with radix-ui #1530

Open marvinhagemeister opened 11 months ago

marvinhagemeister commented 11 months ago

Reported on discord:

I have updated the project with 22 components.

I have issues with Slider ContextMenu NavigationMenu Switch Toast

I have some errors like

An error occurred during route handling or page rendering. TypeError: Cannot
read properties of null (reading 'useMemo') at n.useMemo
(https://esm.sh/stable/react@18.2.0/es2022/react.mjs:2:6723) at
fdemir commented 10 months ago

It's because of the preact exports. Preact does not export useMemo hook from the root module. It exports from preact/hooks. Possibly it can solved by adding alias or external params to radix-ui.

We also should add it to the doc imo. Because so many libraries depends on react and should marked as external.

marvinhagemeister commented 10 months ago

@fdemir FYI: I work on Preact and wrote a good chunk of the react compatiblity layer.

React should always be aliased to preact/compat. It re-exports the preact/hooks entry and others. I mainly made this issue because we should have an easy way in Fresh to do that and have that applied automatically to dependencies coming from esm.sh and elsewhere.

king8fisher commented 9 months ago

1.4.2 -> 1.4.3 brought some new errors. Adding alias=react:preact/compat,@types/react:preact/compat to the https://esm.sh/ links has definitely made compiler happier. New compiler errors surfaced after that, around forwardRef. https://github.com/king8fisher/test-fresh-radix-ui is a fork from original reporter with these adjustments.

kevingorski commented 8 months ago

@king8fisher The alias params you mentioned helped me out, thanks!

I see in your fork that there appear to be some typos that may be causing issues: reac instead of react in &external=reac,react-dom

king8fisher commented 8 months ago

Oh! Great catch @kevingorski! Going to try and see if that affects the build!

king8fisher commented 8 months ago

1.4.3 -> 1.5.0 Still no great results. Errors around forwardRef:

hapaxlife commented 8 months ago

The link to fork and experiment modifications https://github.com/hapaxlife/test-fresh-radix-ui

harrysolovay commented 6 months ago

Pinging this issue, as I believe this compatibility is very important to many users, who may want to depend on radix-based libs such as shadcn/ui.

ooker777 commented 3 months ago

React should always be aliased to preact/compat

By this do you mean to add this to the import map?

"react": "https://esm.sh/preact@10.15.1/compat",

It does alleviate the compiler, but it doesn't seem to be able to replace it completely. I use it to use cmdk but I don't see any UI from it.