Skip to content

Commit 5d4355e

Browse files
authoredMar 16, 2022
Replace got w/ node-fetch
Backports wooorm/xdm@6276fcc. Closes GH-1978.
1 parent 46fae4f commit 5d4355e

File tree

4 files changed

+40
-404
lines changed

4 files changed

+40
-404
lines changed
 

‎package-lock.json

+27-399
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/esbuild/lib/index.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import assert from 'node:assert'
1717
import {promises as fs} from 'node:fs'
1818
import path from 'node:path'
1919
import process from 'node:process'
20-
import got from 'got'
20+
import fetch from 'node-fetch'
2121
import {VFile} from 'vfile'
2222
import {createFormatAwareProcessors} from '@mdx-js/mdx/lib/util/create-format-aware-processors.js'
2323
import {extnamesToRegex} from '@mdx-js/mdx/lib/util/extnames-to-regex.js'
@@ -97,7 +97,17 @@ export function esbuild(options = {}) {
9797
async function onloadremote(data) {
9898
const href = data.path
9999
console.log('%s: downloading `%s`', remoteNamespace, href)
100-
const contents = (await got(href, {cache})).body
100+
101+
/** @type {string} */
102+
let contents
103+
104+
const cachedContents = cache.get(href)
105+
if (cachedContents) {
106+
contents = cachedContents
107+
} else {
108+
contents = await (await fetch(href)).text()
109+
cache.set(href, contents)
110+
}
101111

102112
return filter.test(href)
103113
? onload({

‎packages/esbuild/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
],
4040
"dependencies": {
4141
"@mdx-js/mdx": "^2.0.0",
42-
"got": "^11.0.0",
42+
"node-fetch": "^3.0.0",
4343
"vfile": "^5.0.0"
4444
},
4545
"peerDependencies": {

‎renovate.json5

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
packageRules: [
55
{
66
matchPackageNames: [
7-
// `got@12` depends on Node 14+.
8-
'got',
97
// `react`/`react-dom`/`react-server-dom-webpack` latest don’t support
108
// RSC.
119
'react',

1 commit comments

Comments
 (1)

vercel[bot] commented on Mar 16, 2022

@vercel[bot]

Successfully deployed to the following URLs:

Please sign in to comment.