Library cannot resolve `Context` when using `index.tsx`
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript
- Lĩnh vực
- build-system, tooling
Hướng nghiên cứu
Bắt đầu với bản tái hiện solid-lib-starter được liên kết tại commit cc4fa3ce988b74ad9fe6d791fd3bcedb9ded98f3 và bản xem trước StackBlitz của nó. So sánh export index.tsx bị lỗi với phiên bản index.ts hoạt động, sau đó kiểm tra hành vi của vite-plugin-solid và Vite resolver liên quan. Công việc được xem là hoàn tất khi đã xác định nguyên nhân, xác định liệu hành vi này có được mong đợi hay không, và ghi lại quy ước thư viện được khuyến nghị hoặc fix cần thiết.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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 a vite-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 an index.tsx file. Previously we were using index.ts to export all our internal modules
For 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
src
├── queryClient.ts
├── QueryClientProvider.tsx
├── createQuery.ts
└── index.tsx
queryClient.tscontains aclasswhich contains a counter.queryClientProvider.tscontains two functionsQueryClientProviderthat will be used to provide an instance ofQueryClientto the component subtree using aContextuseQueryClientthat will consume the context and return the instance ofQueryClient
createQuery.tshas a primitive that will internally consume the client usinguseQueryClientand spit out the countindex.tsxjust reexports all the functions/components above
If we use this library in dev mode with vite. It causes an error
Uncaught Error: No QueryClient set, use QueryClientProvider to set one
at useQueryClient (QueryClientProvider.jsx:7:15)
at createQuery (createQuery.js?v=9181a141:4:25)
at App (index.tsx:11:17)
at chunk-ECDBB74H.js?v=9181a141:557:12
at untrack (chunk-ECDBB74H.js?v=9181a141:448:12)
at Object.fn (chunk-ECDBB74H.js?v=9181a141:553:37)
at runComputation (chunk-ECDBB74H.js?v=9181a141:755:22)
at updateComputation (chunk-ECDBB74H.js?v=9181a141:738:3)
at devComponent (chunk-ECDBB74H.js?v=9181a141:564:3)
at createComponent (chunk-ECDBB74H.js?v=9181a141:1330:10)
Live Preview of the issue mentioned above
Example 2 (Reproduction)
The second example is the exact same thing. EXCEPT, index.tsx is changed to index.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 but index.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 https://github.com/TanStack/query/issues/4673
Thanks a lot in advance!
Aryan
- Ngôn ngữ chính
- TypeScript
- Star
- 522
- Fork
- 72
- Merge trung bình
- 21 giờ 42 phút
- Pull request đã merge (30 ngày)
- 35
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của solidjs/solid-vite-plugin
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
solidjs/solid-vite-plugin#205 · 1 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
solidjs/solid-vite-plugin#391 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
solidjs/solid-vite-plugin#390 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
solidjs/solid-vite-plugin#388 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
solidjs/solid-vite-plugin#387 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solidjs/solid-vite-plugin
Issue tương tự
-
keytrace logo svg?Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
cyclofinance/cyclo.site#448 ·
-
[sanity-plugin-media] Searching for a word with an apostrophe shows an error instead of resultsĐang mở@sanity-io/studio bug sanity-plugin-media Sieve-Agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
bug via-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
pingdotgg/t3code#15221 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày