esm.sh icon indicating copy to clipboard operation
esm.sh copied to clipboard

Failed to import - @solidjs/router

Open b3nten opened this issue 2 years ago • 4 comments

Failing module

  • GitHub: https://github.com/solidjs/solid-router/
  • npm: https://www.npmjs.com/package/@solidjs/router
import { Router } from 'https://esm.sh/@solidjs/router'

Error message

After running deno run I got this:

Uncaught SyntaxError: The requested module /v106/[email protected]/deno/web.js does not provide an export named 'template'.

Additional info

  • esm.sh version:
  • Deno version: 1.29.1

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

b3nten avatar Jan 29 '23 03:01 b3nten

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 avatar Jan 29 '23 06:01 ije

Screenshot 2023-01-29 at 14 44 01 ~~oh i think this is a solid-js bug~~

ije avatar Jan 29 '23 06:01 ije

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.

b3nten avatar Jan 29 '23 06:01 b3nten

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

ije avatar Jan 29 '23 07:01 ije