Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,12 @@ The loader appends `export const knightedCss = "/* compiled css */"` to the modu

#### TypeScript support for loader queries

Until we publish the ambient declarations to npm, copy [`packages/types/loader-queries.d.ts`](./packages/types/loader-queries.d.ts) into your project (or reference it directly via `typeRoots`). That file declares the two query patterns we rely on:
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:

- `*?knighted-css` imports expose a `knightedCss: string` export.
- `*?knighted-css&combined` (and permutations that include both flags) also gain a default export typed as `KnightedCssCombinedModule<Record<string, unknown>>` so you can narrow it to your source module.
- `*?knighted-css&combined` (and any query that includes both flags) expose `knightedCss` and return the original module exports, which you can narrow with `KnightedCssCombinedModule` before destructuring named members.

> [!NOTE]
> We plan to publish these under an `@types/knighted__css` package. Until then, vendoring the declaration file keeps your project unblocked.
No vendor copies are necessary—the declarations live inside `@knighted/css`, you just need to point your TypeScript config at the shipped `loader-queries` subpath once.

#### Combined module + CSS import

Expand Down
12 changes: 4 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"type": "module",
"workspaces": [
"packages/css",
"packages/types",
"packages/playwright"
],
"engines": {
Expand Down
File renamed without changes.
27 changes: 23 additions & 4 deletions packages/css/package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
{
"name": "@knighted/css",
"version": "1.0.0-rc.1",
"version": "1.0.0-rc.2",
"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.",
"type": "module",
"main": "./dist/css.js",
"types": "./dist/css.d.ts",
"types": "./types.d.ts",
"typesVersions": {
"*": {
"loader": [
"./dist/loader.d.ts"
],
"loader-queries": [
"./loader-queries.d.ts"
],
"*": [
"./types.d.ts"
]
}
},
"exports": {
".": {
"types": "./dist/css.d.ts",
"types": "./types.d.ts",
"import": "./dist/css.js",
"require": "./dist/cjs/css.cjs"
},
"./loader": {
"types": "./dist/loader.d.ts",
"import": "./dist/loader.js",
"require": "./dist/cjs/loader.cjs"
},
"./loader-queries": {
"types": "./loader-queries.d.ts",
"default": "./loader-queries.d.ts"
}
},
"keywords": [
Expand Down Expand Up @@ -56,7 +73,9 @@
}
},
"files": [
"dist"
"dist",
"loader-queries.d.ts",
"types.d.ts"
],
"author": "KCM <knightedcodemonkey@gmail.com>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/types/index.d.ts → packages/css/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/// <reference path="./loader-queries.d.ts" />

export {}
export * from './dist/css.js'
3 changes: 1 addition & 2 deletions packages/playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
"pretest": "npm run build"
},
"dependencies": {
"@knighted/css": "1.0.0-rc.1",
"@knighted/css": "1.0.0-rc.2",
"@knighted/jsx": "^1.2.1",
"lit": "^3.2.1",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@types/knighted__css": "1.0.0-rc.1",
"@types/react": "^19.0.4",
"@types/react-dom": "^19.0.2",
"@vanilla-extract/webpack-plugin": "^2.3.15",
Expand Down
3 changes: 2 additions & 1 deletion packages/playwright/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"outDir": "dist",
"skipLibCheck": true,
"declaration": true,
"jsx": "react-jsx"
"jsx": "react-jsx",
"types": ["@knighted/css/loader-queries"]
},
"include": ["src"]
}
3 changes: 0 additions & 3 deletions packages/types/loader.d.ts

This file was deleted.

14 changes: 0 additions & 14 deletions packages/types/package.json

This file was deleted.