Skip to content

Commit 9b98874

Browse files
author
Marco Muser
committed
Fix cjs build for ts
1 parent 60570ef commit 9b98874

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

packages/openapi-fetch/package.json

+9-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@
1313
"types": "./dist/index.d.ts",
1414
"exports": {
1515
".": {
16-
"require": "./dist/index.cjs",
17-
"import": "./dist/index.js",
18-
"types": "./dist/index.d.ts"
16+
"import": {
17+
"types": "./dist/index.d.ts",
18+
"default": "./dist/index.js"
19+
},
20+
"require": {
21+
"types": "./dist/cjs/index.d.cts",
22+
"default": "./dist/cjs/index.cjs"
23+
}
1924
},
2025
"./*": "./*"
2126
},
@@ -46,7 +51,7 @@
4651
"build:clean": "del dist",
4752
"build:ts": "tsc -p tsconfig.build.json",
4853
"build:ts-min": "esbuild --bundle src/index.ts --format=esm --minify --outfile=dist/index.min.js && cp dist/index.d.ts dist/index.min.d.ts",
49-
"build:cjs": "esbuild --bundle src/index.ts --format=cjs --outfile=dist/index.cjs",
54+
"build:cjs": "esbuild --bundle src/index.ts --format=cjs --outfile=dist/cjs/index.cjs && node ./scripts/copy-types-cjs.js",
5055
"lint": "pnpm run lint:js",
5156
"lint:js": "eslint \"{src,test}/**/*.{js,ts}\"",
5257
"lint:prettier": "prettier --check \"{src,test}/**/*\"",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import fs from "node:fs/promises";
2+
3+
async function copyTypesForCjs() {
4+
const sourceFilePath = "./dist/index.d.ts";
5+
const targetFilePath = "./dist/cjs/index.d.cts";
6+
7+
await fs.copyFile(sourceFilePath, targetFilePath);
8+
}
9+
10+
copyTypesForCjs();

0 commit comments

Comments
 (0)