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
>`stableSelectors`hereisforruntimeuse; TypeScriptstillreadsliteraltokensfromthegenerated`.knighted-css.*`modules. Forafulldecisionmatrix, see [docs/combined-queries.md](./docs/combined-queries.md).
Copy file name to clipboardExpand all lines: docs/combined-queries.md
+12-2Lines changed: 12 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,12 @@ This document summarizes how `?knighted-css&combined` behaves for different modu
5
5
> [!NOTE]
6
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.
7
7
8
+
> [!TIP]
9
+
> `KnightedCssCombinedModule` accepts an optional second generic parameter so you can describe loader-injected exports (for example, `{ stableSelectors: Record<string, string> }` when you append `&types`). That keeps the helper self-contained without intersecting additional types in your own code.
10
+
11
+
> [!TIP]
12
+
> Prefer importing `asKnightedCssCombinedModule` from `@knighted/css/loader-helpers` when you want a runtime helper—the file has zero Node dependencies, so both browser and Node builds stay green.
Prefer `?knighted-css&combined&named-only` plus the [named exports only](#named-exports-only) snippet when you intentionally avoid default exports but still need the named members and `knightedCss`.
// Need to describe additional loader-injected exports (for example, `stableSelectors` when
50
+
// using `?knighted-css&combined&types`)? Pass a second generic:
51
+
const {
52
+
default: ButtonWithSelectors,
53
+
knightedCss: buttonCss,
54
+
stableSelectors,
55
+
} =asKnightedCssCombinedModule<
56
+
typeofimport('./button.js'),
57
+
{ stableSelectors: Record<string, string> }
58
+
>(buttonModule)
48
59
```
49
60
50
61
Append `&named-only` (alias: `&no-default`) if you never consume the default export. Refer to [docs/combined-queries.md](./combined-queries.md) for the full matrix of query flags and destructuring patterns.
51
62
63
+
> [!TIP]
64
+
> `@knighted/css/loader-helpers` ships the `asKnightedCssCombinedModule` helper in isolation so you can safely import it from browser bundles. This keeps the heavy loader implementation (and its Node dependencies) out of client builds.
65
+
52
66
### Runtime selectors (`&types`)
53
67
54
68
When you need the runtime `stableSelectors` map alongside `knightedCss`, append `&types` to either the plain or combined import:
0 commit comments