Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.

Tree shaking of debug code? #34

Open
andrewthebold opened this issue Apr 30, 2022 · 3 comments · May be fixed by #29
Open

Tree shaking of debug code? #34

andrewthebold opened this issue Apr 30, 2022 · 3 comments · May be fixed by #29
Labels
1.2.0 enhancement New feature or request

Comments

@andrewthebold
Copy link

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!)

@FarazzShaikh
Copy link
Member

FarazzShaikh commented May 1, 2022

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

@FarazzShaikh FarazzShaikh added enhancement New feature or request 1.2.0 labels May 1, 2022
@FarazzShaikh FarazzShaikh linked a pull request May 1, 2022 that will close this issue
10 tasks
@andrewthebold
Copy link
Author

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.

@emcfarlane
Copy link

emcfarlane commented Dec 4, 2022

Lamina dependency on levas dependency on radix-ui is causing some conflicts. Would be great to have it conditionally!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1.2.0 enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants