Skip to content

Commit b59e431

Browse files
marcomuserMarco Muser
and
Marco Muser
authored
Fix CJS build for TypeScript (#1360)
* Fix cjs build for ts * add changeset * refactor: copy index.d.ts with cp --------- Co-authored-by: Marco Muser <[email protected]>
1 parent 60570ef commit b59e431

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.changeset/gold-islands-double.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"openapi-fetch": patch
3+
---
4+
5+
Fix CJS build for TypeScript

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 && cp dist/index.d.ts dist/cjs/index.d.cts",
5055
"lint": "pnpm run lint:js",
5156
"lint:js": "eslint \"{src,test}/**/*.{js,ts}\"",
5257
"lint:prettier": "prettier --check \"{src,test}/**/*\"",

0 commit comments

Comments
 (0)