@alex.radulescu/styled-static 0.2.0

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/dist/vite.js ADDED
@@ -0,0 +1,395 @@
1
+ /**
2
+ * styled-static Vite Plugin
3
+ *
4
+ * Transforms styled-static syntax into optimized React components with
5
+ * static CSS extraction.
6
+ *
7
+ * ## Why AST over Regex?
8
+ *
9
+ * We use Vite's built-in parser (via Rollup's acorn) instead of regex because:
10
+ *
11
+ * 1. **Robustness**: Regex breaks on edge cases like CSS containing backticks,
12
+ * strings that look like styled calls, or complex nesting.
13
+ *
14
+ * Example that would break regex:
15
+ * ```tsx
16
+ * const x = styled.div`content: "styled.button\`test\`";`;
17
+ * const comment = "// styled.div`fake`"; // This isn't actually a styled call
18
+ * ```
19
+ *
20
+ * 2. **No extra dependencies**: Vite provides `this.parse()` for free via Rollup.
21
+ * We don't need acorn or acorn-walk as separate dependencies.
22
+ *
23
+ * 3. **Accuracy**: AST gives us exact node positions for surgical code replacement
24
+ * with proper source maps. Regex can't reliably handle nested backticks or
25
+ * escaped characters.
26
+ *
27
+ * 4. **Maintainability**: Adding new syntax patterns is straightforward with AST
28
+ * visitors vs. increasingly complex regex patterns that become unmaintainable.
29
+ *
30
+ * ## Transformation Pipeline
31
+ *
32
+ * 1. Parse source with Vite's parser
33
+ * 2. Find all styled/css/createGlobalStyle tagged template literals
34
+ * 3. For each:
35
+ * - Extract CSS content
36
+ * - Hash it to generate unique class name
37
+ * - Process CSS (nesting, autoprefixer)
38
+ * - Create virtual CSS module
39
+ * - Replace original code with runtime call + import
40
+ * 4. Return transformed code with source map
41
+ *
42
+ * ## className Order (CSS Cascade)
43
+ *
44
+ * When components are extended, classes are ordered for proper cascade:
45
+ * - Base styles first
46
+ * - Extension styles second (override base)
47
+ * - User className last (override all)
48
+ *
49
+ * Example:
50
+ * ```tsx
51
+ * const Button = styled.button`padding: 1rem;`; // .ss-abc
52
+ * const Primary = styled(Button)`background: blue;`; // .ss-def
53
+ * <Primary className="custom" />
54
+ * // Renders: class="ss-abc ss-def custom"
55
+ * // CSS cascade: padding → background → custom overrides
56
+ * ```
57
+ */
58
+ import MagicString from "magic-string";
59
+ import postcss from "postcss";
60
+ import postcssNested from "postcss-nested";
61
+ import autoprefixer from "autoprefixer";
62
+ import { hash } from "./hash.js";
63
+ // ============================================================================
64
+ // Plugin
65
+ // ============================================================================
66
+ /**
67
+ * Vite plugin for styled-static.
68
+ *
69
+ * @example
70
+ * import { defineConfig } from 'vite';
71
+ * import react from '@vitejs/plugin-react';
72
+ * import { styledStatic } from 'styled-static/vite';
73
+ *
74
+ * export default defineConfig({
75
+ * plugins: [styledStatic(), react()],
76
+ * });
77
+ */
78
+ export function styledStatic(options = {}) {
79
+ const { classPrefix = "ss", autoprefixer: autoprefixerOption = [
80
+ "last 2 Chrome versions",
81
+ "last 2 Firefox versions",
82
+ "last 2 Safari versions",
83
+ "last 2 Edge versions",
84
+ ], } = options;
85
+ // Virtual CSS modules: filename -> CSS content
86
+ const cssModules = new Map();
87
+ let config;
88
+ let isDev = false;
89
+ return {
90
+ name: "styled-static",
91
+ enforce: "pre", // Run before other plugins (especially React)
92
+ configResolved(resolvedConfig) {
93
+ config = resolvedConfig;
94
+ isDev = config.command === "serve";
95
+ },
96
+ // Resolve virtual CSS module IDs
97
+ resolveId(id) {
98
+ // Handle the virtual module prefix
99
+ if (id.startsWith("\0styled-static:")) {
100
+ return id;
101
+ }
102
+ // Handle imports without the \0 prefix (from our generated code)
103
+ if (id.startsWith("styled-static:")) {
104
+ return "\0" + id;
105
+ }
106
+ return null;
107
+ },
108
+ // Load virtual CSS module content
109
+ load(id) {
110
+ if (id.startsWith("\0styled-static:")) {
111
+ const filename = id.slice("\0styled-static:".length);
112
+ return cssModules.get(filename) ?? "";
113
+ }
114
+ return null;
115
+ },
116
+ // Handle HMR for virtual CSS modules
117
+ handleHotUpdate({ file, server }) {
118
+ // When a source file changes, the transform will re-run
119
+ // and update cssModules. We just need to invalidate any
120
+ // cached virtual modules.
121
+ if (/\.[tj]sx?$/.test(file)) {
122
+ // Invalidate all virtual CSS modules from this file
123
+ const fileHash = hash(normalizePath(file)).slice(0, 6);
124
+ for (const [name] of cssModules) {
125
+ if (name.startsWith(fileHash)) {
126
+ const mod = server.moduleGraph.getModuleById(`\0styled-static:${name}`);
127
+ if (mod) {
128
+ server.moduleGraph.invalidateModule(mod);
129
+ }
130
+ }
131
+ }
132
+ }
133
+ },
134
+ async transform(code, id) {
135
+ // Only process .tsx/.jsx/.ts/.js files, skip node_modules
136
+ if (!/\.[tj]sx?$/.test(id) || /node_modules/.test(id)) {
137
+ return null;
138
+ }
139
+ // Quick check: does file import from styled-static?
140
+ if (!code.includes("styled-static")) {
141
+ return null;
142
+ }
143
+ console.log("[styled-static] Transforming:", id);
144
+ // Parse AST using Vite's built-in parser
145
+ let ast;
146
+ try {
147
+ ast = this.parse(code);
148
+ console.log("[styled-static] AST parsed successfully, body length:", ast.body.length);
149
+ }
150
+ catch (e) {
151
+ // Parse error - this might be a partial file or syntax error
152
+ console.log("[styled-static] AST parse error:", e);
153
+ return null;
154
+ }
155
+ // Find styled-static imports and their local names
156
+ const imports = findStyledStaticImports(ast);
157
+ console.log("[styled-static] Found imports:", imports);
158
+ if (!imports.css && !imports.styled && !imports.createGlobalStyle) {
159
+ console.log("[styled-static] No imports found, skipping");
160
+ return null;
161
+ }
162
+ // Find all tagged template literals using our imports
163
+ const templates = findTaggedTemplates(ast, imports);
164
+ console.log("[styled-static] Found templates:", templates.length);
165
+ if (templates.length === 0) {
166
+ console.log("[styled-static] No templates found, skipping");
167
+ return null;
168
+ }
169
+ const s = new MagicString(code);
170
+ const fileHash = hash(normalizePath(id)).slice(0, 6);
171
+ const cssImports = [];
172
+ let needsStyledRuntime = false;
173
+ let needsExtendRuntime = false;
174
+ let needsGlobalRuntime = false;
175
+ for (let i = 0; i < templates.length; i++) {
176
+ const t = templates[i];
177
+ if (!t)
178
+ continue; // Guard against undefined (noUncheckedIndexedAccess)
179
+ const cssContent = extractTemplateContent(code, t.node.quasi);
180
+ const cssHash = hash(cssContent).slice(0, 6);
181
+ const className = `${classPrefix}-${cssHash}`;
182
+ // Process CSS
183
+ const processedCss = await processCSS(cssContent, className, t.type === "createGlobalStyle", autoprefixerOption);
184
+ // Create virtual CSS module
185
+ const cssFilename = `${fileHash}-${i}.css`;
186
+ cssModules.set(cssFilename, processedCss);
187
+ cssImports.push(`import "styled-static:${cssFilename}";`);
188
+ // Generate replacement code and track runtime needs
189
+ const replacement = generateReplacement(t, className, isDev);
190
+ s.overwrite(t.node.start, t.node.end, replacement);
191
+ if (t.type === "styled")
192
+ needsStyledRuntime = true;
193
+ if (t.type === "styledExtend")
194
+ needsExtendRuntime = true;
195
+ if (t.type === "createGlobalStyle")
196
+ needsGlobalRuntime = true;
197
+ }
198
+ // Build runtime imports
199
+ const runtimeImports = [];
200
+ if (needsStyledRuntime)
201
+ runtimeImports.push("__styled");
202
+ if (needsExtendRuntime)
203
+ runtimeImports.push("__styledExtend");
204
+ if (needsGlobalRuntime)
205
+ runtimeImports.push("__GlobalStyle");
206
+ // Prepend imports (CSS first, then runtime)
207
+ let prepend = "";
208
+ if (cssImports.length > 0) {
209
+ prepend += cssImports.join("\n") + "\n";
210
+ }
211
+ if (runtimeImports.length > 0) {
212
+ prepend += `import { ${runtimeImports.join(", ")} } from "styled-static/runtime";\n`;
213
+ }
214
+ if (prepend) {
215
+ s.prepend(prepend);
216
+ }
217
+ return {
218
+ code: s.toString(),
219
+ map: s.generateMap({ hires: true }),
220
+ };
221
+ },
222
+ };
223
+ }
224
+ // ============================================================================
225
+ // AST Helpers
226
+ // ============================================================================
227
+ /**
228
+ * Find all imports from 'styled-static' and return their local names.
229
+ * Handles aliased imports like `import { styled as s } from 'styled-static'`
230
+ */
231
+ function findStyledStaticImports(ast) {
232
+ const imports = {};
233
+ for (const node of ast.body) {
234
+ if (node.type === "ImportDeclaration" &&
235
+ node.source.value === "styled-static") {
236
+ for (const spec of node.specifiers) {
237
+ if (spec.type === "ImportSpecifier") {
238
+ const imported = spec.imported.name;
239
+ const local = spec.local.name;
240
+ if (imported === "styled")
241
+ imports.styled = local;
242
+ if (imported === "css")
243
+ imports.css = local;
244
+ if (imported === "createGlobalStyle")
245
+ imports.createGlobalStyle = local;
246
+ }
247
+ }
248
+ }
249
+ }
250
+ return imports;
251
+ }
252
+ /**
253
+ * Find all tagged template literals that use styled-static imports.
254
+ * Walks the AST to find variable declarations with our tagged templates.
255
+ */
256
+ function findTaggedTemplates(ast, imports) {
257
+ const results = [];
258
+ /**
259
+ * Process a variable declaration that might contain a styled template
260
+ */
261
+ function processVariableDeclaration(node) {
262
+ for (const decl of node.declarations) {
263
+ if (decl.init?.type === "TaggedTemplateExpression" &&
264
+ decl.id.type === "Identifier") {
265
+ const template = decl.init;
266
+ const varName = decl.id.name;
267
+ const found = classifyTemplate(template, imports, varName);
268
+ if (found)
269
+ results.push(found);
270
+ }
271
+ }
272
+ }
273
+ for (const node of ast.body) {
274
+ // Regular variable declaration: const X = styled.div`...`
275
+ if (node.type === "VariableDeclaration") {
276
+ processVariableDeclaration(node);
277
+ }
278
+ // Exported variable: export const X = styled.div`...`
279
+ if (node.type === "ExportNamedDeclaration" &&
280
+ node.declaration?.type === "VariableDeclaration") {
281
+ processVariableDeclaration(node.declaration);
282
+ }
283
+ }
284
+ return results;
285
+ }
286
+ /**
287
+ * Classify a tagged template expression into one of our supported types.
288
+ */
289
+ function classifyTemplate(node, imports, variableName) {
290
+ const { tag } = node;
291
+ // styled.element`...`
292
+ if (tag.type === "MemberExpression" &&
293
+ tag.object.type === "Identifier" &&
294
+ tag.object.name === imports.styled &&
295
+ tag.property.type === "Identifier") {
296
+ return {
297
+ type: "styled",
298
+ node,
299
+ tag: tag.property.name,
300
+ variableName,
301
+ };
302
+ }
303
+ // styled(Component)`...`
304
+ if (tag.type === "CallExpression" &&
305
+ tag.callee.type === "Identifier" &&
306
+ tag.callee.name === imports.styled &&
307
+ tag.arguments[0]?.type === "Identifier") {
308
+ return {
309
+ type: "styledExtend",
310
+ node,
311
+ tag: "",
312
+ baseComponent: tag.arguments[0].name,
313
+ variableName,
314
+ };
315
+ }
316
+ // css`...`
317
+ if (tag.type === "Identifier" && tag.name === imports.css) {
318
+ return {
319
+ type: "css",
320
+ node,
321
+ tag: "",
322
+ variableName,
323
+ };
324
+ }
325
+ // createGlobalStyle`...`
326
+ if (tag.type === "Identifier" && tag.name === imports.createGlobalStyle) {
327
+ return {
328
+ type: "createGlobalStyle",
329
+ node,
330
+ tag: "",
331
+ variableName,
332
+ };
333
+ }
334
+ return null;
335
+ }
336
+ // ============================================================================
337
+ // CSS Processing
338
+ // ============================================================================
339
+ /**
340
+ * Extract raw CSS content from a template literal.
341
+ * Handles the content between the backticks.
342
+ */
343
+ function extractTemplateContent(code, quasi) {
344
+ // Get raw content between backticks
345
+ return code.slice(quasi.start + 1, quasi.end - 1);
346
+ }
347
+ /**
348
+ * Process CSS with PostCSS.
349
+ * - Wraps in class selector (unless global)
350
+ * - Processes nested selectors
351
+ * - Adds vendor prefixes
352
+ */
353
+ async function processCSS(content, className, isGlobal, autoprefixerOption) {
354
+ // Wrap in class selector unless global
355
+ const wrapped = isGlobal ? content : `.${className} { ${content} }`;
356
+ // Build PostCSS plugins
357
+ const plugins = [postcssNested()];
358
+ if (autoprefixerOption !== false) {
359
+ plugins.push(autoprefixer({
360
+ overrideBrowserslist: autoprefixerOption,
361
+ }));
362
+ }
363
+ // Process with PostCSS
364
+ const result = await postcss(plugins).process(wrapped, { from: undefined });
365
+ return result.css;
366
+ }
367
+ // ============================================================================
368
+ // Code Generation
369
+ // ============================================================================
370
+ /**
371
+ * Generate the replacement code for a styled template.
372
+ */
373
+ function generateReplacement(template, className, isDev) {
374
+ const displayName = isDev ? template.variableName : undefined;
375
+ const displayNameArg = displayName ? `, "${displayName}"` : "";
376
+ switch (template.type) {
377
+ case "styled":
378
+ return `__styled("${template.tag}", "${className}"${displayNameArg})`;
379
+ case "styledExtend":
380
+ return `__styledExtend(${template.baseComponent}, "${className}"${displayNameArg})`;
381
+ case "css":
382
+ return `"${className}"`;
383
+ case "createGlobalStyle":
384
+ return `__GlobalStyle`;
385
+ }
386
+ }
387
+ /**
388
+ * Normalize file paths for consistent hashing across platforms.
389
+ */
390
+ function normalizePath(p) {
391
+ return p.replace(/\\/g, "/").toLowerCase();
392
+ }
393
+ // Default export for convenience
394
+ export default styledStatic;
395
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAIH,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAoDjC,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,UAA+B,EAAE;IAC5D,MAAM,EACJ,WAAW,GAAG,IAAI,EAClB,YAAY,EAAE,kBAAkB,GAAG;QACjC,wBAAwB;QACxB,yBAAyB;QACzB,wBAAwB;QACxB,sBAAsB;KACvB,GACF,GAAG,OAAO,CAAC;IAEZ,+CAA+C;IAC/C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE7C,IAAI,MAAsB,CAAC;IAC3B,IAAI,KAAK,GAAG,KAAK,CAAC;IAElB,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,KAAK,EAAE,8CAA8C;QAE9D,cAAc,CAAC,cAAc;YAC3B,MAAM,GAAG,cAAc,CAAC;YACxB,KAAK,GAAG,MAAM,CAAC,OAAO,K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AK;YACR,OAAO,IAAI,SAAS,GAAG,CAAC;QAE1B,KAAK,mBAAmB;YACtB,OAAO,eAAe,CAAC;IAC3B,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,CAAS;IAC9B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;AAC7C,CAAC;AAED,iCAAiC;AACjC,eAAe,YAAY,CAAC"}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@alex.radulescu/styled-static",
3
+ "version": "0.2.0",
4
+ "description": "Zero-runtime styled components for React 19+ with Vite. CSS extracted at build time.",
5
+ "type": "module",
6
+ "private": false,
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "module": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ },
18
+ "./vite": {
19
+ "types": "./dist/vite.d.ts",
20
+ "import": "./dist/vite.js"
21
+ },
22
+ "./runtime": {
23
+ "types": "./dist/runtime.d.ts",
24
+ "import": "./dist/runtime.js"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "scripts": {
31
+ "build": "tsc",
32
+ "dev": "vite",
33
+ "dev:watch": "tsc --watch",
34
+ "test": "vitest",
35
+ "prepublishOnly": "npm run build"
36
+ },
37
+ "peerDependencies": {
38
+ "vite": "^5.0.0 || ^6.0.0",
39
+ "react": "^19.0.0"
40
+ },
41
+ "dependencies": {},
42
+ "devDependencies": {
43
+ "@types/node": "^22.10.1",
44
+ "@types/react": "^19.0.1",
45
+ "@types/react-dom": "^19.0.2",
46
+ "@vitejs/plugin-react": "^4.3.4",
47
+ "acorn": "^8.15.0",
48
+ "react": "^19.0.0",
49
+ "react-dom": "^19.0.0",
50
+ "typescript": "^5.7.2",
51
+ "vite": "^6.0.3",
52
+ "vitest": "^2.1.8"
53
+ },
54
+ "keywords": [
55
+ "styled-components",
56
+ "css-in-js",
57
+ "vite",
58
+ "react",
59
+ "zero-runtime",
60
+ "static-css"
61
+ ],
62
+ "license": "MIT",
63
+ "repository": {
64
+ "type": "git",
65
+ "url": "https://github.com/alexradulescu/styled-static"
66
+ },
67
+ "author": "Alex Radulescu"
68
+ }