knip 6.26.0 → 6.28.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.
Files changed (96) hide show
  1. package/dist/ConfigurationChief.d.ts +12 -0
  2. package/dist/DependencyDeputy.d.ts +1 -1
  3. package/dist/DependencyDeputy.js +3 -3
  4. package/dist/ProjectPrincipal.d.ts +3 -3
  5. package/dist/ProjectPrincipal.js +4 -4
  6. package/dist/WorkspaceWorker.js +9 -0
  7. package/dist/binaries/fallback.js +5 -1
  8. package/dist/binaries/resolvers/bun.js +13 -5
  9. package/dist/binaries/resolvers/npm.js +4 -2
  10. package/dist/binaries/resolvers/pnpm.js +11 -1
  11. package/dist/binaries/resolvers/yarn.js +10 -4
  12. package/dist/binaries/util.d.ts +4 -0
  13. package/dist/binaries/util.js +14 -0
  14. package/dist/compilers/index.d.ts +20 -0
  15. package/dist/compilers/less.js +1 -1
  16. package/dist/compilers/mdx.d.ts +2 -1
  17. package/dist/compilers/scss.js +1 -1
  18. package/dist/compilers/stylus.js +1 -1
  19. package/dist/constants.js +20 -0
  20. package/dist/graph/analyze.js +7 -5
  21. package/dist/graph/build.js +16 -4
  22. package/dist/graph-explorer/explorer.d.ts +1 -1
  23. package/dist/graph-explorer/operations/is-referenced.d.ts +1 -1
  24. package/dist/graph-explorer/operations/is-referenced.js +47 -33
  25. package/dist/manifest/index.d.ts +2 -1
  26. package/dist/plugins/_vue/auto-import.js +64 -4
  27. package/dist/plugins/_vue/types.d.ts +18 -11
  28. package/dist/plugins/angular/index.js +3 -0
  29. package/dist/plugins/babel/helpers.d.ts +9 -7
  30. package/dist/plugins/convex/index.js +11 -2
  31. package/dist/plugins/convex/types.d.ts +3 -0
  32. package/dist/plugins/convex/types.js +1 -0
  33. package/dist/plugins/github-actions/index.js +5 -2
  34. package/dist/plugins/index.d.ts +2 -0
  35. package/dist/plugins/index.js +4 -0
  36. package/dist/plugins/markdownlint/index.js +26 -5
  37. package/dist/plugins/markdownlint/types.d.ts +6 -0
  38. package/dist/plugins/nitro/index.js +3 -1
  39. package/dist/plugins/nuxt/index.js +19 -8
  40. package/dist/plugins/openclaw/index.d.ts +3 -0
  41. package/dist/plugins/openclaw/index.js +52 -0
  42. package/dist/plugins/openclaw/types.d.ts +25 -0
  43. package/dist/plugins/openclaw/types.js +1 -0
  44. package/dist/plugins/prettier/index.js +1 -1
  45. package/dist/plugins/react-email/index.js +1 -0
  46. package/dist/plugins/tailwind/compiler.js +9 -4
  47. package/dist/plugins/tailwind/index.js +8 -0
  48. package/dist/plugins/tanstack-router/index.js +3 -1
  49. package/dist/plugins/temporal/index.d.ts +3 -0
  50. package/dist/plugins/temporal/index.js +12 -0
  51. package/dist/plugins/tsdown/index.js +58 -3
  52. package/dist/plugins/tsdown/types.d.ts +4 -1
  53. package/dist/plugins/typescript/index.js +1 -1
  54. package/dist/plugins/vitest/index.js +15 -0
  55. package/dist/plugins/vitest/types.d.ts +5 -0
  56. package/dist/reporters/util/configuration-hints.js +3 -1
  57. package/dist/run.js +3 -3
  58. package/dist/schema/configuration.d.ts +30 -0
  59. package/dist/schema/plugins.d.ts +10 -0
  60. package/dist/schema/plugins.js +2 -0
  61. package/dist/types/PluginNames.d.ts +2 -2
  62. package/dist/types/PluginNames.js +2 -0
  63. package/dist/types/config.d.ts +1 -0
  64. package/dist/types/issues.d.ts +1 -1
  65. package/dist/typescript/ast-nodes.d.ts +4 -1
  66. package/dist/typescript/comments.d.ts +1 -1
  67. package/dist/typescript/comments.js +71 -5
  68. package/dist/typescript/get-imports-and-exports.d.ts +3 -1
  69. package/dist/typescript/get-imports-and-exports.js +9 -6
  70. package/dist/typescript/resolve-module-names.d.ts +2 -2
  71. package/dist/typescript/resolve-module-names.js +97 -18
  72. package/dist/typescript/visitors/walk.d.ts +3 -1
  73. package/dist/typescript/visitors/walk.js +27 -3
  74. package/dist/util/codeowners.js +1 -1
  75. package/dist/util/create-input-handler.js +8 -1
  76. package/dist/util/create-options.d.ts +20 -0
  77. package/dist/util/glob-cache.d.ts +7 -1
  78. package/dist/util/glob-cache.js +52 -29
  79. package/dist/util/glob-core.d.ts +2 -0
  80. package/dist/util/glob-core.js +46 -6
  81. package/dist/util/glob.d.ts +6 -3
  82. package/dist/util/glob.js +23 -9
  83. package/dist/util/loader.d.ts +3 -1
  84. package/dist/util/package-json.d.ts +7 -0
  85. package/dist/util/package-json.js +37 -0
  86. package/dist/util/parse-and-convert-gitignores.d.ts +2 -2
  87. package/dist/util/parse-and-convert-gitignores.js +4 -4
  88. package/dist/util/reporter.js +4 -3
  89. package/dist/util/resolve.d.ts +1 -0
  90. package/dist/util/resolve.js +1 -1
  91. package/dist/util/to-source-path.d.ts +4 -3
  92. package/dist/util/to-source-path.js +22 -5
  93. package/dist/version.d.ts +1 -1
  94. package/dist/version.js +1 -1
  95. package/package.json +11 -11
  96. package/schema.json +8 -0
