Skip to content

Commit e949177

Browse files
committed
npm author, node-fetch commonjs import fix
1 parent bf87041 commit e949177

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

node/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "tpy",
33
"version": "v1.0.0-pre-release-5",
44
"description": "🔑 A strongly typed Pylon API client.",
5+
"author": "insyri",
56
"license": "MIT",
67
"type": "commonjs",
78
"main": "lib/mod.js",

src/fetch_polyfill.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ if (
55
'process' in globalThis && // If Node
66
Number(globalThis.process.version.substring(1, 3)) < 18
77
) {
8+
const fetch = (url: RequestInfo, init?: RequestInit): Promise<Response> =>
9+
import('node-fetch').then(({ default: fetch }) => fetch(url, init));
810
Object.defineProperty(
911
globalThis,
1012
'fetch',
11-
require('node-fetch'),
13+
fetch,
1214
);
1315
}

0 commit comments

Comments
 (0)