-
Notifications
You must be signed in to change notification settings - Fork 51
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
Library cannot resolve Context
when using index.tsx
#80
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good Evening!
Hope you are having a wonderful holiday! I am the maintainer of the TanStack
solid-query
package and we are running into a peculiar issue that I am not really sure if this is avite-plugin-solid
issue or maybe something with the vite resolver itself.Overview
Recently, We moved
solid-query
to follow the patterns set up by Solid Lib Starter where the root of the library is exported by anindex.tsx
file. Previously we were usingindex.ts
to export all our internal modulesFor
solid-query
to work, it needs a Context Provider at the top level to share the query cache to its component subtree. The implementation detail of which doesn't matter. I have created a very simple reproduction that removes all external dependencies to make it easy to pinpoint the issue.Example 1 (Reproduction)
Here is a small example library that simulates the issue.
https://github.com/ardeora/solid-lib-starter/tree/cc4fa3ce988b74ad9fe6d791fd3bcedb9ded98f3
Directory structure
queryClient.ts
contains aclass
which contains a counter.queryClientProvider.ts
contains two functionsQueryClientProvider
that will be used to provide an instance ofQueryClient
to the component subtree using aContext
useQueryClient
that will consume the context and return the instance ofQueryClient
createQuery.ts
has a primitive that will internally consume the client usinguseQueryClient
and spit out the countindex.tsx
just reexports all the functions/components aboveIf we use this library in dev mode with vite. It causes an error
Live Preview of the issue mentioned above
Example 2 (Reproduction)
The second example is the exact same thing. EXCEPT,
index.tsx
is changed toindex.ts
https://github.com/ardeora/solid-lib-starter/tree/main/src
And now the library works as expected
Live Preview of the working version
Is this behavior expected? What is the reason
index.tsx
doesn't work butindex.ts
works here? What is the convention you recommend we follow for future versions of SolidJS libraries going forward?Referencing the
solid-query
issue here as well TanStack/query#4673Thanks a lot in advance!
Aryan
The text was updated successfully, but these errors were encountered: