Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require cycle #768

Open
SusulAdam opened this issue Mar 2, 2022 · 4 comments
Open

Require cycle #768

SusulAdam opened this issue Mar 2, 2022 · 4 comments

Comments

@SusulAdam
Copy link

"rn-fetch-blob": "0.12.0"
"react-native": "0.63.3"

I am struggle with three warning Require cycle:

Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/Blob.js -> node_modules/rn-fetch-blob/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/XMLHttpRequest.js -> node_modules/rn-fetch-blob/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/Fetch.js -> node_modules/rn-fetch-blob/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
@tuantvk
Copy link

tuantvk commented Mar 4, 2022

@SusulAdam create file rn-fetch-blob.js from root project.

// rn-fetch-blob.js
const fs = require('fs');

const replaced = "import RNFetchBlob from '../index.js'";
const replacement =
  "import {NativeModules} from 'react-native';\nconst RNFetchBlob = NativeModules.RNFetchBlob";

const files = [
  'node_modules/rn-fetch-blob/polyfill/Fetch.js',
  'node_modules/rn-fetch-blob/polyfill/Blob.js',
  'node_modules/rn-fetch-blob/polyfill/XMLHttpRequest.js',
];

files.forEach(file => {
  fs.readFile(file, 'utf8', function (readErr, data) {
    if (readErr) {
      return null;
    }
    const result = data.replace(new RegExp(replaced, 'g'), replacement);
    fs.writeFile(file, result, 'utf8', function (err) {
      if (err) {
        return null;
      }
    });
  });
});

Run node rn-fetch-blob.js

@dhon2407
Copy link

dhon2407 commented Mar 7, 2022

Is there a permanent solution to this? I don't have my node_modules included on the project repository.

@JacquesWhite
Copy link

JacquesWhite commented Mar 7, 2022

@SusulAdam create file rn-fetch-blob.js from root project.

// rn-fetch-blob.js
const fs = require('fs');

const replaced = "import RNFetchBlob from '../index.js'";
const replacement =
  "import {NativeModules} from 'react-native';\nconst RNFetchBlob = NativeModules.RNFetchBlob";

const files = [
  'node_modules/rn-fetch-blob/polyfill/Fetch.js',
  'node_modules/rn-fetch-blob/polyfill/Blob.js',
  'node_modules/rn-fetch-blob/polyfill/XMLHttpRequest.js',
];

files.forEach(file => {
  fs.readFile(file, 'utf8', function (readErr, data) {
    if (readErr) {
      return null;
    }
    const result = data.replace(new RegExp(replaced, 'g'), replacement);
    fs.writeFile(file, result, 'utf8', function (err) {
      if (err) {
        return null;
      }
    });
  });
});

Run node rn-fetch-blob.js

Probably it is easier to use patch-package,
But is there any reason to not include it this way in this repo?

@GregoireDucharme
Copy link

Same issue as #183
Something got merged 15 days ago #688.

Is there going to be a new release with those fixes ? 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants