@whatwg-node/fetch 0.9.14 → 0.9.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/create-node-ponyfill.js +3 -2
- package/dist/node-ponyfill.js +5 -5
- package/dist/shouldSkipPonyfill.js +18 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @whatwg-node/fetch
|
|
2
2
|
|
|
3
|
+
## 0.9.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`772552c`](https://github.com/ardatan/whatwg-node/commit/772552c0521b883c30d8f4d64c8ea093e75a95a0) Thanks [@ardatan](https://github.com/ardatan)! - Skip ponyfilling if NextJS
|
|
8
|
+
|
|
3
9
|
## 0.9.14
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const shouldSkipPonyfill = require('./shouldSkipPonyfill');
|
|
2
|
+
|
|
1
3
|
module.exports = function createNodePonyfill(opts = {}) {
|
|
2
4
|
const ponyfills = {};
|
|
3
5
|
|
|
@@ -7,8 +9,7 @@ module.exports = function createNodePonyfill(opts = {}) {
|
|
|
7
9
|
ponyfills.URLPattern = urlPatternModule.URLPattern;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
if (globalThis.Deno || process.versions.bun) {
|
|
12
|
+
if (shouldSkipPonyfill()) {
|
|
12
13
|
return globalThis;
|
|
13
14
|
}
|
|
14
15
|
|
package/dist/node-ponyfill.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
|
|
2
2
|
const createNodePonyfill = require('./create-node-ponyfill');
|
|
3
|
+
const shouldSkipPonyfill = require('./shouldSkipPonyfill');
|
|
3
4
|
const ponyfills = createNodePonyfill();
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
try {
|
|
6
|
+
if (!shouldSkipPonyfill()) {
|
|
7
|
+
try {
|
|
8
8
|
const nodelibcurlName = 'node-libcurl'
|
|
9
9
|
globalThis.libcurl = globalThis.libcurl || require(nodelibcurlName);
|
|
10
|
-
} catch(e) {}
|
|
11
|
-
|
|
10
|
+
} catch (e) { }
|
|
11
|
+
}
|
|
12
12
|
|
|
13
13
|
module.exports.fetch = ponyfills.fetch;
|
|
14
14
|
module.exports.Headers = ponyfills.Headers;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
function isNextJs() {
|
|
3
|
+
return Object.keys(globalThis).some(key => key.startsWith('__NEXT'))
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
module.exports = function shouldSkipPonyfill() {
|
|
7
|
+
// Bun and Deno already have a Fetch API
|
|
8
|
+
if (globalThis.Deno) {
|
|
9
|
+
return true
|
|
10
|
+
}
|
|
11
|
+
if (process.versions.bun) {
|
|
12
|
+
return true
|
|
13
|
+
}
|
|
14
|
+
if (isNextJs()) {
|
|
15
|
+
return true
|
|
16
|
+
}
|
|
17
|
+
return false
|
|
18
|
+
}
|