Skip to content

Commit a180b16

Browse files
committed
build: fix exports for typescript support :}
1 parent a5e7c55 commit a180b16

File tree

7 files changed

+63
-16
lines changed

7 files changed

+63
-16
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
dist
22
node_modules
33
lib/empty.mjs
4+
lib/empty.cjs
45
coverage

lib/empty.cjs

Whitespace-only changes.

lib/index.d.cts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export declare const fetch: typeof globalThis.fetch;
2+
export declare const Blob: typeof globalThis.Blob;
3+
export declare const File: typeof globalThis.File;
4+
export declare const FormData: typeof globalThis.FormData;
5+
export declare const Headers: typeof globalThis.Headers;
6+
export declare const Request: typeof globalThis.Request;
7+
export declare const Response: typeof globalThis.Response;
8+
export declare const AbortController: typeof globalThis.AbortController;
9+
10+
export default fetch;

lib/index.d.mts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export declare const fetch: typeof globalThis.fetch;
2+
export declare const Blob: typeof globalThis.Blob;
3+
export declare const File: typeof globalThis.File;
4+
export declare const FormData: typeof globalThis.FormData;
5+
export declare const Headers: typeof globalThis.Headers;
6+
export declare const Request: typeof globalThis.Request;
7+
export declare const Response: typeof globalThis.Response;
8+
export declare const AbortController: typeof globalThis.AbortController;
9+
10+
export default fetch;

lib/polyfill.d.cts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

lib/polyfill.d.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

package.json

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"type": "module",
88
"exports": {
99
".": {
10-
"types": "./lib/index.d.ts",
1110
"browser": "./dist/native.mjs",
1211
"bun": "./dist/native.mjs",
1312
"deno": "./dist/native.mjs",
@@ -20,33 +19,58 @@
2019
"worker": "./dist/native.mjs",
2120
"workerd": "./dist/native.mjs",
2221
"node": {
23-
"import": "./dist/index.mjs",
24-
"require": "./lib/index.cjs"
22+
"import": {
23+
"types": "./lib/index.d.mts",
24+
"default": "./dist/index.mjs"
25+
},
26+
"require": {
27+
"types": "./lib/index.d.cts",
28+
"default": "./lib/index.cjs"
29+
}
2530
},
31+
"types": "./lib/index.d.mts",
2632
"import": "./dist/native.mjs",
27-
"require": "./dist/native.cjs"
33+
"require": "./dist/native.cjs",
34+
"default": "./dist/native.mjs"
2835
},
2936
"./polyfill": {
30-
"types": "./lib/polyfill.d.ts",
3137
"node": {
32-
"import": "./dist/polyfill.mjs",
33-
"require": "./dist/polyfill.cjs"
38+
"import": {
39+
"types": "./lib/polyfill.d.mts",
40+
"default": "./dist/polyfill.mjs"
41+
},
42+
"require": {
43+
"types": "./lib/polyfill.d.cts",
44+
"default": "./dist/polyfill.cjs"
45+
}
3446
},
47+
"types": "./lib/polyfill.d.mts",
3548
"import": "./lib/empty.mjs",
36-
"require": "./lib/empty.mjs"
49+
"require": "./lib/empty.cjs",
50+
"default": "./lib/empty.mjs"
3751
},
3852
"./node": {
39-
"types": "./lib/index.d.ts",
40-
"import": "./dist/node.mjs",
41-
"require": "./dist/node.cjs"
53+
"import": {
54+
"types": "./lib/index.d.mts",
55+
"default": "./dist/node.mjs"
56+
},
57+
"require": {
58+
"types": "./lib/index.d.cts",
59+
"default": "./dist/node.cjs"
60+
}
4261
},
4362
"./src/index.js": {
44-
"types": "./lib/index.d.ts",
45-
"import": "./dist/index.mjs",
46-
"require": "./lib/index.cjs"
63+
"import": {
64+
"types": "./lib/index.d.mts",
65+
"default": "./dist/index.mjs"
66+
},
67+
"require": {
68+
"types": "./lib/index.d.cts",
69+
"default": "./lib/index.cjs"
70+
}
4771
}
4872
},
49-
"types": "./lib/index.d.ts",
73+
"types": "./lib/index.d.mts",
5074
"main": "./lib/index.cjs",
5175
"module": "./dist/index.mjs",
5276
"files": [
@@ -77,4 +101,4 @@
77101
"vitest": "^0.34.2"
78102
},
79103
"packageManager": "[email protected]"
80-
}
104+
}

0 commit comments

Comments
 (0)