Skip to content

Commit

Permalink
build: fix exports for typescript support :}
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 22, 2023
1 parent a5e7c55 commit a180b16
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 16 deletions.
1 change: 1 addition & 0 deletions .eslintignore
@@ -1,4 +1,5 @@
dist
node_modules
lib/empty.mjs
lib/empty.cjs
coverage
Empty file added lib/empty.cjs
Empty file.
10 changes: 10 additions & 0 deletions lib/index.d.cts
@@ -0,0 +1,10 @@
export declare const fetch: typeof globalThis.fetch;
export declare const Blob: typeof globalThis.Blob;
export declare const File: typeof globalThis.File;
export declare const FormData: typeof globalThis.FormData;
export declare const Headers: typeof globalThis.Headers;
export declare const Request: typeof globalThis.Request;
export declare const Response: typeof globalThis.Response;
export declare const AbortController: typeof globalThis.AbortController;

export default fetch;
10 changes: 10 additions & 0 deletions lib/index.d.mts
@@ -0,0 +1,10 @@
export declare const fetch: typeof globalThis.fetch;
export declare const Blob: typeof globalThis.Blob;
export declare const File: typeof globalThis.File;
export declare const FormData: typeof globalThis.FormData;
export declare const Headers: typeof globalThis.Headers;
export declare const Request: typeof globalThis.Request;
export declare const Response: typeof globalThis.Response;
export declare const AbortController: typeof globalThis.AbortController;

export default fetch;
1 change: 1 addition & 0 deletions lib/polyfill.d.cts
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions lib/polyfill.d.mts
@@ -0,0 +1 @@
export {};
56 changes: 40 additions & 16 deletions package.json
Expand Up @@ -7,7 +7,6 @@
"type": "module",
"exports": {
".": {
"types": "./lib/index.d.ts",
"browser": "./dist/native.mjs",
"bun": "./dist/native.mjs",
"deno": "./dist/native.mjs",
Expand All @@ -20,33 +19,58 @@
"worker": "./dist/native.mjs",
"workerd": "./dist/native.mjs",
"node": {
"import": "./dist/index.mjs",
"require": "./lib/index.cjs"
"import": {
"types": "./lib/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./lib/index.d.cts",
"default": "./lib/index.cjs"
}
},
"types": "./lib/index.d.mts",
"import": "./dist/native.mjs",
"require": "./dist/native.cjs"
"require": "./dist/native.cjs",
"default": "./dist/native.mjs"
},
"./polyfill": {
"types": "./lib/polyfill.d.ts",
"node": {
"import": "./dist/polyfill.mjs",
"require": "./dist/polyfill.cjs"
"import": {
"types": "./lib/polyfill.d.mts",
"default": "./dist/polyfill.mjs"
},
"require": {
"types": "./lib/polyfill.d.cts",
"default": "./dist/polyfill.cjs"
}
},
"types": "./lib/polyfill.d.mts",
"import": "./lib/empty.mjs",
"require": "./lib/empty.mjs"
"require": "./lib/empty.cjs",
"default": "./lib/empty.mjs"
},
"./node": {
"types": "./lib/index.d.ts",
"import": "./dist/node.mjs",
"require": "./dist/node.cjs"
"import": {
"types": "./lib/index.d.mts",
"default": "./dist/node.mjs"
},
"require": {
"types": "./lib/index.d.cts",
"default": "./dist/node.cjs"
}
},
"./src/index.js": {
"types": "./lib/index.d.ts",
"import": "./dist/index.mjs",
"require": "./lib/index.cjs"
"import": {
"types": "./lib/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./lib/index.d.cts",
"default": "./lib/index.cjs"
}
}
},
"types": "./lib/index.d.ts",
"types": "./lib/index.d.mts",
"main": "./lib/index.cjs",
"module": "./dist/index.mjs",
"files": [
Expand Down Expand Up @@ -77,4 +101,4 @@
"vitest": "^0.34.2"
},
"packageManager": "pnpm@8.6.12"
}
}

0 comments on commit a180b16

Please sign in to comment.