feat: better import attribute support. - #53
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #53 +/- ##
==========================================
- Coverage 92.54% 91.86% -0.69%
==========================================
Files 12 12
Lines 3126 3281 +155
Branches 550 572 +22
==========================================
+ Hits 2893 3014 +121
- Misses 210 244 +34
Partials 23 23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request adds comprehensive support for CSS import attributes (with { type: "css" }) to the @knighted/css module graph walker. The feature enables the library to recognize and handle CSS imports that use import attributes, including extensionless imports, aliased specifiers, and static dynamic imports.
Changes:
- Enhanced module graph walker to detect and handle
with { type: "css" }and legacyassert { type: "css" }import attributes - Added 7 comprehensive test cases covering static imports, dynamic imports, re-exports, extensionless specifiers, and path-mapped imports
- Created Playwright fixtures demonstrating both bundled and native (no-bundler) import attribute workflows
- Updated documentation across README files to explain the new attribute-aware import functionality
- Bumped package version from 1.0.9 to 1.0.10
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/css/src/moduleGraph.ts | Core implementation: added ExtractedSpecifier type, attribute extraction functions, and logic to treat attribute-marked imports as CSS regardless of file extension |
| packages/css/test/moduleGraph.test.ts | Added 7 test cases covering import attributes with various syntax forms, extensionless imports, path mappings, re-exports, and dynamic imports |
| packages/playwright/test/native-attr.spec.ts | New Playwright test for native CSS import attributes without bundler (Chromium-only) |
| packages/playwright/test/lit-react.spec.ts | Added test case for bundled attribute import card |
| packages/playwright/src/native-attr/* | New demo files showing native CSS module import with attribute syntax |
| packages/playwright/src/lit-react/cards/attr-import-card/* | New card component demonstrating bundled import attributes |
| packages/playwright/rspack.config.js | Added .css to resolve extensions to support extensionless attribute imports |
| packages/playwright/package.json | Updated @knighted/css dependency to 1.0.10 |
| packages/css/package.json | Bumped version to 1.0.10 |
| packages/css/README.md | Updated feature list to mention import attribute support |
| README.md | Added "Attribute-aware imports" bullet to feature overview |
| packages/playwright/README.md | Expanded to document three test scenarios including native import attributes |
| package-lock.json | Updated lock file with new version references |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
with { type: "css" }import attribute. #52