brillout / react-streaming

React Streaming. Full-fledged & Easy.
MIT License
220 stars 14 forks source link

Deno usage? #3

Closed deckchairlabs closed 2 years ago

deckchairlabs commented 2 years ago

Hey! Long time! Hope all is well.

I'm trying to use this in a Deno framework, do you have plans to publish a Deno specific module, or have recommendations on how to import and use?

brillout commented 2 years ago

Hi James, yea — we are making a lot of progress with Vike frameworks being built on top of vite-plugin-ssr 0.4 :-). A Remix clone should be fairly easy to achieve now ;-).

As for Deno, yes, I'm open for this although I don't know how much change is required? Deno now has this Node.js compat layer, right?

deckchairlabs commented 2 years ago

It does yeah, and works quite well. I think all would be needed are "import" conditions in package.json for esm.

https://esm.sh/react-streaming is how I'd be importing, which doesn't seem to support the browser field you have currently.

brillout commented 2 years ago

Done & released in 0.2.7.

deckchairlabs commented 2 years ago

Well the import resolves correctly now! Thanks for that. although, since reanderToPipeableStream is only available on Node environments, the import fails.

Reproduction https://github.dev/deckchairlabs/react-streaming-deno

error: Uncaught SyntaxError: The requested module '/v78/react-dom@18.1.0/deno/server.development.js' does not provide an export named 'renderToPipeableStream'
    at https://cdn.esm.sh/v78/react-streaming@0.2.7/deno/server.development.js:13:10

I'm wondering if the simplest solution is to have a separate "export" for web platform environments?

brillout commented 2 years ago

Currently react-streaming statically imports from React: import { renderToPipeableStream, renderToReadableStream } from 'react-dom/server'. But we can dynamically import() these only if needed instead. That should fix it. Up for PR?

deckchairlabs commented 2 years ago

That should work! I'll get to it!

brillout commented 2 years ago

Fixed in https://github.com/brillout/react-streaming/pull/4.

Released in 0.2.8.

deckchairlabs commented 2 years ago

It works! Nice

brillout commented 2 years ago

👍.

Btw do you know if there are efforts to make Vite work with Deno? Although I'm thinking Deno already has built-in support for bundling, right? Does it support browser transpilation and HMR? E.g. React or Vue files? Custom transfomers (e.g. for Telefunc)?

Deno is quite exciting :-).