lamina
lamina copied to clipboard
Tree shaking of debug code?
I noticed that the DebugLayerMaterial
code adds ~50KB gzipped to my production js bundle even if I'm not using the debug layer. Looks like the main reason is because it's importing leva
and its dependencies. I think this is something like an extra 2-3x the size of lamina's core code.
Tested with webpack and vite, but it's possible this is just my setup. I did a hacky fix with my bundler to alias leva
to an empty exports file in production, but it would be nice to have the debug code automatically excluded if unused.
(Also, love the library!)
Thanks!
I'm not too familiear with tree shaking but in the next release 1.2.0
the debugger will be broken off into lamina/debug
. Correct me if i'm wrong but that should mean that as long as lamina/debug
is not imported, Leva will not end up in the bundle.
You can follow the progress of 1.2.0
in #29 however beware, its an in-dev branch and quite a lot might be broken up till release
Yeah sounds like that'll work. I was going to suggest an experience like react query's devtools, which conditionally imports the module depending on the NODE_ENV
, but realize there's probably use cases to intentionally ship the lamina debugger.
Lamina dependency on levas dependency on radix-ui is causing some conflicts. Would be great to have it conditionally!