Skip to content

Commit c6d945b

Browse files
authored
Separate outputs for CommonJS and ESM when building openapi-typescrip… (#1479)
* Separate outputs for CommonJS and ESM when building openapi-typescript-helpers * Add top-level build * Add changeset * Build TS helpers before building fetch
1 parent c947515 commit c6d945b

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

Diff for: .changeset/hot-terms-vanish.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"openapi-fetch": patch
3+
"openapi-typescript-helpers": patch
4+
---
5+
6+
Fixed build of openapi-typescript-helpers for CommonJS environments

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"scripts": {
1111
"build": "run-p -s build:*",
1212
"build:openapi-typescript": "cd packages/openapi-typescript && pnpm run build",
13-
"build:openapi-fetch": "cd packages/openapi-fetch && pnpm run build",
13+
"build:openapi-fetch": "cd packages/openapi-typescript-helpers && pnpm run build && cd ../openapi-fetch && pnpm run build",
1414
"lint": "run-p -s lint:*",
1515
"lint:openapi-typescript": "cd packages/openapi-typescript && pnpm run lint",
1616
"lint:openapi-typescript-helpers": "cd packages/openapi-typescript-helpers && pnpm run lint",

Diff for: packages/openapi-typescript-helpers/package.json

+12-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@
1212
"types": "./index.d.ts",
1313
"exports": {
1414
".": {
15-
"default": "./index.js",
16-
"types": "./index.d.ts"
15+
"import": {
16+
"types": "./dist/index.d.ts",
17+
"default": "./dist/index.js"
18+
},
19+
"require": {
20+
"types": "./dist/cjs/index.d.cts",
21+
"default": "./dist/cjs/index.cjs"
22+
}
1723
},
1824
"./*": "./*"
1925
},
@@ -27,6 +33,10 @@
2733
"url": "https://github.com/drwpow/openapi-typescript/issues"
2834
},
2935
"scripts": {
36+
"build": "pnpm run build:clean && pnpm run build:js && pnpm run build:cjs",
37+
"build:clean": "del dist",
38+
"build:js": "mkdir -p dist && cp index.js index.d.ts dist",
39+
"build:cjs": "mkdir -p dist/cjs && cp index.js dist/cjs/index.js && cp index.d.ts dist/cjs/index.d.cts",
3040
"lint": "pnpm run lint:js",
3141
"lint:js": "eslint \"*.{js,ts}\"",
3242
"lint:prettier": "prettier --check \"{src,test}/**/*\"",

0 commit comments

Comments
 (0)