From 6d499edb52e93c1110a585e4eda9bd5bd2592901 Mon Sep 17 00:00:00 2001 From: Andrew Dodson Date: Tue, 8 Mar 2022 10:20:09 +0000 Subject: [PATCH] fix(bundling): bundling in webpack/typescript esm commonjs hack --- src/api.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api.js b/src/api.js index 7c05d498..931c28cb 100644 --- a/src/api.js +++ b/src/api.js @@ -1,6 +1,8 @@ const fetch = require('node-fetch') const extend = require('tricks/object/extend') +// This is a hack for an instance whereby the node-fetch module is incorrectly being imported +const fetchFunction = typeof fetch === 'function' ? fetch : fetch.default module.exports = class Hub { constructor(opts) { @@ -47,7 +49,7 @@ module.exports = class Hub { } } - const resp = await fetch(url, {...opts, headers}) + const resp = await fetchFunction(url, {...opts, headers}) if (convertToJSON) { return resp.json()