|
| 1 | +# Chromatic Build Issue Summary |
| 2 | + |
| 3 | +## Problem |
| 4 | +Storybook builds locally but fails in Chromatic with error: |
| 5 | +``` |
| 6 | +TypeError: a is not a function |
| 7 | +at https://68e30fca49979473fc9abc73-...chromatic.com/assets/AssistantMessage.stories-...js:6:11 |
| 8 | +``` |
| 9 | + |
| 10 | +This is the minified version of `styled is not a function` - @emotion/styled's default export isn't being resolved correctly in Chromatic's build environment. |
| 11 | + |
| 12 | +## Root Cause |
| 13 | +Almost every component in the project uses `@emotion/styled` (25+ files). The issue appears to be a module resolution problem specific to Chromatic's infrastructure where the default export from @emotion/styled becomes undefined in the production build. |
| 14 | + |
| 15 | +## Attempted Solutions |
| 16 | +1. ✅ Converted 2 tool components (BashToolCall, FileReadToolCall) to CSS modules |
| 17 | +2. ✅ Added dedupe config for emotion packages |
| 18 | +3. ❌ CommonJS inclusion config (broke build) |
| 19 | +4. ❌ Explicit emotion/styled alias (broke build) |
| 20 | +5. ❌ Various Babel/Vite configurations |
| 21 | + |
| 22 | +## Current Status |
| 23 | +- Local Storybook build: ✅ Works |
| 24 | +- Chromatic build: ❌ Fails with "a is not a function" |
| 25 | +- Partially converted: 2/4 tool components, but 25+ other components still use styled |
| 26 | + |
| 27 | +## Options Going Forward |
| 28 | + |
| 29 | +### Option 1: Complete CSS Modules Conversion (High Effort) |
| 30 | +- Convert all 25+ components from @emotion/styled to CSS modules |
| 31 | +- Pros: Eliminates dependency on emotion/styled entirely |
| 32 | +- Cons: 10-20 hours of work, risky refactor, may break styling |
| 33 | + |
| 34 | +### Option 2: Debug Chromatic Bundle (Medium Effort) |
| 35 | +- Deep dive into Chromatic's Vite build process |
| 36 | +- Compare local vs Chromatic bundle outputs |
| 37 | +- May require Chromatic support ticket |
| 38 | +- Pros: Fixes root cause |
| 39 | +- Cons: May be Chromatic infrastructure issue outside our control |
| 40 | + |
| 41 | +### Option 3: Skip Chromatic for Now (Low Effort) |
| 42 | +- Disable Chromatic workflow temporarily |
| 43 | +- Use local Storybook for development |
| 44 | +- Revisit when Chromatic updates or when we have more time |
| 45 | +- Pros: Unblocks current work |
| 46 | +- Cons: Loses visual regression testing |
| 47 | + |
| 48 | +### Option 4: Simplify Storybook Scope (Medium Effort) |
| 49 | +- Only include stories for components that don't use styled |
| 50 | +- Or create simplified versions of components for Storybook only |
| 51 | +- Pros: Gets some stories working in Chromatic |
| 52 | +- Cons: Limited coverage |
| 53 | + |
| 54 | +## Recommendation |
| 55 | +**Option 3** (Skip Chromatic for now) + document the issue for later investigation. |
| 56 | + |
| 57 | +The emotion/styled issue appears to be environmental (Chromatic-specific) rather than a code problem. Local Storybook works fine for development. Visual regression testing can be added back once the root cause is identified. |
| 58 | + |
| 59 | +## Files Modified |
| 60 | +- `.storybook/main.ts` - Added dedupe config |
| 61 | +- `src/components/tools/BashToolCall.tsx` - Converted to CSS modules |
| 62 | +- `src/components/tools/FileReadToolCall.tsx` - Converted to CSS modules |
| 63 | +- `src/components/tools/shared/ToolPrimitives.tsx` - Converted to CSS modules |
| 64 | +- Created corresponding `.module.css` files |
| 65 | + |
| 66 | +## Components Still Using @emotion/styled |
| 67 | +- AssistantMessage, UserMessage, MessageWindow, MarkdownRenderer |
| 68 | +- TypewriterMarkdown, TypewriterText, StreamErrorMessage |
| 69 | +- ReasoningMessage, TerminalOutput, ChatBarrier |
| 70 | +- AIView, ChatInput, ProjectSidebar, ChatInputToast |
| 71 | +- ErrorMessage, ErrorBoundary, CommandSuggestions |
| 72 | +- ToggleGroup, Tooltip, ThinkingSlider, TipsCarousel |
| 73 | +- NewWorkspaceModal, ChatMetaSidebar (and tabs) |
| 74 | +- ProposePlanToolCall, FileEditToolCall |
| 75 | + |
0 commit comments