@@ -13,11 +13,13 @@ export type Gitignores = {
13
13
  ignores: Set<string>;
14
14
  unignores: Set<string>;
15
15
  };
16
+ export declare const getGitignoreFingerprint: () => string;
16
17
  export declare const findAndParseGitignores: (cwd: string, workspaceDirs?: Set<string>) => Promise<{
17
18
  gitignoreFiles: string[];
18
19
  ignores: Set<string>;
19
20
  unignores: Set<string>;
20
21
  }>;
21
22
  export declare function glob(_patterns: string[], options: GlobOptions): Promise<string[]>;
23
+ export declare function reconcileGitignoredPaths(paths: string[], cwd: string): string[];
22
24
  export declare function getGitIgnoredHandler(options: Options, workspaceDirs?: Set<string>): Promise<(path: string) => boolean>;
23
25
  export {};
@@ -1,3 +1,4 @@
1
+ import { createHash } from 'node:crypto';
1
2
  import { readFileSync } from 'node:fs';
2
3
  import { basename } from 'node:path';
3
4
  import { fdir } from 'fdir';
@@ -10,9 +11,25 @@ import { isDirectory, isFile } from './fs.js';
10
11
  import { getCachedGitignore, isGitignoreCacheEnabled, setCachedGitignore } from './gitignore-cache.js';
11
12
  import { timerify } from './Performance.js';
12
13
  import { expandIgnorePatterns, parseAndConvertGitignorePatterns } from './parse-and-convert-gitignores.js';
13
- import { dirname, join, relative, toPosix } from './path.js';
14
+ import { dirname, isAbsolute, join, relative, toPosix } from './path.js';
14
15
  const cachedGitIgnores = new Map();
15
16
  const cachedGlobIgnores = new Map();
