dependency-cruiser 17.3.5 → 17.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/LICENSE +1 -1
  2. package/package.json +6 -4
  3. package/src/{enrich/enrich-modules.mjs → analyze/analyze-modules.mjs} +1 -1
  4. package/src/{enrich → analyze}/derive/dependents.mjs +14 -3
  5. package/src/{enrich → analyze}/index.mjs +3 -3
  6. package/src/cache/cache.mjs +9 -27
  7. package/src/cache/content-strategy.mjs +1 -1
  8. package/src/cache/helpers.mjs +16 -6
  9. package/src/cli/init-config/config-template.mjs +112 -145
  10. package/src/cli/init-config/find-extensions.mjs +4 -0
  11. package/src/cli/listeners/ndjson.mjs +16 -1
  12. package/src/config-utl/extract-depcruise-config/merge-configs.mjs +2 -2
  13. package/src/extract/acorn/parse.mjs +18 -25
  14. package/src/extract/resolve/external-module-helpers.mjs +9 -7
  15. package/src/extract/resolve/get-manifest.mjs +25 -13
  16. package/src/extract/resolve/resolve-amd.mjs +10 -5
  17. package/src/extract/resolve/resolve.mjs +4 -5
  18. package/src/extract/swc/parse.mjs +12 -8
  19. package/src/extract/tsc/parse.mjs +12 -15
  20. package/src/main/cruise.mjs +6 -6
  21. package/src/main/report-wrap.mjs +1 -1
  22. package/src/meta.cjs +1 -1
  23. package/src/report/anon/anonymize-path-element.mjs +11 -3
  24. package/src/report/dot/prepare-flat-level.mjs +12 -2
  25. package/src/report/plugins.mjs +1 -1
  26. package/src/report/teamcity.mjs +76 -58
  27. package/src/report/text.mjs +7 -7
  28. /package/src/{enrich → analyze}/add-validations.mjs +0 -0
  29. /package/src/{enrich → analyze}/derive/circular.mjs +0 -0
  30. /package/src/{enrich → analyze}/derive/folders/aggregate-to-folders.mjs +0 -0
  31. /package/src/{enrich → analyze}/derive/folders/index.mjs +0 -0
  32. /package/src/{enrich → analyze}/derive/folders/utl.mjs +0 -0
  33. /package/src/{enrich → analyze}/derive/metrics/get-module-metrics.mjs +0 -0
  34. /package/src/{enrich → analyze}/derive/metrics/index.mjs +0 -0
  35. /package/src/{enrich → analyze}/derive/module-utl.mjs +0 -0
  36. /package/src/{enrich → analyze}/derive/orphan/index.mjs +0 -0
  37. /package/src/{enrich → analyze}/derive/orphan/is-orphan.mjs +0 -0
  38. /package/src/{enrich → analyze}/derive/reachable.mjs +0 -0
  39. /package/src/{enrich → analyze}/soften-known-violations.mjs +0 -0
  40. /package/src/{enrich → analyze}/summarize/add-rule-set-used.mjs +0 -0
  41. /package/src/{enrich → analyze}/summarize/get-stats.mjs +0 -0
  42. /package/src/{enrich → analyze}/summarize/index.mjs +0 -0
  43. /package/src/{enrich → analyze}/summarize/is-same-violation.mjs +0 -0
  44. /package/src/{enrich → analyze}/summarize/summarize-folders.mjs +0 -0
  45. /package/src/{enrich → analyze}/summarize/summarize-modules.mjs +0 -0
  46. /package/src/{enrich → analyze}/summarize/summarize-options.mjs +0 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016-2025 Sander Verweij
3
+ Copyright (c) 2016-2026 Sander Verweij
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dependency-cruiser",
3
- "version": "17.3.5",
3
+ "version": "17.3.7",
4
4
  "description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
