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

feat: macro can customize importModuleName #3422

Merged

Conversation

agriffis
Copy link
Contributor

@agriffis agriffis commented Mar 6, 2021

If styled should come from a wrapper instead of directly from
styled-components, this enables users of the macro to customize the
import by configuring in packages.json:

"babelMacros": {
  "styledComponents": {
    "importModuleName": "my-styled-components"
  }
}

Previously similar functionality landed in
babel-plugin-styled-components so users of the plugin could use
a wrapper at that level, but it wasn't available to users of the macro.
This builds on that work by passing the customized module name through
to the plugin. Consequently we also update the dependency to ensure the
plugin supports topLevelImportPaths

See styled-components/babel-plugin-styled-components@325167b

Fixes styled-components/xstyled#44

@@ -66,7 +66,7 @@
"@babel/traverse": "^7.4.5",
"@emotion/is-prop-valid": "^0.8.8",
"@emotion/unitless": "^0.7.4",
"babel-plugin-styled-components": ">= 1",
"babel-plugin-styled-components": "^1.12.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to continue using the >= notation so we don't have to update the library here if v2 comes out that doesn't contain incompatible changes with styled-components core

Copy link
Contributor Author

Choose a reason for hiding this comment

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

np, will force push that change

Copy link
Contributor

@quantizor quantizor left a comment

Choose a reason for hiding this comment

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

Code looks great to me! If you could make that one change and write up a short changelog entry, that would be much appreciated.

@agriffis agriffis force-pushed the feat/macro-importModuleName branch from c1aaffb to 18d8c32 Compare March 10, 2021 17:03
If `styled` should come from a wrapper instead of directly from
styled-components, this enables users of the macro to customize the
import by configuring in `packages.json`:

    "babelMacros": {
      "styledComponents": {
        "importModuleName": "my-styled-components"
      }
    }

Previously similar functionality landed in
babel-plugin-styled-components so users of the plugin could use
a wrapper at that level, but it wasn't available to users of the macro.
This builds on that work by passing the customized module name through
to the plugin. Consequently we also update the dependency to ensure the
plugin supports `topLevelImportPaths`

See styled-components/babel-plugin-styled-components@325167b

Fixes styled-components/xstyled#44
@agriffis agriffis force-pushed the feat/macro-importModuleName branch from 18d8c32 to 83c8b0c Compare March 10, 2021 17:06
@agriffis
Copy link
Contributor Author

@probablyup That should be all set now. I force-pushed twice because I hadn't run yarn the first time, so yarn.lock wasn't updated.

Would you mind cherry-picking this to legacy-v5? Or do you prefer another PR?

@quantizor
Copy link
Contributor

@probablyup That should be all set now. I force-pushed twice because I hadn't run yarn the first time, so yarn.lock wasn't updated.

Would you mind cherry-picking this to legacy-v5? Or do you prefer another PR?

Another PR please

@quantizor quantizor merged commit cc08c23 into styled-components:master Mar 10, 2021
@agriffis
Copy link
Contributor Author

Another PR please

See #3432, thanks!

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.

Babel Macros - not working
2 participants