Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Astro loads two copies of SolidJS #6709

Closed
1 task
lxsmnsyc opened this issue Mar 30, 2023 · 1 comment · Fixed by #6934
Closed
1 task

Astro loads two copies of SolidJS #6709

lxsmnsyc opened this issue Mar 30, 2023 · 1 comment · Fixed by #6934
Assignees
Labels
- P2: has workaround Bug, but has workaround (priority)

Comments

@lxsmnsyc
Copy link

What version of astro are you using?

2.1.8

Are you using an SSR adapter? If so, which one?

None (if @astrojs/node doesn't count)

What package manager are you using?

pnpm

What operating system are you using?

Windows

What browser are you using?

Chrome

Describe the Bug

image

As you see in the image, Astro loads two copies of SolidJS, one through the file:/// URL (see createResource), the other with the POSIX path (see createMemo).

Based on what I know with Vite's module resolution, since this is close to the browser behavior, two copies are loaded because they come from different URLs, despite pointing to the same file locally. This behavior breaks SolidJS packages that uses SolidJS APIs that relies on the existence of a root (e.g. createUniqueId, createResource). The code basically thinks that the APIs are called "outside a root".

I do think this same issue might be prevalent to other integrations that rely on the same mechanism (e.g. React), but I don't have any evidence for that yet.

Another potential issue is how @astrojs/solid-js has SolidJS as both a peer dependency and a dependency, I do think it should be both a peer and a dev dependency?

Link to Minimal Reproducible Example

https://github.com/lxsmnsyc/astro-solid-spa-nested

Participation

  • I am willing to submit a pull request for this issue.
@matthewp
Copy link
Contributor

This fixes it:

    ssr: {
      noExternal: ['solid-swr-store']
    }

Since this is an ecosystem package I'll add this to the Solid integration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants