feat: type generation mode declaration.#70
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #70 +/- ##
==========================================
- Coverage 91.23% 90.67% -0.57%
==========================================
Files 16 17 +1
Lines 5136 6316 +1180
Branches 920 1143 +223
==========================================
+ Hits 4686 5727 +1041
- Misses 418 553 +135
- Partials 32 36 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a new “declaration” type generation mode (plus a resolver plugin + a Playwright demo fixture) so consumers can keep idiomatic imports (e.g. import { knightedCss } from './card.js') while still getting correct runtime exports and TypeScript types.
Changes:
- Implement declaration-mode
.d.tssidecar generation (optionally with a sidecar manifest) and extend the CLI/help/docs accordingly. - Add a resolver plugin (
@knighted/css/plugin) to auto-append?knighted-css(and&combined) based on strict sidecar detection + manifest lookup. - Add a new Playwright “mode” demo (module/declaration/hashed/stable/strict) with a dedicated rspack config, type generation script, HTML page, and E2E tests.
Reviewed changes
Copilot reviewed 31 out of 33 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/playwright/test/mode.spec.ts | New E2E coverage for module vs declaration behavior, hashed/stable selectors, and strict manifest rewriting. |
| packages/playwright/src/mode/module/module-card.tsx | Module-mode demo component with shared styling. |
| packages/playwright/src/mode/module/host.ts | Lit host rendering the module-mode component in Shadow DOM using generated knightedCss. |
| packages/playwright/src/mode/mode.css | Shared demo styling for the new mode fixture UI. |
| packages/playwright/src/mode/index.ts | Renders the mode demo sections and strict probes; registers custom elements. |
| packages/playwright/src/mode/declaration/host.ts | Lit host rendering the declaration-mode component in Shadow DOM, relying on resolver rewrites. |
| packages/playwright/src/mode/declaration/declaration-card.tsx | Declaration-mode demo component. |
| packages/playwright/src/mode/declaration-strict/strict-skip-card.tsx | Strict-sidecar “skip” demo card. |
| packages/playwright/src/mode/declaration-strict/strict-ok-card.tsx | Strict-sidecar “ok/manifest” demo card. |
| packages/playwright/src/mode/declaration-stable/styles.module.css | CSS Modules styling for auto-stable selector demo. |
| packages/playwright/src/mode/declaration-stable/host.ts | Host for the declaration+autoStable demo. |
| packages/playwright/src/mode/declaration-stable/declaration-stable-card.tsx | Auto-stable selector demo wiring (stableClass/mergeStableClass). |
| packages/playwright/src/mode/declaration-hashed/styles.module.css | CSS Modules styling for hashed selector demo. |
| packages/playwright/src/mode/declaration-hashed/host.ts | Host for the declaration+hashed demo. |
| packages/playwright/src/mode/declaration-hashed/declaration-hashed-card.tsx | Hashed selector export demo (selectors = styles). |
| packages/playwright/src/mode/constants.ts | Centralizes mode fixture tags/test IDs. |
| packages/playwright/scripts/generate-mode-types.ts | Generates mode fixture types in multiple configs and merges sidecar manifests for strict resolver use. |
| packages/playwright/rspack.mode.config.js | Mode-demo bundling config including resolver plugin + strict manifest wiring. |
| packages/playwright/package.json | Adds types:mode, build:mode, preview:mode, and bumps @knighted/css to 1.2.0-rc.0. |
| packages/playwright/mode.html | New standalone page to host the mode demo bundle. |
| packages/playwright/README.md | Documents the new mode fixture and its generation/build workflow. |
| packages/css/test/plugin.test.ts | Adds unit tests validating resolver plugin behavior (strict markers, manifest, caching, hooks). |
| packages/css/test/generateTypes.test.ts | Adds tests for declaration-mode generation and sidecar manifest output; updates CLI parsing expectations. |
| packages/css/test/snapshots/generateTypes.snap.json | Updates CLI help snapshot for new flags (--mode, --manifest). |
| packages/css/src/plugin.ts | Implements the resolver plugin supporting strict sidecars, manifests, and combined query handling. |
| packages/css/src/lexer.ts | Extends module analysis to also return named exports for declaration-mode type emission decisions. |
| packages/css/src/generateTypes.ts | Adds `mode: module |
| packages/css/package.json | Publishes new subpath export @knighted/css/plugin and bumps version to 1.2.0-rc.0. |
| packages/css/README.md | Documents declaration-mode workflow and resolver plugin usage. |
| package-lock.json | Updates locked versions for @knighted/css and fixture dependency. |
| docs/type-generation.md | Adds mode/manifest flags + a quick-reference table and declaration-mode guidance. |
| docs/loader.md | Documents tradeoffs between modes and how to wire the resolver plugin. |
| .gitignore | Broadens dist/knighted ignore patterns and ignores generated mode .d.ts sidecars. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 31 out of 33 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 34 out of 36 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Closing in favor of #72 |
No description provided.