17
+ let gitignoreReconciler;
18
+ let gitignoreFingerprint = '';
19
+ export const getGitignoreFingerprint = () => gitignoreFingerprint;
20
+ const hashIgnores = (ignores, unignores) => {
21
+ const h = createHash('sha1');
22
+ for (const p of [...ignores].sort()) {
23
+ h.update(p);
24
+ h.update('\0');
25
+ }
26
+ h.update('\u0001');
27
+ for (const p of [...unignores].sort()) {
28
+ h.update(p);
29
+ h.update('\0');
30
+ }
31
+ return h.digest('base64url');
32
+ };
16
33
  const isGitRoot = (dir) => isDirectory(dir, '.git') || isFile(dir, '.git');
17
34
  const getGitDir = (cwd) => {
18
35
  const dotGit = join(cwd, '.git');
@@ -194,15 +211,23 @@ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
194
211
  p = parent;
195
212
  }
196
213
  }
214
+ const isShadowed = new Map();
197
215
  for (const cacheForDir of cachedGitIgnores.values()) {
198
216
  for (const pattern of cacheForDir.ignores) {
199
- const match = picomatch(pattern);
200
- for (const p of unignorePaths) {
201
- if (match(p)) {
202
- cacheForDir.ignores.delete(pattern);
203
- break;
217
+ let shadowed = isShadowed.get(pattern);
218
+ if (shadowed === undefined) {
219
+ const match = picomatch(pattern);
220
+ shadowed = false;
221
+ for (const p of unignorePaths) {
222
+ if (match(p)) {
223
+ shadowed = true;
224
+ break;
225
+ }
204
226
  }
227
+ isShadowed.set(pattern, shadowed);
205
228
  }
229
+ if (shadowed)
230
+ cacheForDir.ignores.delete(pattern);
206
231
  }
207
232
  }
208
233
  }
@@ -245,11 +270,24 @@ export async function glob(_patterns, options) {
245
270
  }));
246
271
  return paths;
247
272
  }
273
+ export function reconcileGitignoredPaths(paths, cwd) {
274
+ if (!gitignoreReconciler || paths.length === 0)
275
+ return paths;
276
+ const isGitIgnored = gitignoreReconciler;
277
+ const result = [];
278
+ for (const path of paths)
279
+ if (!isGitIgnored(isAbsolute(path) ? path : join(cwd, path)))
280
+ result.push(path);
281
+ return result;
282
+ }
248
283
  export async function getGitIgnoredHandler(options, workspaceDirs) {
249
284
  cachedGitIgnores.clear();
285
+ gitignoreReconciler = undefined;
286
+ gitignoreFingerprint = '';
250
287
  if (options.gitignore === false)
251
288
  return () => false;
252
289
  const { ignores, unignores } = await _parseFindGitignores(options.cwd, workspaceDirs);
290
+ gitignoreFingerprint = hashIgnores(ignores, unignores);
253
291
  const matcher = picomatch(expandIgnorePatterns(ignores), { ignore: expandIgnorePatterns(unignores) });
254
292
  const cache = new Map();
255
293
  const isGitIgnored = (filePath) => {
@@ -260,5 +298,7 @@ export async function getGitIgnoredHandler(options, workspaceDirs) {
260
298
  }
261
299
  return result;
262
300
  };
301
+ if (unignores.size > 0)
302
+ gitignoreReconciler = isGitIgnored;
263
303
  return isGitIgnored;
264
304
  }
@@ -11,10 +11,13 @@ export declare const prependDirToPattern: (dir: string, pattern: string) => stri
11
11
  export declare const negate: (pattern: string) => string;
12
12
  export declare const hasProductionSuffix: (pattern: string) => boolean;
13
13
  export declare const hasNoProductionSuffix: (pattern: string) => boolean;
