esm-dev / esm.sh

A fast, smart, & global CDN for modern(es2015+) web development.
https://esm.sh
MIT License
3.1k stars 150 forks source link

Failed to import - @solidjs/router #511

Open b3nten opened 1 year ago

b3nten commented 1 year ago

Failing module

import { Router } from 'https://esm.sh/@solidjs/router'

Error message

After running deno run I got this:

Uncaught SyntaxError: The requested module /v106/solid-js@1.6.9/deno/web.js does not provide an export named 'template'.

Additional info

This is occurring because the project uses Conditional exports to export server code versus client-code. https://github.com/solidjs/solid-router/blob/main/package.json#L21-L26

This could be fixed by giving us an option to provide conditionals. https://esbuild.github.io/api/#conditions

ije commented 1 year ago

currently we don't use conditionals of esbuild, since solid-js/web server.js doesn't export template, you can set the target to es2020 to force using web.js instead of `server.js of solid-js/web if you don't use the SSR.

ije commented 1 year ago
Screenshot 2023-01-29 at 14 44 01

oh i think this is a solid-js bug

b3nten commented 1 year ago

Isn't that running the client version of solid-js/web? So it's looking for browser stuff in Deno?

The issue afaik is that the router defaults to client code. So if you pass it the client version of solid-js/web then the router will work but solid-js/web will not.

ije commented 1 year ago

for deno target, the server will build the module with the ./web/dist/server.js to support SSR, check https://github.com/solidjs/solid/blob/695d99b6fbc1f55c91aed0600b0c1f13e4ee426c/packages/solid/package.json#LL180C16-L180C16