knip 5.47.0 → 5.49.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 (82) hide show
  1. package/dist/ConfigurationChief.d.ts +3 -0
  2. package/dist/ProjectPrincipal.d.ts +2 -2
  3. package/dist/ProjectPrincipal.js +9 -7
  4. package/dist/WorkspaceWorker.d.ts +9 -8
  5. package/dist/WorkspaceWorker.js +100 -72
  6. package/dist/cli.js +2 -2
  7. package/dist/compilers/index.d.ts +31 -0
  8. package/dist/graph/analyze.js +0 -2
  9. package/dist/graph/build.js +62 -33
  10. package/dist/plugins/astro/index.d.ts +1 -0
  11. package/dist/plugins/astro/index.js +3 -1
  12. package/dist/plugins/ava/index.js +1 -1
  13. package/dist/plugins/cucumber/index.js +1 -1
  14. package/dist/plugins/cypress/index.js +1 -1
  15. package/dist/plugins/github-actions/index.js +1 -1
  16. package/dist/plugins/index.d.ts +27 -2
  17. package/dist/plugins/index.js +6 -0
  18. package/dist/plugins/jest/index.js +3 -1
  19. package/dist/plugins/ladle/index.js +1 -1
  20. package/dist/plugins/mocha/index.js +2 -2
  21. package/dist/plugins/next/index.d.ts +3 -2
  22. package/dist/plugins/next/index.js +19 -8
  23. package/dist/plugins/next/resolveFromAST.d.ts +2 -0
  24. package/dist/plugins/next/resolveFromAST.js +15 -0
  25. package/dist/plugins/node/index.js +1 -1
  26. package/dist/plugins/nodemon/index.js +1 -1
  27. package/dist/plugins/nuxt/index.d.ts +1 -1
  28. package/dist/plugins/nuxt/index.js +2 -2
  29. package/dist/plugins/playwright/index.js +1 -3
  30. package/dist/plugins/preconstruct/index.js +1 -1
  31. package/dist/plugins/react-cosmos/index.js +1 -1
  32. package/dist/plugins/react-router/index.js +4 -2
  33. package/dist/plugins/sst/index.d.ts +9 -0
  34. package/dist/plugins/sst/index.js +17 -0
  35. package/dist/plugins/sst/resolveFromAST.d.ts +2 -0
  36. package/dist/plugins/sst/resolveFromAST.js +47 -0
  37. package/dist/plugins/starlight/index.d.ts +9 -0
  38. package/dist/plugins/starlight/index.js +18 -0
  39. package/dist/plugins/starlight/resolveFromAST.d.ts +2 -0
  40. package/dist/plugins/starlight/resolveFromAST.js +20 -0
  41. package/dist/plugins/storybook/index.js +5 -2
  42. package/dist/plugins/tanstack-router/index.d.ts +12 -0
  43. package/dist/plugins/tanstack-router/index.js +46 -0
  44. package/dist/plugins/tanstack-router/resolveFromAST.d.ts +2 -0
  45. package/dist/plugins/tanstack-router/resolveFromAST.js +28 -0
  46. package/dist/plugins/tanstack-router/types.d.ts +7 -0
  47. package/dist/plugins/tanstack-router/types.js +1 -0
  48. package/dist/plugins/unbuild/index.js +1 -1
  49. package/dist/plugins/vitest/index.js +1 -1
  50. package/dist/reporters/codeowners.js +8 -6
  51. package/dist/reporters/json.js +3 -3
  52. package/dist/schema/configuration.d.ts +172 -1
  53. package/dist/schema/configuration.js +3 -1
  54. package/dist/schema/plugins.d.ts +69 -0
  55. package/dist/schema/plugins.js +3 -0
  56. package/dist/types/PluginNames.d.ts +2 -2
  57. package/dist/types/PluginNames.js +3 -0
  58. package/dist/types/config.d.ts +8 -0
  59. package/dist/typescript/ast-helpers.d.ts +4 -0
  60. package/dist/typescript/ast-helpers.js +62 -0
  61. package/dist/typescript/create-hosts.d.ts +3 -2
  62. package/dist/typescript/create-hosts.js +1 -3
  63. package/dist/util/Performance.js +7 -7
  64. package/dist/util/codeowners.d.ts +2 -0
  65. package/dist/util/codeowners.js +32 -0
  66. package/dist/util/errors.d.ts +1 -1
  67. package/dist/util/errors.js +2 -2
  68. package/dist/util/glob-core.js +1 -1
  69. package/dist/util/input.d.ts +1 -0
  70. package/dist/util/math.d.ts +6 -0
  71. package/dist/util/math.js +11 -0
  72. package/dist/util/object.d.ts +0 -1
  73. package/dist/util/object.js +0 -16
  74. package/dist/util/package-json.d.ts +1 -3
  75. package/dist/util/package-json.js +28 -5
  76. package/dist/util/plugin.d.ts +0 -2
  77. package/dist/util/plugin.js +1 -14
  78. package/dist/util/to-source-path.js +9 -12
  79. package/dist/version.d.ts +1 -1
  80. package/dist/version.js +1 -1
  81. package/package.json +3 -5
  82. package/schema.json +12 -0
