knip 5.44.3 → 5.44.5
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.js +3 -2
- package/dist/WorkspaceWorker.d.ts +1 -1
- package/dist/WorkspaceWorker.js +1 -1
- package/dist/graph/build.js +25 -16
- package/dist/plugins/webpack/index.js +3 -3
- package/dist/util/get-referenced-inputs.js +2 -2
- package/dist/util/glob-core.js +1 -1
- package/dist/util/input.d.ts +3 -0
- package/dist/util/input.js +7 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
1
2
|
import picomatch from 'picomatch';
|
|
2
3
|
import { partitionCompilers } from './compilers/index.js';
|
|
3
4
|
import { DEFAULT_EXTENSIONS, KNIP_CONFIG_LOCATIONS, ROOT_WORKSPACE_NAME } from './constants.js';
|
|
@@ -14,7 +15,7 @@ import { defaultRules } from './util/issue-initializers.js';
|
|
|
14
15
|
import { _load } from './util/loader.js';
|
|
15
16
|
import mapWorkspaces from './util/map-workspaces.js';
|
|
16
17
|
import { getKeysByValue } from './util/object.js';
|
|
17
|
-
import { join, relative
|
|
18
|
+
import { join, relative } from './util/path.js';
|
|
18
19
|
import { normalizePluginConfig } from './util/plugin.js';
|
|
19
20
|
import { toRegexOrString } from './util/regex.js';
|
|
20
21
|
import { unwrapFunction } from './util/unwrap-function.js';
|
|
@@ -205,7 +206,7 @@ export class ConfigurationChief {
|
|
|
205
206
|
}
|
|
206
207
|
getIncludedWorkspaces() {
|
|
207
208
|
if (this.workspace) {
|
|
208
|
-
const dir = resolve(this.cwd, this.workspace);
|
|
209
|
+
const dir = path.resolve(this.cwd, this.workspace);
|
|
209
210
|
if (!isDirectory(dir))
|
|
210
211
|
throw new ConfigurationError('Workspace is not a directory');
|
|
211
212
|
if (!isFile(join(dir, 'package.json')))
|
|
@@ -57,7 +57,7 @@ export declare class WorkspaceWorker {
|
|
|
57
57
|
getProductionProjectFilePatterns(negatedTestFilePatterns: string[]): string[];
|
|
58
58
|
private getConfigurationFilePatterns;
|
|
59
59
|
getIgnorePatterns(): string[];
|
|
60
|
-
|
|
60
|
+
runPlugins(): Promise<Input[]>;
|
|
61
61
|
onDispose(): void;
|
|
62
62
|
}
|
|
63
63
|
export {};
|
package/dist/WorkspaceWorker.js
CHANGED
|
@@ -156,7 +156,7 @@ export class WorkspaceWorker {
|
|
|
156
156
|
getIgnorePatterns() {
|
|
157
157
|
return [...this.rootIgnore, ...this.config.ignore.map(pattern => prependDirToPattern(this.name, pattern))];
|
|
158
158
|
}
|
|
159
|
-
async
|
|
159
|
+
async runPlugins() {
|
|
160
160
|
const name = this.name;
|
|
161
161
|
const cwd = this.dir;
|
|
162
162
|
const rootCwd = this.cwd;
|
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 { isConfigPattern, isEntry, isProductionEntry, toProductionEntry } from '../util/input.js';
|
|
7
|
+
import { isConfigPattern, isDeferResolveEntry, isDeferResolveProductionEntry, isEntry, isProductionEntry, 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';
|
|
@@ -58,21 +58,21 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
58
58
|
allConfigFilePaths,
|
|
59
59
|
});
|
|
60
60
|
await worker.init();
|
|
61
|
-
const
|
|
61
|
+
const inputs = new Set();
|
|
62
62
|
if (definitionPaths.length > 0) {
|
|
63
63
|
debugLogArray(name, 'Definition paths', definitionPaths);
|
|
64
64
|
for (const id of definitionPaths)
|
|
65
|
-
|
|
65
|
+
inputs.add(toProductionEntry(id, { containingFilePath: tsConfigFilePath }));
|
|
66
66
|
}
|
|
67
67
|
const ignore = worker.getIgnorePatterns();
|
|
68
68
|
const sharedGlobOptions = { cwd, dir, gitignore };
|
|
69
69
|
collector.addIgnorePatterns(ignore.map(pattern => join(cwd, pattern)));
|
|
70
70
|
const entryPathsFromManifest = await getEntryPathsFromManifest(manifest, { ...sharedGlobOptions, ignore });
|
|
71
71
|
for (const id of entryPathsFromManifest.map(id => toProductionEntry(id)))
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
for (const id of
|
|
75
|
-
|
|
72
|
+
inputs.add(id);
|
|
73
|
+
const inputsFromPlugins = await worker.runPlugins();
|
|
74
|
+
for (const id of inputsFromPlugins)
|
|
75
|
+
inputs.add(id);
|
|
76
76
|
enabledPluginsStore.set(name, worker.enabledPlugins);
|
|
77
77
|
const principal = factory.createPrincipal({
|
|
78
78
|
cwd: dir,
|
|
@@ -90,19 +90,28 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
90
90
|
});
|
|
91
91
|
const entryFilePatterns = new Set();
|
|
92
92
|
const productionEntryFilePatterns = new Set();
|
|
93
|
-
for (const
|
|
94
|
-
const s =
|
|
95
|
-
if (isEntry(
|
|
93
|
+
for (const input of inputs) {
|
|
94
|
+
const s = input.specifier;
|
|
95
|
+
if (isEntry(input)) {
|
|
96
96
|
entryFilePatterns.add(isAbsolute(s) ? relative(dir, s) : s);
|
|
97
97
|
}
|
|
98
|
-
else if (isProductionEntry(
|
|
98
|
+
else if (isProductionEntry(input)) {
|
|
99
99
|
productionEntryFilePatterns.add(isAbsolute(s) ? relative(dir, s) : s);
|
|
100
100
|
}
|
|
101
|
-
else if (!isConfigPattern(
|
|
102
|
-
const ws = (
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
|
|
101
|
+
else if (!isConfigPattern(input)) {
|
|
102
|
+
const ws = (input.containingFilePath && chief.findWorkspaceByFilePath(input.containingFilePath)) || workspace;
|
|
103
|
+
const resolvedFilePath = getReferencedInternalFilePath(input, ws);
|
|
104
|
+
if (resolvedFilePath) {
|
|
105
|
+
if (isDeferResolveProductionEntry(input)) {
|
|
106
|
+
productionEntryFilePatterns.add(resolvedFilePath);
|
|
107
|
+
}
|
|
108
|
+
else if (isDeferResolveEntry(input)) {
|
|
109
|
+
entryFilePatterns.add(resolvedFilePath);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
principal.addEntryPath(resolvedFilePath, { skipExportsAnalysis: true });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
106
115
|
}
|
|
107
116
|
}
|
|
108
117
|
if (isProduction) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compact } from '../../util/array.js';
|
|
2
|
-
import { toDeferResolve,
|
|
2
|
+
import { toDeferResolve, toDeferResolveEntry, toDeferResolveProductionEntry, toDependency, toDevDependency, } from '../../util/input.js';
|
|
3
3
|
import { isAbsolute, isInternal, join, relative } from '../../util/path.js';
|
|
4
4
|
import { hasDependency } from '../../util/plugin.js';
|
|
5
5
|
import { getDependenciesFromConfig } from '../babel/index.js';
|
|
@@ -83,8 +83,8 @@ export const findWebpackDependenciesFromConfig = async ({ config, cwd }) => {
|
|
|
83
83
|
else {
|
|
84
84
|
const absoluteEntry = isAbsolute(entry) ? entry : join(options.context ? options.context : cwd, entry);
|
|
85
85
|
const item = relative(cwd, absoluteEntry);
|
|
86
|
-
const
|
|
87
|
-
inputs.add(
|
|
86
|
+
const input = options.mode === 'development' ? toDeferResolveEntry(item) : toDeferResolveProductionEntry(item);
|
|
87
|
+
inputs.add(input);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IGNORED_RUNTIME_DEPENDENCIES } from '../constants.js';
|
|
2
2
|
import { debugLog } from './debug.js';
|
|
3
|
-
import { toDebugString } from './input.js';
|
|
3
|
+
import { isDeferResolve, toDebugString } from './input.js';
|
|
4
4
|
import { fromBinary, isBinary, isConfigPattern, isDeferResolveEntry, isDependency } from './input.js';
|
|
5
5
|
import { getPackageNameFromSpecifier } from './modules.js';
|
|
6
6
|
import { dirname, isAbsolute, isInternal, join } from './path.js';
|
|
@@ -54,7 +54,7 @@ export const getReferencedInputsHandler = (collector, deputy, chief, isGitIgnore
|
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
if (
|
|
57
|
+
if (isDeferResolve(input) && deputy.isProduction && !input.production) {
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
const baseDir = input.dir ?? dirname(containingFilePath);
|
package/dist/util/glob-core.js
CHANGED
|
@@ -187,7 +187,7 @@ export async function glob(patterns, options) {
|
|
|
187
187
|
const ignore = cachedIgnores || compact(_ignore);
|
|
188
188
|
const { dir, label, ...fgOptions } = { ...options, ignore };
|
|
189
189
|
const paths = await fg.glob(patterns, fgOptions);
|
|
190
|
-
debugLogObject(relative(options.cwd,
|
|
190
|
+
debugLogObject(relative(options.cwd, dir) || ROOT_WORKSPACE_NAME, label ? `Finding ${label} paths` : 'Finding paths', () => ({ patterns, ...fgOptions, ignore: cachedIgnores ? `// identical to ${dir}` : ignore, paths }));
|
|
191
191
|
if (willCache)
|
|
192
192
|
cachedGlobIgnores.set(options.dir, ignore);
|
|
193
193
|
return paths;
|
package/dist/util/input.d.ts
CHANGED
|
@@ -32,6 +32,9 @@ export declare const isDependency: (input: Input) => boolean;
|
|
|
32
32
|
export declare const toProductionDependency: (specifier: string) => Input;
|
|
33
33
|
export declare const toDevDependency: (specifier: string) => Input;
|
|
34
34
|
export declare const toDeferResolve: (specifier: string) => Input;
|
|
35
|
+
export declare const isDeferResolve: (input: Input) => boolean;
|
|
36
|
+
export declare const toDeferResolveProductionEntry: (specifier: string) => Input;
|
|
37
|
+
export declare const isDeferResolveProductionEntry: (input: Input) => boolean;
|
|
35
38
|
export declare const toDeferResolveEntry: (specifier: string) => Input;
|
|
36
39
|
export declare const isDeferResolveEntry: (input: Input) => boolean;
|
|
37
40
|
export declare const toDebugString: (input: Input) => string;
|
package/dist/util/input.js
CHANGED
|
@@ -35,6 +35,13 @@ export const toProductionDependency = (specifier) => ({
|
|
|
35
35
|
});
|
|
36
36
|
export const toDevDependency = (specifier) => ({ type: 'dependency', specifier });
|
|
37
37
|
export const toDeferResolve = (specifier) => ({ type: 'deferResolve', specifier });
|
|
38
|
+
export const isDeferResolve = (input) => input.type === 'deferResolve';
|
|
39
|
+
export const toDeferResolveProductionEntry = (specifier) => ({
|
|
40
|
+
type: 'deferResolveEntry',
|
|
41
|
+
specifier,
|
|
42
|
+
production: true,
|
|
43
|
+
});
|
|
44
|
+
export const isDeferResolveProductionEntry = (input) => input.type === 'deferResolveEntry' && input.production === true;
|
|
38
45
|
export const toDeferResolveEntry = (specifier) => ({ type: 'deferResolveEntry', specifier });
|
|
39
46
|
export const isDeferResolveEntry = (input) => input.type === 'deferResolveEntry';
|
|
40
47
|
export const toDebugString = (input) => `${input.type}:${input.specifier}${input.containingFilePath ? ` (${toRelative(input.containingFilePath)})` : ''}`;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.44.
|
|
1
|
+
export declare const version = "5.44.5";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.44.
|
|
1
|
+
export const version = '5.44.5';
|