Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree shaking #14

Closed
nandorojo opened this issue Sep 9, 2021 · 6 comments
Closed

Tree shaking #14

nandorojo opened this issue Sep 9, 2021 · 6 comments

Comments

@nandorojo
Copy link

See my comment at stitchesjs/stitches#596

The styled function shouldn’t accept strings.

@Temzasse
Copy link
Owner

@nandorojo thanks for bringing this up 🙂

I think staying consistent with the Stitches API is quite important so I'm hesitant to make this kind of a change.

I'm wondering how other React Native styling libraries handle tree shaking 🤔 It seems that styled-components also requires the whole react-native but there is comment about lazy-requiring that goes beyond my understanding of how React Native internals work.

@nandorojo
Copy link
Author

Yeah, styled components for native also breaks tree shaking.

@nandorojo
Copy link
Author

Dripsy has tree shaking enabled. The only way to do so is to build with expo-module-scripts rather than react-native-bob (I did a lot of research for this for Dripsy).

@Temzasse
Copy link
Owner

I feel like this is not a priority for this project right now especially if tree shaking cannot be achieved with the string based API. I wouldn't want to diverge from the API that the main Stitches lib uses.

I'm gonna close this issue for now but I'm definitely open to continuing the discussion with potential solution ideas 🙂

@nandorojo
Copy link
Author

Makes sense. In my opinion, this is one of the differences with RN and React DOM — you interact directly with components instead of with markdown-based elements. The ideal situation would be for tree shaking to work, even with strings 🤷‍♂️ oh well, thanks again!

@nandorojo
Copy link
Author

One other idea: you could have a separate import (like stitches-native/universal) which exports all the same stuff, but whose styled function doesn't support strings. That way, if you import from there, you only get the tree shaken API. It could work using the exports field in package.json, similar to swr/infinite in the swr library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants