d3 / d3-interpolate

Interpolate numbers, colors, strings, arrays, objects, whatever!
https://d3js.org/d3-interpolate
ISC License
493 stars 70 forks source link

Require cycle: `value.js` -> `object.js` -> `value.js` #99

Closed mrousavy closed 2 years ago

mrousavy commented 2 years ago

Hey! I'm getting the same require cycle again as mentioned in #97, I believe a change has overridden those fixes.

 WARN  Require cycle: node_modules/d3-interpolate/src/value.js -> node_modules/d3-interpolate/src/object.js -> node_modules/d3-interpolate/src/value.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. 
mbostock commented 2 years ago

This is not an error. Circular imports are allowed in ES modules.

mrousavy commented 2 years ago

I never said it was an error, I'm just reporting it because it "can result in uninitialized values". Looks like here this can't be the case, but the warning is annoying nonetheless.

martsie commented 1 year ago

This can cause issues when using react-native, breaking end-to-end tests and strict environments. For other react-native using the following code may prevent log boxes from showing up in UI when these warnings occur until the library is updated with a fix (although #97 and #99 indicate that it's probably not high on the priority list). Warnings will still show up in metro logs.

// Add to your root index.js file.
import { LogBox } from 'react-native'

LogBox.ignoreLogs([
  // See https://github.com/d3/d3-interpolate/issues/97 and https://github.com/d3/d3-interpolate/issues/99.
  'Require cycle: node_modules/d3-interpolate/src/value.js -> node_modules/d3-interpolate/src/array.js -> node_modules/d3-interpolate/src/value.js\n\nRequire cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.',
  'Require cycle: node_modules/d3-interpolate/src/value.js -> node_modules/d3-interpolate/src/object.js -> node_modules/d3-interpolate/src/value.js\n\nRequire cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.',
])