Comments (7)
I tested it out. Works exactly as expected for our use case. Thank you very much!
from dependency-cruiser.
Awesome! I've merged the PR and published it as part of [email protected]
from dependency-cruiser.
hi @fongandrew thanks for this suggestion - there's currently indeed no elegant way to distinguish dynamic imports in rules, and there should be. Especially when dependency-cruiser will start recognizing dynamic imports with arguments that can only be determined at runtime (which is on the backlog )
They way I'm thinking to do this is to flag dynamic dependencies so they can be used in rules e.g. something like this:
{
forbidden: [
{
name: "no-circular",
from: {
},
to {
dynamicImport: false, //
circular: true
}
]
from dependency-cruiser.
Ooh, that rule syntax would be perfect. Looking forward to it!
from dependency-cruiser.
hi @fongandrew - it's taken some time to address this issue; had to get #142 out the door first...
I've implemented my proposal above. It works, but it I realised it likely won't resolve the issue you have (see below) unless all the dependencies in a circle are dynamic ones (see background below).
The dynamic
attribute is probably going to stay because it's useful for other things, but I'm looking into a different solution for this issue (several ideas; including the followDynamic switch you proposed above - will ping you with one(s?) that works out).
background below
Given this dependency-graph...
...with a rule that forbids circular dependencies, except for dynamic ones ...
module.exports = {
forbidden: [{
name: 'no-circular',
severity: 'warn',
from: {},
to: {
circular: true,
dynamic: false
}
}]
}
Close. No cigar ...
from dependency-cruiser.
Oh, that's unfortunate, but I appreciate you taking the time to figure this out!
from dependency-cruiser.
hi @fongandrew so here's another stab, that works better in your use case - it excludes all dependencies that are dynamic:
module.exports = {
forbidden: [{
name: 'no-circular',
from: {},
to: {
circular: true
}
}],
options: {
exclude: {
dynamic: true
}
}
}
This now works in [email protected], so if you want to you can give it a spin you can. I'll be interested in your findings!
from dependency-cruiser.
Related Issues (20)
- Issue: numberOfDependentsLessThan does not calculate dependents properly when index.ts is used inbetween HOT 5
- Feature request: Allow to have rules checking Typescript types but also rules that ignore Typescript types HOT 2
- Issue: false positive for couldNotResolve for type only package HOT 5
- Question: A dependency view of each "TYPE" or "INTERFACE" HOT 3
- Question: monorepo, combinedDependencies & not-dev-dep HOT 2
- Error: No "exports" main defined in <project_name>/node_modules/dependency-cruiser/package.json HOT 3
- What am I missing about rcdot? "'rcdot' is not a valid output type" HOT 2
- Issue: not-to-unresolvable return error when using typescript alias in module project HOT 2
- Why doesn't dependency-cruiser "ignore" my private-registry package like it does with node-modules? HOT 6
- Q: Dep Graph for each file HOT 3
- Feature request: consider symlinked workspaces HOT 5
- Issue: not-to-spec and not-to-dev-dep default config should include tsx and jsx HOT 3
- Issue: using `workspace:` to implement nohoist in a package.json while using pnpm throws an error HOT 4
- Missing mermaid example HOT 1
- Feature request: reporters might report `comment` of rules other than `forbidden` HOT 3
- Issue: cruise API - breaking changes HOT 4
- Question: Resolving typescript source files imported from outside specified package HOT 2
- Question: dependency-cruiser API gives a different result when `baseDir` is changed HOT 6
- Question: Can I access the classes/methods/functions in modules? HOT 4
- Listing dependancy tree via dependency-cruiser gives me the reference from barel files HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dependency-cruiser.