diff --git a/docs/package.json b/docs/package.json index 086a431..43fe341 100644 --- a/docs/package.json +++ b/docs/package.json @@ -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", diff --git a/docs/pages/docs/_meta.json b/docs/pages/docs/_meta.json index 09b8545..fb3d8fd 100644 --- a/docs/pages/docs/_meta.json +++ b/docs/pages/docs/_meta.json @@ -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" } \ No newline at end of file diff --git a/docs/pages/docs/cjs.mdx b/docs/pages/docs/cjs.mdx deleted file mode 100644 index a417194..0000000 --- a/docs/pages/docs/cjs.mdx +++ /dev/null @@ -1,9 +0,0 @@ -# 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. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index fb58b23..0f96295 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@zhttp/monorepo", - "version": "2.0.0", + "version": "2.0.1-refactor-remove-cjs-support.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@zhttp/monorepo", - "version": "2.0.0", + "version": "2.0.1-refactor-remove-cjs-support.0", "license": "MIT", "workspaces": [ "packages/errors", @@ -30,7 +30,7 @@ }, "docs": { "name": "@zhttp/docs", - "version": "2.0.0", + "version": "2.0.1-refactor-remove-cjs-support.0", "dependencies": { "next": "^13.0.6", "nextra": "^3.0.0", @@ -11642,12 +11642,12 @@ }, "packages/core": { "name": "@zhttp/core", - "version": "2.0.0", + "version": "2.0.1-refactor-remove-cjs-support.0", "license": "MIT", "dependencies": { "@asteasolutions/zod-to-openapi": "^8.0.0", "@types/express": "^5.0.0", - "@zhttp/errors": "2.0.0", + "@zhttp/errors": "2.0.1-refactor-remove-cjs-support.0", "cookie-parser": "^1.4.6", "cors": "^2.8.5", "express": "^5.2.1", @@ -11674,7 +11674,7 @@ "npm": "^10.2.3" }, "peerDependencies": { - "@zhttp/errors": "2.0.0", + "@zhttp/errors": "2.0.1-refactor-remove-cjs-support.0", "zod": "^4.0.0" } }, @@ -11697,7 +11697,7 @@ }, "packages/errors": { "name": "@zhttp/errors", - "version": "2.0.0", + "version": "2.0.1-refactor-remove-cjs-support.0", "license": "MIT", "dependencies": { "zod": "^4.0.0" @@ -11734,7 +11734,7 @@ }, "packages/extract-oas": { "name": "@zhttp/extract-oas", - "version": "2.0.0", + "version": "2.0.1-refactor-remove-cjs-support.0", "license": "MIT", "dependencies": { "tsx": "^4.19.0", @@ -11742,7 +11742,7 @@ "yargs": "^17.7.2" }, "bin": { - "extract-oas": "dist/esm/main.js" + "extract-oas": "dist/main.js" }, "devDependencies": { "@types/node": "^20.11.0", diff --git a/package.json b/package.json index bb5108d..2b1aef7 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/core/package.json b/packages/core/package.json index 83b5fe1..510af7c 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -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", @@ -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", @@ -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": { diff --git a/packages/core/tsconfig.build.esm.json b/packages/core/tsconfig.build.esm.json deleted file mode 100644 index fcad4be..0000000 --- a/packages/core/tsconfig.build.esm.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "rootDir": "./src", - "outDir": "./dist/esm", - }, - "include": ["src/**/*"], - "exclude": ["src/**/*.test.ts"] -} \ No newline at end of file diff --git a/packages/extract-oas/tsconfig.build.esm.json b/packages/core/tsconfig.build.json similarity index 84% rename from packages/extract-oas/tsconfig.build.esm.json rename to packages/core/tsconfig.build.json index b48fff7..2acbe16 100644 --- a/packages/extract-oas/tsconfig.build.esm.json +++ b/packages/core/tsconfig.build.json @@ -2,7 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "rootDir": "./src", - "outDir": "./dist/esm" + "outDir": "./dist" }, "include": ["src/**/*"], "exclude": ["src/**/*.test.ts"] diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 43bf37b..7f1e7ad 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -1,10 +1,9 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "baseUrl": ".", - "declarationDir": "./dist/types" + "baseUrl": "." }, "include": [ "./src/**/*.ts" ] -} \ No newline at end of file +} diff --git a/packages/errors/package.json b/packages/errors/package.json index 0ce270a..c837846 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -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", @@ -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": { diff --git a/packages/errors/tsconfig.build.esm.json b/packages/errors/tsconfig.build.esm.json deleted file mode 100644 index 4ca01c0..0000000 --- a/packages/errors/tsconfig.build.esm.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "rootDir": "./src", - "outDir": "./dist/esm" - }, - "include": ["src/**/*"], - "exclude": ["src/**/*.test.ts"] -} \ No newline at end of file diff --git a/packages/errors/tsconfig.build.json b/packages/errors/tsconfig.build.json new file mode 100644 index 0000000..2acbe16 --- /dev/null +++ b/packages/errors/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "rootDir": "./src", + "outDir": "./dist" + }, + "include": ["src/**/*"], + "exclude": ["src/**/*.test.ts"] +} diff --git a/packages/errors/tsconfig.json b/packages/errors/tsconfig.json index 43bf37b..7f1e7ad 100644 --- a/packages/errors/tsconfig.json +++ b/packages/errors/tsconfig.json @@ -1,10 +1,9 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "baseUrl": ".", - "declarationDir": "./dist/types" + "baseUrl": "." }, "include": [ "./src/**/*.ts" ] -} \ No newline at end of file +} diff --git a/packages/extract-oas/package.json b/packages/extract-oas/package.json index e89c71a..4b72e44 100644 --- a/packages/extract-oas/package.json +++ b/packages/extract-oas/package.json @@ -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", @@ -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", diff --git a/packages/extract-oas/tsconfig.build.json b/packages/extract-oas/tsconfig.build.json new file mode 100644 index 0000000..2acbe16 --- /dev/null +++ b/packages/extract-oas/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "rootDir": "./src", + "outDir": "./dist" + }, + "include": ["src/**/*"], + "exclude": ["src/**/*.test.ts"] +} diff --git a/packages/extract-oas/tsconfig.json b/packages/extract-oas/tsconfig.json index 5b307fe..7f1e7ad 100644 --- a/packages/extract-oas/tsconfig.json +++ b/packages/extract-oas/tsconfig.json @@ -1,8 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "baseUrl": ".", - "declarationDir": "./dist/types" + "baseUrl": "." }, "include": [ "./src/**/*.ts" diff --git a/readme.md b/readme.md index 3aebe1a..cd661be 100644 --- a/readme.md +++ b/readme.md @@ -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.