knip 5.47.0 → 5.48.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 +3 -0
- package/dist/ProjectPrincipal.d.ts +2 -2
- package/dist/ProjectPrincipal.js +9 -7
- package/dist/WorkspaceWorker.d.ts +9 -8
- package/dist/WorkspaceWorker.js +100 -72
- package/dist/cli.js +2 -2
- package/dist/compilers/index.d.ts +31 -0
- package/dist/graph/analyze.js +0 -2
- package/dist/graph/build.js +7 -8
- package/dist/plugins/astro/index.d.ts +1 -0
- package/dist/plugins/astro/index.js +3 -1
- package/dist/plugins/ava/index.js +1 -1
- package/dist/plugins/index.d.ts +27 -2
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/jest/index.js +3 -1
- package/dist/plugins/next/index.d.ts +3 -2
- package/dist/plugins/next/index.js +19 -8
- package/dist/plugins/next/resolveFromAST.d.ts +2 -0
- package/dist/plugins/next/resolveFromAST.js +15 -0
- package/dist/plugins/nodemon/index.js +1 -1
- package/dist/plugins/nuxt/index.d.ts +1 -1
- package/dist/plugins/nuxt/index.js +2 -2
- package/dist/plugins/playwright/index.js +1 -3
- package/dist/plugins/react-router/index.js +3 -1
- package/dist/plugins/sst/index.d.ts +9 -0
- package/dist/plugins/sst/index.js +17 -0
- package/dist/plugins/sst/resolveFromAST.d.ts +2 -0
- package/dist/plugins/sst/resolveFromAST.js +47 -0
- package/dist/plugins/starlight/index.d.ts +9 -0
- package/dist/plugins/starlight/index.js +18 -0
- package/dist/plugins/starlight/resolveFromAST.d.ts +2 -0
- package/dist/plugins/starlight/resolveFromAST.js +20 -0
- package/dist/plugins/storybook/index.js +4 -1
- package/dist/plugins/tanstack-router/index.d.ts +12 -0
- package/dist/plugins/tanstack-router/index.js +46 -0
- package/dist/plugins/tanstack-router/resolveFromAST.d.ts +2 -0
- package/dist/plugins/tanstack-router/resolveFromAST.js +28 -0
- package/dist/plugins/tanstack-router/types.d.ts +7 -0
- package/dist/plugins/tanstack-router/types.js +1 -0
- package/dist/reporters/codeowners.js +8 -6
- package/dist/reporters/json.js +3 -3
- package/dist/schema/configuration.d.ts +172 -1
- package/dist/schema/configuration.js +3 -1
- package/dist/schema/plugins.d.ts +69 -0
- package/dist/schema/plugins.js +3 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +3 -0
- package/dist/types/config.d.ts +8 -0
- package/dist/typescript/ast-helpers.d.ts +4 -0
- package/dist/typescript/ast-helpers.js +62 -0
- package/dist/typescript/create-hosts.d.ts +3 -2
- package/dist/typescript/create-hosts.js +1 -3
- package/dist/util/Performance.js +7 -7
- package/dist/util/codeowners.d.ts +2 -0
- package/dist/util/codeowners.js +32 -0
- package/dist/util/errors.d.ts +1 -1
- package/dist/util/errors.js +2 -2
- package/dist/util/math.d.ts +6 -0
- package/dist/util/math.js +11 -0
- package/dist/util/plugin.d.ts +0 -2
- package/dist/util/plugin.js +1 -14
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -5
- 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
|
|
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
|
|
26
|
+
compilerHost?: ts.CompilerHost;
|
|
27
27
|
resolveModuleNames: ResolveModuleNames;
|
|
28
28
|
program?: ts.Program;
|
|
29
29
|
typeChecker?: ts.TypeChecker;
|
package/dist/ProjectPrincipal.js
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
74
|
-
|
|
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:
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
51
|
-
|
|
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;
|
package/dist/WorkspaceWorker.js
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
34
|
-
|
|
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.
|
|
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
|
|
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) =>
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
const
|
|
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
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
284
|
-
|
|
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.
|
|
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(
|
|
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,
|
|
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 (
|
|
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;
|
package/dist/graph/analyze.js
CHANGED
|
@@ -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);
|
package/dist/graph/build.js
CHANGED
|
@@ -12,8 +12,7 @@ import {} from '../util/tag.js';
|
|
|
12
12
|
import { augmentWorkspace, getToSourcePathHandler } from '../util/to-source-path.js';
|
|
13
13
|
import { loadTSConfig } from '../util/tsconfig-loader.js';
|
|
14
14
|
export async function build({ cacheLocation, chief, collector, cwd, deputy, factory, gitignore, isCache, isFixExports, isFixTypes, isGitIgnored, isIsolateWorkspaces, isProduction, isSkipLibs, isStrict, isWatch, report, streamer, tags, tsConfigFile, workspaces, }) {
|
|
15
|
-
const
|
|
16
|
-
const allConfigFilesMap = new Map();
|
|
15
|
+
const configFilesMap = new Map();
|
|
17
16
|
const enabledPluginsStore = new Map();
|
|
18
17
|
const toSourceFilePath = getToSourcePathHandler(chief);
|
|
19
18
|
const getReferencedInternalFilePath = getReferencedInputsHandler(collector, deputy, chief, isGitIgnored);
|
|
@@ -55,10 +54,10 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
55
54
|
negatedWorkspacePatterns: chief.getNegatedWorkspacePatterns(name),
|
|
56
55
|
ignoredWorkspacePatterns: chief.getIgnoredWorkspacesFor(name),
|
|
57
56
|
enabledPluginsInAncestors: ancestors.flatMap(ancestor => enabledPluginsStore.get(ancestor) ?? []),
|
|
57
|
+
getSourceFile: (filePath) => principal.backend.fileManager.getSourceFile(filePath),
|
|
58
58
|
isCache,
|
|
59
59
|
cacheLocation,
|
|
60
|
-
|
|
61
|
-
allConfigFilesMap,
|
|
60
|
+
configFilesMap,
|
|
62
61
|
});
|
|
63
62
|
await worker.init();
|
|
64
63
|
const inputs = new Set();
|
|
@@ -73,10 +72,6 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
73
72
|
const entryPathsFromManifest = await getEntryPathsFromManifest(manifest, { ...sharedGlobOptions, ignore });
|
|
74
73
|
for (const id of entryPathsFromManifest.map(id => toProductionEntry(id)))
|
|
75
74
|
inputs.add(id);
|
|
76
|
-
const inputsFromPlugins = await worker.runPlugins();
|
|
77
|
-
for (const id of inputsFromPlugins)
|
|
78
|
-
inputs.add(id);
|
|
79
|
-
enabledPluginsStore.set(name, worker.enabledPlugins);
|
|
80
75
|
const principal = factory.createPrincipal({
|
|
81
76
|
cwd: dir,
|
|
82
77
|
paths: config.paths,
|
|
@@ -91,6 +86,10 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
91
86
|
isCache,
|
|
92
87
|
cacheLocation,
|
|
93
88
|
});
|
|
89
|
+
const inputsFromPlugins = await worker.runPlugins();
|
|
90
|
+
for (const id of inputsFromPlugins)
|
|
91
|
+
inputs.add(id);
|
|
92
|
+
enabledPluginsStore.set(name, worker.enabledPlugins);
|
|
94
93
|
const entryFilePatterns = new Set();
|
|
95
94
|
const productionEntryFilePatterns = new Set();
|
|
96
95
|
const projectFilePatterns = new Set();
|
|
@@ -3,7 +3,8 @@ import { hasDependency } from '../../util/plugin.js';
|
|
|
3
3
|
const title = 'Astro';
|
|
4
4
|
const enablers = ['astro'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
-
const
|
|
6
|
+
const config = ['astro.config.{js,cjs,mjs,ts}'];
|
|
7
|
+
const entry = ['src/content/config.ts', 'src/content.config.ts'];
|
|
7
8
|
const production = [
|
|
8
9
|
'src/pages/**/*.{astro,mdx,js,ts}',
|
|
9
10
|
'src/content/**/*.mdx',
|
|
@@ -24,6 +25,7 @@ export default {
|
|
|
24
25
|
title,
|
|
25
26
|
enablers,
|
|
26
27
|
isEnabled,
|
|
28
|
+
config,
|
|
27
29
|
entry,
|
|
28
30
|
production,
|
|
29
31
|
resolve,
|
|
@@ -19,7 +19,7 @@ const entry = [
|
|
|
19
19
|
const resolveEntryPaths = localConfig => {
|
|
20
20
|
if (typeof localConfig === 'function')
|
|
21
21
|
localConfig = localConfig();
|
|
22
|
-
return (localConfig?.files ??
|
|
22
|
+
return (localConfig?.files ?? entry).map(toEntry);
|
|
23
23
|
};
|
|
24
24
|
const resolveConfig = async (localConfig, options) => {
|
|
25
25
|
if (typeof localConfig === 'function')
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare const Plugins: {
|
|
|
10
10
|
title: string;
|
|
11
11
|
enablers: string[];
|
|
12
12
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
13
|
+
config: string[];
|
|
13
14
|
entry: string[];
|
|
14
15
|
production: string[];
|
|
15
16
|
resolve: import("../types/config.js").Resolve;
|
|
@@ -322,8 +323,9 @@ export declare const Plugins: {
|
|
|
322
323
|
title: string;
|
|
323
324
|
enablers: string[];
|
|
324
325
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
325
|
-
|
|
326
|
+
config: string[];
|
|
326
327
|
production: string[];
|
|
328
|
+
resolveFromAST: import("../types/config.js").ResolveFromAST;
|
|
327
329
|
};
|
|
328
330
|
node: {
|
|
329
331
|
title: string;
|
|
@@ -359,7 +361,7 @@ export declare const Plugins: {
|
|
|
359
361
|
title: string;
|
|
360
362
|
enablers: string[];
|
|
361
363
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
362
|
-
|
|
364
|
+
config: string[];
|
|
363
365
|
production: string[];
|
|
364
366
|
resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("./nuxt/types.js").NuxtConfig>;
|
|
365
367
|
};
|
|
@@ -536,6 +538,20 @@ export declare const Plugins: {
|
|
|
536
538
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
537
539
|
config: string[];
|
|
538
540
|
};
|
|
541
|
+
sst: {
|
|
542
|
+
title: string;
|
|
543
|
+
enablers: string[];
|
|
544
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
545
|
+
config: string[];
|
|
546
|
+
resolveFromAST: import("../types/config.js").ResolveFromAST;
|
|
547
|
+
};
|
|
548
|
+
starlight: {
|
|
549
|
+
title: string;
|
|
550
|
+
enablers: string[];
|
|
551
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
552
|
+
config: string[];
|
|
553
|
+
resolveFromAST: import("../types/config.js").ResolveFromAST;
|
|
554
|
+
};
|
|
539
555
|
storybook: {
|
|
540
556
|
title: string;
|
|
541
557
|
enablers: (string | RegExp)[];
|
|
@@ -579,6 +595,15 @@ export declare const Plugins: {
|
|
|
579
595
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
580
596
|
entry: string[];
|
|
581
597
|
};
|
|
598
|
+
'tanstack-router': {
|
|
599
|
+
title: string;
|
|
600
|
+
enablers: string[];
|
|
601
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
602
|
+
config: string[];
|
|
603
|
+
production: string[];
|
|
604
|
+
resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("./tanstack-router/types.js").TanstackRouterConfig>;
|
|
605
|
+
resolveFromAST: import("../types/config.js").ResolveFromAST;
|
|
606
|
+
};
|
|
582
607
|
travis: {
|
|
583
608
|
title: string;
|
|
584
609
|
enablers: string;
|