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

rewrite styled import to "no tags" entry #150

Merged
merged 5 commits into from
Aug 21, 2018
Merged

rewrite styled import to "no tags" entry #150

merged 5 commits into from
Aug 21, 2018

Conversation

quantizor
Copy link
Collaborator

@quantizor quantizor commented Aug 12, 2018

*/
export default path => {
if (path.node.source.value === 'styled-components') {
path.node.source = t.stringLiteral('styled-components/no-tags')
Copy link
Member

@kitten kitten Aug 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means though that we’re currently breaking styled-components/native and /primitives if we’d merge this and this starts being on by default?

Nevermind, reviewing on mobile sucks

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think as of right now it would only break styled-components/native due to the implicit resolution from https://github.com/styled-components/styled-components/blob/f401eda35ef16065509ea8a7375290fb8b5858a6/package.json#L9

Maybe we should remove that and just have people do this again

import styled from 'styled-components/native'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems safer overall and less prone to bundler wonkiness

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@probablyup yea, sorry, the comment was half-baked anyway.

I’m not sure whether we should be going back on that change or not. Currently I’m even thinking tempting people to use universal switches by suggesting it ourselves is bad.

The reality is React Native and Web are extremely different and shared styles should be explicit and mindful. So we should probably deprecate it again. The alternative would be to add a no-tags.native.js to the index to fix it up automatically, which I think is a neat compromise for now.

Long term the RN library should maybe even be separate from styles-components tbh. API-parity is important, sure, but I’d rather have RN specific changes and a playground there and port stuff manually.

cc @mxstbr

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-tags.native.js

Yeah I can definitely do that. I'm 50/50 on what to do about native in general. Keeping it in the same repo definitely helps keep the API in sync, but it's true that how it works is so very different.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah honestly we should probably revert that change 😕 It's just made typing impossible and I don't think we should encourage that usage...

mxstbr
mxstbr previously requested changes Aug 19, 2018
Copy link
Member

@mxstbr mxstbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that the tagless calls don't have the attribute whitelist, right? I think styled('button') doesn't filter attributes, while styled.button will—meaning we shouldn't be doing this automatically from the Babel plugin since it will break things?!

@quantizor
Copy link
Collaborator Author

quantizor commented Aug 19, 2018 via email

@mxstbr mxstbr dismissed their stale review August 20, 2018 07:05

Oh shit you're right, nevermind: https://codesandbox.io/s/82w3xoj3x9

@kitten
Copy link
Member

kitten commented Aug 20, 2018

@probablyup @mxstbr yea, I think it just checks whether the target is a string. I don’t think any constructWithOptions path has knowledge of whether it was called from a shorthand.

Copy link
Member

@mxstbr mxstbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM

@quantizor quantizor merged commit 48bd359 into master Aug 21, 2018
@quantizor quantizor deleted the rewrite-import branch August 21, 2018 05:46
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

Successfully merging this pull request may close these issues.

3 participants