Disable require cycle warnings

Summary: The holier-than-thou warnings of metro about require cycles are annoying. Require cycles are generally speaking well handles by ESM, and cause only harm if modules themselves are stateful, which is a bad smell. But warning for every cycle is just a flooding of false positives and removes the insentive to drop actual warnings.

Reviewed By: jknoxville

Differential Revision: D21859908

fbshipit-source-id: 66ec9a619a3737ccab5b16d11be5623d1d97c9f6
This commit is contained in:
Michel Weststrate
2020-06-03 08:42:39 -07:00
committed by Facebook GitHub Bot
parent 650030598a
commit 89de3d4ae2

View File

@@ -1,8 +1,8 @@
diff --git a/node_modules/metro/src/lib/polyfills/require.js b/node_modules/metro/src/lib/polyfills/require.js
index 8c04756..3610bba 100644
index 8c04756..d773811 100644
--- a/node_modules/metro/src/lib/polyfills/require.js
+++ b/node_modules/metro/src/lib/polyfills/require.js
@@ -114,11 +114,13 @@ function metroRequire(moduleId) {
@@ -114,11 +114,6 @@ function metroRequire(moduleId) {
.map(id => (modules[id] ? modules[id].verboseName : "[unknown]")); // We want to show A -> B -> A:
cycle.push(cycle[0]);
@@ -11,13 +11,6 @@ index 8c04756..3610bba 100644
- "Require cycles are allowed, but can result in uninitialized values. " +
- "Consider refactoring to remove the need for a cycle."
- );
+ if (!cycle.every(path => path.includes('/node_modules/'))) {
+ console.warn(
+ `Require cycle: ${cycle.join(" -> ")}\n\n` +
+ "Require cycles are allowed, but can result in uninitialized values. " +
+ "Consider refactoring to remove the need for a cycle."
+ );
+ }
}
}