Skip to content

Instantly share code, notes, and snippets.

@s4ff0x
Created October 15, 2022 10:07
Show Gist options
  • Save s4ff0x/c0ebb0dcff5bcef0db6423ed1417fcb7 to your computer and use it in GitHub Desktop.
Save s4ff0x/c0ebb0dcff5bcef0db6423ed1417fcb7 to your computer and use it in GitHub Desktop.
Dependency cruiser config for "Feature Sliced Design"
/** @type {import('dependency-cruiser').IConfiguration} */
module.exports = {
options: {
doNotFollow: {
dependencyTypes: [
"npm",
"npm-dev",
"npm-optional",
"npm-peer",
"npm-bundled",
"npm-no-pkg",
],
},
includeOnly: "^src",
// exclude: {
// path: "^src/shared",
// },
tsPreCompilationDeps: false,
tsConfig: {
fileName: "./tsconfig.json",
},
/* How to resolve external modules - use "yarn-pnp" if you're using yarn's Plug'n'Play.
otherwise leave it out (or set to the default, which is 'node_modules')
*/
externalModuleResolutionStrategy: "yarn-pnp",
progress: { type: "performance-log" },
reporterOptions: {
archi: {
collapsePattern:
"^src/app/[^/]+|^src/processes/[^/]+|^src/pages/[^/]+|^src/widgets/[^/]+|^src/features/[^/]+|^src/entities/[^/]+|^src/shared/[^/]+",
theme: {
modules: [
{
criteria: { collapsed: true },
attributes: { shape: "tab" },
},
{
criteria: { source: "^src/app/[^/]+" },
attributes: { fillcolor: "#ffbdbd" },
},
{
criteria: { source: "^src/processes/[^/]+" },
attributes: { fillcolor: "#da96ff" },
},
{
criteria: { source: "^src/pages/[^/]+" },
attributes: { fillcolor: "#ffd9a3" },
},
{
criteria: { source: "^src/widgets/[^/]+" },
attributes: { fillcolor: "#94fffa" },
},
{
criteria: { source: "^src/features/[^/]+" },
attributes: { fillcolor: "#aedaff" },
},
{
criteria: { source: "^src/entities/[^/]+" },
attributes: { fillcolor: "#d3ffc6" },
},
{
criteria: { source: "^src/shared/[^/]+" },
attributes: { fillcolor: "#efefef" },
},
],
graph: {
splines: "ortho",
rankdir: "TB",
ranksep: "1",
},
},
},
},
},
};
"scripts": {
"depcruise:archi": "depcruise --version && depcruise --config fsd-depcruise-config.js --output-type archi src | dot -T svg | tee fsd-high-level-dependencies.svg | depcruise-wrap-stream-in-html > fsd-high-level-dependencies.html"
},
@s4ff0x
Copy link
Author

s4ff0x commented Oct 15, 2022

don't forget to install graphviz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment