Validate and visualize dependencies. Your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.
MIT License
Bot releases are hidden (Show)
Handles more types of babel configurations. If you put your babel config in package.json or use a commonjs module that exports an object you'll be able to use them with dependency-cruiser as of this release.
And here's some convenience for writing dependency cruiser configuration files:
This release contains mainly improvements in the --init
command, so on-boarding becomes easier.
depcruise --init experimental-scripts
). It might make it into the --init script in a later release.If you want to start using babel:
depcruise --init
. It will detect the presence of many shapes of .babelrc's and configure it in your .dependency-cruiser.js// ...
babelConfig: {
fileName: ".babelrc.json" // or however your .babelrc is called.
}
// ...
As noted in the PR and the documentation the babel support is ⚠️ experimental. This means it works and is well tested, but small tweaks that might be considered breaking for normal features might be implemented without dependency-cruiser bumping major versions
feature(main): add tripple slash directives to the module systems scanned by default (#289)
(💥 breaking change)
feature(validate): advanced module isolation checks with reachable: true (#283) - fixes #191.
This feature includes...
Many thanks to @abierbaum and @jomi-se for raising and re-raising the issue, testing and providing genuinely useful feedback on the beta's of this feature. And for their patience.
(💥 breaking change)
feature(extract): Faster and more intuitive doNotFollow behavior (#282) - fixes #281.
A big thanks to @electrovir for raising the issue, patiently explaining the problem and validating the beta's
(💥 breaking change)
feature(init): to improve the first time use experience --init
now ask better questions for specifying src
and test
folders (#284)
From this version on dependency-cruiser supports node 10, 12, 13 and 14 (which are not coincidentally the same as the ones nodejs support).
Dependency-cruiser follows the support schedule of nodejs - which desupported node 8 by the end of last year. It has kept supporting node 8 for a while, but many dependencies also stopped supporting it, so it's getting less easy (and safe!) to maintain that situation. The release date of node 14 (last Tuesday) seemed as good a moment as any
None if you're on node 10 or higher - which is likely. Low in all other cases (see How to migrate below
If you still are on one node 8.x there's two options:
By default, in addition to amd, commonjs and es6 dependency-cruiser will cruise dependencies defined in triple slash directives as well.
Dependency-cruiser has supported triple slash directives for a very long time, but didn't include them by default initially because it would've been a breaking change - despite it being useful and expected. This change rectifies that. Also: if you do have triple slash directives you probably want them cruised, visualised and validated without having to tell dependency-cruiser separately.
None if you're not using TypeScript or are using TypeScript, but not triple slash directives.
Some if you are using triple slash directives (either ) - dependencies might be showing up (and triggering rules) that didn't before this release.
If you want to keep the old behavior, explicitly specify the module systems either in the options
section of your dependency-cruiser configuration:
"moduleSystems": ["amd", "cjs", "es6"]
... or on the command line with a flag: --module-systems amd,cjs,es6
In rules the reachable attribute now yields correct results if you use the value true (to enforce isolation, even via via).
This functionality was missing - and is useful (see issue #191 for a practical example)
Likely none, unless you're using reachable with the value true in your rules. If you do, you'll have noticed the results of the validations were wild, many (and largely incorrect). With this release they're correct, so you're likely to see (a lot) less violations which were false positives.
Enjoy the reduction in false positives 😎.
From this version on dependency-cruiser does not report over modules matching the doNotFollow pattern when they're part of the arguments, unless they're reached through modules matching the arguments.
So in this example node_modules is part of both the arguments and of the doNotFollow pattern:
depcruise src test node_modules --do-not-follow node_modules --validate
The old behavior was to scan all modules in src test and node_modules and after that apply filters on node_modules while crawling through the dependencies. Note that in this case the result was the same as leaving out --do-not-follow.
The new behavior is to scan all modules in src and test, and only visit modules in node_modules if they are reachable from src and test
None if the path you pass in the arguments (e.g. src lib test) and the path in doNotFollow (typically node_modules) do not overlap.
Low if they do overlap (e.g. when you have node_modules in the sub packages in your mono repo) - dependency-cruiser now only reports over modules matching doNotFollow if they're reached through dependencies in the other arguments.
If you're in that last category (some mono-repos might be, inadvertently), likely you will experience a (considerable) speed up in the time dependency-cruiser takes to cruise your repo.
Probably you'll be happy to leave the new behavior as-is as it will be faster for you, and yield results closer to your intention.
However, in the less likely case your intention was to do scan everything in doNotFollow: remove the pattern of the files you want to follow from the doNotFollow option (either on the command line (--do-not-follow) or in the configuration file).
preCompilationDeps: "specify"
and have rules set up with preCompilationOnly
- see below for details.What: If dependency-cruiser is asked to specify whether a dependency exists before compilation from typescript to javascript, it used to compare the before and after too strictly (also heeding the module system - see #261). It does now less strictly, which will yield accurate results.
Impact: Small, and only if you use both:
"specify"
for tsPreCompilationDepspreCompilationOnly
attributeNo impact if you don't use both of them (i.e. only one of them or neither).
How to migrate: If there's new dependencies flagged by your specific set up, you probably want to fix them. If that's not a short term option you can set up an exception (e.g. with the pathNot
in either the to
or from
of that rule, making sure the newly found dependencies don't get triggered).
What: dependencies to aliased paths in tsconfigs now get the same detection treatment as all other dependencies, overriding the typescript config paths behaviour that by default only looked at .ts ad .tsx.
Impact: Only if you use tsconfig aliasses/ paths dependency-cruiser might detect dependencies to typescript declaration files it didn't detect before, which might trigger rules that didn't trigger before (typically, but not limited to typescript declaration files)
How to migrate? Either fix the transgressions or add an exception to exclude the newly discovered dependencies (the pathNot
attribute in the to
part of the rule that triggered will be your friend).