brillout/react-streaming

Importing "server.js" from esm.sh fails

deckchairlabs opened this issue · 14 comments

Attempting to use this library in a Deno context, with esm.sh new option of specifying external deps. I believe it's failing as there is no esm source specified for the server.js export as the client export works fine, https://esm.sh/react-streaming@0.2.15/client?external=react

https://esm.sh/react-streaming@0.2.15/server?external=react

Is there a deno exports? That'd be more precise than adding an import exports.

Looks like esm.sh uses the module condition if it's defined for the export

https://github.com/ije/esm.sh/blob/master/server/build.go#L208

I suppose a better option would be to possibly publish a deno compatible version to https://deno.land/x

Is there a way to automatically publish to deno.land/x when running npm publish?

Neat.

I just re-published 0.2.15, as 0.2.16 with a tag https://github.com/brillout/react-streaming/tags.

Is there anything else that needs to be done? (PR welcome if that's something you'd be up for.)

I'm just seeing https://deno.land/add_module.

So I guess it wants the source files and not dist/, i.e. the src/ directory as "Subdirectory". Does it work with TypeScript Node.js source files? E.g. when importing npm packages, will it work?

Here we are: https://deno.land/x/react_streaming@v0.2.17. Let me know if it works, it's the src/ directory, I'm not sure if that's what Deno wants.

FYI 8342ebb.

It's going to need a separate output unfortunately. Deno requires the file extensions in the import specifier.

I know latest typescript now supports this? And can output the relevant code etc

PR welcome

Actually, I don't think we should complexify the build process (just because Deno stubbornly doesn't want to interop with Node.js).

Let's try with esm.sh first, ideally with esm-dev/esm.sh#376, but we can try import in the meantime and see if Node.js will be ok with that.

PR welcome to add the import field in a way that works with Node.js.

esm.sh actually does support the deno export field: esm-dev/esm.sh#376 (comment).

Which I just added 4b5c6b2, so I guess we're good?

Released in 0.2.18.