Skip to content

Commit

Permalink
feat(styled): add esm support
Browse files Browse the repository at this point in the history
It fixes ##3601
  • Loading branch information
gregberge committed Dec 22, 2021
1 parent 36f8bdb commit a080d96
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/styled-components/src/createStyled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import scStyled, {
} from 'styled-components'
import { createCssFunction, XCSSFunction } from './createCssFunction'

const scStyledInterop =
// @ts-ignore
typeof scStyled === 'function' ? scStyled : scStyled.default

const getCreateStyle = (
baseCreateStyle: ThemedStyledFunction<any, any>,
css: XCSSFunction,
Expand Down Expand Up @@ -76,7 +80,7 @@ export const createBaseStyled = <TGen extends StyleGenerator>(
}
: {}
return ((component: Parameters<typeof scStyled>[0]) => {
const baseStyled = scStyled(component)
const baseStyled = scStyledInterop(component)
return getCreateStyle(
config ? baseStyled.withConfig(config) : baseStyled,
css,
Expand All @@ -92,7 +96,7 @@ export const createStyled = <TGen extends StyleGenerator>(
const styled = createBaseStyled(css)
const xstyled = createBaseStyled(css, generator)
styled.box = xstyled('div')
Object.keys(scStyled).forEach((key) => {
Object.keys(scStyledInterop).forEach((key) => {
// @ts-ignore
styled[key] = styled(key)
// @ts-ignore
Expand Down

0 comments on commit a080d96

Please sign in to comment.