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
Copy file name to clipboardExpand all lines: README.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,15 +17,16 @@
17
17
18
18
## Features
19
19
20
-
- Traverses module graphs using [`dependency-tree`](https://github.com/dependents/node-dependency-tree) to find transitive style imports.
20
+
- Traverses module graphs with a built-in walker to find transitive style imports (no bundler required).
21
+
- Resolution parity via [`oxc-resolver`](https://github.com/oxc-project/oxc-resolver): tsconfig `paths`, package `exports` conditions, and extension aliasing (e.g., `.css.js` → `.css.ts`) are honored without wiring up a bundler.
21
22
- Compiles `*.css`, `*.scss`, `*.sass`, `*.less`, and `*.css.ts` (vanilla-extract) files out of the box.
22
23
- Optional post-processing via [`lightningcss`](https://github.com/parcel-bundler/lightningcss) for minification, prefixing, media query optimizations, or specificity boosts.
23
24
- Pluggable resolver/filter hooks for custom module resolution (e.g., Rspack/Vite/webpack aliases) or selective inclusion.
24
25
- First-class loader (`@knighted/css/loader`) so bundlers can import compiled CSS alongside their modules via `?knighted-css`.
25
26
26
27
## Requirements
27
28
28
-
- Node.js `>= 22.15.0`
29
+
- Node.js `>= 22.17.0`
29
30
- npm `>= 10.9.0`
30
31
- Install peer toolchains you intend to use (`sass`, `less`, `@vanilla-extract/integration`, etc.).
31
32
@@ -66,10 +67,10 @@ type CssOptions = {
66
67
strategy?:SpecificityStrategy
67
68
match?:SpecificitySelector[]
68
69
}
69
-
dependencyTree?:DependencyTreeOptions
70
+
moduleGraph?:ModuleGraphOptions
70
71
resolver?: (
71
72
specifier:string,
72
-
ctx: { cwd:string },
73
+
ctx: { cwd:string; from?:string },
73
74
) =>string|Promise<string|undefined>
74
75
peerResolver?: (name:string) =>Promise<unknown> // for custom module loading
Thebuilt-inwalkeralreadyleanson [`oxc-resolver`](https://github.com/oxc-project/oxc-resolver), so tsconfig `paths`, package `exports` conditions, and common extension aliases work out of the box. If you still need to mirror bespoke behavior (virtual modules, framework-specific loaders, etc.), plug in a custom resolver. Here’s how to use [`enhanced-resolve`](https://github.com/webpack/enhanced-resolve):
392
394
393
395
```ts
394
396
import { ResolverFactory } from 'enhanced-resolve'
Copy file name to clipboardExpand all lines: docs/how-it-works.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,8 @@
3
3
## Overview
4
4
5
5
- The loader walks the module graph and gathers style-producing files (`.css`, `.scss`, `.sass`, `.less`, `.css.ts`, etc.).
6
-
- It uses `dependency-tree` (via `precinct`) to follow imports in the order they appear in source.
6
+
- It walks the module graph with a built-in depth-first resolver so imports are visited in source order.
7
+
- Resolution is powered by [`oxc-resolver`](https://github.com/oxc-project/oxc-resolver), so tsconfig `paths`, package `exports` conditions, and extension aliasing (like `.css.js` → `.css.ts`) all map to the same targets you’d get in a bundler.
7
8
- CSS from those files is concatenated in that discovery order and returned as `knightedCss` for injection (e.g., Lit ` css`` `, SSR, SSG).
8
9
- We do **not** sort or reorder; first-seen order is kept, so the CSS cascade mirrors the original import sequence.
9
10
@@ -16,7 +17,7 @@
16
17
17
18
### Example ordering
18
19
19
-
We rely on `dependency-tree` (via `precinct`) to follow imports in the order they appear in source. We concatenate CSS in depth-first, preorder (parent before children), preserving sibling order as written. Files are deduped: the first time a file is seen, it’s included; later encounters are skipped to avoid reshuffling the cascade. We never sort the list, and `lightningcss` preserves the rule order we provide.
20
+
The walker performs a depth-first, preorder traversal (parent before children) so imports are resolved exactly as they are written in source. Files are deduped: the first time a file is seen, it’s included; later encounters are skipped to avoid reshuffling the cascade. We never sort the list, and `lightningcss` preserves the rule order we provide.
0 commit comments