From 77a2507c8b8979b1a3dd9ca646483c07a9a39036 Mon Sep 17 00:00:00 2001 From: rinsuki <428rinsuki+git@gmail.com> Date: Mon, 4 Apr 2022 23:19:55 +0000 Subject: [PATCH 1/2] Add UMD build --- package.json | 3 ++- rollup.config.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 6723732de..02cfa879c 100644 --- a/package.json +++ b/package.json @@ -49,11 +49,12 @@ "check": "yarn lint:check && yarn prettier:check", "fix": "yarn lint:fix && yarn prettier:fix", "clean": "rm -rf lib/* deno/lib/*", - "build": "yarn run clean && npm run build:cjs && npm run build:esm && npm run build:deno", + "build": "yarn run clean && npm run build:cjs && npm run build:esm && npm run build:deno && yarn run build:tweak-dts", "build:deno": "node ./deno/build.mjs", "build:esm": "rollup --config rollup.config.js", "build:cjs": "tsc --p tsconfig.cjs.json", "build:types": "tsc --p tsconfig.types.json", + "build:tweak-dts": "echo 'export as namespace Zod;' >> lib/index.d.ts", "rollup": "rollup --config rollup.config.js", "test": "jest --coverage", "test:deno": "cd deno && deno test", diff --git a/rollup.config.js b/rollup.config.js index 7275a1441..76dabca04 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -10,6 +10,12 @@ export default [ format: "es", sourcemap: false, }, + { + file: "lib/index.umd.js", + name: "Zod", + format: "umd", + sourcemap: false, + }, ], plugins: [ typescript({ From a7bdad3af3f59cc5afc8de25b5cb70100e91c4f3 Mon Sep 17 00:00:00 2001 From: rinsuki <428rinsuki+git@gmail.com> Date: Wed, 6 Apr 2022 21:28:32 +0000 Subject: [PATCH 2/2] use more better way to `export as namespace` --- index.d.ts | 2 ++ package.json | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 000000000..97b0b2272 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,2 @@ +export * from "./lib"; +export as namespace Zod; diff --git a/package.json b/package.json index 02cfa879c..e48cdc607 100644 --- a/package.json +++ b/package.json @@ -3,19 +3,20 @@ "version": "3.14.4", "description": "TypeScript-first schema declaration and validation library with static type inference", "main": "./lib/index.js", - "types": "./lib/index.d.ts", + "types": "./index.d.ts", "module": "./lib/index.mjs", "dependencies": {}, "exports": { ".": { "require": "./lib/index.js", "import": "./lib/index.mjs", - "types": "./lib/index.d.ts" + "types": "./index.d.ts" }, "./package.json": "./package.json" }, "files": [ - "/lib" + "/lib", + "/index.d.ts" ], "repository": { "type": "git", @@ -49,12 +50,11 @@ "check": "yarn lint:check && yarn prettier:check", "fix": "yarn lint:fix && yarn prettier:fix", "clean": "rm -rf lib/* deno/lib/*", - "build": "yarn run clean && npm run build:cjs && npm run build:esm && npm run build:deno && yarn run build:tweak-dts", + "build": "yarn run clean && npm run build:cjs && npm run build:esm && npm run build:deno", "build:deno": "node ./deno/build.mjs", "build:esm": "rollup --config rollup.config.js", "build:cjs": "tsc --p tsconfig.cjs.json", "build:types": "tsc --p tsconfig.types.json", - "build:tweak-dts": "echo 'export as namespace Zod;' >> lib/index.d.ts", "rollup": "rollup --config rollup.config.js", "test": "jest --coverage", "test:deno": "cd deno && deno test",