knip 5.46.5 → 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 +4 -0
- package/dist/ProjectPrincipal.d.ts +2 -2
- package/dist/ProjectPrincipal.js +9 -7
- package/dist/WorkspaceWorker.d.ts +10 -9
- package/dist/WorkspaceWorker.js +101 -74
- package/dist/binaries/package-manager/pnpm.js +1 -0
- package/dist/cli.js +2 -2
- package/dist/compilers/index.d.ts +41 -0
- package/dist/graph/analyze.js +0 -2
- package/dist/graph/build.js +13 -10
- 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/github-action/index.d.ts +9 -0
- package/dist/plugins/github-action/index.js +28 -0
- package/dist/plugins/github-actions/index.d.ts +2 -1
- package/dist/plugins/github-actions/index.js +1 -1
- package/dist/plugins/husky/index.js +1 -1
- package/dist/plugins/index.d.ts +34 -2
- package/dist/plugins/index.js +8 -0
- package/dist/plugins/jest/index.js +3 -1
- package/dist/plugins/karma/helpers.js +4 -4
- package/dist/plugins/lint-staged/index.js +2 -0
- 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/plugins/vitest/index.js +12 -1
- package/dist/plugins/vitest/types.d.ts +5 -0
- package/dist/plugins/vue/index.js +2 -2
- package/dist/plugins/webpack/index.js +2 -2
- package/dist/reporters/codeowners.js +8 -6
- package/dist/reporters/json.js +3 -3
- package/dist/schema/configuration.d.ts +228 -1
- package/dist/schema/configuration.js +3 -1
- package/dist/schema/plugins.d.ts +92 -0
- package/dist/schema/plugins.js +4 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +4 -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/input.d.ts +3 -2
- package/dist/util/input.js +2 -1
- 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 +4 -6
- package/schema.json +16 -0
|
@@ -92,6 +92,7 @@ export declare class ConfigurationChief {
|
|
|
92
92
|
eslint?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
93
93
|
expo?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
94
94
|
gatsby?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
95
|
+
"github-action"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
95
96
|
"github-actions"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
96
97
|
glob?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
97
98
|
"graphql-codegen"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
@@ -137,12 +138,15 @@ export declare class ConfigurationChief {
|
|
|
137
138
|
sentry?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
138
139
|
"simple-git-hooks"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
139
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;
|
|
140
143
|
storybook?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
141
144
|
stryker?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
142
145
|
stylelint?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
143
146
|
svelte?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
144
147
|
syncpack?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
145
148
|
tailwind?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
149
|
+
"tanstack-router"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
146
150
|
travis?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
147
151
|
"ts-node"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
|
|
148
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,15 +49,14 @@ 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;
|
|
56
57
|
getEntryFilePatterns(): string[];
|
|
57
58
|
getProjectFilePatterns(projectFilePatterns: string[]): string[];
|
|
58
|
-
getPluginProjectFilePatterns(): string[];
|
|
59
|
+
getPluginProjectFilePatterns(patterns?: string[]): string[];
|
|
59
60
|
getPluginConfigPatterns(): string[];
|
|
60
61
|
getPluginEntryFilePatterns(patterns: string[]): string[];
|
|
61
62
|
getProductionEntryFilePatterns(negatedTestFilePatterns: string[]): string[];
|
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() {
|
|
@@ -100,8 +100,7 @@ export class WorkspaceWorker {
|
|
|
100
100
|
this.negatedWorkspacePatterns,
|
|
101
101
|
].flat();
|
|
102
102
|
}
|
|
103
|
-
getPluginProjectFilePatterns() {
|
|
104
|
-
const patterns = [];
|
|
103
|
+
getPluginProjectFilePatterns(patterns = []) {
|
|
105
104
|
for (const [pluginName, plugin] of PluginEntries) {
|
|
106
105
|
const pluginConfig = this.getConfigForPlugin(pluginName);
|
|
107
106
|
if (this.enabledPluginsMap[pluginName]) {
|
|
@@ -163,7 +162,7 @@ export class WorkspaceWorker {
|
|
|
163
162
|
return [...this.rootIgnore, ...this.config.ignore.map(pattern => prependDirToPattern(this.name, pattern))];
|
|
164
163
|
}
|
|
165
164
|
async runPlugins() {
|
|
166
|
-
const
|
|
165
|
+
const wsName = this.name;
|
|
167
166
|
const cwd = this.dir;
|
|
168
167
|
const rootCwd = this.cwd;
|
|
169
168
|
const manifest = this.manifest;
|
|
@@ -180,19 +179,27 @@ export class WorkspaceWorker {
|
|
|
180
179
|
const createGetInputsFromScripts = (containingFilePath) => (scripts, options) => _getInputsFromScripts(scripts, { ...baseOptions, ...options, containingFilePath });
|
|
181
180
|
const inputs = [];
|
|
182
181
|
const remainingPlugins = new Set(this.enabledPlugins);
|
|
183
|
-
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);
|
|
184
192
|
const handleConfigInput = (pluginName, input) => {
|
|
185
193
|
const configFilePath = this.getReferencedInternalFilePath(input);
|
|
186
194
|
if (configFilePath) {
|
|
187
195
|
const workspace = this.findWorkspaceByFilePath(configFilePath);
|
|
188
196
|
if (workspace) {
|
|
189
197
|
const name = this.name === ROOT_WORKSPACE_NAME ? workspace.name : this.name;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
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);
|
|
196
203
|
}
|
|
197
204
|
}
|
|
198
205
|
};
|
|
@@ -209,22 +216,11 @@ export class WorkspaceWorker {
|
|
|
209
216
|
}
|
|
210
217
|
const runPlugin = async (pluginName, patterns) => {
|
|
211
218
|
const plugin = Plugins[pluginName];
|
|
212
|
-
const hasResolveEntryPaths = typeof plugin.resolveEntryPaths === 'function';
|
|
213
|
-
const hasResolveConfig = typeof plugin.resolveConfig === 'function';
|
|
214
|
-
const hasResolve = typeof plugin.resolve === 'function';
|
|
215
219
|
const config = this.getConfigForPlugin(pluginName);
|
|
216
220
|
if (!config)
|
|
217
221
|
return;
|
|
218
222
|
const label = 'config file';
|
|
219
223
|
const configFilePaths = await _glob({ patterns, cwd: rootCwd, dir: cwd, gitignore: false, label });
|
|
220
|
-
const remainingConfigFilePaths = configFilePaths.filter(filePath => !this.allConfigFilePaths.has(filePath));
|
|
221
|
-
for (const filePath of remainingConfigFilePaths) {
|
|
222
|
-
if (basename(filePath) !== 'package.json') {
|
|
223
|
-
this.allConfigFilePaths.add(filePath);
|
|
224
|
-
addInput(toEntry(filePath));
|
|
225
|
-
addInput(toConfig(pluginName, filePath));
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
224
|
const options = {
|
|
229
225
|
...baseScriptOptions,
|
|
230
226
|
config,
|
|
@@ -233,66 +229,97 @@ export class WorkspaceWorker {
|
|
|
233
229
|
configFileName: '',
|
|
234
230
|
getInputsFromScripts: createGetInputsFromScripts(containingFilePath),
|
|
235
231
|
};
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
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 = {
|
|
239
265
|
...options,
|
|
240
266
|
getInputsFromScripts: createGetInputsFromScripts(configFilePath),
|
|
241
267
|
configFilePath,
|
|
242
268
|
configFileDir: dirname(configFilePath),
|
|
243
269
|
configFileName: basename(configFilePath),
|
|
244
270
|
};
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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;
|
|
255
282
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
fd.meta.data = data;
|
|
280
|
-
}
|
|
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;
|
|
292
|
+
}
|
|
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;
|
|
281
306
|
}
|
|
282
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;
|
|
283
314
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
addInput(id, id.containingFilePath);
|
|
287
|
-
if (hasResolve) {
|
|
288
|
-
const dependencies = (await plugin.resolve?.(options)) ?? [];
|
|
315
|
+
if (plugin.resolve) {
|
|
316
|
+
const dependencies = (await plugin.resolve(options)) ?? [];
|
|
289
317
|
for (const id of dependencies)
|
|
290
318
|
addInput(id, containingFilePath);
|
|
291
319
|
}
|
|
292
320
|
};
|
|
293
321
|
const enabledPluginTitles = this.enabledPlugins.map(name => Plugins[name].title);
|
|
294
322
|
debugLogObject(this.name, 'Enabled plugins', enabledPluginTitles);
|
|
295
|
-
const configFiles = this.allConfigFilesMap.get(name);
|
|
296
323
|
for (const pluginName of this.enabledPlugins) {
|
|
297
324
|
const patterns = [...this.getConfigurationFilePatterns(pluginName), ...(configFiles?.get(pluginName) ?? [])];
|
|
298
325
|
configFiles?.delete(pluginName);
|
|
@@ -300,7 +327,7 @@ export class WorkspaceWorker {
|
|
|
300
327
|
remainingPlugins.delete(pluginName);
|
|
301
328
|
}
|
|
302
329
|
{
|
|
303
|
-
const configFiles = this.
|
|
330
|
+
const configFiles = this.configFilesMap.get(wsName);
|
|
304
331
|
if (configFiles) {
|
|
305
332
|
do {
|
|
306
333
|
for (const [pluginName, dependencies] of configFiles.entries()) {
|
|
@@ -314,7 +341,7 @@ export class WorkspaceWorker {
|
|
|
314
341
|
} while (remainingPlugins.size > 0 && configFiles.size > 0);
|
|
315
342
|
}
|
|
316
343
|
}
|
|
317
|
-
debugLogArray(
|
|
344
|
+
debugLogArray(wsName, 'Plugin dependencies', () => compact(inputs.map(toDebugString)));
|
|
318
345
|
return inputs;
|
|
319
346
|
}
|
|
320
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');
|
|
@@ -109,6 +109,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
109
109
|
entry?: string | string[] | undefined;
|
|
110
110
|
project?: string | string[] | undefined;
|
|
111
111
|
} | undefined;
|
|
112
|
+
'github-action'?: string | boolean | string[] | {
|
|
113
|
+
config?: string | string[] | undefined;
|
|
114
|
+
entry?: string | string[] | undefined;
|
|
115
|
+
project?: string | string[] | undefined;
|
|
116
|
+
} | undefined;
|
|
112
117
|
'github-actions'?: string | boolean | string[] | {
|
|
113
118
|
config?: string | string[] | undefined;
|
|
114
119
|
entry?: string | string[] | undefined;
|
|
@@ -334,6 +339,16 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
334
339
|
entry?: string | string[] | undefined;
|
|
335
340
|
project?: string | string[] | undefined;
|
|
336
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;
|
|
337
352
|
storybook?: string | boolean | string[] | {
|
|
338
353
|
config?: string | string[] | undefined;
|
|
339
354
|
entry?: string | string[] | undefined;
|
|
@@ -364,6 +379,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
364
379
|
entry?: string | string[] | undefined;
|
|
365
380
|
project?: string | string[] | undefined;
|
|
366
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;
|
|
367
387
|
travis?: string | boolean | string[] | {
|
|
368
388
|
config?: string | string[] | undefined;
|
|
369
389
|
entry?: string | string[] | undefined;
|
|
@@ -464,6 +484,7 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
464
484
|
entry?: string | string[] | undefined;
|
|
465
485
|
project?: string | string[] | undefined;
|
|
466
486
|
} | undefined;
|
|
487
|
+
$schema?: string | undefined;
|
|
467
488
|
rules?: Partial<Record<"dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
|
|
468
489
|
paths?: Record<string, string[]> | undefined;
|
|
469
490
|
ignore?: string | string[] | undefined;
|
|
@@ -578,6 +599,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
578
599
|
entry?: string | string[] | undefined;
|
|
579
600
|
project?: string | string[] | undefined;
|
|
580
601
|
} | undefined;
|
|
602
|
+
'github-action'?: string | boolean | string[] | {
|
|
603
|
+
config?: string | string[] | undefined;
|
|
604
|
+
entry?: string | string[] | undefined;
|
|
605
|
+
project?: string | string[] | undefined;
|
|
606
|
+
} | undefined;
|
|
581
607
|
'github-actions'?: string | boolean | string[] | {
|
|
582
608
|
config?: string | string[] | undefined;
|
|
583
609
|
entry?: string | string[] | undefined;
|
|
@@ -803,6 +829,16 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
803
829
|
entry?: string | string[] | undefined;
|
|
804
830
|
project?: string | string[] | undefined;
|
|
805
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;
|
|
806
842
|
storybook?: string | boolean | string[] | {
|
|
807
843
|
config?: string | string[] | undefined;
|
|
808
844
|
entry?: string | string[] | undefined;
|
|
@@ -833,6 +869,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
|
|
|
833
869
|
entry?: string | string[] | undefined;
|
|
834
870
|
project?: string | string[] | undefined;
|
|
835
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;
|
|
836
877
|
travis?: string | boolean | string[] | {
|
|
837
878
|
config?: string | string[] | undefined;
|
|
838
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
|
@@ -4,7 +4,7 @@ import { getCompilerExtensions, getIncludedCompilers } from '../compilers/index.
|
|
|
4
4
|
import { debugLog, debugLogArray } from '../util/debug.js';
|
|
5
5
|
import { getReferencedInputsHandler } from '../util/get-referenced-inputs.js';
|
|
6
6
|
import { _glob, negate } from '../util/glob.js';
|
|
7
|
-
import { isConfig, isDeferResolveEntry, isDeferResolveProductionEntry, isEntry, isProductionEntry, toProductionEntry, } from '../util/input.js';
|
|
7
|
+
import { isConfig, isDeferResolveEntry, isDeferResolveProductionEntry, isEntry, isProductionEntry, isProject, toProductionEntry, } from '../util/input.js';
|
|
8
8
|
import { getOrCreateFileNode, updateImportMap } from '../util/module-graph.js';
|
|
9
9
|
import { getEntryPathsFromManifest } from '../util/package-json.js';
|
|
10
10
|
import { dirname, isAbsolute, join, relative } from '../util/path.js';
|
|
@@ -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,8 +86,13 @@ 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();
|
|
95
|
+
const projectFilePatterns = new Set();
|
|
96
96
|
for (const input of inputs) {
|
|
97
97
|
const specifier = input.specifier;
|
|
98
98
|
if (isEntry(input)) {
|
|
@@ -101,6 +101,9 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
101
101
|
else if (isProductionEntry(input)) {
|
|
102
102
|
productionEntryFilePatterns.add(isAbsolute(specifier) ? relative(dir, specifier) : specifier);
|
|
103
103
|
}
|
|
104
|
+
else if (isProject(input)) {
|
|
105
|
+
projectFilePatterns.add(isAbsolute(specifier) ? relative(dir, specifier) : specifier);
|
|
106
|
+
}
|
|
104
107
|
else if (!isConfig(input)) {
|
|
105
108
|
const ws = (input.containingFilePath && chief.findWorkspaceByFilePath(input.containingFilePath)) || workspace;
|
|
106
109
|
const resolvedFilePath = getReferencedInternalFilePath(input, ws);
|
|
@@ -149,7 +152,7 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
149
152
|
}
|
|
150
153
|
{
|
|
151
154
|
const label = 'project';
|
|
152
|
-
const patterns = worker.getProjectFilePatterns([...productionEntryFilePatterns]);
|
|
155
|
+
const patterns = worker.getProjectFilePatterns([...productionEntryFilePatterns, ...projectFilePatterns]);
|
|
153
156
|
const workspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns, label });
|
|
154
157
|
for (const projectPath of workspaceProjectPaths)
|
|
155
158
|
principal.addProjectPath(projectPath);
|