Skip to content

Commit ac2030e

Browse files
committed
a workaround for node-fetch using esm
1 parent 05e6de2 commit ac2030e

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@
378378
"js-yaml": "^4.0.0",
379379
"jszip": "^3.7.1",
380380
"mocha": "^9.1.3",
381-
"node-fetch": "^3.x",
382381
"path-browserify": "^1.0.1",
383382
"process": "^0.11.10",
384383
"rimraf": "^3.0.2",
@@ -389,6 +388,9 @@
389388
"webpack": "^5.64.4",
390389
"webpack-cli": "^4.9.1"
391390
},
391+
"dependencies": {
392+
"node-fetch": "^3.x"
393+
},
392394
"repository": {
393395
"type": "git",
394396
"url": "https://github.com/dosasm/masm-tasm"
@@ -398,4 +400,4 @@
398400
"email": "[email protected]"
399401
},
400402
"license": "MIT"
401-
}
403+
}

src/utils/downloadFile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* API for downloading information from web
33
*/
44
import { logger } from "./logger";
5-
import fetch from "node-fetch";
5+
import { fetch } from "./fetch";
66

77
export async function downloadFromMultiSources(urls: string[]): Promise<string | undefined> {
88
for (const url of urls) {

src/utils/fetch.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
// @ts-check
3+
4+
export const fetch =
5+
process.platform
6+
? eval("(...args) => import('node-fetch').then(({default: fetch}) => fetch(...args))")
7+
: window.fetch;

0 commit comments

Comments
 (0)