knip 6.26.0 → 6.27.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/ConfigurationChief.d.ts +6 -0
- package/dist/DependencyDeputy.d.ts +1 -1
- package/dist/DependencyDeputy.js +2 -2
- package/dist/ProjectPrincipal.d.ts +3 -3
- package/dist/ProjectPrincipal.js +4 -4
- package/dist/binaries/fallback.js +5 -1
- package/dist/binaries/resolvers/bun.js +13 -5
- package/dist/binaries/resolvers/npm.js +4 -2
- package/dist/binaries/resolvers/pnpm.js +11 -1
- package/dist/binaries/resolvers/yarn.js +10 -4
- package/dist/binaries/util.d.ts +4 -0
- package/dist/binaries/util.js +14 -0
- package/dist/compilers/index.d.ts +10 -0
- package/dist/compilers/less.js +1 -1
- package/dist/compilers/scss.js +1 -1
- package/dist/compilers/stylus.js +1 -1
- package/dist/constants.js +6 -0
- package/dist/graph/analyze.js +1 -1
- package/dist/graph/build.js +16 -4
- package/dist/plugins/_vue/auto-import.js +64 -4
- package/dist/plugins/_vue/types.d.ts +18 -11
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/react-email/index.js +1 -0
- package/dist/plugins/tailwind/compiler.js +9 -4
- package/dist/plugins/tanstack-router/index.js +3 -1
- package/dist/plugins/temporal/index.d.ts +3 -0
- package/dist/plugins/temporal/index.js +12 -0
- package/dist/plugins/tsdown/index.js +15 -3
- package/dist/plugins/tsdown/types.d.ts +4 -1
- package/dist/plugins/vitest/index.js +15 -0
- package/dist/plugins/vitest/types.d.ts +5 -0
- package/dist/run.js +3 -3
- package/dist/schema/configuration.d.ts +15 -0
- package/dist/schema/plugins.d.ts +5 -0
- package/dist/schema/plugins.js +1 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +1 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/typescript/ast-nodes.d.ts +1 -0
- package/dist/typescript/get-imports-and-exports.js +8 -5
- package/dist/typescript/resolve-module-names.d.ts +2 -2
- package/dist/typescript/resolve-module-names.js +97 -18
- package/dist/typescript/visitors/walk.d.ts +2 -1
- package/dist/typescript/visitors/walk.js +13 -2
- package/dist/util/create-input-handler.js +8 -1
- package/dist/util/create-options.d.ts +10 -0
- package/dist/util/package-json.d.ts +7 -0
- package/dist/util/package-json.js +37 -0
- package/dist/util/resolve.d.ts +1 -0
- package/dist/util/resolve.js +1 -1
- package/dist/util/to-source-path.d.ts +4 -3
- package/dist/util/to-source-path.js +22 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +4 -0
|
@@ -35,6 +35,43 @@ const getEntriesFromExports = (obj) => {
|
|
|
35
35
|
}
|
|
36
36
|
return values;
|
|
37
37
|
};
|
|
38
|
+
export const getPackageMapTarget = (map, key) => {
|
|
39
|
+
if (!map || typeof map !== 'object' || Array.isArray(map))
|
|
40
|
+
return key === '.' ? { target: map } : undefined;
|
|
41
|
+
const entries = Object.entries(map);
|
|
42
|
+
let hasSubpaths = false;
|
|
43
|
+
for (const [subpath, target] of entries) {
|
|
44
|
+
if (!subpath.startsWith('.') && !subpath.startsWith('#'))
|
|
45
|
+
continue;
|
|
46
|
+
hasSubpaths = true;
|
|
47
|
+
if (subpath === key)
|
|
48
|
+
return { target };
|
|
49
|
+
}
|
|
50
|
+
if (!hasSubpaths)
|
|
51
|
+
return key === '.' ? { target: map } : undefined;
|
|
52
|
+
let best;
|
|
53
|
+
for (const [subpath, target] of entries) {
|
|
54
|
+
const starIndex = subpath.indexOf('*');
|
|
55
|
+
if (starIndex < 0)
|
|
56
|
+
continue;
|
|
57
|
+
const prefix = subpath.slice(0, starIndex);
|
|
58
|
+
const suffix = subpath.slice(starIndex + 1);
|
|
59
|
+
if (!key.startsWith(prefix) || !key.endsWith(suffix) || key.length < prefix.length + suffix.length)
|
|
60
|
+
continue;
|
|
61
|
+
if (!best ||
|
|
62
|
+
prefix.length > best.prefixLength ||
|
|
63
|
+
(prefix.length === best.prefixLength && subpath.length > best.subpathLength)) {
|
|
64
|
+
best = {
|
|
65
|
+
target,
|
|
66
|
+
patternMatch: key.slice(prefix.length, key.length - suffix.length),
|
|
67
|
+
prefixLength: prefix.length,
|
|
68
|
+
subpathLength: subpath.length,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (best)
|
|
73
|
+
return { target: best.target, patternMatch: best.patternMatch };
|
|
74
|
+
};
|
|
38
75
|
export const load = async (filePath) => {
|
|
39
76
|
const file = await readFile(filePath, 'utf8');
|
|
40
77
|
return parseJson(file);
|
package/dist/util/resolve.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const extensionAlias: Record<string, string[]>;
|
|
1
2
|
export declare const _resolveModuleSync: (specifier: string, basePath: string) => string | undefined;
|
|
2
3
|
export declare const _createSyncModuleResolver: (extensions: string[], tsConfigFile?: string) => (specifier: string, basePath: string) => string | undefined;
|
|
3
4
|
export declare function clearResolverCache(): void;
|
package/dist/util/resolve.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ResolverFactory } from 'oxc-resolver';
|
|
|
2
2
|
import { DEFAULT_EXTENSIONS, DTS_EXTENSIONS } from '../constants.js';
|
|
3
3
|
import { timerify } from './Performance.js';
|
|
4
4
|
import { toPosix } from './path.js';
|
|
5
|
-
const extensionAlias = {
|
|
5
|
+
export const extensionAlias = {
|
|
6
6
|
'.js': ['.js', '.ts', '.tsx', '.d.ts'],
|
|
7
7
|
'.jsx': ['.jsx', '.tsx'],
|
|
8
8
|
'.mjs': ['.mjs', '.mts', '.d.mts'],
|
|
@@ -2,11 +2,12 @@ import type { SourceMap } from '../types/config.ts';
|
|
|
2
2
|
import type { CompilerOptions } from '../types/project.ts';
|
|
3
3
|
import type { ConfigurationChief, Workspace } from '../ConfigurationChief.ts';
|
|
4
4
|
export declare const augmentWorkspace: (workspace: Workspace, dir: string, compilerOptions: CompilerOptions | undefined, pluginSourceMaps?: SourceMap[]) => void;
|
|
5
|
-
export type
|
|
5
|
+
export type WorkspacePackageTargetHandler = (specifier: string, filePath: string) => {
|
|
6
6
|
dir: string;
|
|
7
|
-
|
|
7
|
+
target: unknown;
|
|
8
|
+
patternMatch?: string;
|
|
8
9
|
} | undefined;
|
|
9
|
-
export declare const
|
|
10
|
+
export declare const getWorkspacePackageTargetHandler: (chief: ConfigurationChief) => WorkspacePackageTargetHandler;
|
|
10
11
|
export declare const getModuleSourcePathHandler: (chief: ConfigurationChief) => (filePath: string) => string | undefined;
|
|
11
12
|
export declare const getToSourcePathsHandler: (chief: ConfigurationChief) => (specifiers: Set<string>, dir: string, extensions: string | undefined, label: string) => Promise<string[]>;
|
|
12
13
|
export declare const toSourceMappedSpecifiers: (ws: Workspace | undefined, absSpecifier: string, extensions?: string) => string[];
|
|
@@ -2,6 +2,8 @@ import { DEFAULT_EXTENSIONS } from '../constants.js';
|
|
|
2
2
|
import { debugLog, debugLogArray } from './debug.js';
|
|
3
3
|
import { findFileWithExtensions, isDirectory } from './fs.js';
|
|
4
4
|
import { _glob, prependDirToPattern } from './glob.js';
|
|
5
|
+
import { getPackageNameFromModuleSpecifier } from './modules.js';
|
|
6
|
+
import { getPackageMapTarget } from './package-json.js';
|
|
5
7
|
import { isAbsolute, isInternal, join, toRelative } from './path.js';
|
|
6
8
|
const defaultExtensions = `.{${[...DEFAULT_EXTENSIONS].map(ext => ext.slice(1)).join(',')}}`;
|
|
7
9
|
const hasTSExt = /(?<!\.d)\.(m|c)?tsx?$/;
|
|
@@ -41,15 +43,30 @@ const rewritePattern = (sourceMaps, absSpecifier, extensions) => {
|
|
|
41
43
|
return r;
|
|
42
44
|
}
|
|
43
45
|
};
|
|
44
|
-
export const
|
|
45
|
-
return (filePath) => {
|
|
46
|
-
const
|
|
46
|
+
export const getWorkspacePackageTargetHandler = (chief) => {
|
|
47
|
+
return (specifier, filePath) => {
|
|
48
|
+
const isImports = specifier.startsWith('#');
|
|
49
|
+
let workspace;
|
|
50
|
+
let key = specifier;
|
|
51
|
+
if (isImports) {
|
|
52
|
+
workspace = chief.findWorkspaceByFilePath(filePath);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const packageName = getPackageNameFromModuleSpecifier(specifier);
|
|
56
|
+
if (!packageName)
|
|
57
|
+
return;
|
|
58
|
+
workspace = chief.workspacesByPkgName.get(packageName);
|
|
59
|
+
key = packageName === specifier ? '.' : `.${specifier.slice(packageName.length)}`;
|
|
60
|
+
}
|
|
47
61
|
if (!workspace)
|
|
48
62
|
return;
|
|
49
63
|
const manifest = chief.workspacePackages.get(workspace.name)?.manifest;
|
|
50
|
-
|
|
64
|
+
const map = isImports ? manifest?.imports : manifest?.exports;
|
|
65
|
+
if (!manifest || !map)
|
|
51
66
|
return;
|
|
52
|
-
|
|
67
|
+
const result = getPackageMapTarget(map, key);
|
|
68
|
+
if (result)
|
|
69
|
+
return { dir: workspace.dir, ...result };
|
|
53
70
|
};
|
|
54
71
|
};
|
|
55
72
|
export const getModuleSourcePathHandler = (chief) => {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.
|
|
1
|
+
export declare const version = "6.27.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '6.
|
|
1
|
+
export const version = '6.27.0';
|
package/package.json
CHANGED
package/schema.json
CHANGED
|
@@ -942,6 +942,10 @@
|
|
|
942
942
|
"title": "tauri plugin configuration (https://knip.dev/reference/plugins/tauri)",
|
|
943
943
|
"$ref": "#/definitions/plugin"
|
|
944
944
|
},
|
|
945
|
+
"temporal": {
|
|
946
|
+
"title": "temporal plugin configuration (https://knip.dev/reference/plugins/temporal)",
|
|
947
|
+
"$ref": "#/definitions/plugin"
|
|
948
|
+
},
|
|
945
949
|
"travis": {
|
|
946
950
|
"title": "travis plugin configuration (https://knip.dev/reference/plugins/travis)",
|
|
947
951
|
"$ref": "#/definitions/plugin"
|