Skip to content

Commit 9916d74

Browse files
committed
u
1 parent c78e295 commit 9916d74

File tree

1 file changed

+35
-30
lines changed

1 file changed

+35
-30
lines changed

src/docs/guide/usage/transformer.md

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ const result = transform("App.jsx", sourceCode, {
5454

5555
#### Configuration Options
5656

57-
| Option | Type | Default | Description |
58-
|--------|------|---------|-------------|
59-
| `refreshReg` | `string` | `"$RefreshReg$"` | The name of the function to register components for refresh |
60-
| `refreshSig` | `string` | `"$RefreshSig$"` | The name of the function to create signatures for refresh |
61-
| `emitFullSignatures` | `boolean` | `false` | Whether to emit full signatures for better debugging |
57+
| Option | Type | Default | Description |
58+
| -------------------- | --------- | ---------------- | ----------------------------------------------------------- |
59+
| `refreshReg` | `string` | `"$RefreshReg$"` | The name of the function to register components for refresh |
60+
| `refreshSig` | `string` | `"$RefreshSig$"` | The name of the function to create signatures for refresh |
61+
| `emitFullSignatures` | `boolean` | `false` | Whether to emit full signatures for better debugging |
6262

6363
### Styled Components
6464

@@ -84,8 +84,9 @@ const result = transform("Component.jsx", sourceCode, {
8484
#### Example
8585

8686
**Input:**
87+
8788
```jsx
88-
import styled from 'styled-components';
89+
import styled from "styled-components";
8990

9091
const Button = styled.div`
9192
color: blue;
@@ -94,69 +95,71 @@ const Button = styled.div`
9495
```
9596

9697
**Output (with default options):**
98+
9799
```jsx
98-
import styled from 'styled-components';
100+
import styled from "styled-components";
99101

100102
const Button = styled.div.withConfig({
101103
displayName: "Button",
102-
componentId: "sc-1234567-0"
104+
componentId: "sc-1234567-0",
103105
})(["color:blue;padding:10px;"]);
104106
```
105107

106108
#### Configuration Options
107109

108110
##### Core Options
109111

110-
| Option | Type | Default | Description |
111-
|--------|------|---------|-------------|
112-
| `displayName` | `boolean` | `true` | Enhances the attached CSS class name with component names for easier debugging |
113-
| `ssr` | `boolean` | `true` | Adds unique component IDs to avoid checksum mismatches during server-side rendering |
114-
| `fileName` | `boolean` | `true` | Controls whether the displayName is prefixed with the filename |
112+
| Option | Type | Default | Description |
113+
| ------------- | --------- | ------- | ----------------------------------------------------------------------------------- |
114+
| `displayName` | `boolean` | `true` | Enhances the attached CSS class name with component names for easier debugging |
115+
| `ssr` | `boolean` | `true` | Adds unique component IDs to avoid checksum mismatches during server-side rendering |
116+
| `fileName` | `boolean` | `true` | Controls whether the displayName is prefixed with the filename |
115117

116118
##### Template Literal Options
117119

118-
| Option | Type | Default | Description |
119-
|--------|------|---------|-------------|
120-
| `transpileTemplateLiterals` | `boolean` | `true` | Converts template literals to a smaller representation for reduced bundle size |
121-
| `minify` | `boolean` | `true` | Minifies CSS content by removing whitespace and comments |
120+
| Option | Type | Default | Description |
121+
| --------------------------- | --------- | ------- | ------------------------------------------------------------------------------ |
122+
| `transpileTemplateLiterals` | `boolean` | `true` | Converts template literals to a smaller representation for reduced bundle size |
123+
| `minify` | `boolean` | `true` | Minifies CSS content by removing whitespace and comments |
122124

123125
##### Advanced Options
124126

125-
| Option | Type | Default | Description |
126-
|--------|------|---------|-------------|
127-
| `pure` | `boolean` | `false` | Adds `/*#__PURE__*/` comments for better tree-shaking |
128-
| `namespace` | `string` | `undefined` | Adds a namespace prefix to component IDs |
127+
| Option | Type | Default | Description |
128+
| ---------------------- | ---------- | ----------- | ------------------------------------------------------------- |
129+
| `pure` | `boolean` | `false` | Adds `/*#__PURE__*/` comments for better tree-shaking |
130+
| `namespace` | `string` | `undefined` | Adds a namespace prefix to component IDs |
129131
| `meaninglessFileNames` | `string[]` | `["index"]` | List of filenames considered meaningless for component naming |
130132

131133
##### Not Yet Implemented
132134

133-
| Option | Type | Default | Description |
134-
|--------|------|---------|-------------|
135-
| `cssProp` | `boolean` | `true` | JSX css prop transformation (planned) |
136-
| `topLevelImportPaths` | `string[]` | `[]` | Custom import path handling (planned) |
135+
| Option | Type | Default | Description |
136+
| --------------------- | ---------- | ------- | ------------------------------------- |
137+
| `cssProp` | `boolean` | `true` | JSX css prop transformation (planned) |
138+
| `topLevelImportPaths` | `string[]` | `[]` | Custom import path handling (planned) |
137139

138140
#### Supported Import Patterns
139141

140142
The plugin works with various styled-components import patterns:
141143

142144
```javascript
143145
// Default import
144-
import styled from 'styled-components';
146+
import styled from "styled-components";
145147

146148
// Namespace import
147-
import * as styled from 'styled-components';
149+
import * as styled from "styled-components";
148150

149151
// Named imports
150-
import { css, createGlobalStyle, keyframes } from 'styled-components';
152+
import { createGlobalStyle, css, keyframes } from "styled-components";
151153

152154
// Native and primitives
153-
import styled from 'styled-components/native';
154-
import styled from 'styled-components/primitives';
155+
import styled from "styled-components/native";
156+
import styled from "styled-components/primitives";
155157
```
156158

157159
#### Features
158160

159161
**✅ Fully Supported:**
162+
160163
- Display names for debugging
161164
- Filename prefixing in display names
162165
- Server-side rendering support
@@ -166,9 +169,11 @@ import styled from 'styled-components/primitives';
166169
- Pure annotations for call expressions
167170

168171
**⚠️ Partially Supported:**
172+
169173
- Pure annotations (call expressions only, not tagged templates due to bundler limitations)
170174

171175
**❌ Not Yet Implemented:**
176+
172177
- JSX css prop transformation
173178
- Custom import path handling
174179

0 commit comments

Comments
 (0)