Skip to content

Commit 6b839af

Browse files
ushironokoclaude
andcommitted
refactor: scope the runtime package as @tskm/core
npm rejects the unscoped name `tskm` as too similar to existing packages (tsm/tsx/tsc/...), so rename the runtime library to @tskm/core, matching the @tskm/compiler and @tskm/vite family. The compiler discovers schemas imported from the runtime module and emits imports for it, so update its RUNTIME_MODULE constant and generated import to @tskm/core, and bump @tskm/compiler to 0.0.2 (the already-published 0.0.1 still targets the old name). README, examples, compiler test fixtures, and the publish/smoke scripts are updated to match. The `tskm` CLI command (the @tskm/compiler bin) and the Standard Schema vendor string are intentionally left unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 51d3c75 commit 6b839af

20 files changed

Lines changed: 48 additions & 48 deletions

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tskm is two things that fit together:
1212

1313
- **An AOT (ahead-of-time) type compiler** — instead of deriving a type from a schema with `z.infer<typeof schema>` at every use site, tskm pre-computes it once and writes the fully-expanded, concrete type to a real file. The answer comes from the actual TypeScript type checker, queried out of process.
1414

15-
It is a bun-workspaces monorepo: `tskm` (runtime), `@tskm/compiler` (AOT codegen + CLI), `@tskm/vite` (Vite plugin).
15+
It is a bun-workspaces monorepo: `@tskm/core` (runtime), `@tskm/compiler` (AOT codegen + CLI), `@tskm/vite` (Vite plugin).
1616

1717
## Why tskm?
1818

@@ -35,7 +35,7 @@ tskm goes the **opposite direction — schema → type, not type → validator
3535
**Validate at runtime** — schemas are values; `parse` / `safeParse` are standalone functions:
3636

3737
```ts
38-
import { object, string, number, array, pipe, minLength, parse, safeParse } from "tskm"
38+
import { object, string, number, array, pipe, minLength, parse, safeParse } from "@tskm/core"
3939

4040
const userSchema = object({
4141
name: pipe(string(), minLength(2)),
@@ -54,7 +54,7 @@ const result = safeParse(userSchema, { name: "", age: 1, tags: [] })
5454

5555
```ts
5656
// user.schema.ts (you write — note: no `type User = Infer<...>` needed)
57-
import { object, string, number, array, pipe, minLength } from "tskm"
57+
import { object, string, number, array, pipe, minLength } from "@tskm/core"
5858

5959
export const userSchema = object({
6060
name: pipe(string(), minLength(2)),
@@ -102,12 +102,12 @@ it runs the compiler on `buildStart` and watches during `vite dev`.
102102

103103
The compiler never reads your schema at runtime — the inferred type only exists in the type system, so it asks the type checker directly:
104104

105-
1. **Discover**[`oxc-parser`](https://oxc.rs) scans each source file (syntactically) for exported `const`s whose factory is imported from `tskm`, and for explicit `type T = Infer<typeof X>` markers.
105+
1. **Discover**[`oxc-parser`](https://oxc.rs) scans each source file (syntactically) for exported `const`s whose factory is imported from `@tskm/core`, and for explicit `type T = Infer<typeof X>` markers.
106106
2. **Query** — for each schema, the compiler writes a tiny sibling file (`<base>.tskm-query.ts`, deleted afterward) next to the source that declares a marker against the schema's output type:
107107

108108
```ts
109109
import { userSchema } from "./user.schema"
110-
import type { InferOutput } from "tskm"
110+
import type { InferOutput } from "@tskm/core"
111111
type __P<T> = { [K in keyof T]: T[K] } & {}
112112
declare const __tskm_0: __P<InferOutput<typeof userSchema>>
113113
```

bun.lock

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

examples/basic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"type": "module",
66
"dependencies": {
7-
"tskm": "workspace:*"
7+
"@tskm/core": "workspace:*"
88
},
99
"devDependencies": {
1010
"@tskm/compiler": "workspace:*"

examples/basic/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { safeParse } from "tskm"
1+
import { safeParse } from "@tskm/core"
22
import type { Product, User } from "./user.schema.gen.ts"
33
import { productSchema, userSchema } from "./user.schema.ts"
44

examples/basic/src/user.schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { minLength, number, object, pipe, string } from "tskm"
1+
import { minLength, number, object, pipe, string } from "@tskm/core"
22

33
export const userSchema = object({
44
name: pipe(string(), minLength(2)),

examples/basic/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"skipLibCheck": true,
99
"noEmit": true,
1010
"paths": {
11-
"tskm": ["../../packages/tskm/src/index.ts"]
11+
"@tskm/core": ["../../packages/tskm/src/index.ts"]
1212
}
1313
},
1414
"include": ["src"]

packages/compiler/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tskm/compiler",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "AOT schema-to-type compiler for tskm, powered by the tsgo (Corsa) checker API",
55
"type": "module",
66
"license": "MIT",

packages/compiler/src/discovery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { parseSync } from "oxc-parser"
22

33
/** The runtime package whose exports mark a value as a tskm schema. */
4-
const RUNTIME_MODULE = "tskm"
4+
const RUNTIME_MODULE = "@tskm/core"
55

66
/** Type-level aliases that mark `export type T = ...<typeof schema>` AOT targets. */
77
const INFER_ALIASES = new Set(["Infer", "InferOutput"])
@@ -73,7 +73,7 @@ function calleeName(init: OxcNode | undefined): string | undefined {
7373

7474
/**
7575
* Reads an `export type T = Infer<typeof X>` (or `InferOutput<...>`, or
76-
* `import("tskm").InferOutput<typeof X>`) alias and returns the referenced
76+
* `import("@tskm/core").InferOutput<typeof X>`) alias and returns the referenced
7777
* schema name plus the declared alias name.
7878
*/
7979
function readInferAlias(decl: OxcNode | undefined): DiscoveredSchema | undefined {

packages/compiler/src/inplace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const START_LINE = /^\/\/ @tskm-gen (\w+) from (\w+) #([0-9a-f]{8})$/
5757
const END_LINE = /^\/\/ @tskm-end (\w+)$/
5858

5959
// First-run marker: only the SINGLE-LINE form is supported. Accepts the bare
60-
// `Infer`/`InferOutput` reference and the `import("tskm").Infer*<...>` form — matching
60+
// `Infer`/`InferOutput` reference and the `import("@tskm/core").Infer*<...>` form — matching
6161
// discovery's alias set. (`InferInput` is intentionally excluded: the resolver always
6262
// queries `InferOutput`, so an input marker would be silently filled with the output type.)
6363
const INFER_MARKER =

packages/compiler/src/resolve.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function buildQueryBody(
3030
if (names.length > 0) {
3131
lines.push(`import { ${names.join(", ")} } from "${sourceImportPath}"`)
3232
}
33-
lines.push(`import type { InferOutput } from "tskm"`)
33+
lines.push(`import type { InferOutput } from "@tskm/core"`)
3434
lines.push(`type __P<T> = { [K in keyof T]: T[K] } & {}`)
3535
schemas.forEach((schema, i) => {
3636
lines.push(`declare const ${markers[i]}: __P<InferOutput<typeof ${schema.name}>>`)

0 commit comments

Comments
 (0)