knip 6.44.2 → 6.45.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 +23 -1033
- package/dist/ConfigurationChief.js +71 -15
- package/dist/DependencyDeputy.d.ts +10 -6
- package/dist/DependencyDeputy.js +51 -27
- package/dist/IssueCollector.d.ts +14 -11
- package/dist/IssueCollector.js +25 -20
- package/dist/IssueFixer.js +1 -1
- package/dist/PackagePeeker.d.ts +6 -0
- package/dist/PackagePeeker.js +43 -14
- package/dist/ProjectPrincipal.d.ts +6 -3
- package/dist/ProjectPrincipal.js +83 -32
- package/dist/WorkspaceWorker.d.ts +5 -1
- package/dist/WorkspaceWorker.js +39 -22
- package/dist/binaries/bash-parser.js +1 -7
- package/dist/binaries/command.d.ts +3 -3
- package/dist/binaries/command.js +6 -2
- package/dist/binaries/fallback.js +1 -1
- package/dist/binaries/plugins.d.ts +4 -1
- package/dist/binaries/plugins.js +66 -18
- package/dist/binaries/resolvers/npm.js +7 -5
- package/dist/binaries/resolvers/npx.js +8 -40
- package/dist/binaries/util.d.ts +13 -1
- package/dist/binaries/util.js +35 -1
- package/dist/cli.js +10 -84
- package/dist/configuration-hints.d.ts +16 -0
- package/dist/configuration-hints.js +64 -0
- package/dist/constants.d.ts +2 -1
- package/dist/constants.js +2 -0
- package/dist/graph/SubpathReferences.d.ts +33 -0
- package/dist/graph/SubpathReferences.js +114 -0
- package/dist/graph/analyze.d.ts +4 -1
- package/dist/graph/analyze.js +16 -5
- package/dist/graph/build.d.ts +3 -1
- package/dist/graph/build.js +47 -23
- package/dist/graph-explorer/operations/resolve-export-origins.js +1 -1
- package/dist/plugins/angular/index.js +10 -17
- package/dist/plugins/aws-cdk/index.d.ts +3 -0
- package/dist/plugins/aws-cdk/index.js +32 -0
- package/dist/plugins/aws-cdk/types.d.ts +5 -0
- package/dist/plugins/aws-cdk/types.js +1 -0
- package/dist/plugins/babel/index.d.ts +1 -1
- package/dist/plugins/babel/index.js +19 -5
- package/dist/plugins/bun/index.js +8 -7
- package/dist/plugins/c8/index.js +17 -4
- package/dist/plugins/changesets/index.js +3 -2
- package/dist/plugins/commitizen/index.js +6 -3
- package/dist/plugins/commitlint/index.js +10 -11
- package/dist/plugins/cypress/index.js +4 -2
- package/dist/plugins/danger/index.js +1 -1
- package/dist/plugins/docusaurus/helpers.js +6 -6
- package/dist/plugins/docusaurus/index.js +2 -2
- package/dist/plugins/electron-forge/index.js +2 -2
- package/dist/plugins/electron-vite/index.js +2 -2
- package/dist/plugins/eleventy/index.js +3 -2
- package/dist/plugins/eslint/helpers.js +4 -3
- package/dist/plugins/eslint/resolveFromAST.js +2 -2
- package/dist/plugins/evalite/index.d.ts +3 -0
- package/dist/plugins/evalite/index.js +26 -0
- package/dist/plugins/flue/index.js +2 -2
- package/dist/plugins/github-action/index.js +2 -2
- package/dist/plugins/github-actions/index.js +2 -2
- package/dist/plugins/graphql-codegen/index.js +13 -9
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.js +10 -0
- package/dist/plugins/jest/index.js +5 -5
- package/dist/plugins/knex/index.js +2 -2
- package/dist/plugins/laravel-vite-plugin/resolveFromAST.js +2 -2
- package/dist/plugins/lunaria/index.js +5 -2
- package/dist/plugins/markdownlint/index.js +8 -2
- package/dist/plugins/marko/index.js +2 -2
- package/dist/plugins/marko/taglibs.d.ts +1 -1
- package/dist/plugins/marko/taglibs.js +4 -28
- package/dist/plugins/mdx/index.d.ts +2 -1
- package/dist/plugins/mdx/index.js +7 -4
- package/dist/plugins/mdxlint/index.js +18 -15
- package/dist/plugins/mikro-orm/index.d.ts +3 -0
- package/dist/plugins/mikro-orm/index.js +77 -0
- package/dist/plugins/mikro-orm/types.d.ts +21 -0
- package/dist/plugins/mikro-orm/types.js +1 -0
- package/dist/plugins/msw/index.js +6 -3
- package/dist/plugins/msw/types.d.ts +1 -1
- package/dist/plugins/netlify/index.js +7 -3
- package/dist/plugins/next/index.js +63 -9
- package/dist/plugins/next/types.d.ts +5 -0
- package/dist/plugins/next-mdx/resolveFromAST.js +15 -10
- package/dist/plugins/nitro/index.js +5 -6
- package/dist/plugins/node/index.js +4 -4
- package/dist/plugins/npm-package-json-lint/index.js +10 -3
- package/dist/plugins/nuxt/index.js +18 -10
- package/dist/plugins/nuxt/types.d.ts +4 -0
- package/dist/plugins/nx/index.js +6 -3
- package/dist/plugins/openclaw/index.js +11 -11
- package/dist/plugins/oxlint/index.js +2 -2
- package/dist/plugins/payload/index.js +1 -1
- package/dist/plugins/playwright/index.js +3 -3
- package/dist/plugins/pm2/index.js +7 -7
- package/dist/plugins/prettier/index.js +2 -1
- package/dist/plugins/prisma/index.js +2 -2
- package/dist/plugins/quasar/resolveFromAST.js +14 -9
- package/dist/plugins/react-router/index.js +2 -2
- package/dist/plugins/release-it/index.js +6 -2
- package/dist/plugins/remix/index.js +3 -3
- package/dist/plugins/retry-cli/index.d.ts +3 -0
- package/dist/plugins/retry-cli/index.js +14 -0
- package/dist/plugins/rollup/index.js +1 -4
- package/dist/plugins/rstest/index.js +3 -3
- package/dist/plugins/semantic-release/index.js +3 -3
- package/dist/plugins/serverless-framework/index.js +10 -8
- package/dist/plugins/solidjs-vite-plugin/resolveFromAST.js +2 -2
- package/dist/plugins/stencil/resolveFromAST.js +5 -5
- package/dist/plugins/stryker/index.js +2 -2
- package/dist/plugins/swc/index.js +4 -3
- package/dist/plugins/tailwind/index.js +2 -2
- package/dist/plugins/tanstack-router/index.js +2 -2
- package/dist/plugins/ts-node/index.js +6 -1
- package/dist/plugins/turbo/index.js +3 -3
- package/dist/plugins/typedoc/index.js +2 -2
- package/dist/plugins/typescript/content-mappers.d.ts +1 -1
- package/dist/plugins/typescript/index.js +6 -9
- package/dist/plugins/varlock/scan.js +1 -1
- package/dist/plugins/vite/helpers.d.ts +1 -0
- package/dist/plugins/vite/helpers.js +13 -3
- package/dist/plugins/vite/index.js +5 -2
- package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +2 -2
- package/dist/plugins/vitest/index.js +14 -16
- package/dist/plugins/vue/index.js +1 -1
- package/dist/plugins/web-test-runner/index.d.ts +3 -0
- package/dist/plugins/web-test-runner/index.js +86 -0
- package/dist/plugins/wrangler/index.js +3 -3
- package/dist/plugins/yarn/index.js +5 -5
- package/dist/plugins.js +2 -5
- package/dist/reporters/github-actions.js +3 -7
- package/dist/reporters/json.d.ts +1 -0
- package/dist/reporters/json.js +1 -0
- package/dist/reporters/util/configuration-hints.d.ts +3 -1
- package/dist/reporters/util/configuration-hints.js +40 -21
- package/dist/reporters/util/util.d.ts +1 -1
- package/dist/run-cli.d.ts +2 -0
- package/dist/run-cli.js +82 -0
- package/dist/run.js +12 -0
- package/dist/session/incremental.d.ts +1 -0
- package/dist/session/incremental.js +1 -0
- package/dist/session/watch.js +2 -1
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +5 -0
- package/dist/types/args.d.ts +3 -1
- package/dist/types/config.d.ts +17 -10
- package/dist/types/configuration.d.ts +45 -0
- package/dist/types/configuration.js +1 -0
- package/dist/types/issues.d.ts +4 -0
- package/dist/types/module-graph.d.ts +1 -0
- package/dist/types/options.d.ts +1 -0
- package/dist/types/package-json.d.ts +3 -8
- package/dist/types/workspace.d.ts +1 -0
- package/dist/typescript/get-imports-and-exports.js +18 -6
- package/dist/typescript/resolve-module-names.js +7 -45
- package/dist/typescript/visitors/calls.d.ts +1 -1
- package/dist/typescript/visitors/calls.js +14 -10
- package/dist/typescript/visitors/exports.js +16 -26
- package/dist/typescript/visitors/imports.d.ts +2 -1
- package/dist/typescript/visitors/imports.js +41 -24
- package/dist/typescript/visitors/members.d.ts +1 -1
- package/dist/typescript/visitors/members.js +38 -24
- package/dist/typescript/visitors/shadow.d.ts +2 -0
- package/dist/typescript/visitors/shadow.js +25 -0
- package/dist/typescript/visitors/walk.d.ts +20 -12
- package/dist/typescript/visitors/walk.js +78 -48
- package/dist/util/Performance.d.ts +25 -3
- package/dist/util/Performance.js +51 -27
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +4 -2
- package/dist/util/create-input-handler.js +138 -119
- package/dist/util/create-options.d.ts +4 -2071
- package/dist/util/create-options.js +6 -4
- package/dist/util/create-workspace-graph.js +2 -1
- package/dist/util/errors.d.ts +5 -2
- package/dist/util/errors.js +11 -18
- package/dist/util/fs.js +4 -2
- package/dist/util/input.d.ts +2 -2
- package/dist/util/input.js +2 -2
- package/dist/util/is-plugin-name.d.ts +2 -0
- package/dist/util/is-plugin-name.js +3 -0
- package/dist/util/jiti.d.ts +2 -1
- package/dist/util/jiti.js +10 -3
- package/dist/util/load-config.d.ts +1 -1
- package/dist/util/load-config.js +3 -2
- package/dist/util/loader.js +3 -2
- package/dist/util/map-workspaces.js +23 -1
- package/dist/util/module-graph.js +1 -0
- package/dist/util/modules.d.ts +2 -0
- package/dist/util/modules.js +78 -0
- package/dist/util/package-json.d.ts +12 -5
- package/dist/util/package-json.js +54 -26
- package/dist/util/parse-and-convert-gitignores.d.ts +2 -2
- package/dist/util/parse-and-convert-gitignores.js +5 -5
- package/dist/util/parse-configuration.d.ts +2 -0
- package/dist/util/parse-configuration.js +66 -0
- package/dist/util/plugin.js +8 -12
- package/dist/util/resolve.d.ts +1 -0
- package/dist/util/resolve.js +3 -2
- package/dist/util/scripts.d.ts +0 -5
- package/dist/util/scripts.js +1 -32
- package/dist/util/to-source-path.d.ts +4 -1
- package/dist/util/to-source-path.js +2 -2
- package/dist/util/unhandled-rejection.d.ts +8 -0
- package/dist/util/unhandled-rejection.js +29 -0
- package/dist/util/validation.d.ts +11 -0
- package/dist/util/validation.js +68 -0
- package/dist/util/watch.d.ts +3 -1
- package/dist/util/watch.js +5 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -7
- package/schema.json +34 -0
- package/dist/schema/configuration.d.ts +0 -3103
- package/dist/schema/configuration.js +0 -94
- package/dist/schema/plugins.d.ts +0 -1019
- package/dist/schema/plugins.js +0 -215
|
@@ -4,11 +4,11 @@ declare class Performance {
|
|
|
4
4
|
readonly isTimerifyFunctions: boolean;
|
|
5
5
|
readonly isMemoryUsageEnabled: boolean;
|
|
6
6
|
readonly isDurationEnabled: boolean;
|
|
7
|
-
private
|
|
7
|
+
private startTime;
|
|
8
|
+
private endTime;
|
|
8
9
|
private readonly memId;
|
|
9
10
|
private readonly histograms;
|
|
10
11
|
private readonly memEntries;
|
|
11
|
-
private readonly memObserver?;
|
|
12
12
|
constructor({ isTimerifyFunctions, isMemoryUsageEnabled, isDurationEnabled }: {
|
|
13
13
|
isDurationEnabled?: boolean | undefined;
|
|
14
14
|
isMemoryUsageEnabled?: boolean | undefined;
|
|
@@ -16,12 +16,34 @@ declare class Performance {
|
|
|
16
16
|
});
|
|
17
17
|
registerHistogram(name: string): RecordableHistogram;
|
|
18
18
|
addMemoryMark(label: string): void;
|
|
19
|
+
getSnapshot(): {
|
|
20
|
+
durationMs: number;
|
|
21
|
+
processMs: number;
|
|
22
|
+
functions: {
|
|
23
|
+
name: string;
|
|
24
|
+
count: number;
|
|
25
|
+
minMs: number;
|
|
26
|
+
maxMs: number;
|
|
27
|
+
meanMs: number;
|
|
28
|
+
medianMs: number;
|
|
29
|
+
p95Ms: number;
|
|
30
|
+
sumMs: number;
|
|
31
|
+
}[];
|
|
32
|
+
memory: {
|
|
33
|
+
label: string;
|
|
34
|
+
heapUsed: number;
|
|
35
|
+
heapTotal: number;
|
|
36
|
+
rss: number;
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
19
39
|
getTimerifiedFunctionsTable(): string;
|
|
20
40
|
getMemoryUsageTable(): string;
|
|
21
41
|
getCurrentDurationInMs(): number;
|
|
42
|
+
getProcessDurationInMs(): number;
|
|
43
|
+
startRun(): void;
|
|
22
44
|
getMemHeapUsage(): number;
|
|
23
45
|
getCurrentMemUsageInMb(): any;
|
|
24
|
-
finalize():
|
|
46
|
+
finalize(): void;
|
|
25
47
|
reset(): void;
|
|
26
48
|
}
|
|
27
49
|
export declare const perfObserver: Performance;
|
package/dist/util/Performance.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHistogram, performance } from 'node:perf_hooks';
|
|
2
2
|
import { memoryUsage } from 'node:process';
|
|
3
3
|
import { parseArgs } from 'node:util';
|
|
4
4
|
import { Table } from './table.js';
|
|
@@ -22,6 +22,7 @@ const getMemInfo = (label) => {
|
|
|
22
22
|
return { label, heapUsed: usage.heapUsed, heapTotal: usage.heapTotal, rss: usage.rss };
|
|
23
23
|
};
|
|
24
24
|
const twoFixed = (value) => (typeof value === 'number' ? value.toFixed(2) : value);
|
|
25
|
+
const formatDuration = (ms) => typeof ms === 'number' ? (ms < 0.01 ? `${(ms * 1000).toFixed(2)}µs` : `${ms.toFixed(2)}ms`) : String(ms);
|
|
25
26
|
const inMB = (bytes) => bytes / 1024 / 1024;
|
|
26
27
|
const keys = ['heapUsed', 'heapTotal', 'rss'];
|
|
27
28
|
const logHead = () => console.log(['phase', ...keys].map(key => key.padStart(10)).join(' '));
|
|
@@ -32,21 +33,16 @@ class Performance {
|
|
|
32
33
|
isMemoryUsageEnabled;
|
|
33
34
|
isDurationEnabled;
|
|
34
35
|
startTime = performance.now();
|
|
36
|
+
endTime;
|
|
35
37
|
memId = `mem-${Math.floor(performance.now() * 100)}`;
|
|
36
38
|
histograms = new Map();
|
|
37
39
|
memEntries = [];
|
|
38
|
-
memObserver;
|
|
39
40
|
constructor({ isTimerifyFunctions = false, isMemoryUsageEnabled = false, isDurationEnabled = false }) {
|
|
40
41
|
this.isEnabled = isTimerifyFunctions || isMemoryUsageEnabled;
|
|
41
42
|
this.isTimerifyFunctions = isTimerifyFunctions;
|
|
42
43
|
this.isMemoryUsageEnabled = isMemoryUsageEnabled;
|
|
43
44
|
this.isDurationEnabled = isDurationEnabled;
|
|
44
45
|
if (isMemoryUsageEnabled) {
|
|
45
|
-
this.memObserver = new PerformanceObserver(items => {
|
|
46
|
-
for (const entry of items.getEntries())
|
|
47
|
-
this.memEntries.push(entry);
|
|
48
|
-
});
|
|
49
|
-
this.memObserver.observe({ type: 'mark' });
|
|
50
46
|
if (isMemoryRealtime)
|
|
51
47
|
logHead();
|
|
52
48
|
this.addMemoryMark('start');
|
|
@@ -65,25 +61,45 @@ class Performance {
|
|
|
65
61
|
return;
|
|
66
62
|
const detail = getMemInfo(label);
|
|
67
63
|
performance.mark(`${this.memId}:${label}`, { detail });
|
|
64
|
+
this.memEntries.push(detail);
|
|
68
65
|
if (isMemoryRealtime)
|
|
69
66
|
log(detail);
|
|
70
67
|
}
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
const
|
|
68
|
+
getSnapshot() {
|
|
69
|
+
const processMs = this.getProcessDurationInMs();
|
|
70
|
+
const functions = [];
|
|
74
71
|
for (const [name, h] of this.histograms) {
|
|
75
72
|
if (h.count === 0)
|
|
76
73
|
continue;
|
|
77
74
|
const meanMs = h.mean / 1e6;
|
|
78
|
-
|
|
75
|
+
functions.push({
|
|
76
|
+
name,
|
|
77
|
+
count: h.count,
|
|
78
|
+
minMs: h.min / 1e6,
|
|
79
|
+
maxMs: h.max / 1e6,
|
|
80
|
+
meanMs,
|
|
81
|
+
medianMs: h.percentile(50) / 1e6,
|
|
82
|
+
p95Ms: h.percentile(95) / 1e6,
|
|
83
|
+
sumMs: meanMs * h.count,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const memory = [];
|
|
87
|
+
for (const entry of this.memEntries)
|
|
88
|
+
memory.push({ ...entry });
|
|
89
|
+
return { durationMs: processMs - this.startTime, processMs, functions, memory };
|
|
90
|
+
}
|
|
91
|
+
getTimerifiedFunctionsTable() {
|
|
92
|
+
const { durationMs, functions } = this.getSnapshot();
|
|
93
|
+
const table = new Table({ header: true });
|
|
94
|
+
for (const entry of functions) {
|
|
79
95
|
table.row();
|
|
80
|
-
table.cell('Name', name);
|
|
81
|
-
table.cell('size',
|
|
82
|
-
table.cell('min',
|
|
83
|
-
table.cell('max',
|
|
84
|
-
table.cell('median',
|
|
85
|
-
table.cell('sum', sumMs,
|
|
86
|
-
table.cell('%', (sumMs /
|
|
96
|
+
table.cell('Name', entry.name);
|
|
97
|
+
table.cell('size', entry.count);
|
|
98
|
+
table.cell('min', entry.minMs, formatDuration);
|
|
99
|
+
table.cell('max', entry.maxMs, formatDuration);
|
|
100
|
+
table.cell('median', entry.medianMs, formatDuration);
|
|
101
|
+
table.cell('sum', entry.sumMs, formatDuration);
|
|
102
|
+
table.cell('%', (entry.sumMs / durationMs) * 100, v => (typeof v === 'number' ? `${v.toFixed(0)}%` : ''));
|
|
87
103
|
}
|
|
88
104
|
table.sort('sum', 'desc');
|
|
89
105
|
return table.toString();
|
|
@@ -94,9 +110,7 @@ class Performance {
|
|
|
94
110
|
let peakHeapUsed = 0;
|
|
95
111
|
let peakRss = 0;
|
|
96
112
|
for (const entry of this.memEntries) {
|
|
97
|
-
|
|
98
|
-
continue;
|
|
99
|
-
const { label, heapUsed, rss } = entry.detail;
|
|
113
|
+
const { label, heapUsed, rss } = entry;
|
|
100
114
|
const delta = heapUsed - prevHeapUsed;
|
|
101
115
|
if (heapUsed > peakHeapUsed)
|
|
102
116
|
peakHeapUsed = heapUsed;
|
|
@@ -117,7 +131,14 @@ class Performance {
|
|
|
117
131
|
return table.toString();
|
|
118
132
|
}
|
|
119
133
|
getCurrentDurationInMs() {
|
|
120
|
-
return
|
|
134
|
+
return this.getProcessDurationInMs() - this.startTime;
|
|
135
|
+
}
|
|
136
|
+
getProcessDurationInMs() {
|
|
137
|
+
return this.endTime ?? performance.now();
|
|
138
|
+
}
|
|
139
|
+
startRun() {
|
|
140
|
+
this.startTime = performance.now();
|
|
141
|
+
this.endTime = undefined;
|
|
121
142
|
}
|
|
122
143
|
getMemHeapUsage() {
|
|
123
144
|
return memoryUsage().heapUsed;
|
|
@@ -125,16 +146,19 @@ class Performance {
|
|
|
125
146
|
getCurrentMemUsageInMb() {
|
|
126
147
|
return twoFixed(inMB(this.getMemHeapUsage()));
|
|
127
148
|
}
|
|
128
|
-
|
|
129
|
-
if (!this.isEnabled)
|
|
149
|
+
finalize() {
|
|
150
|
+
if (!this.isEnabled && !this.isDurationEnabled)
|
|
130
151
|
return;
|
|
152
|
+
this.endTime = performance.now();
|
|
131
153
|
this.addMemoryMark('end');
|
|
132
|
-
await new Promise(resolve => setTimeout(resolve, 1));
|
|
133
154
|
}
|
|
134
155
|
reset() {
|
|
135
|
-
this.histograms.
|
|
156
|
+
for (const histogram of this.histograms.values())
|
|
157
|
+
histogram.reset();
|
|
158
|
+
for (const entry of this.memEntries)
|
|
159
|
+
performance.clearMarks(`${this.memId}:${entry.label}`);
|
|
136
160
|
this.memEntries.length = 0;
|
|
137
|
-
this.
|
|
161
|
+
this.startRun();
|
|
138
162
|
}
|
|
139
163
|
}
|
|
140
164
|
export const perfObserver = new Performance({ isTimerifyFunctions, isMemoryUsageEnabled, isDurationEnabled });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const helpText = "\u2702\uFE0F Find unused dependencies, exports and files in your JavaScript and TypeScript projects\n\nUsage: knip [options]\n\nOptions:\n -h, --help Print this help text\n -V, --version Print version\n -n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)\n -c, --config [file] Configuration file path\n (default: [.]knip.json[c], knip.(js|ts), knip.config.(js|ts) or package.json#knip)\n --use-tsconfig-files Use tsconfig.json to define project files (override `project` patterns)\n -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)\n\nMode\n --cache Enable caching\n --cache-location Change cache location (default: node_modules/.cache/knip)\n --include-entry-exports Include entry files when reporting unused exports\n --no-gitignore Don't respect .gitignore\n -p, --production Analyze only production source files (e.g. no test files, devDependencies)\n -s, --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)\n -w, --watch Watch mode\n\nScope\n -W, --workspace [filter] Filter workspaces by name, directory, or glob (can be repeated)\n -D, --directory [dir] Run process from a different directory (default: cwd)\n --include Include provided issue type(s), can be comma-separated or repeated (1)\n --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)\n --dependencies Shortcut for --include dependencies,unlisted,binaries,unresolved,catalog,catalogReferences\n --exports Shortcut for --include exports,nsExports,types,nsTypes,enumMembers,namespaceMembers,duplicates\n --files Shortcut for --include files\n --cycles Shortcut for --include cycles (circular dependencies)\n --tags Include or exclude tagged exports\n\nFix\n -f, --fix Fix issues (modifies files in your repo)\n --fix-type Fix only issues of type, can be comma-separated or repeated (2)\n --allow-remove-files Allow Knip to remove files (with --fix)\n -F, --format Format modified files after --fix using the local formatter\n\nOutput\n --preprocessor Preprocess the results before providing them to the reporter(s), can be repeated\n --preprocessor-options Pass extra options to the preprocessor (as JSON string, see --reporter-options example)\n --reporter Select reporter (default: symbols), can be repeated (3)\n --reporter-options Pass extra options to the reporter (as JSON string, see example)\n --output-file Write reporter output to a file instead of stdout ([reporter=]path), can be repeated\n --no-config-hints Suppress configuration hints\n --no-tag-hints Suppress tag hints\n --treat-config-hints-as-errors Exit with non-zero code (1) if there are any configuration hints\n --treat-tag-hints-as-errors Exit with non-zero code (1) if there are any tag hints\n --max-issues Maximum number of total issues before non-zero exit code (default: 0)\n --max-show-issues Maximum number of issues to display per type\n --no-exit-code Always exit with code zero (0)\n\nTroubleshooting\n -d, --debug Show debug output\n --memory Measure memory usage and display data table\n --memory-realtime Log memory usage in realtime\n --performance Measure count and running time of key functions and display stats table\n --performance-fn [name] Measure only function [name]\n -u, --duration Print
|
|
1
|
+
export declare const helpText = "\u2702\uFE0F Find unused dependencies, exports and files in your JavaScript and TypeScript projects\n\nUsage: knip [options]\n\nOptions:\n -h, --help Print this help text\n -V, --version Print version\n -n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)\n -c, --config [file] Configuration file path\n (default: [.]knip.json[c], knip.(js|ts), knip.config.(js|ts) or package.json#knip)\n --use-tsconfig-files Use tsconfig.json to define project files (override `project` patterns)\n -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)\n\nMode\n --cache Enable caching\n --cache-location Change cache location (default: node_modules/.cache/knip)\n --include-entry-exports Include entry files when reporting unused exports\n --include-subpath-exports Report unused subpaths in package.json#exports\n --no-gitignore Don't respect .gitignore\n -p, --production Analyze only production source files (e.g. no test files, devDependencies)\n -s, --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)\n -w, --watch Watch mode\n\nScope\n -W, --workspace [filter] Filter workspaces by name, directory, or glob (can be repeated)\n -D, --directory [dir] Run process from a different directory (default: cwd)\n --include Include provided issue type(s), can be comma-separated or repeated (1)\n --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)\n --dependencies Shortcut for --include dependencies,unlisted,binaries,unresolved,catalog,catalogReferences\n --exports Shortcut for --include exports,nsExports,types,nsTypes,enumMembers,namespaceMembers,duplicates\n --files Shortcut for --include files\n --cycles Shortcut for --include cycles (circular dependencies)\n --tags Include or exclude tagged exports\n\nFix\n -f, --fix Fix issues (modifies files in your repo)\n --fix-type Fix only issues of type, can be comma-separated or repeated (2)\n --allow-remove-files Allow Knip to remove files (with --fix)\n -F, --format Format modified files after --fix using the local formatter\n\nOutput\n --preprocessor Preprocess the results before providing them to the reporter(s), can be repeated\n --preprocessor-options Pass extra options to the preprocessor (as JSON string, see --reporter-options example)\n --reporter Select reporter (default: symbols), can be repeated (3)\n --reporter-options Pass extra options to the reporter (as JSON string, see example)\n --output-file Write reporter output to a file instead of stdout ([reporter=]path), can be repeated\n --no-config-hints Suppress configuration hints\n --no-tag-hints Suppress tag hints\n --treat-config-hints-as-errors Exit with non-zero code (1) if there are any configuration hints\n --treat-tag-hints-as-errors Exit with non-zero code (1) if there are any tag hints\n --max-issues Maximum number of total issues before non-zero exit code (default: 0)\n --max-show-issues Maximum number of issues to display per type\n --no-exit-code Always exit with code zero (0)\n\nTroubleshooting\n -d, --debug Show debug output\n --memory Measure memory usage and display data table\n --memory-realtime Log memory usage in realtime\n --performance Measure count and running time of key functions and display stats table\n --performance-fn [name] Measure only function [name]\n -u, --duration Print run time and startup overhead (no instrumentation)\n --trace Show trace output\n --trace-dependency [name] Show files that import the named dependency\n --trace-export [name] Show trace output for named export(s)\n --trace-file [file] Show trace output for exports in file\n\n(1) Issue types: files, subpaths, dependencies, unlisted, unresolved, exports, nsExports, types, nsTypes, enumMembers, namespaceMembers, duplicates, catalog, catalogReferences, cycles\n(2) Fixable issue types: dependencies, exports, types, files, catalog\n(3) Built-in reporters: symbols (default), compact, codeowners, cycles, json, codeclimate, markdown, disclosure, github-actions, sarif\n\nExamples:\n\n$ knip\n$ knip --production\n$ knip --workspace packages/client --include files,dependencies\n$ knip --workspace @myorg/* --workspace '!@myorg/legacy'\n$ knip --workspace './apps/*' --workspace '@shared/utils'\n$ knip -c ./config/knip.json --reporter compact\n$ knip --reporter codeowners --reporter-options '{\"path\":\".github/CODEOWNERS\"}'\n$ knip --reporter symbols --reporter json --output-file json=knip.json\n$ knip --tags=-lintignore\n\nWebsite: https://knip.dev";
|
|
2
2
|
export type ParsedCLIArgs = ReturnType<typeof parseCLIArgs>;
|
|
3
3
|
export declare const parseNumericOption: (value: string | undefined, option: string) => number | undefined;
|
|
4
4
|
export default function parseCLIArgs(): {
|
|
@@ -20,6 +20,7 @@ export default function parseCLIArgs(): {
|
|
|
20
20
|
help?: boolean | undefined;
|
|
21
21
|
include?: string[] | undefined;
|
|
22
22
|
'include-entry-exports'?: boolean | undefined;
|
|
23
|
+
'include-subpath-exports'?: boolean | undefined;
|
|
23
24
|
'max-issues'?: string | undefined;
|
|
24
25
|
'max-show-issues'?: string | undefined;
|
|
25
26
|
memory?: boolean | undefined;
|
|
@@ -17,6 +17,7 @@ Mode
|
|
|
17
17
|
--cache Enable caching
|
|
18
18
|
--cache-location Change cache location (default: node_modules/.cache/knip)
|
|
19
19
|
--include-entry-exports Include entry files when reporting unused exports
|
|
20
|
+
--include-subpath-exports Report unused subpaths in package.json#exports
|
|
20
21
|
--no-gitignore Don't respect .gitignore
|
|
21
22
|
-p, --production Analyze only production source files (e.g. no test files, devDependencies)
|
|
22
23
|
-s, --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)
|
|
@@ -59,13 +60,13 @@ Troubleshooting
|
|
|
59
60
|
--memory-realtime Log memory usage in realtime
|
|
60
61
|
--performance Measure count and running time of key functions and display stats table
|
|
61
62
|
--performance-fn [name] Measure only function [name]
|
|
62
|
-
-u, --duration Print
|
|
63
|
+
-u, --duration Print run time and startup overhead (no instrumentation)
|
|
63
64
|
--trace Show trace output
|
|
64
65
|
--trace-dependency [name] Show files that import the named dependency
|
|
65
66
|
--trace-export [name] Show trace output for named export(s)
|
|
66
67
|
--trace-file [file] Show trace output for exports in file
|
|
67
68
|
|
|
68
|
-
(1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, types, nsTypes, enumMembers, namespaceMembers, duplicates, catalog, catalogReferences, cycles
|
|
69
|
+
(1) Issue types: files, subpaths, dependencies, unlisted, unresolved, exports, nsExports, types, nsTypes, enumMembers, namespaceMembers, duplicates, catalog, catalogReferences, cycles
|
|
69
70
|
(2) Fixable issue types: dependencies, exports, types, files, catalog
|
|
70
71
|
(3) Built-in reporters: symbols (default), compact, codeowners, cycles, json, codeclimate, markdown, disclosure, github-actions, sarif
|
|
71
72
|
|
|
@@ -111,6 +112,7 @@ export default function parseCLIArgs() {
|
|
|
111
112
|
help: { type: 'boolean', short: 'h' },
|
|
112
113
|
include: { type: 'string', multiple: true },
|
|
113
114
|
'include-entry-exports': { type: 'boolean' },
|
|
115
|
+
'include-subpath-exports': { type: 'boolean' },
|
|
114
116
|
'max-issues': { type: 'string' },
|
|
115
117
|
'max-show-issues': { type: 'string' },
|
|
116
118
|
memory: { type: 'boolean' },
|
|
@@ -1,134 +1,153 @@
|
|
|
1
|
-
import { IGNORED_GLOBAL_BINARIES
|
|
1
|
+
import { IGNORED_GLOBAL_BINARIES } from '../constants.js';
|
|
2
2
|
import { debugLog } from './debug.js';
|
|
3
|
-
import { fromBinary,
|
|
4
|
-
import { getPackageNameFromSpecifier } from './modules.js';
|
|
3
|
+
import { fromBinary, isConfig, isDeferResolveEntry, toDebugString } from './input.js';
|
|
4
|
+
import { getPackageNameFromFilePath, getPackageNameFromSpecifier } from './modules.js';
|
|
5
5
|
import { dirname, isAbsolute, isInNodeModules, isInternal, join } from './path.js';
|
|
6
|
-
import { _resolveModuleSync, _resolveSync } from './resolve.js';
|
|
6
|
+
import { _resolveModuleSync, _resolveSync, resolvePackageManifestPath } from './resolve.js';
|
|
7
|
+
const CHAR_HASH = 35;
|
|
8
|
+
const CHAR_AT = 64;
|
|
9
|
+
const CHAR_TILDE = 126;
|
|
7
10
|
const isJoinable = (specifier) => {
|
|
8
11
|
const char = specifier.charCodeAt(0);
|
|
9
|
-
return char !==
|
|
12
|
+
return char !== CHAR_HASH && char !== CHAR_TILDE && char !== CHAR_AT && !isAbsolute(specifier);
|
|
10
13
|
};
|
|
11
|
-
const
|
|
12
|
-
(input
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
map.get(containingFilePath).add(ref);
|
|
18
|
-
};
|
|
19
|
-
export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, externalRefs, options) => (input, workspace) => {
|
|
20
|
-
const { specifier, containingFilePath } = input;
|
|
21
|
-
if (!containingFilePath)
|
|
22
|
-
return;
|
|
23
|
-
if (isBinary(input)) {
|
|
24
|
-
const binaryName = fromBinary(input);
|
|
25
|
-
const inputWorkspace = getWorkspaceFor(input, chief, workspace);
|
|
26
|
-
const dependencies = deputy.maybeAddReferencedBinary(inputWorkspace, binaryName);
|
|
27
|
-
if (dependencies) {
|
|
28
|
-
if (externalRefs) {
|
|
29
|
-
for (const dependency of dependencies) {
|
|
30
|
-
addExternalRef(externalRefs, containingFilePath, { specifier: dependency, identifier: binaryName });
|
|
31
|
-
}
|
|
32
|
-
}
|
|
14
|
+
export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, externalRefs, options) => {
|
|
15
|
+
const getWorkspaceFor = (input, containingFilePath, workspace) => (input.dir && chief.findWorkspaceByFilePath(`${input.dir}/`)) ||
|
|
16
|
+
chief.findWorkspaceByFilePath(containingFilePath) ||
|
|
17
|
+
workspace;
|
|
18
|
+
const addExternalRef = (containingFilePath, specifier, identifier) => {
|
|
19
|
+
if (!externalRefs)
|
|
33
20
|
return;
|
|
21
|
+
const ref = { specifier, identifier };
|
|
22
|
+
const refs = externalRefs.get(containingFilePath);
|
|
23
|
+
if (refs)
|
|
24
|
+
refs.add(ref);
|
|
25
|
+
else
|
|
26
|
+
externalRefs.set(containingFilePath, new Set([ref]));
|
|
27
|
+
};
|
|
28
|
+
const isReportable = (input) => !input.optional && (!options.isProduction || input.production);
|
|
29
|
+
const report = (type, filePath, workspace, symbol) => addIssue({ type, filePath, workspace: workspace.name, symbol, specifier: symbol, fixes: [] });
|
|
30
|
+
const credit = (input, containingFilePath, workspace, packageName) => {
|
|
31
|
+
const reference = {
|
|
32
|
+
specifier: input.specifier,
|
|
33
|
+
isDevOnly: isConfig(input),
|
|
34
|
+
isTypeOnly: input.isTypeOnly,
|
|
35
|
+
isDevelopment: !input.production,
|
|
36
|
+
};
|
|
37
|
+
const isHandled = deputy.maybeAddReferencedExternalDependency(workspace, packageName, reference);
|
|
38
|
+
if (!input.alsoReferenceOwner)
|
|
39
|
+
return isHandled;
|
|
40
|
+
const owner = chief.findWorkspaceByFilePath(containingFilePath);
|
|
41
|
+
if (!owner || owner === workspace)
|
|
42
|
+
return isHandled;
|
|
43
|
+
const isOwnerHandled = deputy.maybeAddReferencedExternalDependency(owner, packageName, reference);
|
|
44
|
+
return isHandled || isOwnerHandled;
|
|
45
|
+
};
|
|
46
|
+
const resolveWorkspacePath = (specifier, containingFilePath) => {
|
|
47
|
+
const filePath = _resolveSync(specifier, dirname(containingFilePath));
|
|
48
|
+
if (filePath && isInternal(filePath) && !isGitIgnored(filePath))
|
|
49
|
+
return filePath;
|
|
50
|
+
};
|
|
51
|
+
const handleFile = (input, containingFilePath, workspace, recordedPackageName) => {
|
|
52
|
+
const { specifier } = input;
|
|
53
|
+
const basePath = input.dir ? join(input.dir, 'file.ts') : containingFilePath;
|
|
54
|
+
const filePath = isJoinable(specifier) ? join(input.dir ?? dirname(containingFilePath), specifier) : specifier;
|
|
55
|
+
const resolvedFilePath = _resolveModuleSync(filePath, basePath) ??
|
|
56
|
+
(filePath === specifier ? undefined : _resolveModuleSync(specifier, basePath));
|
|
57
|
+
if (resolvedFilePath && isInternal(resolvedFilePath)) {
|
|
58
|
+
return isGitIgnored(resolvedFilePath) ? undefined : resolvedFilePath;
|
|
34
59
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
fixes: [],
|
|
44
|
-
});
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
if (IGNORED_RUNTIME_DEPENDENCIES.has(specifier))
|
|
48
|
-
return;
|
|
49
|
-
const packageName = getPackageNameFromSpecifier(specifier);
|
|
50
|
-
if (packageName &&
|
|
51
|
-
(isDependency(input) ||
|
|
52
|
-
isDeferResolve(input) ||
|
|
53
|
-
(isDeferResolveEntry(input) && isInNodeModules(specifier)) ||
|
|
54
|
-
isConfig(input))) {
|
|
55
|
-
const isWorkspace = chief.workspacesByPkgName.has(packageName);
|
|
56
|
-
const inputWorkspace = getWorkspaceFor(input, chief, workspace);
|
|
57
|
-
if (inputWorkspace) {
|
|
58
|
-
let isHandled = deputy.maybeAddReferencedExternalDependency(inputWorkspace, packageName, {
|
|
59
|
-
specifier,
|
|
60
|
-
isDevOnly: isConfig(input),
|
|
61
|
-
isTypeOnly: input.isTypeOnly,
|
|
62
|
-
});
|
|
63
|
-
if (input.alsoReferenceOwner && input.containingFilePath) {
|
|
64
|
-
const owningWorkspace = chief.findWorkspaceByFilePath(input.containingFilePath);
|
|
65
|
-
if (owningWorkspace && owningWorkspace !== inputWorkspace) {
|
|
66
|
-
const isOwnerHandled = deputy.maybeAddReferencedExternalDependency(owningWorkspace, packageName, {
|
|
67
|
-
specifier,
|
|
68
|
-
isDevOnly: isConfig(input),
|
|
69
|
-
isTypeOnly: input.isTypeOnly,
|
|
70
|
-
});
|
|
71
|
-
isHandled = isHandled || isOwnerHandled;
|
|
60
|
+
const inputWorkspace = getWorkspaceFor(input, containingFilePath, workspace);
|
|
61
|
+
if (resolvedFilePath || !isInternal(filePath)) {
|
|
62
|
+
const packageName = resolvedFilePath
|
|
63
|
+
? getPackageNameFromFilePath(resolvedFilePath)
|
|
64
|
+
: getPackageNameFromSpecifier(specifier);
|
|
65
|
+
if (packageName) {
|
|
66
|
+
if (packageName !== recordedPackageName && !chief.findWorkspaceByPackageName(packageName, containingFilePath)) {
|
|
67
|
+
addExternalRef(containingFilePath, packageName);
|
|
72
68
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
addExternalRef(externalRefs, containingFilePath, { specifier: packageName, identifier: undefined });
|
|
76
|
-
}
|
|
77
|
-
if (isWorkspace || isDependency(input)) {
|
|
78
|
-
if (!isHandled) {
|
|
79
|
-
if (!input.optional && ((options.isProduction && input.production) || !options.isProduction)) {
|
|
80
|
-
addIssue({
|
|
81
|
-
type: 'unlisted',
|
|
82
|
-
filePath: containingFilePath,
|
|
83
|
-
workspace: inputWorkspace.name,
|
|
84
|
-
symbol: packageName,
|
|
85
|
-
specifier: packageName,
|
|
86
|
-
fixes: [],
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
return;
|
|
69
|
+
if (!credit(input, containingFilePath, inputWorkspace, packageName) && isReportable(input)) {
|
|
70
|
+
report('unlisted', containingFilePath, inputWorkspace, packageName);
|
|
90
71
|
}
|
|
91
|
-
const internalPath = _resolveSync(specifier, dirname(containingFilePath));
|
|
92
|
-
if (internalPath && isInternal(internalPath) && !isGitIgnored(internalPath))
|
|
93
|
-
return internalPath;
|
|
94
|
-
}
|
|
95
|
-
if (isHandled)
|
|
96
72
|
return;
|
|
73
|
+
}
|
|
97
74
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const filePath = isJoinable(specifier) ? join(input.dir ?? dirname(containingFilePath), specifier) : specifier;
|
|
103
|
-
const basePath = input.dir ? join(input.dir, 'file.ts') : containingFilePath;
|
|
104
|
-
const resolvedFilePath = _resolveModuleSync(filePath, basePath);
|
|
105
|
-
if (resolvedFilePath && isInternal(resolvedFilePath)) {
|
|
106
|
-
return isGitIgnored(resolvedFilePath) ? undefined : resolvedFilePath;
|
|
107
|
-
}
|
|
108
|
-
if (input.optional)
|
|
109
|
-
return;
|
|
110
|
-
if (!isInternal(filePath)) {
|
|
111
|
-
addIssue({
|
|
112
|
-
type: 'unlisted',
|
|
113
|
-
filePath: containingFilePath,
|
|
114
|
-
workspace: workspace.name,
|
|
115
|
-
symbol: packageName ?? specifier,
|
|
116
|
-
specifier: packageName ?? specifier,
|
|
117
|
-
fixes: [],
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
else if (!isGitIgnored(filePath)) {
|
|
121
|
-
if (!isDeferResolveEntry(input) && !isConfig(input)) {
|
|
122
|
-
addIssue({
|
|
123
|
-
type: 'unresolved',
|
|
124
|
-
filePath: containingFilePath,
|
|
125
|
-
workspace: workspace.name,
|
|
126
|
-
symbol: specifier,
|
|
127
|
-
fixes: [],
|
|
128
|
-
});
|
|
75
|
+
if ((isInternal(filePath) && isGitIgnored(filePath)) || !isReportable(input))
|
|
76
|
+
return;
|
|
77
|
+
if (isDeferResolveEntry(input) || isConfig(input)) {
|
|
78
|
+
debugLog(inputWorkspace.name, `Unable to resolve ${toDebugString(input, options.cwd)}`);
|
|
129
79
|
}
|
|
130
80
|
else {
|
|
131
|
-
|
|
81
|
+
report('unresolved', containingFilePath, inputWorkspace, specifier);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const handleBinary = (input, containingFilePath, workspace) => {
|
|
85
|
+
const binaryName = fromBinary(input);
|
|
86
|
+
const inputWorkspace = getWorkspaceFor(input, containingFilePath, workspace);
|
|
87
|
+
const dependencies = deputy.maybeAddReferencedBinary(inputWorkspace, binaryName, !input.production);
|
|
88
|
+
if (dependencies) {
|
|
89
|
+
for (const dependency of dependencies) {
|
|
90
|
+
addExternalRef(containingFilePath, dependency, binaryName);
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (!isReportable(input) ||
|
|
95
|
+
(inputWorkspace.config.ignoreGlobalBinaries && IGNORED_GLOBAL_BINARIES.has(binaryName))) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
report('binaries', containingFilePath, inputWorkspace, binaryName);
|
|
99
|
+
};
|
|
100
|
+
const handleDependency = (input, containingFilePath, workspace) => {
|
|
101
|
+
const packageName = getPackageNameFromSpecifier(input.specifier);
|
|
102
|
+
if (!packageName)
|
|
103
|
+
return handleFile(input, containingFilePath, workspace);
|
|
104
|
+
const inputWorkspace = getWorkspaceFor(input, containingFilePath, workspace);
|
|
105
|
+
if (externalRefs && !chief.findWorkspaceByPackageName(packageName, containingFilePath)) {
|
|
106
|
+
addExternalRef(containingFilePath, packageName);
|
|
107
|
+
}
|
|
108
|
+
if (credit(input, containingFilePath, inputWorkspace, packageName)) {
|
|
109
|
+
return resolveWorkspacePath(input.specifier, containingFilePath);
|
|
110
|
+
}
|
|
111
|
+
if (isReportable(input))
|
|
112
|
+
report('unlisted', containingFilePath, inputWorkspace, packageName);
|
|
113
|
+
};
|
|
114
|
+
const handlePackageOrFile = (input, containingFilePath, workspace) => {
|
|
115
|
+
const packageName = getPackageNameFromSpecifier(input.specifier);
|
|
116
|
+
if (!packageName)
|
|
117
|
+
return handleFile(input, containingFilePath, workspace);
|
|
118
|
+
const inputWorkspace = getWorkspaceFor(input, containingFilePath, workspace);
|
|
119
|
+
const isWorkspace = chief.findWorkspaceByPackageName(packageName, containingFilePath) !== undefined;
|
|
120
|
+
if (!isWorkspace)
|
|
121
|
+
addExternalRef(containingFilePath, packageName);
|
|
122
|
+
if (credit(input, containingFilePath, inputWorkspace, packageName)) {
|
|
123
|
+
return isWorkspace ? resolveWorkspacePath(input.specifier, containingFilePath) : undefined;
|
|
124
|
+
}
|
|
125
|
+
if (isWorkspace || resolvePackageManifestPath(packageName, input.dir ?? dirname(containingFilePath))) {
|
|
126
|
+
if (isReportable(input))
|
|
127
|
+
report('unlisted', containingFilePath, inputWorkspace, packageName);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
return handleFile(input, containingFilePath, workspace, packageName);
|
|
131
|
+
};
|
|
132
|
+
return (input, workspace) => {
|
|
133
|
+
const { specifier, containingFilePath } = input;
|
|
134
|
+
if (!containingFilePath)
|
|
135
|
+
return;
|
|
136
|
+
switch (input.type) {
|
|
137
|
+
case 'binary':
|
|
138
|
+
handleBinary(input, containingFilePath, workspace);
|
|
139
|
+
return;
|
|
140
|
+
case 'dependency':
|
|
141
|
+
return handleDependency(input, containingFilePath, workspace);
|
|
142
|
+
case 'deferResolve':
|
|
143
|
+
case 'config':
|
|
144
|
+
return handlePackageOrFile(input, containingFilePath, workspace);
|
|
145
|
+
case 'deferResolveEntry':
|
|
146
|
+
return isInNodeModules(specifier)
|
|
147
|
+
? handlePackageOrFile(input, containingFilePath, workspace)
|
|
148
|
+
: handleFile(input, containingFilePath, workspace);
|
|
149
|
+
case 'entry':
|
|
150
|
+
return handleFile(input, containingFilePath, workspace);
|
|
132
151
|
}
|
|
133
|
-
}
|
|
152
|
+
};
|
|
134
153
|
};
|