5
5
  "keywords": [
6
6
  "static analysis",
@@ -131,8 +131,8 @@
131
131
  "configs/plugins/",
132
132
  "src",
133
133
  "!src/**/*.json",
134
- "!src/**/*.ts",
135
134
  "!src/**/*.md",
135
+ "!src/**/*.ts",
136
136
  "!src/**/*.schema.mjs",
137
137
  "!types/README.md",
138
138
  "!src/schema/README.md",
@@ -154,14 +154,16 @@
154
154
  "interpret": "3.1.1",
155
155
  "is-installed-globally": "1.0.0",
156
156
  "json5": "2.2.3",
157
- "memoize": "10.2.0",
158
157
  "picomatch": "4.0.3",
159
158
  "prompts": "2.4.2",
160
159
  "rechoir": "0.8.0",
161
160
  "safe-regex": "2.1.1",
162
161
  "semver": "7.7.3",
163
162
  "tsconfig-paths-webpack-plugin": "4.2.0",
164
- "watskeburt": "5.0.0"
163
+ "watskeburt": "5.0.2"
164
+ },
165
+ "overrides": {
166
+ "baseline-browser-mapping": "^2.9.15"
165
167
  },
166
168
  "engines": {
167
169
  "node": "^20.12||^22||>=24"
@@ -15,7 +15,7 @@ import { bus } from "#utl/bus.mjs";
15
15
  * @param {IOptions} pOptions
16
16
  * @returns {IModule[]}
17
17
  */
18
- export default function enrichModules(pModules, pOptions) {
18
+ export default function analyzeModules(pModules, pOptions) {
19
19
  bus.info("analyze: cycles");
20
20
 
21
21
  let lModules = deriveCycles(pModules, {
@@ -27,12 +27,23 @@ export function hasDependentsRule(pRuleSet) {
27
27
  (pRuleSet?.allowed ?? []).some(isDependentsRule)
28
28
  );
29
29
  }
30
-
30
+ /**
31
+ *
32
+ * @param {Partial<import("../../../types/cruise-result.d.mts").IModule[]>} pModules
33
+ * @param {import("../../../types/options.d.mts").ICruiseOptions} options
34
+ * @returns
35
+ */
31
36
  export default function addDependents(
32
37
  pModules,
33
- { skipAnalysisNotInRules, metrics, ruleSet },
38
+ { skipAnalysisNotInRules, metrics, ruleSet, reaches, focus },
34
39
  ) {
35
- if (!skipAnalysisNotInRules || metrics || hasDependentsRule(ruleSet)) {
40
+ if (
41
+ !skipAnalysisNotInRules ||
42
+ metrics ||
43
+ reaches ||
44
+ focus ||
45
+ hasDependentsRule(ruleSet)
46
+ ) {
36
47
  // creating this optimized structure here might seem overkill, but on
37
48
  // large graphs it pays off significantly - creation is a few centiseconds
38
49
  // but it cuts analysis in half on large graphs (and even on smaller
@@ -1,4 +1,4 @@
1
- import enrichModules from "./enrich-modules.mjs";
1
+ import analyzeModules from "./analyze-modules.mjs";
2
2
  import aggregateToFolders from "./derive/folders/index.mjs";
3
3
  import summarize from "./summarize/index.mjs";
4
4
  import { bus } from "#utl/bus.mjs";
@@ -16,8 +16,8 @@ import { bus } from "#utl/bus.mjs";
16
16
  * @param {string[]} pFileAndDirectoryArray
17
17
  * @returns {import("../../types/dependency-cruiser.js").ICruiseResult}
18
18
  */
19
- export default function enrich(pModules, pOptions, pFileAndDirectoryArray) {
20
- const lModules = enrichModules(pModules, pOptions);
19
+ export default function analyze(pModules, pOptions, pFileAndDirectoryArray) {
20
+ const lModules = analyzeModules(pModules, pOptions);
21
21
  bus.info("analyze: aggregate to folders");
22
22
  const lFolders = aggregateToFolders(lModules, pOptions);
23
23
 
@@ -31,19 +31,12 @@ const EMPTY_CACHE = {
31
31
  optionsUsed: {},
32
32
  },
33
33
  };
34
- // Bump this to the current major.minor version when the cache format changes in
35
- // a way that's not backwards compatible.
36
- // e.g. version 3.0.0 => 3
37
- // version 3.1.0 => 3.1
38
- // version 3.1.1 => 3.1
39
- // version 3.11.0 => 3.11
40
- // This means we assume breaking cache format versions won't occur
41
- // in patch releases. If worst case scenario it _is_ necessary we could
42
- // add the patch version divided by 1000_000 e.g.:
43
- // version 3.14.16 => 3.14 + 16/1000_000 = 3.140016
34
+
35
+ // see ./cache-rationales.md#cache-format-versioning for rationale & bump instructions
44
36
  const CACHE_FORMAT_VERSION = 16.2;
45
37
 
46
38
  export default class Cache {
39
+ /** @type {(IRevisionData | null)=} */
47
40
  #revisionData;
48
41
  #cacheStrategy;
49
42
  #compress;
@@ -59,7 +52,11 @@ export default class Cache {
59
52
  : new MetadataStrategy();
60
53
  this.#compress = pCompress ?? false;
61
54
  }
62
-
55
+ /**
56
+ *
57
+ * @param {ICruiseResult} pCachedCruiseResult
58
+ * @returns {boolean}
59
+ */
63
60
  cacheFormatVersionCompatible(pCachedCruiseResult) {
64
61
  return (
65
62
  (pCachedCruiseResult?.revisionData?.cacheFormatVersion ?? 1) >=
@@ -130,22 +127,7 @@ export default class Cache {
130
127
  */
131
128
  #compact(pPayload, pCompress) {
132
129
  if (pCompress) {
133
- /**
134
- * we landed on brotli with BROTLI_MIN_QUALITY because:
135
- * - even with BROTLI_MIN_QUALITY it compresses better than gzip
136
- * (regardless of compression level)
137
- * - at BROTLI_MIN_QUALITY it's faster than gzip
138
- * - BROTLI_MAX_QUALITY gives a bit better compression but is _much_
139
- * slower than even gzip
140
- *
141
- * In our situation the sync version is significantly faster than the
142
- * async version + zlib functions need to be promisified before they
143
- * can be used in promises, which will add the to the execution time
144
- * as well.
145
- *
146
- * As sync or async doesn't _really_
147
- * matter for the cli, we're using the sync version here.
148
- */
130
+ // see ./cache-rationales.md#cache-compression for rationale
149
131
  return brotliCompressSync(pPayload, {
150
132
  params: {
151
133
  [zlibConstants.BROTLI_PARAM_QUALITY]:
@@ -17,7 +17,7 @@ import {
17
17
 
18
18
  /**
19
19
  * @param {string} pBaseDirectory
20
- * @returns {(IModule) => IModule}
20
+ * @returns {(pModule: IModule) => IModule}
21
21
  */
22
22
  function addCheckSumToModule(pBaseDirectory) {
23
23
  return (pModule) => {
@@ -2,7 +2,6 @@
2
2
  import { createHash } from "node:crypto";
3
3
  import { readFileSync } from "node:fs";
4
4
  import { extname } from "node:path";
5
- import memoize from "memoize";
6
5
  import { filenameMatchesPattern } from "#graph-utl/match-facade.mjs";
7
6
 
8
7
  /**
@@ -20,20 +19,31 @@ function hash(pString) {
20
19
  return createHash("sha1").update(pString).digest("base64");
21
20
  }
22
21
 
22
+ // We should clear this cache when we're done with it (typically: after a cruise
23
+ // is done). Not a big issue for cli use, though, might become one for repeated
24
+ // runs in a long running process (e.g. when used as a library).
25
+ /** @type {Map<string, string>} */
26
+ const HASHES_CACHE = new Map();
27
+
23
28
  /**
24
29
  * @param {string} pFileName
25
30
  * @returns {string}
26
31
  */
27
- function _getFileHashSync(pFileName) {
32
+ export function getFileHashSync(pFileName) {
33
+ if (HASHES_CACHE.has(pFileName)) {
34
+ // @ts-expect-error TS2322 .has already guarantees the pFileName exists, and hence we can't get undefined
35
+ return HASHES_CACHE.get(pFileName);
36
+ }
37
+ let lHashedFileName = "file not found";
28
38
  try {
29
- return hash(readFileSync(pFileName, "utf8"));
39
+ lHashedFileName = hash(readFileSync(pFileName, "utf8"));
30
40
  } catch (pError) {
31
- return "file not found";
41
+ // will return "file not found" as per default
32
42
  }
43
+ HASHES_CACHE.set(pFileName, lHashedFileName);
44
+ return lHashedFileName;
33
45
  }
34
46
 
35
- export const getFileHashSync = memoize(_getFileHashSync);
36
-
37
47
  /**
38
48
  * @param {IChange} pChange
39
49
  * @return {IRevisionChange}
@@ -6,8 +6,8 @@ module.exports = {
6
6
  name: 'no-circular',
7
7
  severity: 'warn',
8
8
  comment:
9
- 'This dependency is part of a circular relationship. You might want to revise ' +
10
- 'your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ',
9
+ "This dependency is part of a circular relationship. You might want to revise " +
10
+ "your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ",
11
11
  from: {},
12
12
  to: {
13
13
  circular: true
@@ -118,19 +118,18 @@ module.exports = {
118
118
  from: {},
119
119
  to: {
120
120
  moreThanOneDependencyType: true,
121
- // as it's pretty common to have a type import be a type only import
122
- // _and_ (e.g.) a devDependency - don't consider type-only dependency
123
- // types for this rule
121
+ // as it's common to use a devDependency for type-only imports: don't
122
+ // consider type-only dependencyTypes for this rule
124
123
  dependencyTypesNot: ["type-only"]
125
124
  }
126
125
  },
127
126
 
128
- /* rules you might want to tweak for your specific situation: */
127
+ // rules you might want to tweak for your specific situation:
129
128
  {{notToTestRule}}
130
129
  {
131
130
  name: 'not-to-spec',
132
131
  comment:
133
- 'This module depends on a spec (test) file. The sole responsibility of a spec file is to test code. ' +
132
+ 'This module depends on a spec (test) file. The responsibility of a spec file is to test code. ' +
134
133
  "If there's something in a spec that's of use to other modules, it doesn't have that single " +
135
134
  'responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.',
136
135
  severity: 'error',
@@ -172,7 +171,7 @@ module.exports = {
172
171
  comment:
173
172
  "This module depends on an npm package that is declared as an optional dependency " +
174
173
  "in your package.json. As this makes sense in limited situations only, it's flagged here. " +
175
- "If you're using an optional dependency here by design - add an exception to your" +
174
+ "If you use an optional dependency here by design - add an exception to your" +
176
175
  "dependency-cruiser configuration.",
177
176
  from: {},
178
177
  to: {
@@ -198,196 +197,164 @@ module.exports = {
198
197
  }
199
198
  ],
200
199
  options: {
201
-
202
- /* Which modules not to follow further when encountered */
200
+ // Which modules not to follow further when encountered
203
201
  doNotFollow: {
204
- /* path: an array of regular expressions in strings to match against */
202
+ // path: an array of regular expressions in strings to match against
205
203
  path: ['node_modules']
206
204
  },
207
205
 
208
- /* Which modules to exclude */
206
+ // Which modules to exclude
209
207
  // exclude : {
210
- // /* path: an array of regular expressions in strings to match against */
208
+ // // path: an array of regular expressions in strings to match against
211
209
  // path: '',
212
210
  // },
213
211
 
214
- /* Which modules to exclusively include (array of regular expressions in strings)
215
- dependency-cruiser will skip everything not matching this pattern
216
- */
212
+ // Which modules to exclusively include (array of regular expressions in strings)
213
+ // dependency-cruiser will skip everything that doesn't match this pattern
217
214
  // includeOnly : [''],
218
215
 
219
- /* List of module systems to cruise.
220
- When left out dependency-cruiser will fall back to the list of _all_
221
- module systems it knows of. It's the default because it's the safe option
222
- It might come at a performance penalty, though.
223
- moduleSystems: ['amd', 'cjs', 'es6', 'tsd']
224
-
225
- As in practice only commonjs ('cjs') and ecmascript modules ('es6')
226
- are widely used, you can limit the moduleSystems to those.
227
- */
228
-
216
+ // List of module systems to cruise.
217
+ // When left out dependency-cruiser will fall back to the list of _all_
218
+ // module systems it knows of ('amd', 'cjs', 'es6', 'tsd']). It's the
219
+ // default because it's the safe option. It comes at a performance penalty, though
220
+ // As in practice only commonjs ('cjs') and ecmascript modules ('es6')
221
+ // are in wide use, you can limit the moduleSystems to those.
229
222
  // moduleSystems: ['cjs', 'es6'],
230
223
 
231
- /*
232
- false: don't look at JSDoc imports (the default)
233
- true: dependency-cruiser will detect dependencies in JSDoc-style
234
- import statements. Implies "parser": "tsc", so the dependency-cruiser
235
- will use the typescript parser for JavaScript files.
236
-
237
- For this to work the typescript compiler will need to be installed in the
238
- same spot as you're running dependency-cruiser from.
239
- */
224
+ // false: don't look at JSDoc imports (the default)
225
+ // true: detect dependencies in JSDoc-style import statements.
226
+ // Implies parser: 'tsc', which a.o. means the typescript compiler will need
227
+ // to be installed in the same spot you run dependency-cruiser from.
240
228
  {{detectJSDocImportsAttribute}}
241
229
 
242
- /*
243
- false: don't look at process.getBuiltinModule calls (the default)
244
- true: dependency-cruiser will detect calls to process.getBuiltinModule/
245
- globalThis.process.getBuiltinModule as imports.
246
- */
230
+ // false: don't look at process.getBuiltinModule calls (the default)
231
+ // true: dependency-cruiser will detect calls to process.getBuiltinModule/
232
+ // globalThis.process.getBuiltinModule as imports.
247
233
  {{detectProcessBuiltinModuleCalls}}
248
234
 
249
- /* prefix for links in html and svg output (e.g. 'https://github.com/you/yourrepo/blob/main/'
250
- to open it on your online repo or \`vscode://file/$\{process.cwd()}/\` to
251
- open it in visual studio code),
252
- */
235
+ // prefix for links in html, d2, mermaid and dot/ svg output (e.g. 'https://github.com/you/yourrepo/blob/main/'
236
+ // to open it on your online repo or \`vscode://file/$\{process.cwd()}/\` to
237
+ // open it in visual studio code),
253
238
  // prefix: \`vscode://file/$\{process.cwd()}/\`,
254
239
 
255
- /* false (the default): ignore dependencies that only exist before typescript-to-javascript compilation
256
- true: also detect dependencies that only exist before typescript-to-javascript compilation
257
- "specify": for each dependency identify whether it only exists before compilation or also after
258
- */
240
+ // suffix for links in output. E.g. put .html here if you use it to link to
241
+ // your coverage reports.
242
+ // suffix: '.html',
243
+
244
+ // false (the default): ignore dependencies that only exist before typescript-to-javascript compilation
245
+ // true: also detect dependencies that only exist before typescript-to-javascript compilation
246
+ // 'specify': for each dependency identify whether it only exists before compilation or also after
259
247
  {{tsPreCompilationDepsAttribute}}
260
248
 
261
- /* list of extensions to scan that aren't javascript or compile-to-javascript.
262
- Empty by default. Only put extensions in here that you want to take into
263
- account that are _not_ parsable.
264
- */
265
- // extraExtensionsToScan: [".json", ".jpg", ".png", ".svg", ".webp"],
249
+ // list of extensions to scan that aren't javascript or compile-to-javascript.
250
+ // Empty by default. Only put extensions in here that you want to take into
251
+ // account that are _not_ parsable.
252
+ // extraExtensionsToScan: ['.json', '.jpg', '.png', '.svg', '.webp'],
266
253
 
267
- /* if true combines the package.jsons found from the module up to the base
268
- folder the cruise is initiated from. Useful for how (some) mono-repos
269
- manage dependencies & dependency definitions.
270
- */
254
+ // if true combines the package.jsons found from the module up to the base
255
+ // folder the cruise is initiated from. Useful for how (some) mono-repos
256
+ // manage dependencies & dependency definitions.
271
257
  {{combinedDependenciesAttribute}}
272
258
 
273
- /* if true leave symlinks untouched, otherwise use the realpath */
259
+ // if true leave symlinks untouched, otherwise use the realpath
274
260
  // preserveSymlinks: false,
275
261
 
276
- /* TypeScript project file ('tsconfig.json') to use for
277
- (1) compilation and
278
- (2) resolution (e.g. with the paths property)
279
-
280
- The (optional) fileName attribute specifies which file to take (relative to
281
- dependency-cruiser's current working directory). When not provided
282
- defaults to './tsconfig.json'.
283
- */
262
+ // TypeScript project file ('tsconfig.json') to use for
263
+ // (1) compilation and
264
+ // (2) resolution (e.g. with the paths property)
265
+ //
266
+ // The (optional) fileName attribute specifies which file to take (relative to
267
+ // dependency-cruiser's current working directory). When not provided
268
+ // defaults to './tsconfig.json'.
284
269
  {{tsOrJsConfigAttribute}}
285
270
 
286
- /* Webpack configuration to use to get resolve options from.
287
-
288
- The (optional) fileName attribute specifies which file to take (relative
289
- to dependency-cruiser's current working directory. When not provided defaults
290
- to './webpack.conf.js'.
291
-
292
- The (optional) \`env\` and \`arguments\` attributes contain the parameters
293
- to be passed if your webpack config is a function and takes them (see
294
- webpack documentation for details)
295
- */
271
+ // Webpack configuration to use to get resolve options from.
272
+ //
273
+ // The (optional) fileName attribute specifies which file to take (relative
274
+ // to dependency-cruiser's current working directory. When not provided defaults
275
+ // to './webpack.conf.js'.
276
+ //
277
+ // The (optional) 'env' and 'arguments' attributes contain the parameters
278
+ // to be passed if your webpack config is a function and takes them (see
279
+ // webpack documentation for details)
296
280
  {{webpackConfigAttribute}}
297
281
 
298
- /* Babel config ('.babelrc', '.babelrc.json', '.babelrc.json5', ...) to use
299
- for compilation
300
- */
282
+ // Babel config ('.babelrc', '.babelrc.json', '.babelrc.json5', ...) to use
283
+ // for compilation
301
284
  {{babelConfigAttribute}}
302
285
 
303
- /* List of strings you have in use in addition to cjs/ es6 requires
304
- & imports to declare module dependencies. Use this e.g. if you've
305
- re-declared require, use a require-wrapper or use window.require as
306
- a hack.
307
- */
286
+ // List of strings you have in use in addition to cjs/ es6 requires
287
+ // & imports to declare module dependencies. Use this e.g. if you've
288
+ // re-declared require, use a require-wrapper or use window.require as
289
+ // a hack.
308
290
  // exoticRequireStrings: [],
309
291
 
310
- /* options to pass on to enhanced-resolve, the package dependency-cruiser
311
- uses to resolve module references to disk. The values below should be
312
- suitable for most situations
313
-
314
- If you use webpack: you can also set these in webpack.conf.js. The set
315
- there will override the ones specified here.
316
- */
292
+ // options to pass on to enhanced-resolve, the package dependency-cruiser
293
+ // uses to resolve module references to disk. The values below should be
294
+ // suitable for most situations
295
+ //
296
+ // If you use webpack: you can also set these in webpack.conf.js. The set
297
+ // there will override the ones specified here.
317
298
  enhancedResolveOptions: {
318
- /* What to consider as an 'exports' field in package.jsons */
319
- exportsFields: ["exports"],
320
- /* List of conditions to check for in the exports field.
321
- Only works when the 'exportsFields' array is non-empty.
322
- */
323
- conditionNames: ["import", "require", "node", "default", "types"],
324
- /* The extensions, by default are the same as the ones dependency-cruiser
325
- can access (run \`npx depcruise --info\` to see which ones that are in
326
- _your_ environment). If that list is larger than you need you can pass
327
- the extensions you actually use (e.g. [".js", ".jsx"]). This can speed
328
- up module resolution, which is the most expensive step.
329
- */
299
+ // What to consider as an 'exports' field in package.jsons
300
+ exportsFields: ['exports'],
301
+
302
+ // List of conditions to check for in the exports field.
303
+ // Only works when the 'exportsFields' array is non-empty.
304
+ conditionNames: ['import', 'require', 'node', 'default', 'types'],
305
+
306
+ // The extensions, by default are the same as the ones dependency-cruiser
307
+ // can access (run \`npx depcruise --info\` to see which ones that are in
308
+ // _your_ environment). If that list is larger than you need you can pass
309
+ // the extensions you actually use (e.g. ['.js', '.jsx']). This can speed
310
+ // up module resolution, which is the most expensive step.
330
311
  {{extensionsAttribute}}
331
- /* What to consider a 'main' field in package.json */
312
+
313
+ // What to consider a 'main' field in package.json
332
314
  {{mainFieldsAttribute}}
333
- /* A list of alias fields in package.jsons
334
-
335
- See [this specification](https://github.com/defunctzombie/package-browser-field-spec) and
336
- the webpack [resolve.alias](https://webpack.js.org/configuration/resolve/#resolvealiasfields)
337
- documentation.
338
-
339
- Defaults to an empty array (= don't use alias fields).
340
- */
341
- // aliasFields: ["browser"],
315
+
316
+ // A list of alias fields in package.jsons
317
+ // See https://github.com/defunctzombie/package-browser-field-spec and
318
+ // the webpack [resolve.alias](https://webpack.js.org/configuration/resolve/#resolvealiasfields)
319
+ // documentation.
320
+ // Defaults to an empty array (= don't use alias fields).
321
+ // aliasFields: ['browser'],
342
322
  },
343
323
 
344
- /* skipAnalysisNotInRules will make dependency-cruiser execute
345
- analysis strictly necessary for checking the rule set only.
346
-
347
- See https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#skipanalysisnotinrules
348
- for details
349
- */
324
+ // skipAnalysisNotInRules will make dependency-cruiser execute
325
+ // analysis strictly necessary for checking the rule set only.
326
+ // See https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#skipanalysisnotinrules
350
327
  skipAnalysisNotInRules: true,
351
328
  {{builtInModulesAttribute}}
352
329
  reporterOptions: {
353
330
  dot: {
354
- /* pattern of modules that can be consolidated in the detailed
355
- graphical dependency graph. The default pattern in this configuration
356
- collapses everything in node_modules to one folder deep so you see
357
- the external modules, but their innards.
358
- */
331
+ // Pattern of modules to consolidate to. The default pattern in this configuration
332
+ // collapses everything in node_modules to one folder deep so you see
333
+ // the external modules, but not their innards.
359
334
  collapsePattern: 'node_modules/(?:@[^/]+/[^/]+|[^/]+)',
360
335
 
361
- /* Options to tweak the appearance of your graph.See
362
- https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#reporteroptions
363
- for details and some examples. If you don't specify a theme
364
- dependency-cruiser falls back to a built-in one.
365
- */
336
+ // Options to tweak the appearance of your graph. See
337
+ // https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#reporteroptions
338
+ // If you don't specify a theme dependency-cruiser falls back to a built-in one.
366
339
  // theme: {
367
340
  // graph: {
368
- // /* splines: "ortho" gives straight lines, but is slow on big graphs
369
- // splines: "true" gives bezier curves (fast, not as nice as ortho)
370
- // */
371
- // splines: "true"
341
+ // // splines: 'ortho' - straight lines; slow on big graphs
342
+ // // splines: 'true' - bezier curves; fast but not as nice as ortho
343
+ // splines: 'true'
372
344
  // },
373
- // }
345
+ // },
374
346
  },
375
347
  archi: {
376
- /* pattern of modules that can be consolidated in the high level
377
- graphical dependency graph. If you use the high level graphical
378
- dependency graph reporter (\`archi\`) you probably want to tweak
379
- this collapsePattern to your situation.
380
- */
348
+ // Pattern of modules to consolidate to.
381
349
  collapsePattern: '^(?:packages|src|lib(s?)|app(s?)|bin|test(s?)|spec(s?))/[^/]+|node_modules/(?:@[^/]+/[^/]+|[^/]+)',
382
350
 
383
- /* Options to tweak the appearance of your graph. If you don't specify a
384
- theme for 'archi' dependency-cruiser will use the one specified in the
385
- dot section above and otherwise use the default one.
386
- */
351
+ // Options to tweak the appearance of your graph. If you don't specify a
352
+ // theme for 'archi' dependency-cruiser will use the one specified in the
353
+ // dot section above and otherwise use the default one.
387
354
  // theme: { },
388
355
  },
389
- "text": {
390
- "highlightFocused": true
356
+ text: {
357
+ highlightFocused: true
391
358
  },
392
359
  }
393
360
  }
@@ -17,6 +17,10 @@ function reduceToCounts(pAll, pExtension) {
17
17
  return pAll;
18
18
  }
19
19
 
20
+ /**
21
+ * @param {Record<string,number>} pCountsObject
22
+ * @returns {(pLeft: string, pRight: string) => number}
23
+ */
20
24
  function compareByCount(pCountsObject) {
21
25
  return function compare(pLeft, pRight) {
22
26
  return pCountsObject[pRight] - pCountsObject[pLeft];
@@ -1,14 +1,22 @@
1
+ import { randomInt } from "node:crypto";
1
2
  import { EOL } from "node:os";
2
3
  import { INFO, SUMMARY } from "#utl/bus.mjs";
3
4
 
4
- const MICRO_SECONDS_PER_SECOND = 1000000;
5
+ const MICRO_SECONDS_PER_SECOND = 1_000_000;
6
+ // 2 ** 47;
7
+ const MIN_RUN_ID = 140_737_488_355_328;
8
+ // Max safe int (2 ** 48), - 1. Note: != Number.MAX_SAFE_INTEGER, which is too big for crypto.randomInt
9
+ const MAX_RUN_ID = 281_474_976_710_655;
5
10
 
6
11
  function formatPerfLine({
7
12
  runStartTime,
13
+ runId,
8
14
  message,
9
15
  time,
10
16
  elapsedTime,
17
+ user,
11
18
  elapsedUser,
19
+ system,
12
20
  elapsedSystem,
13
21
  rss,
14
22
  heapUsed,
@@ -18,10 +26,13 @@ function formatPerfLine({
18
26
  return (
19
27
  JSON.stringify({
20
28
  runStartTime,
29
+ runId,
21
30
  message,
22
31
  time: Math.round(time * MICRO_SECONDS_PER_SECOND),
23
32
  elapsedTime: Math.round(elapsedTime * MICRO_SECONDS_PER_SECOND),
33
+ user,
24
34
  elapsedUser,
35
+ system,
25
36
  elapsedSystem,
26
37
  rss,
27
38
  heapUsed,
@@ -40,10 +51,13 @@ function getProgressLine(pMessage, pState, pLevel, pMaxLevel) {
40
51
  const { rss, heapTotal, heapUsed, external } = process.memoryUsage();
41
52
  const lStats = {
42
53
  runStartTime: pState.runStartTime,
54
+ runId: pState.runId,
43
55
  message: pState.previousMessage,
44
56
  time: lTime,
45
57
  elapsedTime: lTime - pState.previousTime,
58
+ user,
46
59
  elapsedUser: user - pState.previousUserUsage,
60
+ system,
47
61
  elapsedSystem: system - pState.previousSystemUsage,
48
62
  rss,
49
63
  heapUsed,
@@ -76,6 +90,7 @@ export default function setUpNDJSONListener(
76
90
  ) {
77
91
  let lState = {
78
92
  runStartTime: new Date(Date.now()).toISOString(),
93
+ runId: randomInt(MIN_RUN_ID, MAX_RUN_ID),
79
94
  previousMessage: "startup: nodejs loading",
80
95
  previousTime: 0,
81
96
  previousUserUsage: 0,