dependency-cruiser 10.3.0 → 10.4.0-beta-1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dependency-cruiser",
3
- "version": "10.3.0",
3
+ "version": "10.4.0-beta-1",
4
4
  "description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
5
5
  "keywords": [
6
6
  "static analysis",
@@ -30,6 +30,9 @@ function extractImportsAndExports(pAST) {
30
30
  module: pStatement.moduleSpecifier.text,
31
31
  moduleSystem: "es6",
32
32
  exoticallyRequired: false,
33
+ ...(pStatement.importClause && pStatement.importClause.isTypeOnly
34
+ ? { typeOnly: true }
35
+ : {}),
33
36
  }));
34
37
  }
35
38
 
@@ -144,7 +144,7 @@ function determineExternalModuleDependencyTypes(
144
144
  /* eslint max-params:0, complexity:0 */
145
145
  /**
146
146
  *
147
- * @param {import("../../../types/cruise-result").IModule} pModule the dependency object with all information found hitherto
147
+ * @param {import("../../../types/cruise-result").IDependency} pDependency the dependency object with all information found hitherto
148
148
  * @param {string} pModuleName the module name as found in the source
149
149
  * @param {any} pManifest a package.json, in object format
150
150
  * @param {string} pFileDirectory the directory relative to which to resolve (only used for npm deps here)
@@ -154,7 +154,7 @@ function determineExternalModuleDependencyTypes(
154
154
  * @return {import("../../../types/shared-types").DependencyType[]} an array of dependency types for the dependency
155
155
  */
156
156
  module.exports = function determineDependencyTypes(
157
- pModule,
157
+ pDependency,
158
158
  pModuleName,
159
159
  pManifest,
160
160
  pFileDirectory,
@@ -165,7 +165,7 @@ module.exports = function determineDependencyTypes(
165
165
  let lReturnValue = ["undetermined"];
166
166
  pResolveOptions = pResolveOptions || {};
167
167
 
168
- if (pModule.couldNotResolve) {
168
+ if (pDependency.couldNotResolve) {
169
169
  lReturnValue = ["unknown"];
170
170
  } else if (isCore(pModuleName)) {
171
171
  // this 'isCore' business seems duplicate (it's already in
@@ -177,20 +177,28 @@ module.exports = function determineDependencyTypes(
177
177
  } else if (isRelativeModuleName(pModuleName)) {
178
178
  lReturnValue = ["local"];
179
179
  } else if (
180
- isExternalModule(pModule.resolved, pResolveOptions.modules, pBaseDirectory)
180
+ isExternalModule(
181
+ pDependency.resolved,
182
+ pResolveOptions.modules,
183
+ pBaseDirectory
184
+ )
181
185
  ) {
182
186
  lReturnValue = determineExternalModuleDependencyTypes(
183
- pModule,
187
+ pDependency,
184
188
  pModuleName,
185
189
  pManifest,
186
190
  pFileDirectory,
187
191
  pResolveOptions,
188
192
  pBaseDirectory
189
193
  );
190
- } else if (isAliassy(pModuleName, pModule.resolved, pResolveOptions)) {
194
+ } else if (isAliassy(pModuleName, pDependency.resolved, pResolveOptions)) {
191
195
  lReturnValue = ["aliased"];
192
196
  }
193
197
 
198
+ if (pDependency.typeOnly) {
199
+ lReturnValue.push("type-only");
200
+ }
201
+
194
202
  return lReturnValue;
195
203
  };
196
204
 
package/src/meta.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* generated - don't edit */
2
2
 
3
3
  module.exports = {
4
- version: "10.3.0",
4
+ version: "10.4.0-beta-1",
5
5
  engines: {
6
6
  node: "^12.20||^14||>=16",
7
7
  },
@@ -234,6 +234,7 @@ module.exports = {
234
234
  "npm-unknown",
235
235
  "undetermined",
236
236
  "unknown",
237
+ "type-only",
237
238
  ],
238
239
  },
239
240
  REAsStringsType: {
@@ -116,6 +116,7 @@ module.exports = {
116
116
  matchesDoNotFollow: { type: "boolean" },
117
117
  couldNotResolve: { type: "boolean" },
118
118
  preCompilationOnly: { type: "boolean" },
119
+ typeOnly: { type: "boolean" },
119
120
  circular: { type: "boolean" },
120
121
  cycle: { type: "array", items: { type: "string" } },
121
122
  moduleSystem: { $ref: "#/definitions/ModuleSystemType" },
@@ -143,6 +144,7 @@ module.exports = {
143
144
  "npm-unknown",
144
145
  "undetermined",
145
146
  "unknown",
147
+ "type-only",
146
148
  ],
147
149
  },
148
150
  ModuleSystemType: { type: "string", enum: ["cjs", "es6", "amd", "tsd"] },
@@ -41,7 +41,7 @@ function match(pFrom, pTo) {
41
41
  // is in the rule but not in the dependency there won't be a match
42
42
  // anyway, so we can use the default propertyEquals method regardless
43
43
  propertyEquals(pTo, pRule, "preCompilationOnly") &&
44
- // couldNotResolve, circular, dynamic and exoticallyRequired are
44
+ // couldNotResolve, circular, dynamic and exoticallyRequired _are_ mandatory
45
45
  propertyEquals(pTo, pRule, "couldNotResolve") &&
46
46
  propertyEquals(pTo, pRule, "circular") &&
47
47
  propertyEquals(pTo, pRule, "dynamic") &&
@@ -122,6 +122,13 @@ export interface IDependency {
122
122
  * then only when the option 'tsPreCompilationDeps' has the value 'specify'.
123
123
  */
124
124
  preCompilationOnly?: boolean;
125
+ /**
126
+ * 'true' when the module included the module explicitly as type only with the '
127
+ * type' keyword e.g. import type { IThingus } from 'thing' Dependency-cruiser
128
+ * will only specify this attribute for TypeScript and when the 'tsPreCompilationDeps'
129
+ * option has either the value true or 'specify'.
130
+ */
131
+ typeOnly?: boolean;
125
132
  /**
126
133
  * If following this dependency will ultimately return to the source (circular === true),
127
134
  * this attribute will contain an (ordered) array of module names that shows (one of) the
@@ -37,6 +37,7 @@ export type DependencyType =
37
37
  | "npm-peer"
38
38
  | "npm-unknown"
39
39
  | "undetermined"
40
- | "unknown";
40
+ | "unknown"
41
+ | "type-only";
41
42
 
42
- export type ProtocolType = "data:" | "file:" | "node";
43
+ export type ProtocolType = "data:" | "file:" | "node:";