Skip to content

Commit

Permalink
feat: remove our dependency on undici (#442)
Browse files Browse the repository at this point in the history
erunion authored Nov 8, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 3440d51 commit fe496fc
Showing 3 changed files with 6 additions and 29 deletions.
24 changes: 2 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
"./package.json": "./package.json"
},
"engines": {
"node": ">=18"
"node": ">=18.13.0"
},
"files": [
"dist"
@@ -47,8 +47,7 @@
"homepage": "https://github.com/readmeio/fetch-har#readme",
"dependencies": {
"@readme/data-urls": "^3.0.0",
"@types/har-format": "^1.2.13",
"undici": "^5.25.1"
"@types/har-format": "^1.2.13"
},
"devDependencies": {
"@jsdevtools/host-environment": "^2.1.2",
6 changes: 2 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -60,11 +60,9 @@ export default async function fetchHAR(har: Har, opts: FetchHAROptions = {}): Pr

if (!globalThis.File) {
try {
// Node's native `fetch` implementation unfortunately does not make this API global so we need
// to pull it in if we don't have it.
const UndiciFile = (await import('undici')).File;
const NodeFile = (await import('node:buffer')).File;
// @ts-expect-error the types don't match exactly, which is expected!
globalThis.File = UndiciFile;
globalThis.File = NodeFile;
} catch (e) {
throw new Error(
'The File API is required for this library. https://developer.mozilla.org/en-US/docs/Web/API/File',

0 comments on commit fe496fc

Please sign in to comment.