From c2a17873cb3139bbceb8a521b7141072ef6acca7 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Mon, 30 May 2022 03:41:33 -0700 Subject: [PATCH] Fix node-fetch bundling Summary: In electron setup, bundlers usually bundle for browser environments. In browser envs, bundles seem to pick up .mjs files first. .mjs fro node-fetch exports fetch as a default export. This fix allows bundling of npm-api for electron. Closes https://github.com/facebook/flipper/issues/3752 https://github.com/doowb/npm-api/pull/25/files Reviewed By: lblasa Differential Revision: D36758469 fbshipit-source-id: bf6c27ed37cb0baa54382ea563902e6e77a118e9 --- desktop/patches/npm-api+1.0.1.patch | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 desktop/patches/npm-api+1.0.1.patch diff --git a/desktop/patches/npm-api+1.0.1.patch b/desktop/patches/npm-api+1.0.1.patch new file mode 100644 index 000000000..2bedf3c71 --- /dev/null +++ b/desktop/patches/npm-api+1.0.1.patch @@ -0,0 +1,15 @@ +diff --git a/node_modules/npm-api/lib/registry.js b/node_modules/npm-api/lib/registry.js +index daca66a..38e0ae9 100644 +--- a/node_modules/npm-api/lib/registry.js ++++ b/node_modules/npm-api/lib/registry.js +@@ -1,6 +1,9 @@ + 'use strict'; + +-const fetch = require('node-fetch'); ++let fetch = require('node-fetch'); ++if (fetch.default) { ++ fetch = fetch.default ++} + const utils = require('./utils'); + const config = require('./config'); +