Skip to content

Releases: styled-components/babel-plugin-styled-components

v2.3.0

Choose a tag to compare

@github-actions github-actions released this 21 May 02:04
ab3aaf5

Minor Changes

  • 0c5f21d: Add a cssPropImportPath option to control which package the css-prop transform auto-imports styled from when the file has no existing styled import. Defaults to 'styled-components' (existing behavior). React Native targets can set it to 'styled-components/native' so the auto-injected import resolves to the right runtime.
  • 0c5f21d: Detect styled declarations that go through a local alias of the import, including the TypeScript theme-typing pattern const styled = baseStyled as ThemedStyledInterface<MyTheme>. After type-stripping Babel sees a plain const styled = baseStyled, and the detector now follows single-identifier alias chains so styled.div resolves back to the original import.

Patch Changes

  • 0c5f21d: Fix invalid output when a css={{ ... }} object key matches a local binding name (e.g. ({ position }) => <div css={{ position: 'absolute' }} />). The reducer no longer mis-treats non-computed property names as scope references, so plain keys stay literal while only computed [expr] keys are extracted as prop interpolations.
  • 0c5f21d: Recognize TypeScript's __importDefault interop helper alongside Babel's _interopRequireDefault. Files compiled through tsc / ts-jest (which emit var sc_1 = __importDefault(require('styled-components'))) now flow into the same detection path as Babel-compiled output, so styled declarations downstream pick up displayName and componentId as expected.

v2.2.0

Choose a tag to compare

@github-actions github-actions released this 20 May 23:17
d0add03

Minor Changes

  • a40e3f7: Refresh the toolchain and fix a handful of css-prop transform bugs that had crept in under recent Babel versions.
    • When a file already imports styled and also uses one or more css={…} props, every styled component now keeps its display name and stable component id. Previously the cache that tracks the local default import could be overwritten on each css-prop usage, which silently dropped the display name and id for the surrounding styled.div declarations.
    • css={{ [foo]: bar }} with a non-primitive value no longer fails Babel's validator. Computed keys are preserved through the css-prop object rewrite.
    • Friendlier error messages when the css-prop transform encounters a JSX name shape it can't infer, instead of a confusing internal ReferenceError.
    • Long-running watch processes (Next dev, webpack-dev-server, jest watch) no longer leak import-detection state between files.
    • Removed the runtime lodash dependency. The plugin now ships with @babel/core as a declared peer.
    • Dev tooling moved to pnpm and changesets. Plugin behavior is unchanged.

v2.1.4

Choose a tag to compare

@quantizor quantizor released this 23 Jun 19:14
  • Bump ansi-regex from 5.0.0 to 5.0.1 by @dependabot in #391
  • migrate off an EOL babel package

Full Changelog: v2.1.3...v2.1.4

v2.1.3

Choose a tag to compare

@quantizor quantizor released this 19 May 03:25

What's Changed

New Contributors

Full Changelog: v2.1.1...v2.1.3

v2.1.1

Choose a tag to compare

@quantizor quantizor released this 06 Apr 01:58

What's Changed

New Contributors

Full Changelog: v2.0.7...v2.1.1

v2.0.7

Choose a tag to compare

@quantizor quantizor released this 07 Apr 13:44

What's Changed

New Contributors

Full Changelog: v2.0.6...v2.0.7

v2.0.6

Choose a tag to compare

@quantizor quantizor released this 25 Feb 14:12

Revert change from 2.0.5 that lead to a major build performance regression.

Full Changelog: v2.0.5...v2.0.6

v2.0.5

Choose a tag to compare

@quantizor quantizor released this 22 Feb 21:34

One more change related to babel macro; eliminates an extra injected import in some cases

Full Changelog: v2.0.4...v2.0.5

v2.0.4

Choose a tag to compare

@quantizor quantizor released this 22 Feb 20:27

fix compat with styled-components babel macro

Full Changelog: v2.0.3...v2.0.4

v2.0.3

Choose a tag to compare

@quantizor quantizor released this 18 Feb 17:59

What's Changed

Full Changelog: v2.0.2...v2.0.3