Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to tshy #3653

Merged
merged 10 commits into from
Jul 19, 2024
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
21 changes: 0 additions & 21 deletions .configs/rollup.esm.mjs

This file was deleted.

14 changes: 10 additions & 4 deletions .configs/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@
"compilerOptions": {
"target": "es2018",
"lib": ["es6", "dom"],
"moduleResolution": "Node",
"module": null,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"jsx": "react",

"strict": true,
"alwaysStrict": true,
"strictPropertyInitialization": false,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"noUnusedLocals": false,
"noUnusedParameters": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,

"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,

"noEmit": true,
"removeComments": true,
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"downlevelIteration": true,
"isolatedModules": true
"isolatedModules": true,

"pretty": true
}
}
16 changes: 0 additions & 16 deletions .configs/tsconfig.cjs.json

This file was deleted.

10 changes: 0 additions & 10 deletions .configs/tsconfig.esm.json

This file was deleted.

16 changes: 0 additions & 16 deletions .configs/tsconfig.types.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ logos
dist
.tshy
.tshy-build
packages/tsc-perf
4 changes: 2 additions & 2 deletions benchmarks/benchUtil.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as zNew from "../packages/zod/dist/esm";
import * as zOld from "./node_modules/zod/lib/index";
import * as zNew from "../packages/zod/dist/commonjs/index.js";
import * as zOld from "./node_modules/zod/dist/commonjs/index.js";

