fnando / i18n

A small library to provide the I18n translations on the JavaScript.
https://fnando.github.io/i18n/
MIT License
169 stars 20 forks source link

Require cycle warning #61

Closed souhilo closed 1 year ago

souhilo commented 1 year ago

Hi! šŸ‘‹

Firstly, thanks for your work on this project! šŸ™‚

Today I used patch-package to patch i18n-js@4.1.1 for the project I'm working on.

I was trying to find a solution for the annoying warning I get everytime I run my React Native app:

**WARN**  Require cycle: node_modules\i18n-js\dist\import\helpers\index.js -> node_modules\i18n-js\dist\import\helpers\formatNumber.js -> node_modules\i18n-js\dist\import\helpers\index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoalues. Consider refactoring to remove alues. Consider refactoring to remove the need for a cycle. 

Here is the diff that solved my problem:

diff --git a/node_modules/i18n-js/dist/import/helpers/formatNumber.js b/node_modules/i18n-js/dist/import/helpers/formatNumber.js
index 5c39971..8856136 100644
--- a/node_modules/i18n-js/dist/import/helpers/formatNumber.js
+++ b/node_modules/i18n-js/dist/import/helpers/formatNumber.js
@@ -1,6 +1,7 @@
 import BigNumber from "bignumber.js";
 import { repeat } from "lodash";
-import { roundNumber } from ".";
+import { roundNumber } from "./roundNumber";
+
 function replaceInFormat(format, { formattedNumber, unit }) {
     return format.replace("%n", formattedNumber).replace("%u", unit);
 }

This issue body was partially generated by patch-package.

fnando commented 1 year ago

Please try the latest versions, as this has already been fixed.