babel-plugin-styled-components icon indicating copy to clipboard operation
babel-plugin-styled-components copied to clipboard

moduleName option

Open gabiseabra opened this issue 7 years ago • 3 comments

Hey. This plugin only works with styled-components, not other packages that export an object with the same interface. I know there aren't many, but this is causing issues with ssr in styled-transition-group (a package I made). Here's the issue for reference https://github.com/gabiseabra/styled-transition-group/issues/2 Would you be accepting a PR adding an "id" option like babel-plugin-lodash's?

gabiseabra avatar Jan 22 '18 02:01 gabiseabra

The only thing that'd have to change is this line I think:

https://github.com/styled-components/babel-plugin-styled-components/blob/856419ba16a5a5002fa60bfe024ae1a3e7b59fac/src/utils/detectors.js#L11

The option should be called moduleName in order to stay consistent with the stylelint-processor options. (ref PR https://github.com/styled-components/stylelint-processor-styled-components/pull/112)

I'm very open to a PR implementing that option! :100:

mxstbr avatar Jan 22 '18 08:01 mxstbr

@mxstbr I think I've mentioned it before, and this is a tricky one 😢; The ISTF/Sweetsour project will require some strict targeting that involves targeting all kinds of tagged template literals, so stuff like our media helper won't work anymore, and we can provide a "plugin factory" to make this check more lenient; However, what would be more scalable would be to use the css helpers.

@gabiseabra For you as an author this means, that transition.div(css()) would always continue to work for every future version of this plugin or styled-components, and that'd be guaranteed. So I'd advise you to support this either way for now

kitten avatar Jan 22 '18 11:01 kitten

@philpl Hey, I'm using the styled constructor to keep consistency and generating regular styled-components inside the constructWithOptions function. I don't recall ever having problems with the css helper, but I'm refactoring and my approach has changed now that styled-components won't ship with the lib folder anymore. I do intend to keep the interface as close as possible to the original. Thanks.

gabiseabra avatar Jan 23 '18 16:01 gabiseabra