@@ -138,12 +138,15 @@ export declare class ConfigurationChief {
138
138
  sentry?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
139
139
  "simple-git-hooks"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
140
140
  "size-limit"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
141
+ sst?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
142
+ starlight?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
141
143
  storybook?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
142
144
  stryker?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
143
145
  stylelint?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
144
146
  svelte?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
145
147
  syncpack?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
146
148
  tailwind?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
149
+ "tanstack-router"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
147
150
  travis?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
148
151
  "ts-node"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
149
152
  tsup?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -4,7 +4,7 @@ import type { AsyncCompilers, SyncCompilers } from './compilers/types.js';
4
4
  import type { GetImportsAndExportsOptions } from './types/config.js';
5
5
  import type { Export, ExportMember, FileNode, ModuleGraph } from './types/module-graph.js';
6
6
  import type { PrincipalOptions } from './types/project.js';
7
- import type { SourceFileManager } from './typescript/SourceFileManager.js';
7
+ import { SourceFileManager } from './typescript/SourceFileManager.js';
8
8
  import type { ResolveModuleNames } from './typescript/resolve-module-names.js';
9
9
  import type { ToSourceFilePath } from './util/to-source-path.js';
10
10
  export declare class ProjectPrincipal {
@@ -23,7 +23,7 @@ export declare class ProjectPrincipal {
23
23
  toSourceFilePath: ToSourceFilePath;
24
24
  backend: {
25
25
  fileManager: SourceFileManager;
26
- compilerHost: ts.CompilerHost;
26
+ compilerHost?: ts.CompilerHost;
27
27
  resolveModuleNames: ResolveModuleNames;
28
28
  program?: ts.Program;
29
29
  typeChecker?: ts.TypeChecker;
@@ -2,6 +2,7 @@ import ts from 'typescript';
2
2
  import { CacheConsultant } from './CacheConsultant.js';
3
3
  import { getCompilerExtensions } from './compilers/index.js';
4
4
  import { ANONYMOUS, DEFAULT_EXTENSIONS, FOREIGN_FILE_EXTENSIONS, PUBLIC_TAG } from './constants.js';
5
+ import { SourceFileManager } from './typescript/SourceFileManager.js';
5
6
  import { createHosts } from './typescript/create-hosts.js';
6
7
  import { _getImportsAndExports } from './typescript/get-imports-and-exports.js';
7
8
  import { timerify } from './util/Performance.js';
@@ -58,9 +59,12 @@ export class ProjectPrincipal {
58
59
  this.isWatch = isWatch;
59
60
  this.cache = new CacheConsultant({ name: pkgName || ANONYMOUS, isEnabled: isCache, cacheLocation });
60
61
  this.toSourceFilePath = toSourceFilePath;
62
+ this.backend = {
63
+ fileManager: new SourceFileManager({ compilers, isSkipLibs }),
64
+ };
61
65
  }
62
66
  init() {
63
- const { fileManager, compilerHost, resolveModuleNames, languageServiceHost } = createHosts({
67
+ const { compilerHost, resolveModuleNames, languageServiceHost } = createHosts({
64
68
  cwd: this.cwd,
65
69
  compilerOptions: this.compilerOptions,
66
70
  entryPaths: this.entryPaths,
@@ -68,13 +72,11 @@ export class ProjectPrincipal {
68
72
  isSkipLibs: this.isSkipLibs,
69
73
  toSourceFilePath: this.toSourceFilePath,
70
74
  useResolverCache: !this.isWatch,
75
+ fileManager: this.backend.fileManager,
71
76
  });
72
- this.backend = {
73
- fileManager,
74
- compilerHost,
75
- resolveModuleNames,
76
- languageServiceHost,
77
- };
77
+ this.backend.compilerHost = compilerHost;
78
+ this.backend.resolveModuleNames = resolveModuleNames;
79
+ this.backend.languageServiceHost = languageServiceHost;
78
80
  }
79
81
  addPaths(paths) {
80
82
  this.compilerOptions.paths = { ...this.compilerOptions.paths, ...paths };
@@ -1,7 +1,7 @@
1
1
  import { CacheConsultant } from './CacheConsultant.js';
2
2
  import type { Workspace } from './ConfigurationChief.js';
3
3
  import type { PluginName } from './types/PluginNames.js';
4
- import type { Configuration, WorkspaceConfiguration } from './types/config.js';
4
+ import type { Configuration, GetReferencedInternalFilePath, GetSourceFile, WorkspaceConfiguration } from './types/config.js';
5
5
  import type { PackageJson } from './types/package-json.js';
6
6
  import type { DependencySet } from './types/workspace.js';
7
7
  import { type Input } from './util/input.js';
@@ -12,8 +12,9 @@ type WorkspaceManagerOptions = {
12
12
  config: WorkspaceConfiguration;
13
13
  manifest: PackageJson;
14
14
  dependencies: DependencySet;
15
- getReferencedInternalFilePath: (input: Input) => string | undefined;
15
+ getReferencedInternalFilePath: GetReferencedInternalFilePath;
16
16
  findWorkspaceByFilePath: (filePath: string) => Workspace | undefined;
17
+ getSourceFile: GetSourceFile;
17
18
  rootIgnore: Configuration['ignore'];
18
19
  negatedWorkspacePatterns: string[];
19
20
  ignoredWorkspacePatterns: string[];
@@ -22,12 +23,12 @@ type WorkspaceManagerOptions = {
22
23
  isStrict: boolean;
23
24
  isCache: boolean;
24
25
  cacheLocation: string;
25
- allConfigFilePaths: Set<string>;
26
- allConfigFilesMap: Map<string, Map<PluginName, Set<string>>>;
26
+ configFilesMap: Map<string, Map<PluginName, Set<string>>>;
27
27
  };
28
28
  type CacheItem = {
29
29
  resolveEntryPaths?: Input[];
30
30
  resolveConfig?: Input[];
31
+ resolveFromAST?: Input[];
31
32
  };
32
33
  export declare class WorkspaceWorker {
33
34
  name: string;
@@ -36,8 +37,9 @@ export declare class WorkspaceWorker {
36
37
  config: WorkspaceConfiguration;
37
38
  manifest: PackageJson;
38
39
  dependencies: DependencySet;
39
- getReferencedInternalFilePath: (input: Input) => string | undefined;
40
+ getReferencedInternalFilePath: GetReferencedInternalFilePath;
40
41
  findWorkspaceByFilePath: (filePath: string) => Workspace | undefined;
42
+ getSourceFile: GetSourceFile;
41
43
  isProduction: boolean;
42
44
  isStrict: boolean;
43
45
  rootIgnore: Configuration['ignore'];
@@ -47,9 +49,8 @@ export declare class WorkspaceWorker {
47
49
  enabledPlugins: PluginName[];
48
50
  enabledPluginsInAncestors: string[];
49
51
  cache: CacheConsultant<CacheItem>;
50
- allConfigFilePaths: Set<string>;
51
- allConfigFilesMap: Map<string, Map<PluginName, Set<string>>>;
52
- constructor({ name, dir, cwd, config, manifest, dependencies, isProduction, isStrict, rootIgnore, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, getReferencedInternalFilePath, findWorkspaceByFilePath, isCache, cacheLocation, allConfigFilePaths, allConfigFilesMap, }: WorkspaceManagerOptions);
52
+ configFilesMap: Map<string, Map<PluginName, Set<string>>>;
53
+ constructor({ name, dir, cwd, config, manifest, dependencies, isProduction, isStrict, rootIgnore, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, getReferencedInternalFilePath, findWorkspaceByFilePath, getSourceFile, isCache, cacheLocation, configFilesMap, }: WorkspaceManagerOptions);
53
54
  init(): Promise<void>;
54
55
  private determineEnabledPlugins;
55
56
  private getConfigForPlugin;
@@ -6,10 +6,10 @@ import { PluginEntries, Plugins } from './plugins.js';
6
6
  import { compact } from './util/array.js';
7
7
  import { debugLogArray, debugLogObject } from './util/debug.js';
8
8
  import { _glob, hasNoProductionSuffix, hasProductionSuffix, negate, prependDirToPattern } from './util/glob.js';
9
- import { isConfig, toConfig, toDebugString, toEntry } from './util/input.js';
9
+ import { isConfig, toConfig, toDebugString, toEntry, toProductionEntry, } from './util/input.js';
10
10
  import { getKeysByValue } from './util/object.js';
11
11
  import { basename, dirname, join } from './util/path.js';
12
- import { getFinalEntryPaths, loadConfigForPlugin } from './util/plugin.js';
12
+ import { loadConfigForPlugin } from './util/plugin.js';
13
13
  const nullConfig = { config: null, entry: null, project: null };
14
14
  const initEnabledPluginsMap = () => Object.keys(Plugins).reduce((enabled, pluginName) => ({ ...enabled, [pluginName]: false }), {});
15
15
  export class WorkspaceWorker {
@@ -21,6 +21,7 @@ export class WorkspaceWorker {
21
21
  dependencies;
22
22
  getReferencedInternalFilePath;
23
23
  findWorkspaceByFilePath;
24
+ getSourceFile;
24
25
  isProduction;
25
26
  isStrict;
26
27
  rootIgnore;
@@ -30,9 +31,8 @@ export class WorkspaceWorker {
30
31
  enabledPlugins = [];
31
32
  enabledPluginsInAncestors;
32
33
  cache;
33
- allConfigFilePaths;
34
- allConfigFilesMap;
35
- constructor({ name, dir, cwd, config, manifest, dependencies, isProduction, isStrict, rootIgnore, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, getReferencedInternalFilePath, findWorkspaceByFilePath, isCache, cacheLocation, allConfigFilePaths, allConfigFilesMap, }) {
34
+ configFilesMap;
35
+ constructor({ name, dir, cwd, config, manifest, dependencies, isProduction, isStrict, rootIgnore, negatedWorkspacePatterns, ignoredWorkspacePatterns, enabledPluginsInAncestors, getReferencedInternalFilePath, findWorkspaceByFilePath, getSourceFile, isCache, cacheLocation, configFilesMap, }) {
36
36
  this.name = name;
37
37
  this.dir = dir;
38
38
  this.cwd = cwd;
@@ -45,10 +45,10 @@ export class WorkspaceWorker {
45
45
  this.negatedWorkspacePatterns = negatedWorkspacePatterns;
46
46
  this.ignoredWorkspacePatterns = ignoredWorkspacePatterns;
47
47
  this.enabledPluginsInAncestors = enabledPluginsInAncestors;
48
- this.allConfigFilePaths = allConfigFilePaths;
49
- this.allConfigFilesMap = allConfigFilesMap;
48
+ this.configFilesMap = configFilesMap;
50
49
  this.getReferencedInternalFilePath = getReferencedInternalFilePath;
51
50
  this.findWorkspaceByFilePath = findWorkspaceByFilePath;
51
+ this.getSourceFile = getSourceFile;
52
52
  this.cache = new CacheConsultant({ name: `plugins-${name}`, isEnabled: isCache, cacheLocation });
53
53
  }
54
54
  async init() {
@@ -162,7 +162,7 @@ export class WorkspaceWorker {
162
162
  return [...this.rootIgnore, ...this.config.ignore.map(pattern => prependDirToPattern(this.name, pattern))];
163
163
  }
164
164
  async runPlugins() {
165
- const name = this.name;
165
+ const wsName = this.name;
166
166
  const cwd = this.dir;
167
167
  const rootCwd = this.cwd;
168
168
  const manifest = this.manifest;
@@ -179,19 +179,27 @@ export class WorkspaceWorker {
179
179
  const createGetInputsFromScripts = (containingFilePath) => (scripts, options) => _getInputsFromScripts(scripts, { ...baseOptions, ...options, containingFilePath });
180
180
  const inputs = [];
181
181
  const remainingPlugins = new Set(this.enabledPlugins);
182
- const addInput = (input, containingFilePath = input.containingFilePath) => inputs.push({ ...input, containingFilePath });
182
+ const addInput = (input, containingFilePath = input.containingFilePath) => {
183
+ if (isConfig(input)) {
184
+ handleConfigInput(input.pluginName, { ...input, containingFilePath });
185
+ }
186
+ else {
187
+ inputs.push({ ...input, containingFilePath });
188
+ }
189
+ };
190
+ const configFilesMap = this.configFilesMap;
191
+ const configFiles = this.configFilesMap.get(wsName);
183
192
  const handleConfigInput = (pluginName, input) => {
184
193
  const configFilePath = this.getReferencedInternalFilePath(input);
185
194
  if (configFilePath) {
186
195
  const workspace = this.findWorkspaceByFilePath(configFilePath);
187
196
  if (workspace) {
188
197
  const name = this.name === ROOT_WORKSPACE_NAME ? workspace.name : this.name;
189
- const files = this.allConfigFilesMap;
190
- if (!files.has(name))
191
- files.set(name, new Map());
192
- if (!files.get(name)?.has(pluginName))
193
- files.get(name)?.set(pluginName, new Set());
194
- files.get(name)?.get(pluginName)?.add(configFilePath);
198
+ if (!configFilesMap.has(name))
199
+ configFilesMap.set(name, new Map());
200
+ if (!configFilesMap.get(name)?.has(pluginName))
201
+ configFilesMap.get(name)?.set(pluginName, new Set());
202
+ configFilesMap.get(name)?.get(pluginName)?.add(configFilePath);
195
203
  }
196
204
  }
197
205
  };
@@ -208,22 +216,11 @@ export class WorkspaceWorker {
208
216
  }
209
217
  const runPlugin = async (pluginName, patterns) => {
210
218
  const plugin = Plugins[pluginName];
211
- const hasResolveEntryPaths = typeof plugin.resolveEntryPaths === 'function';
212
- const hasResolveConfig = typeof plugin.resolveConfig === 'function';
213
- const hasResolve = typeof plugin.resolve === 'function';
214
219
  const config = this.getConfigForPlugin(pluginName);
215
220
  if (!config)
216
221
  return;
217
222
  const label = 'config file';
218
223
  const configFilePaths = await _glob({ patterns, cwd: rootCwd, dir: cwd, gitignore: false, label });
219
- const remainingConfigFilePaths = configFilePaths.filter(filePath => !this.allConfigFilePaths.has(filePath));
220
- for (const filePath of remainingConfigFilePaths) {
221
- if (basename(filePath) !== 'package.json') {
222
- this.allConfigFilePaths.add(filePath);
223
- addInput(toEntry(filePath));
224
- addInput(toConfig(pluginName, filePath));
225
- }
226
- }
227
224
  const options = {
228
225
  ...baseScriptOptions,
229
226
  config,
@@ -232,66 +229,97 @@ export class WorkspaceWorker {
232
229
  configFileName: '',
233
230
  getInputsFromScripts: createGetInputsFromScripts(containingFilePath),
234
231
  };
235
- const configEntryPaths = [];
236
- for (const configFilePath of remainingConfigFilePaths) {
237
- const opts = {
232
+ if (config.entry) {
233
+ const toInput = isProduction && plugin.production && plugin.production.length > 0 ? toProductionEntry : toEntry;
234
+ for (const id of config.entry)
235
+ addInput(toInput(id));
236
+ }
237
+ else if ((!plugin.resolveEntryPaths && !plugin.resolveFromAST) ||
238
+ (configFilePaths.length === 0 &&
239
+ (!this.configFilesMap.get(wsName)?.get(pluginName) ||
240
+ this.configFilesMap.get(wsName)?.get(pluginName)?.size === 0))) {
241
+ if (plugin.entry)
242
+ for (const id of plugin.entry)
243
+ addInput(toEntry(id));
244
+ if (plugin.production)
245
+ for (const id of plugin.production)
246
+ addInput(toProductionEntry(id));
247
+ }
248
+ for (const configFilePath of configFilePaths) {
249
+ const isManifest = basename(configFilePath) === 'package.json';
250
+ const fd = isManifest ? undefined : this.cache.getFileDescriptor(configFilePath);
251
+ if (fd?.meta?.data && !fd.changed) {
252
+ const data = fd.meta.data;
253
+ if (data.resolveEntryPaths)
254
+ for (const id of data.resolveEntryPaths)
255
+ addInput(id, configFilePath);
256
+ if (data.resolveConfig)
257
+ for (const id of data.resolveConfig)
258
+ addInput(id, configFilePath);
259
+ if (data.resolveFromAST)
260
+ for (const id of data.resolveFromAST)
261
+ addInput(id, configFilePath);
262
+ continue;
263
+ }
264
+ const resolveOpts = {
238
265
  ...options,
239
266
  getInputsFromScripts: createGetInputsFromScripts(configFilePath),
240
267
  configFilePath,
241
268
  configFileDir: dirname(configFilePath),
242
269
  configFileName: basename(configFilePath),
243
270
  };
244
- if (hasResolveEntryPaths || hasResolveConfig) {
245
- const isManifest = basename(configFilePath) === 'package.json';
246
- const fd = isManifest ? undefined : this.cache.getFileDescriptor(configFilePath);
247
- if (fd?.meta?.data && !fd.changed) {
248
- if (fd.meta.data.resolveEntryPaths)
249
- for (const id of fd.meta.data.resolveEntryPaths)
250
- configEntryPaths.push(id);
251
- if (fd.meta.data.resolveConfig)
252
- for (const id of fd.meta.data.resolveConfig)
253
- addInput(id, configFilePath);
271
+ const seen = this.configFilesMap.get(wsName)?.get(pluginName)?.has(configFilePath);
272
+ const cache = {};
273
+ let loadedConfig;
274
+ if (plugin.resolveEntryPaths && !seen) {
275
+ if (!loadedConfig)
276
+ loadedConfig = await loadConfigForPlugin(configFilePath, plugin, resolveOpts, pluginName);
277
+ if (loadedConfig) {
278
+ const inputs = await plugin.resolveEntryPaths(loadedConfig, resolveOpts);
279
+ for (const input of inputs)
280
+ addInput(input, configFilePath);
281
+ cache.resolveEntryPaths = inputs;
254
282
  }
255
- else {
256
- const config = await loadConfigForPlugin(configFilePath, plugin, opts, pluginName);
257
- const data = {};
258
- if (config) {
259
- if (hasResolveEntryPaths) {
260
- const entryPaths = (await plugin.resolveEntryPaths?.(config, opts)) ?? [];
261
- for (const entryPath of entryPaths)
262
- configEntryPaths.push(entryPath);
263
- data.resolveEntryPaths = entryPaths;
264
- }
265
- if (hasResolveConfig) {
266
- const inputs = (await plugin.resolveConfig?.(config, opts)) ?? [];
267
- for (const input of inputs) {
268
- if (isConfig(input)) {
269
- handleConfigInput(input.pluginName, { ...input, containingFilePath: configFilePath });
270
- }
271
- else {
272
- addInput(input, configFilePath);
273
- }
274
- }
275
- data.resolveConfig = inputs;
276
- }
277
- if (!isManifest && fd?.changed && fd.meta)
278
- fd.meta.data = data;
279
- }
283
+ }
284
+ if (plugin.resolveConfig && !seen) {
285
+ if (!loadedConfig)
286
+ loadedConfig = await loadConfigForPlugin(configFilePath, plugin, resolveOpts, pluginName);
287
+ if (loadedConfig) {
288
+ const inputs = await plugin.resolveConfig(loadedConfig, resolveOpts);
289
+ for (const input of inputs)
290
+ addInput(input, configFilePath);
291
+ cache.resolveConfig = inputs;
280
292
  }
281
293
  }
294
+ if (plugin.resolveFromAST) {
295
+ const sourceFile = this.getSourceFile(configFilePath);
296
+ const resolveASTOpts = {
297
+ ...resolveOpts,
298
+ getSourceFile: this.getSourceFile,
299
+ getReferencedInternalFilePath: this.getReferencedInternalFilePath,
300
+ };
301
+ if (sourceFile) {
302
+ const inputs = plugin.resolveFromAST(sourceFile, resolveASTOpts);
303
+ for (const input of inputs)
304
+ addInput(input, configFilePath);
305
+ cache.resolveFromAST = inputs;
306
+ }
307
+ }
308
+ if (basename(configFilePath) !== 'package.json') {
309
+ addInput(toEntry(configFilePath));
310
+ addInput(toConfig(pluginName, configFilePath));
311
+ }
312
+ if (!isManifest && fd?.changed && fd.meta)
313
+ fd.meta.data = cache;
282
314
  }
283
- const finalEntryPaths = getFinalEntryPaths(plugin, options, configEntryPaths);
284
- for (const id of finalEntryPaths)
285
- addInput(id, id.containingFilePath);
286
- if (hasResolve) {
287
- const dependencies = (await plugin.resolve?.(options)) ?? [];
315
+ if (plugin.resolve) {
316
+ const dependencies = (await plugin.resolve(options)) ?? [];
288
317
  for (const id of dependencies)
289
318
  addInput(id, containingFilePath);
290
319
  }
291
320
  };
292
321
  const enabledPluginTitles = this.enabledPlugins.map(name => Plugins[name].title);
293
322
  debugLogObject(this.name, 'Enabled plugins', enabledPluginTitles);
294
- const configFiles = this.allConfigFilesMap.get(name);
295
323
  for (const pluginName of this.enabledPlugins) {
296
324
  const patterns = [...this.getConfigurationFilePatterns(pluginName), ...(configFiles?.get(pluginName) ?? [])];
297
325
  configFiles?.delete(pluginName);
@@ -299,7 +327,7 @@ export class WorkspaceWorker {
299
327
  remainingPlugins.delete(pluginName);
300
328
  }
301
329
  {
302
- const configFiles = this.allConfigFilesMap.get(name);
330
+ const configFiles = this.configFilesMap.get(wsName);
303
331
  if (configFiles) {
304
332
  do {
305
333
  for (const [pluginName, dependencies] of configFiles.entries()) {
@@ -313,7 +341,7 @@ export class WorkspaceWorker {
313
341
  } while (remainingPlugins.size > 0 && configFiles.size > 0);
314
342
  }
315
343
  }
316
- debugLogArray(name, 'Plugin dependencies', () => compact(inputs.map(toDebugString)));
344
+ debugLogArray(wsName, 'Plugin dependencies', () => compact(inputs.map(toDebugString)));
317
345
  return inputs;
318
346
  }
319
347
  onDispose() {
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@ import prettyMilliseconds from 'pretty-ms';
2
2
  import { main } from './index.js';
3
3
  import { perfObserver } from './util/Performance.js';
4
4
  import parsedArgValues, { helpText } from './util/cli-arguments.js';
5
- import { getKnownError, hasCause, isConfigurationError, isKnownError } from './util/errors.js';
5
+ import { getKnownError, isConfigurationError, isDisplayReason, isKnownError } from './util/errors.js';
6
6
  import { logError, logWarning } from './util/log.js';
7
7
  import { cwd, join, toPosix } from './util/path.js';
8
8
  import { runPreprocessors, runReporters } from './util/reporter.js';
@@ -94,7 +94,7 @@ const run = async () => {
94
94
  if (!isDebug && error instanceof Error && isKnownError(error)) {
95
95
  const knownError = getKnownError(error);
96
96
  logError('ERROR', knownError.message);
97
- if (hasCause(knownError))
97
+ if (isDisplayReason(knownError))
98
98
  console.error('Reason:', knownError.cause.message);
99
99
  if (isConfigurationError(knownError))
100
100
  console.log('\nRun `knip --help` or visit https://knip.dev for help');
@@ -339,6 +339,16 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
339
339
  entry?: string | string[] | undefined;
340
340
  project?: string | string[] | undefined;
341
341
  } | undefined;
342
+ sst?: string | boolean | string[] | {
343
+ config?: string | string[] | undefined;
344
+ entry?: string | string[] | undefined;
345
+ project?: string | string[] | undefined;
346
+ } | undefined;
347
+ starlight?: string | boolean | string[] | {
348
+ config?: string | string[] | undefined;
349
+ entry?: string | string[] | undefined;
350
+ project?: string | string[] | undefined;
351
+ } | undefined;
342
352
  storybook?: string | boolean | string[] | {
343
353
  config?: string | string[] | undefined;
344
354
  entry?: string | string[] | undefined;
@@ -369,6 +379,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
369
379
  entry?: string | string[] | undefined;
370
380
  project?: string | string[] | undefined;
371
381
  } | undefined;
382
+ 'tanstack-router'?: string | boolean | string[] | {
383
+ config?: string | string[] | undefined;
384
+ entry?: string | string[] | undefined;
385
+ project?: string | string[] | undefined;
386
+ } | undefined;
372
387
  travis?: string | boolean | string[] | {
373
388
  config?: string | string[] | undefined;
374
389
  entry?: string | string[] | undefined;
@@ -469,6 +484,7 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
469
484
  entry?: string | string[] | undefined;
470
485
  project?: string | string[] | undefined;
471
486
  } | undefined;
487
+ $schema?: string | undefined;
472
488
  rules?: Partial<Record<"dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
473
489
  paths?: Record<string, string[]> | undefined;
474
490
  ignore?: string | string[] | undefined;
@@ -813,6 +829,16 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
813
829
  entry?: string | string[] | undefined;
814
830
  project?: string | string[] | undefined;
815
831
  } | undefined;
832
+ sst?: string | boolean | string[] | {
833
+ config?: string | string[] | undefined;
834
+ entry?: string | string[] | undefined;
835
+ project?: string | string[] | undefined;
836
+ } | undefined;
837
+ starlight?: string | boolean | string[] | {
838
+ config?: string | string[] | undefined;
839
+ entry?: string | string[] | undefined;
840
+ project?: string | string[] | undefined;
841
+ } | undefined;
816
842
  storybook?: string | boolean | string[] | {
817
843
  config?: string | string[] | undefined;
818
844
  entry?: string | string[] | undefined;
@@ -843,6 +869,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
843
869
  entry?: string | string[] | undefined;
844
870
  project?: string | string[] | undefined;
845
871
  } | undefined;
872
+ 'tanstack-router'?: string | boolean | string[] | {
873
+ config?: string | string[] | undefined;
874
+ entry?: string | string[] | undefined;
875
+ project?: string | string[] | undefined;
876
+ } | undefined;
846
877
  travis?: string | boolean | string[] | {
847
878
  config?: string | string[] | undefined;
848
879
  entry?: string | string[] | undefined;
@@ -39,8 +39,6 @@ export const analyze = async (options) => {
39
39
  }
40
40
  const importsForExport = file.imported;
41
41
  for (const [identifier, exportedItem] of exportItems.entries()) {
42
- if (!isFix && exportedItem.isReExport)
43
- continue;
44
42
  if (shouldIgnore(exportedItem.jsDocTags))
45
43
  continue;
46
44
  const isIgnored = shouldIgnoreTags(exportedItem.jsDocTags);