14
- export declare const _glob: ({ cwd, dir, patterns, gitignore, label }: GlobOptions) => Promise<string[]>;
15
- export declare const _syncGlob: ({ cwd, patterns }: {
14
+ declare const defaultGlob: ({ cwd, dir, patterns, gitignore, label }: GlobOptions) => Promise<string[]>;
15
+ declare const syncGlob: ({ cwd, patterns }: {
16
16
  cwd: string;
17
17
  patterns: string | string[];
18
18
  }) => string[];
19
- export declare const _dirGlob: ({ cwd, patterns, gitignore }: GlobOptions) => Promise<string[]>;
19
+ declare const dirGlob: ({ cwd, patterns, gitignore }: GlobOptions) => Promise<string[]>;
20
+ export declare const _glob: typeof defaultGlob;
21
+ export declare const _syncGlob: typeof syncGlob;
22
+ export declare const _dirGlob: typeof dirGlob;
20
23
  export {};
package/dist/util/glob.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { globSync } from 'tinyglobby';
2
2
  import { compact } from './array.js';
3
- import { computeGlobCacheKey, getCachedGlob, isGlobCacheEnabled, setCachedGlob } from './glob-cache.js';
4
- import { glob } from './glob-core.js';
3
+ import { computeGlobCacheKey, createDirTracker, getCachedGlob, isGlobCacheEnabled, setCachedGlob, } from './glob-cache.js';
4
+ import { getGitignoreFingerprint, glob, reconcileGitignoredPaths } from './glob-core.js';
5
5
  import { timerify } from './Performance.js';
6
6
  import { isAbsolute, join, relative } from './path.js';
7
7
  const prepend = (pattern, relativePath) => isAbsolute(pattern.replace(/^!/, '')) ? pattern : prependDirToPattern(relativePath, pattern);
@@ -23,12 +23,16 @@ const defaultGlob = async ({ cwd, dir = cwd, patterns, gitignore = true, label }
23
23
  if (globPatterns[0].startsWith('!'))
24
24
  return [];
25
25
  const cacheEnabled = isGlobCacheEnabled();
26
- const cacheKey = cacheEnabled ? computeGlobCacheKey({ patterns: globPatterns, cwd, dir, gitignore }) : '';
26
+ const gitignoreFingerprint = gitignore ? getGitignoreFingerprint() : '';
27
+ const cacheKey = cacheEnabled
28
+ ? computeGlobCacheKey({ patterns: globPatterns, cwd, dir, gitignore, gitignoreFingerprint })
29
+ : '';
27
30
  if (cacheEnabled) {
28
31
  const cached = getCachedGlob(cacheKey);
29
32
  if (cached)
30
- return cached;
33
+ return gitignore ? reconcileGitignoredPaths(cached, cwd) : cached;
31
34
  }
35
+ const tracker = cacheEnabled ? createDirTracker() : undefined;
32
36
  const paths = await glob(globPatterns, {
33
37
  cwd,
34
38
  dir,
@@ -36,23 +40,33 @@ const defaultGlob = async ({ cwd, dir = cwd, patterns, gitignore = true, label }
36
40
  absolute: true,
37
41
  dot: true,
38
42
  label,
43
+ fs: tracker?.fs,
39
44
  });
40
45
  if (cacheEnabled && paths.length > 0)
41
- setCachedGlob(cacheKey, paths, dir);
42
- return paths;
46
+ setCachedGlob(cacheKey, paths, dir, tracker?.dirs);
47
+ return gitignore ? reconcileGitignoredPaths(paths, cwd) : paths;
43
48
  };
44
49
  const syncGlob = ({ cwd, patterns }) => {
45
50
  const cacheEnabled = isGlobCacheEnabled();
46
51
  const patternList = Array.isArray(patterns) ? patterns : [patterns];
47
- const cacheKey = cacheEnabled ? computeGlobCacheKey({ patterns: patternList, cwd, dir: cwd, gitignore: false }) : '';
52
+ const cacheKey = cacheEnabled
53
+ ? computeGlobCacheKey({ patterns: patternList, cwd, dir: cwd, gitignore: false, gitignoreFingerprint: '' })
54
+ : '';
48
55
  if (cacheEnabled) {
49
56
  const cached = getCachedGlob(cacheKey);
50
57
  if (cached)
51
58
  return cached;
52
59
  }
53
- const paths = globSync(patterns, { cwd, absolute: true, followSymbolicLinks: false, expandDirectories: false });
60
+ const tracker = cacheEnabled ? createDirTracker() : undefined;
61
+ const paths = globSync(patterns, {
62
+ cwd,
63
+ absolute: true,
64
+ followSymbolicLinks: false,
65
+ expandDirectories: false,
66
+ fs: tracker?.fs,
67
+ });
54
68
  if (cacheEnabled && paths.length > 0)
55
- setCachedGlob(cacheKey, paths, cwd);
69
+ setCachedGlob(cacheKey, paths, cwd, tracker?.dirs);
56
70
  return paths;
57
71
  };
58
72
  const dirGlob = async ({ cwd, patterns, gitignore = true }) => glob(patterns, {
@@ -1 +1,3 @@
1
- export declare const _load: (filePath: string) => Promise<any>;
1
+ declare const load: (filePath: string) => Promise<any>;
2
+ export declare const _load: typeof load;
3
+ export {};
@@ -5,6 +5,13 @@ interface ExtendedPackageJson extends PackageJson {
5
5
  [INDENT]?: string;
6
6
  [NEWLINE]?: string;
7
7
  }
8
+ export declare const getPackageMapTarget: (map: unknown, key: string) => {
9
+ target: any;
10
+ patternMatch?: undefined;
11
+ } | {
12
+ target: unknown;
13
+ patternMatch: string;
14
+ } | undefined;
8
15
  export declare const load: (filePath: string) => Promise<ExtendedPackageJson>;
9
16
  export declare const save: (filePath: string, content: ExtendedPackageJson) => Promise<void>;
10
17
  export declare const getEntrySpecifiersFromManifest: (manifest: PackageJson) => Set<string>;
@@ -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);
@@ -1,5 +1,5 @@
1
- export declare const toExtendedIgnorePattern: (pattern: string) => string;
2
- export declare const expandIgnorePatterns: (patterns: Iterable<string>) => string[];
1
+ export declare const toExtendedIgnorePattern: (pattern: string, shallow?: boolean) => string;
2
+ export declare const expandIgnorePatterns: (patterns: Iterable<string>, shallow?: boolean) => string[];
3
3
  export declare const convertGitignoreToPicomatchIgnorePatterns: (pattern: string) => {
4
4
  negated: boolean;
5
5
  pattern: string;
@@ -1,15 +1,15 @@
1
- export const toExtendedIgnorePattern = (pattern) => {
1
+ export const toExtendedIgnorePattern = (pattern, shallow = false) => {
2
2
  if (pattern === '*' || pattern === '**')
3
3
  return pattern;
4
- if (pattern.endsWith('/*'))
4
+ if (shallow && pattern.endsWith('/*'))
5
5
  return pattern;
6
6
  return `${pattern}/**`;
7
7
  };
8
- export const expandIgnorePatterns = (patterns) => {
8
+ export const expandIgnorePatterns = (patterns, shallow = false) => {
9
9
  const result = [];
10
10
  for (const p of patterns) {
11
11
  result.push(p);
12
- const ext = toExtendedIgnorePattern(p);
12
+ const ext = toExtendedIgnorePattern(p, shallow);
13
13
  if (ext !== p)
14
14
  result.push(ext);
15
15
  }
@@ -3,9 +3,10 @@ import { _load } from './loader.js';
3
3
  import { isAbsolute, isInternal, resolve } from './path.js';
4
4
  export const runPreprocessors = async (processors, data) => {
5
5
  const preprocessors = await Promise.all(processors.map(proc => _load(isInternal(proc) && !isAbsolute(proc) ? resolve(proc) : proc)));
6
- return preprocessors.length === 0
7
- ? Promise.resolve(data)
8
- : runPreprocessors(preprocessors.slice(1), preprocessors[0](data));
6
+ let result = data;
7
+ for (const preprocessor of preprocessors)
8
+ result = await preprocessor(result);
9
+ return result;
9
10
  };
10
11
  export const runReporters = async (reporter, options) => {
11
12
  const reporters = await Promise.all(reporter.map(async (reporter) => {
@@ -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;
@@ -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 WorkspaceManifestHandler = (filePath: string) => {
5
+ export type WorkspacePackageTargetHandler = (specifier: string, filePath: string) => {
6
6
  dir: string;
7
- imports: unknown;
7
+ target: unknown;
8
+ patternMatch?: string;
8
9
  } | undefined;
9
- export declare const getWorkspaceManifestHandler: (chief: ConfigurationChief) => WorkspaceManifestHandler;
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 getWorkspaceManifestHandler = (chief) => {
45
- return (filePath) => {
46
- const workspace = chief.findWorkspaceByFilePath(filePath);
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
- if (!manifest?.imports)
64
+ const map = isImports ? manifest?.imports : manifest?.exports;
65
+ if (!manifest || !map)
51
66
  return;
52
- return { dir: workspace.dir, imports: manifest.imports };
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.26.0";
1
+ export declare const version = "6.28.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '6.26.0';
1
+ export const version = '6.28.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "6.26.0",
3
+ "version": "6.28.0",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "keywords": [
6
6
  "analysis",
@@ -81,25 +81,25 @@
81
81
  "formatly": "^0.3.0",
82
82
  "get-tsconfig": "4.14.0",
83
83
  "jiti": "^2.7.0",
84
- "oxc-parser": "^0.137.0",
85
- "oxc-resolver": "11.21.3",
86
- "picomatch": "^4.0.4",
87
- "smol-toml": "^1.6.1",
84
+ "oxc-parser": "^0.140.0",
85
+ "oxc-resolver": "11.24.2",
86
+ "picomatch": "^4.0.5",
87
+ "smol-toml": "^1.7.0",
88
88
  "strip-json-comments": "5.0.3",
89
89
  "tinyglobby": "^0.2.17",
90
- "unbash": "^4.0.1",
90
+ "unbash": "^4.0.3",
91
91
  "yaml": "^2.9.0",
92
- "zod": "^4.1.11"
92
+ "zod": "^4.4.3"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@jest/types": "^30.4.1",
96
96
  "@types/bun": "^1.3.14",
97
97
  "@types/picomatch": "^4.0.3",
98
98
  "@types/webpack": "^5.28.5",
99
- "@typescript/native-preview": "7.0.0-dev.20260619.1",
100
99
  "codeclimate-types": "^0.3.1",
101
- "prettier": "^3.8.4",
102
- "tsx": "^4.22.4"
100
+ "prettier": "^3.9.5",
101
+ "tsx": "^4.23.1",
102
+ "typescript": "7.0.2"
103
103
  },
104
104
  "engines": {
105
105
  "node": "^20.19.0 || >=22.12.0"
@@ -112,7 +112,7 @@
112
112
  "fmt": "oxfmt -c ../../.oxfmtrc.json --ignore-path ../../.prettierignore",
113
113
  "test": "node scripts/run-test.js",
114
114
  "prebuild": "pnpm run generate-plugin-defs && node rmdir.js dist",
115
- "build": "tsgo",
115
+ "build": "tsc",
116
116
  "qa": "pnpm lint && pnpm build && pnpm knip && pnpm knip:production && pnpm test",
117
117
  "release": "NODE_OPTIONS=--no-deprecation release-it",
118
118
  "create-plugin": "node ./scripts/create-new-plugin.ts",
package/schema.json CHANGED
@@ -726,6 +726,10 @@
726
726
  "title": "openapi-ts plugin configuration (https://knip.dev/reference/plugins/openapi-ts)",
727
727
  "$ref": "#/definitions/plugin"
728
728
  },
729
+ "openclaw": {
730
+ "title": "openclaw plugin configuration (https://knip.dev/reference/plugins/openclaw)",
731
+ "$ref": "#/definitions/plugin"
732
+ },
729
733
  "orval": {
730
734
  "title": "orval plugin configuration (https://knip.dev/reference/plugins/orval)",
731
735
  "$ref": "#/definitions/plugin"
@@ -942,6 +946,10 @@
942
946
  "title": "tauri plugin configuration (https://knip.dev/reference/plugins/tauri)",
943
947
  "$ref": "#/definitions/plugin"
944
948
  },
949
+ "temporal": {
950
+ "title": "temporal plugin configuration (https://knip.dev/reference/plugins/temporal)",
951
+ "$ref": "#/definitions/plugin"
952
+ },
945
953
  "travis": {
946
954
  "title": "travis plugin configuration (https://knip.dev/reference/plugins/travis)",
947
955
  "$ref": "#/definitions/plugin"