@clerk/react and @clerk/shared do not declare sideEffects: false, which blocks tree-shaking through ClerkProvider
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
- 48/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- nextjs, react, typescript
- Lĩnh vực
- build-system, frontend, performance
Hướng nghiên cứu
Bắt đầu bằng cách kiểm tra các package manifest đã phát hành của @clerk/react và @clerk/shared, sau đó truy vết cách @clerk/react tạo ra dist/ClerkProvider-CNl0Jmp6.mjs. Xác minh xem các package có không có side effect hay không và provider được hợp nhất với các thành phần UI như thế nào. Công việc được xem là hoàn tất khi metadata chính xác và, nếu tiếp tục theo hướng này, provider không còn kéo theo mã UI không liên quan; chạy lại phép đo production bundle đã được báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Package
@clerk/[email protected], @clerk/[email protected] (reached via @clerk/[email protected])
What
@clerk/nextjs declares "sideEffects": false. Neither of the two packages it stands on does — @clerk/react and @clerk/shared both omit the field entirely, so a bundler must assume every module in them has side effects and cannot drop unreachable exports.
$ node -e "for (const p of ['@clerk/react','@clerk/shared','@clerk/nextjs'])
console.log(p, require(p+'/package.json').sideEffects)"
@clerk/react undefined
@clerk/shared undefined
@clerk/nextjs false
Why it matters downstream
Measured on a Next.js 16 App Router app (Turbopack, Cache Components, @clerk/[email protected]), across nine cold production builds:
@clerk/nextjsputs 66,806 bytes gzipped into first load, on every route, becauseClerkProviderlives in the root layout.- With every Clerk UI component deleted from the app — no
<UserButton>, no<SignIn>, no<SignUp>— and the provider resolved past the root barrel, 51,910 gz still remains. That is the floor:ClerkProvideralone.
Two things put it there, and the sideEffects gap is one:
- No
sideEffects: falseon@clerk/react/@clerk/shared, so nothing unreachable can be dropped. @clerk/react's dist is rollup-merged —dist/ClerkProvider-CNl0Jmp6.mjsis a single 59,673-byte file holding the provider and the UI component implementations. Even withsideEffects: false, importing the provider pulls that whole file, because the merge happened at publish time rather than at the consumer's bundler.
So (1) alone is necessary but may not be sufficient — (2) would need the provider split out of the shared chunk for the flag to actually pay. Both together are what would let an app that renders one avatar stop shipping the code for PricingTable, OrganizationProfile, OrganizationSwitcher and the rest.
Ask
Declare "sideEffects": false in @clerk/react and @clerk/shared if it holds (both look side-effect-free from the outside — they are component/hook/util modules), and, if you're open to it, split ClerkProvider out of the merged dist chunk so the flag has something to act on.
Happy to re-run the measurement against a canary if that's useful.
Related
Filed alongside a request for a client-component subpath export on @clerk/nextjs, which is the other half of the same problem for App Router apps.
- Ngôn ngữ chính
- TypeScript
- Star
- 1.8k
- Fork
- 473
- Merge trung bình
- 2 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 269
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- 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 clerk/javascript
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
clerk/javascript#10033 ·
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 78/100
clerk/javascript#10026 ·
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 78/100
clerk/javascript#9987 ·
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 65/100
clerk/javascript#10011 ·
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 50/100
clerk/javascript#9984 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của clerk/javascript
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
MystenLabs/MemWal#1085 · 1 bình luận ·
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 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
📕documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
db-ux-design-system/core-web#8343 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement triage/needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
heygen-com/hyperframes#4944 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Pressing Escape to close the time dropdown in the event form asks to discard the whole eventĐang mởai-driven-qa bug claude
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
linagora/twake-calendar-frontend#1493 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày