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
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zhttp/docs",
"private": true,
"version": "2.0.0",
"version": "2.0.1-refactor-remove-cjs-support.0",
"scripts": {
"fill-code-snippets": "npx embedme ./pages/**/*.*",
"prebuild": "npm run fill-code-snippets",
Expand Down
3 changes: 1 addition & 2 deletions docs/pages/docs/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
"concepts": "Concepts",
"openapi": "OpenAPI",
"errors": "Errors",
"order-of-execution": "Order of execution",
"cjs": "CommonJS support"
"order-of-execution": "Order of execution"
}
9 changes: 0 additions & 9 deletions docs/pages/docs/cjs.mdx

This file was deleted.

18 changes: 9 additions & 9 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zhttp/monorepo",
"version": "2.0.0",
"version": "2.0.1-refactor-remove-cjs-support.0",
"private": true,
"repository": {
"type": "git",
Expand Down
22 changes: 8 additions & 14 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zhttp/core",
"version": "2.0.0",
"version": "2.0.1-refactor-remove-cjs-support.0",
"description": "A minimal, strongly typed HTTP library with Zod validation",
"repository": {
"type": "git",
Expand All @@ -10,29 +10,23 @@
"author": "Evert De Spiegeleer",
"type": "module",
"exports": {
"import": {
"types": "./dist/types/main.d.ts",
"default": "./dist/esm/main.js"
},
"require": {
"types": "./dist/types/main.d.ts",
"default": "./dist/cjs/main.cjs"
".": {
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
}
},
"types": "./dist/types/main.d.ts",
"types": "./dist/main.d.ts",
"files": [
"./dist",
"./readme.md"
],
"scripts": {
"build": "npm run build:esm && npm run build:cjs",
"build:cjs": "npx rollup ./dist/esm/main.js --file ./dist/cjs/main.cjs --format cjs",
"build:esm": "tsc -p tsconfig.build.esm.json",
"build": "tsc -p tsconfig.build.json",
"test": "node --test --test-reporter spec --test-reporter-destination stdout --test-reporter junit --test-reporter-destination=./test-report.xml --loader ts-node/esm ./src/**/*.test.ts"
},
"dependencies": {
"@asteasolutions/zod-to-openapi": "^8.0.0",
"@zhttp/errors": "2.0.0",
"@zhttp/errors": "2.0.1-refactor-remove-cjs-support.0",
"@types/express": "^5.0.0",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
Expand All @@ -56,7 +50,7 @@
"typescript": "^5.5.0"
},
"peerDependencies": {
"@zhttp/errors": "2.0.0",
"@zhttp/errors": "2.0.1-refactor-remove-cjs-support.0",
"zod": "^4.0.0"
},
"engines": {
Expand Down
9 changes: 0 additions & 9 deletions packages/core/tsconfig.build.esm.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist/esm"
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.ts"]
Expand Down
5 changes: 2 additions & 3 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"declarationDir": "./dist/types"
"baseUrl": "."
},
"include": [
"./src/**/*.ts"
]
}
}
18 changes: 6 additions & 12 deletions packages/errors/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zhttp/errors",
"version": "2.0.0",
"version": "2.0.1-refactor-remove-cjs-support.0",
"description": "Error library extending @zhttp/core",
"repository": {
"type": "git",
Expand All @@ -10,24 +10,18 @@
"author": "Evert De Spiegeleer",
"type": "module",
"exports": {
"import": {
"types": "./dist/types/main.d.ts",
"default": "./dist/esm/main.js"
},
"require": {
"types": "./dist/types/main.d.ts",
"default": "./dist/cjs/main.cjs"
".": {
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
}
},
"types": "./dist/types/main.d.ts",
"types": "./dist/main.d.ts",
"files": [
"./dist",
"./readme.md"
],
"scripts": {
"build": "npm run build:esm && npm run build:cjs",
"build:cjs": "npx rollup ./dist/esm/main.js --file ./dist/cjs/main.cjs --format cjs",
"build:esm": "tsc -p tsconfig.build.esm.json",
"build": "tsc -p tsconfig.build.json",
"test": "echo \"No tests here :)\""
},
"dependencies": {
Expand Down
9 changes: 0 additions & 9 deletions packages/errors/tsconfig.build.esm.json

This file was deleted.

9 changes: 9 additions & 0 deletions packages/errors/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.ts"]
}
5 changes: 2 additions & 3 deletions packages/errors/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"declarationDir": "./dist/types"
"baseUrl": "."
},
"include": [
"./src/**/*.ts"
]
}
}
7 changes: 3 additions & 4 deletions packages/extract-oas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zhttp/extract-oas",
"version": "2.0.0",
"version": "2.0.1-refactor-remove-cjs-support.0",
"description": "CLI tool to extract OpenAPI specs from zhttp servers",
"repository": {
"type": "git",
Expand All @@ -10,15 +10,14 @@
"author": "Evert De Spiegeleer",
"type": "module",
"bin": {
"extract-oas": "./dist/esm/main.js"
"extract-oas": "./dist/main.js"
},
"files": [
"./dist",
"./readme.md"
],
"scripts": {
"build": "npm run build:esm",
"build:esm": "tsc -p tsconfig.build.esm.json"
"build": "tsc -p tsconfig.build.json"
},
"dependencies": {
"tsx": "^4.19.0",
Expand Down
9 changes: 9 additions & 0 deletions packages/extract-oas/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.ts"]
}
3 changes: 1 addition & 2 deletions packages/extract-oas/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"declarationDir": "./dist/types"
"baseUrl": "."
},
"include": [
"./src/**/*.ts"
Expand Down
10 changes: 0 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,6 @@ validationExampleController.endpoint(
- Controller 'AFTER' middlewares
- Server 'AFTER' middlewares

# CommonJS support

[📰 CommonJS is hurting JavaScript](https://deno.com/blog/commonjs-is-hurting-javascript)

The JavaScript ecosystem is (slowly but steadily) moving towards ESM and away from CommonJS. zhttp is build as an ESM module. It's strongly encouraged to use it like that.

CommonJS is currently supported; the packages include both builds for ESM and CommonJS. You can use zhttp both ways.

If major issues with supporting CommonJS were to come up, or if we'd notice that the package would become too big (by essentially having to ship the build code twice), CommonJS support might be dropped in the future.

# Migrating to v2 (Zod 4)

Version 2 of zhttp upgrades from Zod 3 to Zod 4. This is a **breaking change** for library consumers.
Expand Down