Skip to content

Instantly share code, notes, and snippets.

@storkyle
Last active December 14, 2022 14:40
Show Gist options
  • Save storkyle/d2f09ef376b3843915345150b0740977 to your computer and use it in GitHub Desktop.
Save storkyle/d2f09ef376b3843915345150b0740977 to your computer and use it in GitHub Desktop.
fix issue: Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/FileReader.js -> node_modules/rn-fetch-blob/index.js
diff --git a/node_modules/rn-fetch-blob/polyfill/Blob.js b/node_modules/rn-fetch-blob/polyfill/Blob.js
old mode 100644
new mode 100755
index 53662a7..379a7ad
--- a/node_modules/rn-fetch-blob/polyfill/Blob.js
+++ b/node_modules/rn-fetch-blob/polyfill/Blob.js
@@ -2,7 +2,9 @@
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
-import RNFetchBlob from '../index.js'
+// import RNFetchBlob from '../index.js'
+import {NativeModules} from 'react-native';
+const RNFetchBlob = NativeModules.RNFetchBlob
import fs from '../fs.js'
import getUUID from '../utils/uuid'
import Log from '../utils/log.js'
diff --git a/node_modules/rn-fetch-blob/polyfill/Fetch.js b/node_modules/rn-fetch-blob/polyfill/Fetch.js
old mode 100644
new mode 100755
index 3ecb591..fbb0702
--- a/node_modules/rn-fetch-blob/polyfill/Fetch.js
+++ b/node_modules/rn-fetch-blob/polyfill/Fetch.js
@@ -1,4 +1,6 @@
-import RNFetchBlob from '../index.js'
+// import RNFetchBlob from '../index.js'
+import {NativeModules} from 'react-native';
+const RNFetchBlob = NativeModules.RNFetchBlob
import Log from '../utils/log.js'
import fs from '../fs'
import unicode from '../utils/unicode'
diff --git a/node_modules/rn-fetch-blob/polyfill/XMLHttpRequest.js b/node_modules/rn-fetch-blob/polyfill/XMLHttpRequest.js
old mode 100644
new mode 100755
index 9036b2b..f1a99e4
--- a/node_modules/rn-fetch-blob/polyfill/XMLHttpRequest.js
+++ b/node_modules/rn-fetch-blob/polyfill/XMLHttpRequest.js
@@ -2,7 +2,9 @@
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
-import RNFetchBlob from '../index.js'
+// import RNFetchBlob from '../index.js'
+import {NativeModules} from 'react-native';
+const RNFetchBlob = NativeModules.RNFetchBlob
import XMLHttpRequestEventTarget from './XMLHttpRequestEventTarget.js'
import Log from '../utils/log.js'
import Blob from './Blob.js'
@Fritsen
Copy link

Fritsen commented Jul 27, 2021

May I suggest adding a comment into this file itself, telling a bit about what it does?
I just spent an hour figuring out what this was, after it had been added by a colleague...

I suggest something like:

Note: This is a git patch, which applies changes to the rn-fetch-blob library, without actually changing the source-files that are downloaded from (and would by overwritten by) NPM.
The patch fixes the 'Require cycle'-warning of rn-fetch-blob library.
More info: joltup/rn-fetch-blob#183 (comment)

.... at the top of the file, where git just ignores it...? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment