-
Notifications
You must be signed in to change notification settings - Fork 296
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
Circular dependencies inside d3 selection #168
Comments
This isn't a problem with d3, and you can suppress this warning in rollup -- see rollup/rollup#1491 (comment). |
I know the warning can be ignored, but isn't it bad practice to have circular dependencies within the D3 modules |
+1 |
Is this unique to d3-flextree? Sorry, I guess I assumed that it was endemic to d3. Let me look at it.... |
I noticed this error as well. Here is a bl.ock that reproduces it: Broken Rollup with D3-Selection - Circular Dependencies. |
ES modules explicitly support cyclic dependencies and I have no current plans to address this warning from Rollup. |
FWIW I figured out how to disable circular dependency warnings: onwarn: function ( message ) {
if (message.code === 'CIRCULAR_DEPENDENCY') {
return;
}
console.error(message);
} This goes at the top level of the configuration object in |
In case it's useful for anyone else coming across this, the helpful example from @curran above could be slightly improved by using the onwarn: function (warning, warn) {
if (warning.code === 'CIRCULAR_DEPENDENCY') return;
warn(warning);
} |
# Pull Request ## 🤨 Rationale The d3 library chooses to intentionally keep circular dependencies: d3/d3-selection#168 Rollup reports circular dependencies as warnings but to limit verbosity only show the first few so all we see are warnings related to d3. Example: ``` > rollup --bundleConfigAsCjs --config dist/esm/all-components.js → dist/all-components-bundle.js... (!) Circular dependencies ../../node_modules/d3-selection/src/selection/index.js -> ../../node_modules/d3-selection/src/selection/select.js -> ../../node_modules/d3-selection/src/selection/index.js ../../node_modules/d3-selection/src/selection/index.js -> ../../node_modules/d3-selection/src/selection/selectAll.js -> ../../node_modules/d3-selection/src/selection/index.js ../../node_modules/d3-selection/src/selection/index.js -> ../../node_modules/d3-selection/src/selection/filter.js -> ../../node_modules/d3-selection/src/selection/index.js ...and 12 more created dist/all-components-bundle.js in 12.3s ``` If we introduce circular dependencies or add a library that introduces additional circular dpendencies they may be missed. ## 👩💻 Implementation Implemented a rollup onwarn handler that can filter out the d3 libraries circular dependency warnings. ## 🧪 Testing Validated locally that choosing a more specific prefix like `d3-selection` will filter only warnings for that subset and let others through. ## ✅ Checklist - [x] I have updated the project documentation to reflect my changes or determined no changes are needed.
We wanted to suppress just warnings from d3 so we can catch our own regressions and audit other dependencies that are added so came up with the following const onwarn = (warning, defaultHandler) => {
const ignoredWarnings = [
{
code: 'CIRCULAR_DEPENDENCY',
file: 'node_modules/d3-'
}
];
if (
!ignoredWarnings.some(
({ code, file }) => warning.code === code && warning.message.includes(file)
)
) {
defaultHandler(warning);
}
}; Based on rollup/rollup#1089 (comment) |
When building D3 application using rollup it reports following circular deps.
Rollup 0.56.0
The text was updated successfully, but these errors were encountered: