@typestyles/migrate 0.0.0-unstable.dc32065699a4 → 0.0.0-unstable.dce5dc80213a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -17
- package/dist/cli.cjs +56 -950
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +57 -59
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +4 -897
- package/dist/index.d.cts +32 -27
- package/dist/index.d.ts +32 -27
- package/dist/index.js +1 -3
- package/dist/migrate-B3MfAQI5.cjs +728 -0
- package/dist/migrate-B3MfAQI5.cjs.map +1 -0
- package/dist/migrate-DUG0GWWo.js +689 -0
- package/dist/migrate-DUG0GWWo.js.map +1 -0
- package/package.json +13 -15
- package/dist/chunk-D2W3OEBT.js +0 -868
- package/dist/chunk-D2W3OEBT.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @typestyles/migrate
|
|
2
2
|
|
|
3
|
-
CLI codemods for migrating from **styled-components** and **Emotion** to [typestyles](https://github.com/
|
|
3
|
+
CLI codemods for migrating from **styled-components** and **Emotion** to [typestyles](https://github.com/phthalo-dev/typestyles).
|
|
4
4
|
|
|
5
5
|
Moving off runtime CSS-in-JS is often the hardest part of adopting typestyles. This package automates the boring, safe transforms so you can focus on prop-based dynamics (`createVar` / `assignVars`) and design tokens — the parts that need human judgment.
|
|
6
6
|
|
|
@@ -8,18 +8,18 @@ Full migration guide: [typestyles.dev/docs/migration](https://typestyles.dev/doc
|
|
|
8
8
|
|
|
9
9
|
## What it transforms
|
|
10
10
|
|
|
11
|
-
| Source | Becomes
|
|
12
|
-
| ----------------------------------- |
|
|
13
|
-
| `styled.div\`...\`` | `
|
|
14
|
-
| `styled(Button)\`...\`` | `
|
|
15
|
-
| `` css`...` `` (Emotion) | `
|
|
16
|
-
| Static template literals | CSS object properties (via PostCSS parser)
|
|
17
|
-
| `` `${props => props.x}` `` | `createVar` + `assignVars` + `
|
|
18
|
-
| `` `${props => props.x ? A : B}` `` | `
|
|
19
|
-
| `` `${({ x }) => x}` `` | `createVar` + `assignVars` (destructured params)
|
|
20
|
-
| `@media` in templates | Nested `'@media (…)'` objects in style definitions
|
|
11
|
+
| Source | Becomes |
|
|
12
|
+
| ----------------------------------- | -------------------------------------------------- |
|
|
13
|
+
| `styled.div\`...\`` | `style('div', { ... })` + `className` on JSX |
|
|
14
|
+
| `styled(Button)\`...\`` | `style('button', { ... })` + `className` |
|
|
15
|
+
| `` css`...` `` (Emotion) | `style(...)` |
|
|
16
|
+
| Static template literals | CSS object properties (via PostCSS parser) |
|
|
17
|
+
| `` `${props => props.x}` `` | `createVar` + `assignVars` + `style` |
|
|
18
|
+
| `` `${props => props.x ? A : B}` `` | `recipe` variants + JSX rewrite |
|
|
19
|
+
| `` `${({ x }) => x}` `` | `createVar` + `assignVars` (destructured params) |
|
|
20
|
+
| `@media` in templates | Nested `'@media (…)'` objects in style definitions |
|
|
21
21
|
|
|
22
|
-
The codemod rewrites JSX usage for styled components it can safely transform and adds
|
|
22
|
+
The codemod rewrites JSX usage for styled components it can safely transform and adds `createTypeStyles` plus a `style` binding when needed (`import { createTypeStyles } from 'typestyles'`).
|
|
23
23
|
|
|
24
24
|
## What it skips (with warnings)
|
|
25
25
|
|
|
@@ -29,7 +29,7 @@ Honest automation beats silent breakage:
|
|
|
29
29
|
- **Exported styled components** — avoids changing your public API shape without review
|
|
30
30
|
- **Non-JSX references** to styled component variables
|
|
31
31
|
|
|
32
|
-
Prop-based patterns like `` `${props => props.color}` `` and `` `${(props) => props.width}px` `` are converted to [`createVar` + `assignVars`](https://typestyles.dev/docs/dynamic-styles). Boolean prop ternaries like `` `${props => props.primary ? '#0066ff' : '#6b7280'}` `` become `
|
|
32
|
+
Prop-based patterns like `` `${props => props.color}` `` and `` `${(props) => props.width}px` `` are converted to [`createVar` + `assignVars`](https://typestyles.dev/docs/dynamic-styles). Boolean prop ternaries like `` `${props => props.primary ? '#0066ff' : '#6b7280'}` `` become `recipe` variants. Suffix text after the interpolation (e.g. `px`) is applied at the call site.
|
|
33
33
|
|
|
34
34
|
## Installation
|
|
35
35
|
|
|
@@ -107,9 +107,11 @@ export function App() {
|
|
|
107
107
|
**After:**
|
|
108
108
|
|
|
109
109
|
```tsx
|
|
110
|
-
import {
|
|
110
|
+
import { createTypeStyles } from 'typestyles';
|
|
111
111
|
|
|
112
|
-
const
|
|
112
|
+
const { style } = createTypeStyles();
|
|
113
|
+
|
|
114
|
+
const button = style('button', {
|
|
113
115
|
padding: '8px 16px',
|
|
114
116
|
background: '#0066ff',
|
|
115
117
|
color: 'white',
|
|
@@ -124,7 +126,7 @@ export function App() {
|
|
|
124
126
|
}
|
|
125
127
|
```
|
|
126
128
|
|
|
127
|
-
For components with variants, follow up manually with `
|
|
129
|
+
For components with variants, follow up manually with `recipe()` — see the [styled-components migration section](https://typestyles.dev/docs/migration#from-styled-components). Consider `createTypeStyles({ scopeId: 'your-app' })` for production apps.
|
|
128
130
|
|
|
129
131
|
## Programmatic API
|
|
130
132
|
|
|
@@ -150,7 +152,7 @@ await runMigration(process.cwd(), {
|
|
|
150
152
|
1. **Dry-run** on a branch and review diffs
|
|
151
153
|
2. **Fix warnings** — convert dynamic templates to vars or inline styles
|
|
152
154
|
3. **Apply with `--write`**
|
|
153
|
-
4. **Refactor** repeated `
|
|
155
|
+
4. **Refactor** repeated `style()` calls into `recipe()` with variants
|
|
154
156
|
5. **Add tokens** — replace hard-coded colors/spacing with `tokens.create`
|
|
155
157
|
6. **Enable extraction** — add `@typestyles/vite` or your bundler plugin for production zero-runtime
|
|
156
158
|
|