From ea76748a46c50d6360acd997110b931f7c630643 Mon Sep 17 00:00:00 2001 From: 0xZensh Date: Tue, 24 Sep 2024 07:35:23 +0800 Subject: [PATCH] chore: export CJS module, #10 --- package.json | 18 ++++++------------ tsconfig-cjs.json | 9 +++++++++ tsconfig.json | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 tsconfig-cjs.json diff --git a/package.json b/package.json index 17a8e5b..0697568 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "xid-ts", "type": "module", - "version": "1.1.2", + "version": "1.1.3", "author": "0xZensh ", "description": "xid is a globally unique id generator thought for the web. A Typescript port of https://github.com/rs/xid.", "license": "MIT", @@ -13,19 +13,13 @@ "files": [ "dist", "package.json", - "pnpm-lock.yaml", "LICENSE", "README.md" ], - "main": "dist/index.js", - "typings": "dist/index.d.ts", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "browser": "./dist/index.js", - "default": "./dist/index.js" - } - }, + "main": "dist/cjs/index", + "module": "dist/esm/index", + "unpkg": "dist/esm/index", + "typings": "dist/esm/index.d.ts", "browser": { "node:crypto": false }, @@ -33,7 +27,7 @@ "node": ">=18.0.0" }, "scripts": { - "build": "npm run clean && tsc -p tsconfig.json", + "build": "npm run clean && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json", "clean": "rm -rf dist", "lint": "eslint .", "lint:fix": "eslint . --fix", diff --git a/tsconfig-cjs.json b/tsconfig-cjs.json new file mode 100644 index 0000000..4bede2f --- /dev/null +++ b/tsconfig-cjs.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "target": "es2018", + "module": "CommonJS", + "outDir": "./dist/cjs", + "moduleResolution": "node" + } +} diff --git a/tsconfig.json b/tsconfig.json index 2220776..3c15aa6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "target": "es2022", "module": "esnext", - "outDir": "./dist", + "outDir": "./dist/esm", "importHelpers": true, "moduleResolution": "bundler", "resolveJsonModule": true,