Releases: styled-components/babel-plugin-styled-components
Releases · styled-components/babel-plugin-styled-components
Release list
v2.3.0
Minor Changes
- 0c5f21d: Add a
cssPropImportPathoption to control which package the css-prop transform auto-importsstyledfrom 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 plainconst styled = baseStyled, and the detector now follows single-identifier alias chains sostyled.divresolves 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
__importDefaultinterop helper alongside Babel's_interopRequireDefault. Files compiled throughtsc/ts-jest(which emitvar sc_1 = __importDefault(require('styled-components'))) now flow into the same detection path as Babel-compiled output, so styled declarations downstream pick updisplayNameandcomponentIdas expected.
v2.2.0
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
styledand also uses one or morecss={…}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 surroundingstyled.divdeclarations. 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
lodashdependency. The plugin now ships with@babel/coreas a declared peer. - Dev tooling moved to pnpm and changesets. Plugin behavior is unchanged.
- When a file already imports
v2.1.4
- 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
What's Changed
- When testing import paths, only use string literals. by @maisano-patreon in #389
- chore: update babel deps and jest (911fc09)
New Contributors
- @maisano-patreon made their first contribution in #389
Full Changelog: v2.1.1...v2.1.3
v2.1.1
What's Changed
- Add tricky expression on object expression by @healtheloper in #381
- bump codeql GH Action to v2 by @dmaklygin in #383
- Support pre-transpiled code (#379) by @rbong in #380
- Bump minimatch from 3.0.4 to 3.1.2 by @dependabot in #385
- Bump minimist from 1.2.5 to 1.2.8 by @dependabot in #384
- updated lodash from 4.17.11 to 4.17.21 by @FatemehOstad in #378
- chore: yarn 3 by @probablyup in #386
- Bump json5 from 2.2.0 to 2.2.3 by @dependabot in #382
New Contributors
- @healtheloper made their first contribution in #381
- @dmaklygin made their first contribution in #383
- @rbong made their first contribution in #380
- @FatemehOstad made their first contribution in #378
Full Changelog: v2.0.7...v2.1.1
v2.0.7
v2.0.6
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
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
fix compat with styled-components babel macro
Full Changelog: v2.0.3...v2.0.4