knip 5.17.1 → 5.17.3
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/ProjectPrincipal.js +3 -3
- package/dist/constants.js +2 -0
- package/dist/types/serializable-map.d.ts +1 -0
- package/dist/typescript/getImportsAndExports.js +1 -1
- package/dist/util/serialize.d.ts +3 -3
- package/dist/util/serialize.js +14 -12
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/ProjectPrincipal.js
CHANGED
|
@@ -8,7 +8,7 @@ import { timerify } from './util/Performance.js';
|
|
|
8
8
|
import { compact } from './util/array.js';
|
|
9
9
|
import { getPackageNameFromModuleSpecifier, isStartsLikePackageName, sanitizeSpecifier } from './util/modules.js';
|
|
10
10
|
import { dirname, extname, isInNodeModules, join } from './util/path.js';
|
|
11
|
-
import {
|
|
11
|
+
import { _deserialize, _serialize } from './util/serialize.js';
|
|
12
12
|
const baseCompilerOptions = {
|
|
13
13
|
allowJs: true,
|
|
14
14
|
allowSyntheticDefaultImports: true,
|
|
@@ -150,7 +150,7 @@ export class ProjectPrincipal {
|
|
|
150
150
|
analyzeSourceFile(filePath, options, isGitIgnored, isPackageNameInternalWorkspace, getPrincipalByFilePath) {
|
|
151
151
|
const fd = this.cache.getFileDescriptor(filePath);
|
|
152
152
|
if (!fd.changed && fd.meta?.data)
|
|
153
|
-
return
|
|
153
|
+
return _deserialize(fd.meta.data);
|
|
154
154
|
if (!this.backend.typeChecker)
|
|
155
155
|
throw new Error('Must initialize TypeChecker before source file analysis');
|
|
156
156
|
const sourceFile = this.backend.fileManager.getSourceFile(filePath);
|
|
@@ -249,7 +249,7 @@ export class ProjectPrincipal {
|
|
|
249
249
|
const fd = this.cache.getFileDescriptor(filePath);
|
|
250
250
|
if (!fd?.meta)
|
|
251
251
|
continue;
|
|
252
|
-
fd.meta.data =
|
|
252
|
+
fd.meta.data = _serialize(serializableMap[filePath]);
|
|
253
253
|
}
|
|
254
254
|
this.cache.reconcile();
|
|
255
255
|
}
|
package/dist/constants.js
CHANGED
|
@@ -35,6 +35,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
35
35
|
'git',
|
|
36
36
|
'grep',
|
|
37
37
|
'gzip',
|
|
38
|
+
'kill',
|
|
38
39
|
'ln',
|
|
39
40
|
'ls',
|
|
40
41
|
'mkdir',
|
|
@@ -47,6 +48,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
47
48
|
'rm',
|
|
48
49
|
'set',
|
|
49
50
|
'sh',
|
|
51
|
+
'ssh',
|
|
50
52
|
'sudo',
|
|
51
53
|
'test',
|
|
52
54
|
'touch',
|
|
@@ -108,7 +108,7 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
|
|
|
108
108
|
if (module) {
|
|
109
109
|
const filePath = module.resolvedFileName;
|
|
110
110
|
if (filePath) {
|
|
111
|
-
if (options.resolve) {
|
|
111
|
+
if (options.resolve && !isInNodeModules(filePath)) {
|
|
112
112
|
resolved.add(filePath);
|
|
113
113
|
return;
|
|
114
114
|
}
|
package/dist/util/serialize.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { SerializableFile } from '../types/serializable-map.js';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
1
|
+
import type { SerializableFile, SerializedFile } from '../types/serializable-map.js';
|
|
2
|
+
export declare const _serialize: (data: SerializableFile) => SerializedFile;
|
|
3
|
+
export declare const _deserialize: (data: SerializedFile) => SerializableFile;
|
package/dist/util/serialize.js
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
import { timerify } from './Performance.js';
|
|
2
|
+
const mapKeys = new Set(['importedAs', 'reExportedBy', 'reExportedAs', 'reExportedNs']);
|
|
3
|
+
const serializeObj = (obj) => {
|
|
3
4
|
if (obj instanceof Set)
|
|
4
5
|
return Array.from(obj);
|
|
5
6
|
if (obj instanceof Map)
|
|
6
|
-
return
|
|
7
|
+
return serializeObj(Object.fromEntries(obj.entries()));
|
|
7
8
|
if (typeof obj === 'object')
|
|
8
|
-
for (const key in obj)
|
|
9
|
-
obj[key] =
|
|
10
|
-
}
|
|
9
|
+
for (const key in obj)
|
|
10
|
+
obj[key] = serializeObj(obj[key]);
|
|
11
11
|
return obj;
|
|
12
12
|
};
|
|
13
|
-
const
|
|
13
|
+
const deserializeObj = (obj) => {
|
|
14
14
|
if (Array.isArray(obj))
|
|
15
15
|
return new Set(obj);
|
|
16
16
|
if (typeof obj === 'object') {
|
|
17
17
|
for (const key in obj) {
|
|
18
|
-
if (
|
|
18
|
+
if (mapKeys.has(key)) {
|
|
19
19
|
if (!(obj[key] instanceof Map))
|
|
20
|
-
obj[key] = new Map(Object.entries(obj[key]).map(v => [v[0],
|
|
20
|
+
obj[key] = new Map(Object.entries(obj[key]).map(v => [v[0], deserializeObj(v[1])]));
|
|
21
21
|
}
|
|
22
22
|
else
|
|
23
|
-
obj[key] =
|
|
23
|
+
obj[key] = deserializeObj(obj[key]);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
return obj;
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const serialize = (data) => serializeObj(structuredClone(data));
|
|
29
|
+
const deserialize = (data) => deserializeObj(data);
|
|
30
|
+
export const _serialize = timerify(serialize);
|
|
31
|
+
export const _deserialize = timerify(deserialize);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.17.
|
|
1
|
+
export declare const version = "5.17.3";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.17.
|
|
1
|
+
export const version = '5.17.3';
|