Thinkmill / keystatic

First class CMS experience, TypeScript API, Markdown & YAML/JSON based, no DB
https://keystatic.com
MIT License
1.22k stars 80 forks source link

~500kb added to bundle when using `NotEditable` in client component #765

Closed stefanprobst closed 4 months ago

stefanprobst commented 11 months ago

issue description: when <NotEditable> is used in a component-block preview component, which also has the use client directive, ~500kb are added to the client bundle.

issue reproduction: https://github.com/stefanprobst/issue-keystatic-noteditable-client-component

steps to reproduce:

Route (app)                              Size     First Load JS
┌ ○ /                                    7.24 kB         532 kB
├ ○ /_not-found                          877 B          84.8 kB
├ ● /[slug]                              479 B           526 kB
├   └ /first-post
├ λ /api/keystatic/[...params]           0 B                0 B
└ λ /keystatic/[[...params]]             142 B          84.1 kB

context: i was trying to add a figure component-block, and display the image in the figure preview (which requires use client because it uses useState). see here: https://github.com/stefanprobst/issue-keystatic-noteditable-client-component/blob/main/components/component-blocks/figure.preview.tsx


workaround: using a separate client component for the preview image, see: https://github.com/stefanprobst/issue-keystatic-noteditable-client-component/commit/4dd85001caac81f57584de8941172814c4ac3555

stefanprobst commented 4 months ago

no longer an issue.