mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 19:38:58 +00:00
Implement CSS Module Scripts (https://web.dev/articles/css-module-scripts) for Bun's bundler. When importing CSS with `{ type: 'css' }` attribute: ```javascript import sheet from './styles.css' with { type: 'css' }; // or dynamically: const module = await import('./styles.css', { with: { type: 'css' } }); ``` The import now returns a CSSStyleSheet object that can be used with `document.adoptedStyleSheets`, instead of the previous behavior of returning an empty object or file path. Changes: - Add `__cssModuleScript` runtime helper that creates CSSStyleSheet - Add `is_css_module_script` flag to ImportRecord - Track CSS Module Script files in LinkerGraph - Generate `__cssModuleScript(cssContent)` for CSS imports with type assertion - Handle both static and dynamic imports correctly - Preserve existing CSS Modules behavior (class name mappings) for imports without the type assertion 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
4.9 KiB
4.9 KiB