Skip to content

Commit ad46852

Browse files
chore: publish loader types. (#15)
1 parent cdc30b4 commit ad46852

10 files changed

Lines changed: 34 additions & 38 deletions

File tree

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,12 @@ The loader appends `export const knightedCss = "/* compiled css */"` to the modu
190190
191191
#### TypeScript support for loader queries
192192
193-
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:
193+
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:
194194

195195
- `*?knighted-css` imports expose a `knightedCss: string` export.
196-
- `*?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.
196+
- `*?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.
197197

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

201200
#### Combined module + CSS import
202201

package-lock.json

Lines changed: 4 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"type": "module",
55
"workspaces": [
66
"packages/css",
7-
"packages/types",
87
"packages/playwright"
98
],
109
"engines": {

packages/css/package.json

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
11
{
22
"name": "@knighted/css",
3-
"version": "1.0.0-rc.1",
3+
"version": "1.0.0-rc.2",
44
"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.",
55
"type": "module",
66
"main": "./dist/css.js",
7-
"types": "./dist/css.d.ts",
7+
"types": "./types.d.ts",
8+
"typesVersions": {
9+
"*": {
10+
"loader": [
11+
"./dist/loader.d.ts"
12+
],
13+
"loader-queries": [
14+
"./loader-queries.d.ts"
15+
],
16+
"*": [
17+
"./types.d.ts"
18+
]
19+
}
20+
},
821
"exports": {
922
".": {
10-
"types": "./dist/css.d.ts",
23+
"types": "./types.d.ts",
1124
"import": "./dist/css.js",
1225
"require": "./dist/cjs/css.cjs"
1326
},
1427
"./loader": {
1528
"types": "./dist/loader.d.ts",
1629
"import": "./dist/loader.js",
1730
"require": "./dist/cjs/loader.cjs"
31+
},
32+
"./loader-queries": {
33+
"types": "./loader-queries.d.ts",
34+
"default": "./loader-queries.d.ts"
1835
}
1936
},
2037
"keywords": [
@@ -56,7 +73,9 @@
5673
}
5774
},
5875
"files": [
59-
"dist"
76+
"dist",
77+
"loader-queries.d.ts",
78+
"types.d.ts"
6079
],
6180
"author": "KCM <knightedcodemonkey@gmail.com>",
6281
"license": "MIT",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/// <reference path="./loader-queries.d.ts" />
22

3-
export {}
3+
export * from './dist/css.js'

packages/playwright/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
"pretest": "npm run build"
1515
},
1616
"dependencies": {
17-
"@knighted/css": "1.0.0-rc.1",
17+
"@knighted/css": "1.0.0-rc.2",
1818
"@knighted/jsx": "^1.2.1",
1919
"lit": "^3.2.1",
2020
"react": "^19.0.0",
2121
"react-dom": "^19.0.0"
2222
},
2323
"devDependencies": {
24-
"@types/knighted__css": "1.0.0-rc.1",
2524
"@types/react": "^19.0.4",
2625
"@types/react-dom": "^19.0.2",
2726
"@vanilla-extract/webpack-plugin": "^2.3.15",

packages/playwright/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"outDir": "dist",
88
"skipLibCheck": true,
99
"declaration": true,
10-
"jsx": "react-jsx"
10+
"jsx": "react-jsx",
11+
"types": ["@knighted/css/loader-queries"]
1112
},
1213
"include": ["src"]
1314
}

packages/types/loader.d.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/types/package.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)