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 +1 -1
- package/src/extract/ast-extractors/extract-typescript-deps.js +3 -0
- package/src/extract/resolve/determine-dependency-types.js +14 -6
- package/src/meta.js +1 -1
- package/src/schema/configuration.schema.js +1 -0
- package/src/schema/cruise-result.schema.js +2 -0
- package/src/validate/match-dependency-rule.js +1 -1
- package/types/cruise-result.d.ts +7 -0
- package/types/shared-types.d.ts +3 -2
package/package.json
CHANGED
|
@@ -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").
|
|
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
|
-
|
|
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 (
|
|
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(
|
|
180
|
+
isExternalModule(
|
|
181
|
+
pDependency.resolved,
|
|
182
|
+
pResolveOptions.modules,
|
|
183
|
+
pBaseDirectory
|
|
184
|
+
)
|
|
181
185
|
) {
|
|
182
186
|
lReturnValue = determineExternalModuleDependencyTypes(
|
|
183
|
-
|
|
187
|
+
pDependency,
|
|
184
188
|
pModuleName,
|
|
185
189
|
pManifest,
|
|
186
190
|
pFileDirectory,
|
|
187
191
|
pResolveOptions,
|
|
188
192
|
pBaseDirectory
|
|
189
193
|
);
|
|
190
|
-
} else if (isAliassy(pModuleName,
|
|
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
|
@@ -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
|
|
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") &&
|
package/types/cruise-result.d.ts
CHANGED
|
@@ -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
|
package/types/shared-types.d.ts
CHANGED