You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run `npxknighted-css-generate-types--root .` to scan your project for `?knighted-css&types` imports. The CLI:
205
+
Import the generated selector module anywhere you want literal tokens:
206
206
207
-
- extracts selectors via the loader, then writes literal module declarations whose specifiers resolve to the real stylesheet paths (TypeScript picks up `import'./foo.scss?knighted-css&types'` directly—no registries or casting helpers required). The default output still lands in `node_modules/@knighted/css/node_modules/.knighted-css`, but every module declaration points back to your source tree.
208
-
- updates the packaged stub at `node_modules/@knighted/css/types-stub/index.d.ts`
209
-
- exposes the declarations automatically because `types.d.ts` references the stub, so no `tsconfig` wiring is required
Run `npxknighted-css-generate-types--root .` to scan for `.knighted-css` specifiers and keep those modules current. The CLI:
210
215
211
-
Re-run the command whenever imports change (add it to a `types:css` npm script or your build). If you need a different destination, pass `--out-dir` and/or `--types-root` to override the defaults.
216
+
- extracts selectors via the loader, applies your `stableNamespace`, and sorts the tokens deterministically
217
+
- writes sibling `*.knighted-css.ts` files next to each stylesheet so editors resolve them immediately
218
+
- records everything inside `<root>/.knighted-css/selector-modules.json` (or your custom `--out-dir`) and removes stale modules when imports disappear
219
+
- warns whenever a specifier cannot be resolved or escapes the configured project root
220
+
221
+
Because these are regular modules—not `.d.ts` shims—you can import the default export or the named `stableSelectors`, and helper types (`KnightedCssStableSelectors`, `KnightedCssStableSelectorToken`) ship alongside the literal map. Pass `--stable-namespace` so the CLI and loader agree on prefixes, and use `--include` / `--out-dir` to expand the scan or relocate the manifest cache (the selector modules themselves always live beside the source stylesheet). Re-run the command whenever you touch `.knighted-css` imports (wire it into a `knighted:types` script or a watch task).
212
222
213
223
Sass/Less projects can import the shared mixins directly:
214
224
@@ -252,7 +262,7 @@ Override the namespace via `:root { --knighted-stable-namespace: 'acme'; }` if y
Append `&types`to any loader import to receive a literal map of the discovered stable selectors alongside the raw CSS:
265
+
Use `?knighted-css&types`when you need the `stableSelectors` map at runtime (Lit styles, SSR, tests, etc.). TypeScript already sees the literal tokens via the generated `.knighted-css` modules, but the loader surfaces the same data for application code:
Namespaces default to `knighted`, but you can configure a global fallback via the loader’s `stableNamespace` option:
287
+
Namespaces default to `knighted`, but you can configure a global fallback via the loader’s `stableNamespace` option (match it with the CLI’s `--stable-namespace` flag so runtime + generated modules agree):
278
288
279
289
```js
280
290
{
@@ -289,24 +299,20 @@ All imports share the namespace resolved by the loader (or the `knighted-css-gen
289
299
290
300
#### TypeScript support for loader queries
291
301
292
-
Loader query types ship directly with `@knighted/css`. Reference them once in your project—either by adding `"types": ["@knighted/css/loader-queries"]` to `tsconfig.json` or dropping `/// <reference types="@knighted/css/loader-queries" />` into a global `.d.ts`—and the following ambient modules become available everywhere:
302
+
Loader query types still ship directly with `@knighted/css`. Reference them once in your project—either by adding `"types": ["@knighted/css/loader-queries"]` to `tsconfig.json` or dropping `/// <reference types="@knighted/css/loader-queries" />` into a global `.d.ts`—and the following ambient modules become available everywhere:
Copy file name to clipboardExpand all lines: docs/combined-queries.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,9 @@
2
2
3
3
This document summarizes how `?knighted-css&combined` behaves for different module export shapes and how to structure your imports accordingly. Use it as guidance when filing documentation feedback for `@knighted/css`.
4
4
5
+
> [!NOTE]
6
+
> TypeScript now reads literal selector tokens from the generated `.knighted-css.ts` modules (emitted by `knighted-css-generate-types`). Append `&types` to combined imports only when you also need `stableSelectors` at runtime—the loader still exports the map, while the double-extension modules keep your editors in sync.
Copy file name to clipboardExpand all lines: packages/css/package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "@knighted/css",
3
-
"version": "1.0.0-rc.11",
3
+
"version": "1.0.0-rc.12",
4
4
"description": "A build-time utility that traverses JavaScript/TypeScript module dependency graphs to extract, compile, and optimize all imported CSS into a single, in-memory string.",
0 commit comments