knip 2.16.2 → 2.17.0
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/dist/index.js +0 -2
- package/dist/types/compilers.d.ts +2 -2
- package/dist/types/imports.d.ts +0 -1
- package/dist/typescript/SourceFileManager.js +2 -2
- package/dist/typescript/getImportsAndExports.d.ts +0 -1
- package/dist/typescript/getImportsAndExports.js +4 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -202,8 +202,6 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
202
202
|
importedModule.isReExport = importItems.isReExport;
|
|
203
203
|
importedModule.isReExportedBy.add(filePath);
|
|
204
204
|
}
|
|
205
|
-
if (importItems.isDynamic)
|
|
206
|
-
importedModule.isDynamic = importItems.isDynamic;
|
|
207
205
|
if (importItems.isStar)
|
|
208
206
|
importedModule.isStar = importItems.isStar;
|
|
209
207
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
type FileExtension = string;
|
|
2
|
-
export type SyncCompilerFn = (source: string) => string;
|
|
3
|
-
export type AsyncCompilerFn = (source: string) => Promise<string>;
|
|
2
|
+
export type SyncCompilerFn = (source: string, path: string) => string;
|
|
3
|
+
export type AsyncCompilerFn = (source: string, path: string) => Promise<string>;
|
|
4
4
|
export type SyncCompilers = Map<FileExtension, SyncCompilerFn>;
|
|
5
5
|
export type AsyncCompilers = Map<FileExtension, AsyncCompilerFn>;
|
|
6
6
|
export {};
|
package/dist/types/imports.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export class SourceFileManager {
|
|
|
23
23
|
throw new Error(`Unable to read ${filePath}`);
|
|
24
24
|
const ext = extname(filePath);
|
|
25
25
|
const compiler = this.syncCompilers?.get(ext);
|
|
26
|
-
const compiled = compiler ? compiler(contents) : contents;
|
|
26
|
+
const compiled = compiler ? compiler(contents, filePath) : contents;
|
|
27
27
|
if (compiler)
|
|
28
28
|
debugLog(`Compiled ${filePath}`);
|
|
29
29
|
return this.createSourceFile(filePath, compiled);
|
|
@@ -45,7 +45,7 @@ export class SourceFileManager {
|
|
|
45
45
|
const ext = extname(filePath);
|
|
46
46
|
const compiler = this.asyncCompilers?.get(ext);
|
|
47
47
|
if (compiler) {
|
|
48
|
-
const compiled = await compiler(contents);
|
|
48
|
+
const compiled = await compiler(contents, filePath);
|
|
49
49
|
debugLog(`Compiled ${filePath}`);
|
|
50
50
|
this.createSourceFile(filePath, compiled);
|
|
51
51
|
}
|
|
@@ -22,7 +22,7 @@ export const getImportsAndExports = (sourceFile, options) => {
|
|
|
22
22
|
const importedInternalSymbols = new Map();
|
|
23
23
|
const visitors = getVisitors(sourceFile);
|
|
24
24
|
const addInternalImport = (options) => {
|
|
25
|
-
const { identifier, specifier, symbol, filePath,
|
|
25
|
+
const { identifier, specifier, symbol, filePath, isReExport } = options;
|
|
26
26
|
const isStar = identifier === '*';
|
|
27
27
|
const internalImport = getOrSet(internalImports, filePath, {
|
|
28
28
|
specifier,
|
|
@@ -30,7 +30,6 @@ export const getImportsAndExports = (sourceFile, options) => {
|
|
|
30
30
|
isReExport,
|
|
31
31
|
isReExportedBy: new Set(),
|
|
32
32
|
symbols: new Set(),
|
|
33
|
-
isDynamic,
|
|
34
33
|
});
|
|
35
34
|
if (isReExport) {
|
|
36
35
|
internalImport.isReExport = isReExport;
|
|
@@ -42,11 +41,9 @@ export const getImportsAndExports = (sourceFile, options) => {
|
|
|
42
41
|
internalImport.symbols.add(identifier);
|
|
43
42
|
if (isStar && symbol)
|
|
44
43
|
importedInternalSymbols.set(symbol, filePath);
|
|
45
|
-
if (isDynamic)
|
|
46
|
-
internalImport.isDynamic = isDynamic;
|
|
47
44
|
};
|
|
48
45
|
const addImport = (options) => {
|
|
49
|
-
const { specifier, symbol, identifier = '__anonymous',
|
|
46
|
+
const { specifier, symbol, identifier = '__anonymous', isReExport = false } = options;
|
|
50
47
|
if (isBuiltin(specifier))
|
|
51
48
|
return;
|
|
52
49
|
const module = sourceFile.resolvedModules?.get(specifier, undefined);
|
|
@@ -55,7 +52,7 @@ export const getImportsAndExports = (sourceFile, options) => {
|
|
|
55
52
|
if (filePath) {
|
|
56
53
|
if (module.resolvedModule.isExternalLibraryImport) {
|
|
57
54
|
if (!isInNodeModules(filePath)) {
|
|
58
|
-
addInternalImport({ identifier, specifier, symbol, filePath,
|
|
55
|
+
addInternalImport({ identifier, specifier, symbol, filePath, isReExport });
|
|
59
56
|
}
|
|
60
57
|
if (!isMaybePackageName(specifier))
|
|
61
58
|
return;
|
|
@@ -67,7 +64,7 @@ export const getImportsAndExports = (sourceFile, options) => {
|
|
|
67
64
|
}
|
|
68
65
|
}
|
|
69
66
|
else {
|
|
70
|
-
addInternalImport({ identifier, specifier, symbol, filePath,
|
|
67
|
+
addInternalImport({ identifier, specifier, symbol, filePath, isReExport });
|
|
71
68
|
}
|
|
72
69
|
}
|
|
73
70
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.
|
|
1
|
+
export declare const version = "2.17.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.17.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://github.com/webpro/knip",
|
|
6
6
|
"repository": "github:webpro/knip",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"format": "prettier scripts src tests schema.json --with-node-modules --write --config .prettierrc",
|
|
25
25
|
"pretest": "node rmdir.js tmp && swc src -d tmp/src && swc tests -d tmp/tests",
|
|
26
26
|
"test": "node --no-warnings --test tmp",
|
|
27
|
-
"coverage": "c8
|
|
27
|
+
"coverage": "c8 --reporter html node --no-warnings --loader tsx --test tests/*.test.ts tests/*/*.test.ts",
|
|
28
28
|
"watch": "tsc --watch",
|
|
29
29
|
"prebuild": "node rmdir.js dist",
|
|
30
30
|
"build": "tsc",
|