export function makeSchema<T>(factory: (z: typeof zNew) => T) {
return {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/datetime-regex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { metabench } from "./metabench";
import { metabench } from "./metabench.js";

const bench = metabench("datetime regex");

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/ipv4-regex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { metabench } from "./metabench";
import { metabench } from "./metabench.js";

const DATA = "127.0.0.1";
const ipv4RegexA =
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/metabench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Table } from "console-table-printer";
import * as mitata from "mitata";
import { Bench } from "tinybench";

import { assertNever } from "../packages/zod/src/helpers/util";
import { formatNumber } from "./benchUtil";
import { assertNever } from "../packages/zod/src/helpers/util.js";
import { formatNumber } from "./benchUtil.js";

type BENCH = "tinybench" | "benchmarkjs" | "mitata";
const BENCH: BENCH = (process.env.BENCH as BENCH) || "benchmarkjs";
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/object-async.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { metabench } from "./metabench";
import { DATA, zod3, zod4 } from "./object-old";
import { metabench } from "./metabench.js";
import { DATA, zod3, zod4 } from "./object-old.js";

const bench = metabench("small: z.object().parseAsync", {
async zod3() {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/object-creation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { metabench } from "./metabench";
import { metabench } from "./metabench.js";

class ZodFail {
status = "fail";
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/object-fail.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { metabench } from "./metabench";
import { DATA, zod3, zod4 } from "./object-old";
import { metabench } from "./metabench.js";
import { DATA, zod3, zod4 } from "./object-old.js";

const bench = metabench("small: z.object().safeParseAsync", {
zod3() {
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/object-safe.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { metabench } from "./metabench";
import { DATA, zod3, zod4 } from "./object-old";
import { metabench } from "./metabench.js";
import { DATA, zod3, zod4 } from "./object-old.js";

const bench = metabench("small: z.object().safeParse", {
zod3() {
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/object-safeasync.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { metabench } from "./metabench";
import { DATA, zod3, zod4 } from "./object-old";
import { metabench } from "./metabench.js";
import { DATA, zod3, zod4 } from "./object-old.js";

const bench = metabench("small: z.object().safeParseAsync", {
async zod3() {
Expand Down
1 change: 1 addition & 0 deletions benchmarks/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"private": true,
"type": "module",
"name": "zod-benchmarks",
"devDependencies": {
"zod": "3.23.8"
Expand Down
6 changes: 0 additions & 6 deletions benchmarks/tsconfig.json

This file was deleted.

6 changes: 3 additions & 3 deletions benchmarks/zodbench.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type z from "../packages/zod/dist/esm";
import { makeSchema } from "./benchUtil";
import { metabench } from "./metabench";
import type z from "../packages/zod/dist/commonjs/index.js";
import { makeSchema } from "./benchUtil.js";
import { metabench } from "./metabench.js";

interface ZodBenchParams<T extends z.ZodType, D> {
name: string;
Expand Down
4 changes: 2 additions & 2 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"formatter": {
"enabled": true,
"indentStyle": "space"
},
"javascript": {
"formatter": {
"trailingComma": "es5"
"trailingCommas": "es5"
}
},
"json": {
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
"vitest": "2.0.3"
},
"lint-staged": {
"src/*.ts": ["biome format --write", "biome lint --apply"],
"src/*.ts": ["biome format --write", "biome lint --write"],
"*.md": ["prettier --ignore-unknown --write"]
},
"scripts": {
"format": "biome check --apply .",
"format": "biome check --write .",
"format:check": "biome check .",
"lint": "biome lint --apply .",
"lint": "biome lint --write .",
"lint:check": "biome lint .",
"clean": "pnpm run -r clean && rm -rf node_modules",
"build": "pnpm run -r build",
Expand All @@ -60,5 +60,8 @@
"bench": "pnpm run build:cjs && tsx benchmarks/index.ts",
"prepare": "husky install",
"publish:jsr": "jsr publish --dry-run"
},
"dependencies": {
"tshy": "^3.0.2"
colinhacks marked this conversation as resolved.
Show resolved Hide resolved
}
}
13 changes: 10 additions & 3 deletions packages/effect-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@zod-plugin/effect",
"type": "module",
"version": "0.1.0",
"author": "Colin McDonnell <[email protected]>",
"files": ["src", "dist"],
Expand All @@ -9,11 +10,13 @@
"license": "MIT",
"sideEffects": false,
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/commonjs/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"@zod/source": "./src/index.ts",
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
Expand All @@ -23,6 +26,12 @@
}
}
},
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/colinhacks/zod.git"
Expand All @@ -41,9 +50,7 @@
},
"scripts": {
"clean": "rm -rf dist",
"build": "pnpm run clean && pnpm build:cjs && pnpm build:esm",
"build:esm": "pnpm tsc -p ./tsconfig.build.json --noEmit false --declaration --declarationMap --sourceMap --rootDir src --module esnext --moduleResolution node10 --outDir dist/esm",
"build:cjs": "pnpm tsc -p ./tsconfig.build.json --noEmit false --rootDir src --sourceMap --module commonjs --moduleResolution node10 --outDir dist/cjs",
"build": "tshy",
"test": "vitest run",
"prepublishOnly": "pnpm test && pnpm build"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/effect-plugin/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "../src/index";
import "../src/index.js";

import { Cause, Effect, Exit } from "effect";
import { describe, expect, test } from "vitest";
Expand Down
7 changes: 0 additions & 7 deletions packages/effect-plugin/tests/tsconfig.json

This file was deleted.

9 changes: 0 additions & 9 deletions packages/effect-plugin/tsconfig.build.json

This file was deleted.

3 changes: 3 additions & 0 deletions packages/effect-plugin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../.configs/tsconfig.base.json"
}
6 changes: 3 additions & 3 deletions packages/effect-plugin/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig, mergeConfig } from "vitest/config";
import rootConfig from "../../vitest.root";
import { defineProject, mergeConfig } from "vitest/config";
import rootConfig from "../../vitest.root.mjs";

const config: Record<string, any> = mergeConfig(rootConfig, defineConfig({}));
const config: Record<string, any> = mergeConfig(rootConfig, defineProject({}));
export default config;
43 changes: 30 additions & 13 deletions packages/zod/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "zod",
"type": "module",
"version": "3.23.8",
"author": "Colin McDonnell <[email protected]>",
"description": "TypeScript-first schema declaration and validation library with static type inference",
Expand All @@ -9,20 +10,39 @@
"keywords": ["typescript", "schema", "validation", "type", "inference"],
"license": "MIT",
"sideEffects": false,
"main": "./dist/cjs/index.js",
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/esm/index.d.ts",
"types": "./dist/commonjs/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dist/esm/index.d.ts",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
"import": {
"@zod/source": "./src/index.ts",
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
},
"./package.json": "./package.json",
"./locales/*": {
"types": "./dist/esm/locales/*.d.ts",
"require": "./dist/cjs/locales/*.js",
"import": "./dist/esm/locales/*.js"
"import": {
"@zod/source": "./src/locales/*",
"types": "./dist/esm/locales/*",
"default": "./dist/esm/locales/*"
},
"require": {
"types": "./dist/commonjs/locales/*",
"default": "./dist/commonjs/locales/*"
}
}
},
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts",
"./locales/*": "./src/locales/*"
}
},
"repository": {
Expand All @@ -39,10 +59,7 @@
},
"scripts": {
"clean": "rm -rf dist",
"build": "pnpm run clean && pnpm build:cjs && pnpm build:esm",
"build:esm": "pnpm tsc -p ./tsconfig.build.json --noEmit false --declaration --declarationMap --sourceMap --rootDir src --module esnext --outDir dist/esm",
"build:cjs": "pnpm tsc -p ./tsconfig.build.json --noEmit false --declaration --declarationMap --sourceMap --rootDir src --module commonjs --outDir dist/cjs",
"build:rollup": "rollup --config ../../.configs/rollup.esm.mjs",
"build": "tshy",
"test:watch": "pnpm vitest",
"test": "pnpm vitest run",
"prepublishOnly": "pnpm test && pnpm run build"
Expand Down
Loading