From 33147c9bfe8d47c63ece41a03903e287f64d5a59 Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Tue, 8 Oct 2024 16:45:56 +0700 Subject: [PATCH] fix: distribution config --- packages/hyperwebjs/package.json | 24 ++++++++++++++++++------ packages/hyperwebjs/tsconfig.esm.json | 9 --------- packages/hyperwebjs/tsconfig.json | 21 ++++++++++++++++----- packages/hyperwebjs/tsconfig.node.json | 15 +++++++++++++++ 4 files changed, 49 insertions(+), 20 deletions(-) delete mode 100644 packages/hyperwebjs/tsconfig.esm.json create mode 100644 packages/hyperwebjs/tsconfig.node.json diff --git a/packages/hyperwebjs/package.json b/packages/hyperwebjs/package.json index 71e13d5..994b265 100644 --- a/packages/hyperwebjs/package.json +++ b/packages/hyperwebjs/package.json @@ -3,9 +3,18 @@ "version": "0.0.3", "author": "Hyperweb ", "description": "JS client for Hyperweb", - "main": "index.js", - "module": "esm/index.js", - "types": "index.d.ts", + "source": "src/index.ts", + "main": "dist/cjs/index.js", + "module": "dist/esm/index.js", + "types": "dist/cjs/index.d.ts", + "exports": { + ".": { + "types": "./dist/cjs/index.d.ts", + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js" + }, + "./package.json": "./package.json" + }, "homepage": "https://github.com/hyperweb-io/hyperweb-build", "license": "SEE LICENSE IN LICENSE", "publishConfig": { @@ -24,8 +33,11 @@ "clean": "rimraf dist/**", "prepare": "npm run build", "codegen": "ts-node ./scripts/codegen.ts", - "build": "npm run clean; npm run codegen; tsc; tsc -p tsconfig.esm.json; npm run copy", - "build:dev": "npm run clean; npm run codegen; tsc --declarationMap; tsc -p tsconfig.esm.json; npm run copy", + "build": "npm run build:esm && npm run build:cjs", + "build:esm": "npm run clean; npm run codegen; tsc; tsc -p tsconfig.json; npm run copy", + "build:cjs": "npm run clean; npm run codegen; tsc; tsc -p tsconfig.node.json; npm run copy", + "build:esm:dev": "npm run clean; npm run codegen; tsc --declarationMap; tsc -p tsconfig.json; npm run copy", + "build:cjs:dev": "npm run clean; npm run codegen; tsc --declarationMap; tsc -p tsconfig.node.json; npm run copy", "lint": "eslint . --fix", "test": "jest", "test:watch": "jest --watch" @@ -45,4 +57,4 @@ }, "keywords": [], "gitHead": "6941f0f94c741b25c3ad79d1c4c758065f1e36d9" -} +} \ No newline at end of file diff --git a/packages/hyperwebjs/tsconfig.esm.json b/packages/hyperwebjs/tsconfig.esm.json deleted file mode 100644 index 800d750..0000000 --- a/packages/hyperwebjs/tsconfig.esm.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "dist/esm", - "module": "es2022", - "rootDir": "src/", - "declaration": false - } -} diff --git a/packages/hyperwebjs/tsconfig.json b/packages/hyperwebjs/tsconfig.json index 1a9d569..ed0e9e6 100644 --- a/packages/hyperwebjs/tsconfig.json +++ b/packages/hyperwebjs/tsconfig.json @@ -1,9 +1,20 @@ { - "extends": "../../tsconfig.json", + "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "dist", - "rootDir": "src/" + "outDir": "dist/esm", + "module": "esnext", + "moduleResolution": "node", + "target": "es2022", + "lib": ["es2022", "dom"], + "rootDir": "src/", + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "esModuleInterop": true, + "strict": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true }, - "include": ["src/**/*.ts"], - "exclude": ["dist", "node_modules", "**/*.spec.*", "**/*.test.*"] + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] } diff --git a/packages/hyperwebjs/tsconfig.node.json b/packages/hyperwebjs/tsconfig.node.json new file mode 100644 index 0000000..5067830 --- /dev/null +++ b/packages/hyperwebjs/tsconfig.node.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "dist/cjs", + "rootDir": "src/", + "module": "commonjs", + "target": "es2015", + "esModuleInterop": true, + "moduleResolution": "node", + "declaration": true, + "sourceMap": true + }, + "include": ["src/**/*.ts"], + "exclude": ["dist", "node_modules", "**/*.spec.*", "**/*.test.*"] +}