knip 6.44.1 → 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/bun.js +2 -2
- package/dist/binaries/resolvers/index.d.ts +1 -0
- package/dist/binaries/resolvers/index.js +2 -0
- package/dist/binaries/resolvers/npm.js +7 -5
- package/dist/binaries/resolvers/npx.js +15 -12
- package/dist/binaries/resolvers/nub.js +2 -2
- package/dist/binaries/resolvers/vp.d.ts +2 -0
- package/dist/binaries/resolvers/vp.js +52 -0
- package/dist/binaries/util.d.ts +13 -1
- package/dist/binaries/util.js +35 -1
- package/dist/cli.js +10 -84
- package/dist/compilers/scss.js +2 -1
- 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 +37 -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 +25 -6
- package/dist/plugins/babel/types.d.ts +1 -0
- 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/gatsby/index.js +1 -1
- 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 +12 -15
- 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/storybook/index.js +9 -3
- package/dist/plugins/stryker/index.js +2 -2
- package/dist/plugins/stylelint/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/unocss/index.js +3 -0
- 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 +26 -18
- package/dist/plugins/vitest/types.d.ts +1 -0
- 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 +5 -3
- 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 +11 -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 +9 -10
- 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
package/dist/constants.js
CHANGED
|
@@ -22,18 +22,24 @@ export const DT_SCOPE = '@types';
|
|
|
22
22
|
export const PROTOCOL_VIRTUAL = 'virtual:';
|
|
23
23
|
export const PROTOCOL_CLOUDFLARE = 'cloudflare:';
|
|
24
24
|
export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
25
|
+
'alias',
|
|
25
26
|
'amplify',
|
|
26
27
|
'aws',
|
|
27
28
|
'az',
|
|
28
29
|
'base64',
|
|
29
30
|
'basename',
|
|
30
31
|
'bash',
|
|
32
|
+
'bg',
|
|
33
|
+
'bind',
|
|
34
|
+
'break',
|
|
35
|
+
'builtin',
|
|
31
36
|
'bun',
|
|
32
37
|
'bundle',
|
|
33
38
|
'bunx',
|
|
34
39
|
'cargo',
|
|
35
40
|
'cat',
|
|
36
41
|
'cd',
|
|
42
|
+
'chgrp',
|
|
37
43
|
'chmod',
|
|
38
44
|
'chown',
|
|
39
45
|
'cksum',
|
|
@@ -41,16 +47,20 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
41
47
|
'clear',
|
|
42
48
|
'cmd',
|
|
43
49
|
'cmd.exe',
|
|
50
|
+
'cmp',
|
|
44
51
|
'code',
|
|
45
52
|
'code-insiders',
|
|
46
53
|
'codesign',
|
|
47
54
|
'comm',
|
|
48
55
|
'command',
|
|
56
|
+
'continue',
|
|
49
57
|
'corepack',
|
|
50
58
|
'cp',
|
|
51
59
|
'curl',
|
|
52
60
|
'cut',
|
|
53
61
|
'date',
|
|
62
|
+
'dd',
|
|
63
|
+
'declare',
|
|
54
64
|
'defaults',
|
|
55
65
|
'deno',
|
|
56
66
|
'devtunnel',
|
|
@@ -59,8 +69,10 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
59
69
|
'dirname',
|
|
60
70
|
'docker',
|
|
61
71
|
'dotnet',
|
|
72
|
+
'du',
|
|
62
73
|
'echo',
|
|
63
74
|
'env',
|
|
75
|
+
'eval',
|
|
64
76
|
'exec',
|
|
65
77
|
'exit',
|
|
66
78
|
'expand',
|
|
@@ -68,28 +80,37 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
68
80
|
'expr',
|
|
69
81
|
'factor',
|
|
70
82
|
'false',
|
|
83
|
+
'fg',
|
|
71
84
|
'find',
|
|
72
85
|
'fuser',
|
|
73
86
|
'gem',
|
|
74
87
|
'getconf',
|
|
88
|
+
'getopts',
|
|
75
89
|
'gh',
|
|
76
90
|
'git',
|
|
77
91
|
'grep',
|
|
78
92
|
'groups',
|
|
93
|
+
'gunzip',
|
|
79
94
|
'gzip',
|
|
95
|
+
'hash',
|
|
80
96
|
'head',
|
|
81
97
|
'hg',
|
|
98
|
+
'hostname',
|
|
82
99
|
'id',
|
|
100
|
+
'jobs',
|
|
83
101
|
'join',
|
|
84
102
|
'kill',
|
|
103
|
+
'killall',
|
|
85
104
|
'launchctl',
|
|
86
105
|
'ln',
|
|
106
|
+
'local',
|
|
87
107
|
'logname',
|
|
88
108
|
'ls',
|
|
89
109
|
'lsof',
|
|
90
110
|
'md5sum',
|
|
91
111
|
'mkdir',
|
|
92
112
|
'mknod',
|
|
113
|
+
'mktemp',
|
|
93
114
|
'mv',
|
|
94
115
|
'nc',
|
|
95
116
|
'nice',
|
|
@@ -104,6 +125,8 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
104
125
|
'open',
|
|
105
126
|
'osascript',
|
|
106
127
|
'paste',
|
|
128
|
+
'pgrep',
|
|
129
|
+
'pkill',
|
|
107
130
|
'pnpm',
|
|
108
131
|
'pnpx',
|
|
109
132
|
'powershell',
|
|
@@ -118,6 +141,10 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
118
141
|
'python3',
|
|
119
142
|
'raft',
|
|
120
143
|
'railway',
|
|
144
|
+
'read',
|
|
145
|
+
'readlink',
|
|
146
|
+
'realpath',
|
|
147
|
+
'return',
|
|
121
148
|
'rm',
|
|
122
149
|
'rmdir',
|
|
123
150
|
'rsync',
|
|
@@ -129,6 +156,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
129
156
|
'sh',
|
|
130
157
|
'sha1sum',
|
|
131
158
|
'sha512sum',
|
|
159
|
+
'shift',
|
|
132
160
|
'shred',
|
|
133
161
|
'shuf',
|
|
134
162
|
'sleep',
|
|
@@ -143,6 +171,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
143
171
|
'sysctl',
|
|
144
172
|
'systemctl',
|
|
145
173
|
'tac',
|
|
174
|
+
'tail',
|
|
146
175
|
'tar',
|
|
147
176
|
'taskkill',
|
|
148
177
|
'tee',
|
|
@@ -157,10 +186,16 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
|
|
|
157
186
|
'true',
|
|
158
187
|
'tsort',
|
|
159
188
|
'tty',
|
|
189
|
+
'type',
|
|
190
|
+
'ulimit',
|
|
191
|
+
'umask',
|
|
192
|
+
'unalias',
|
|
160
193
|
'uname',
|
|
161
194
|
'unexpand',
|
|
162
195
|
'uniq',
|
|
196
|
+
'unset',
|
|
163
197
|
'unzip',
|
|
198
|
+
'wait',
|
|
164
199
|
'wc',
|
|
165
200
|
'which',
|
|
166
201
|
'who',
|
|
@@ -210,6 +245,7 @@ export const IGNORE_DEFINITELY_TYPED = new Set([
|
|
|
210
245
|
]);
|
|
211
246
|
export const ISSUE_TYPES = [
|
|
212
247
|
'files',
|
|
248
|
+
'subpaths',
|
|
213
249
|
'dependencies',
|
|
214
250
|
'devDependencies',
|
|
215
251
|
'optionalPeerDependencies',
|
|
@@ -229,6 +265,7 @@ export const ISSUE_TYPES = [
|
|
|
229
265
|
];
|
|
230
266
|
export const ISSUE_TYPE_TITLE = {
|
|
231
267
|
files: 'Unused files',
|
|
268
|
+
subpaths: 'Unused subpaths',
|
|
232
269
|
dependencies: 'Unused dependencies',
|
|
233
270
|
devDependencies: 'Unused devDependencies',
|
|
234
271
|
optionalPeerDependencies: 'Referenced optional peerDependencies',
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ConfigurationChief, Workspace } from '../ConfigurationChief.ts';
|
|
2
|
+
import type { ProjectPrincipal } from '../ProjectPrincipal.ts';
|
|
3
|
+
import type { Issue } from '../types/issues.ts';
|
|
4
|
+
import type { Input } from '../util/input.ts';
|
|
5
|
+
import type { WorkspacePackageTargetHandler } from '../util/to-source-path.ts';
|
|
6
|
+
interface SubpathReferencesOptions {
|
|
7
|
+
chief: ConfigurationChief;
|
|
8
|
+
principal: ProjectPrincipal;
|
|
9
|
+
workspaces: Workspace[];
|
|
10
|
+
findWorkspacePackageTarget: WorkspacePackageTargetHandler;
|
|
11
|
+
isGitIgnored: (filePath: string) => boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class SubpathReferences {
|
|
14
|
+
private chief;
|
|
15
|
+
private principal;
|
|
16
|
+
private workspaces;
|
|
17
|
+
private findWorkspacePackageTarget;
|
|
18
|
+
private isGitIgnored;
|
|
19
|
+
private extensions;
|
|
20
|
+
private isActive;
|
|
21
|
+
private inputs;
|
|
22
|
+
private seen;
|
|
23
|
+
private referenced;
|
|
24
|
+
constructor({ chief, principal, workspaces, findWorkspacePackageTarget, isGitIgnored }: SubpathReferencesOptions);
|
|
25
|
+
private isSubpathSpecifier;
|
|
26
|
+
addInput(input: Input, owner: string): void;
|
|
27
|
+
add(specifier: string, containingFilePath: string): void;
|
|
28
|
+
release(owner: string): void;
|
|
29
|
+
reset(): void;
|
|
30
|
+
getIssues(): Issue[];
|
|
31
|
+
private hasModuleTarget;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { DEFAULT_EXTENSIONS } from '../constants.js';
|
|
2
|
+
import { PackagePeeker } from '../PackagePeeker.js';
|
|
3
|
+
import { isFile } from '../util/fs.js';
|
|
4
|
+
import { getPackageNameFromModuleSpecifier, sanitizeSpecifier } from '../util/modules.js';
|
|
5
|
+
import { getEntriesFromExports, getExportEntries, getPackageTargetPaths } from '../util/package-json.js';
|
|
6
|
+
import { extname, join } from '../util/path.js';
|
|
7
|
+
export class SubpathReferences {
|
|
8
|
+
chief;
|
|
9
|
+
principal;
|
|
10
|
+
workspaces;
|
|
11
|
+
findWorkspacePackageTarget;
|
|
12
|
+
isGitIgnored;
|
|
13
|
+
extensions = [];
|
|
14
|
+
isActive = false;
|
|
15
|
+
inputs = new Map();
|
|
16
|
+
seen = new Set();
|
|
17
|
+
referenced = new Map();
|
|
18
|
+
constructor({ chief, principal, workspaces, findWorkspacePackageTarget, isGitIgnored }) {
|
|
19
|
+
this.chief = chief;
|
|
20
|
+
this.principal = principal;
|
|
21
|
+
this.workspaces = workspaces;
|
|
22
|
+
this.findWorkspacePackageTarget = findWorkspacePackageTarget;
|
|
23
|
+
this.isGitIgnored = isGitIgnored;
|
|
24
|
+
}
|
|
25
|
+
isSubpathSpecifier(specifier) {
|
|
26
|
+
if (specifier.startsWith('#'))
|
|
27
|
+
return true;
|
|
28
|
+
const packageName = getPackageNameFromModuleSpecifier(specifier);
|
|
29
|
+
return packageName !== undefined && this.chief.isWorkspacePackageName(packageName);
|
|
30
|
+
}
|
|
31
|
+
addInput(input, owner) {
|
|
32
|
+
const { specifier, containingFilePath, dir } = input;
|
|
33
|
+
if (!containingFilePath || !this.isSubpathSpecifier(specifier))
|
|
34
|
+
return;
|
|
35
|
+
const filePath = dir ? join(dir, 'package.json') : containingFilePath;
|
|
36
|
+
const references = this.inputs.get(owner);
|
|
37
|
+
if (references)
|
|
38
|
+
references.push([specifier, filePath]);
|
|
39
|
+
else
|
|
40
|
+
this.inputs.set(owner, [[specifier, filePath]]);
|
|
41
|
+
if (this.isActive)
|
|
42
|
+
this.add(specifier, filePath);
|
|
43
|
+
}
|
|
44
|
+
add(specifier, containingFilePath) {
|
|
45
|
+
const workspace = this.chief.findWorkspaceByFilePath(containingFilePath);
|
|
46
|
+
const id = `${workspace?.name ?? ''}\0${specifier}`;
|
|
47
|
+
if (this.seen.has(id))
|
|
48
|
+
return;
|
|
49
|
+
this.seen.add(id);
|
|
50
|
+
const target = this.findWorkspacePackageTarget(sanitizeSpecifier(specifier), containingFilePath);
|
|
51
|
+
if (!target)
|
|
52
|
+
return;
|
|
53
|
+
const subpaths = this.referenced.get(target.name);
|
|
54
|
+
if (subpaths)
|
|
55
|
+
subpaths.add(target.subpath);
|
|
56
|
+
else
|
|
57
|
+
this.referenced.set(target.name, new Set([target.subpath]));
|
|
58
|
+
for (const targetPath of getPackageTargetPaths(target.target, target.dir, target.patternMatch, true)) {
|
|
59
|
+
const filePath = this.principal.toSourceFilePath(targetPath, this.extensions) ?? (isFile(targetPath) ? targetPath : undefined);
|
|
60
|
+
if (filePath && !this.isGitIgnored(filePath))
|
|
61
|
+
this.principal.claimEntryPath(filePath);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
release(owner) {
|
|
65
|
+
this.inputs.delete(owner);
|
|
66
|
+
}
|
|
67
|
+
reset() {
|
|
68
|
+
this.isActive = true;
|
|
69
|
+
this.extensions = [...DEFAULT_EXTENSIONS, ...this.principal.compilers.keys()];
|
|
70
|
+
this.seen.clear();
|
|
71
|
+
this.referenced.clear();
|
|
72
|
+
this.principal.releaseEntryClaims();
|
|
73
|
+
for (const references of this.inputs.values()) {
|
|
74
|
+
for (const [specifier, containingFilePath] of references)
|
|
75
|
+
this.add(specifier, containingFilePath);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
getIssues() {
|
|
79
|
+
const issues = [];
|
|
80
|
+
for (const { name, manifestPath, manifestStr, config } of this.workspaces) {
|
|
81
|
+
const manifest = this.chief.getManifestForWorkspace(name);
|
|
82
|
+
if (!manifest)
|
|
83
|
+
continue;
|
|
84
|
+
const referenced = this.referenced.get(name);
|
|
85
|
+
const peeker = new PackagePeeker(manifestStr);
|
|
86
|
+
const addIssue = (section, key) => {
|
|
87
|
+
issues.push({
|
|
88
|
+
type: 'subpaths',
|
|
89
|
+
filePath: manifestPath,
|
|
90
|
+
workspace: name,
|
|
91
|
+
symbol: key,
|
|
92
|
+
...(peeker.getPropertyLocation(section, key) ?? peeker.getPropertyLocation(section)),
|
|
93
|
+
fixes: [],
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
if (manifest.imports) {
|
|
97
|
+
for (const key in manifest.imports) {
|
|
98
|
+
if (key.startsWith('#') && manifest.imports[key] !== null && !referenced?.has(key))
|
|
99
|
+
addIssue('imports', key);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (manifest.exports && config.isIncludeSubpathExports) {
|
|
103
|
+
for (const [key, value] of getExportEntries(manifest.exports)) {
|
|
104
|
+
if (value !== null && !referenced?.has(key) && this.hasModuleTarget(value))
|
|
105
|
+
addIssue('exports', key);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return issues;
|
|
110
|
+
}
|
|
111
|
+
hasModuleTarget(value) {
|
|
112
|
+
return getEntriesFromExports(value).some(target => !extname(target) || this.principal.hasAcceptedExtension(target));
|
|
113
|
+
}
|
|
114
|
+
}
|
package/dist/graph/analyze.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { DependencyDeputy } from '../DependencyDeputy.ts';
|
|
|
5
5
|
import type { IssueCollector } from '../IssueCollector.ts';
|
|
6
6
|
import type { ModuleGraph } from '../types/module-graph.ts';
|
|
7
7
|
import type { MainOptions } from '../util/create-options.ts';
|
|
8
|
+
import type { SubpathReferences } from './SubpathReferences.ts';
|
|
8
9
|
interface AnalyzeOptions {
|
|
9
10
|
analyzedFiles: Set<string>;
|
|
10
11
|
counselor: CatalogCounselor;
|
|
@@ -13,9 +14,11 @@ interface AnalyzeOptions {
|
|
|
13
14
|
deputy: DependencyDeputy;
|
|
14
15
|
entryPaths: Set<string>;
|
|
15
16
|
graph: ModuleGraph;
|
|
17
|
+
isGitIgnored: (filePath: string) => boolean;
|
|
16
18
|
streamer: ConsoleStreamer;
|
|
19
|
+
subpathReferences: SubpathReferences;
|
|
17
20
|
unreferencedFiles: Set<string>;
|
|
18
21
|
options: MainOptions;
|
|
19
22
|
}
|
|
20
|
-
export declare const analyze: ({ analyzedFiles, counselor, chief, collector, deputy, entryPaths, graph, streamer, unreferencedFiles, options, }: AnalyzeOptions) => Promise<() => Promise<void>>;
|
|
23
|
+
export declare const analyze: ({ analyzedFiles, counselor, chief, collector, deputy, entryPaths, graph, isGitIgnored, streamer, subpathReferences, unreferencedFiles, options, }: AnalyzeOptions) => Promise<() => Promise<void>>;
|
|
21
24
|
export {};
|
package/dist/graph/analyze.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getUnusedIgnorePatternHints, settleConfigurationHints } from '../configuration-hints.js';
|
|
1
2
|
import { createGraphExplorer } from '../graph-explorer/explorer.js';
|
|
2
3
|
import { getIgnoredCycleImportFlags, getIssueType, getRuntimeImport, hasStrictlyEnumReferences, } from '../graph-explorer/utils.js';
|
|
3
4
|
import traceReporter from '../reporters/trace.js';
|
|
@@ -22,7 +23,7 @@ const getAllowedCyclePaths = (cycles) => {
|
|
|
22
23
|
return paths;
|
|
23
24
|
};
|
|
24
25
|
const isAllowedCycle = (symbols, paths) => paths?.has(toCyclePathKey(symbols.map(s => s.symbol))) ?? false;
|
|
25
|
-
export const analyze = async ({ analyzedFiles, counselor, chief, collector, deputy, entryPaths, graph, streamer, unreferencedFiles, options, }) => {
|
|
26
|
+
export const analyze = async ({ analyzedFiles, counselor, chief, collector, deputy, entryPaths, graph, isGitIgnored, streamer, subpathReferences, unreferencedFiles, options, }) => {
|
|
26
27
|
const shouldIgnore = getShouldIgnoreHandler(options.isProduction);
|
|
27
28
|
const shouldIgnoreTags = getShouldIgnoreTagHandler(options.tags);
|
|
28
29
|
const explorer = createGraphExplorer(graph, entryPaths, options.isSession);
|
|
@@ -102,7 +103,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
};
|
|
105
|
-
const analyzeGraph = async () => {
|
|
106
|
+
const analyzeGraph = timerify(async () => {
|
|
106
107
|
if (options.isReportValues || options.isReportTypes) {
|
|
107
108
|
streamer.cast('Connecting the dots');
|
|
108
109
|
for (const [filePath, file] of graph) {
|
|
@@ -289,6 +290,8 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
289
290
|
if (options.isReportFiles)
|
|
290
291
|
collector.addFilesIssues(unusedFiles);
|
|
291
292
|
collector.addFileCounts({ processed: analyzedFiles.size, unused: unusedFiles.length });
|
|
293
|
+
for (const issue of subpathReferences.getIssues())
|
|
294
|
+
collector.addIssue(issue);
|
|
292
295
|
if (options.isReportDependencies) {
|
|
293
296
|
const { dependencyIssues, devDependencyIssues, optionalPeerDependencyIssues } = deputy.settleDependencyIssues();
|
|
294
297
|
for (const issue of dependencyIssues)
|
|
@@ -314,12 +317,20 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
314
317
|
for (const identifier of unusedIgnoredWorkspaces) {
|
|
315
318
|
collector.addConfigurationHint({ type: 'ignoreWorkspaces', identifier });
|
|
316
319
|
}
|
|
317
|
-
|
|
318
|
-
collector.
|
|
320
|
+
if (options.isReportFiles) {
|
|
321
|
+
const patterns = collector.getUnusedIgnorePatterns();
|
|
322
|
+
const filePaths = [graph.keys(), unreferencedFiles];
|
|
323
|
+
const context = { cwd: options.cwd, filePaths, isGitIgnored };
|
|
324
|
+
for (const hint of getUnusedIgnorePatternHints(patterns, context))
|
|
325
|
+
collector.addConfigurationHint(hint);
|
|
319
326
|
}
|
|
320
327
|
for (const hint of chief.getConfigurationHints())
|
|
321
328
|
collector.addConfigurationHint(hint);
|
|
322
|
-
|
|
329
|
+
const hints = settleConfigurationHints(collector.getConfigurationHintCandidates(), {
|
|
330
|
+
countWorkspaces: configKey => chief.countWorkspacesForConfigKey(configKey),
|
|
331
|
+
});
|
|
332
|
+
collector.setConfigurationHints(hints);
|
|
333
|
+
}, 'analyzeGraph');
|
|
323
334
|
await analyzeGraph();
|
|
324
335
|
perfObserver.addMemoryMark('analyze');
|
|
325
336
|
if (options.isTrace) {
|
package/dist/graph/build.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { ProjectPrincipal } from '../ProjectPrincipal.ts';
|
|
|
8
8
|
import type { ModuleGraph } from '../types/module-graph.ts';
|
|
9
9
|
import type { MainOptions } from '../util/create-options.ts';
|
|
10
10
|
import { ConfigurationFiles } from '../session/configuration.ts';
|
|
11
|
+
import type { SubpathReferences } from './SubpathReferences.ts';
|
|
11
12
|
interface BuildOptions {
|
|
12
13
|
chief: ConfigurationChief;
|
|
13
14
|
collector: IssueCollector;
|
|
@@ -17,10 +18,11 @@ interface BuildOptions {
|
|
|
17
18
|
isGitIgnored: (path: string) => boolean;
|
|
18
19
|
scriptParserContext: ScriptParserContext;
|
|
19
20
|
streamer: ConsoleStreamer;
|
|
21
|
+
subpathReferences: SubpathReferences;
|
|
20
22
|
workspaces: Workspace[];
|
|
21
23
|
options: MainOptions;
|
|
22
24
|
}
|
|
23
|
-
export declare
|
|
25
|
+
export declare const build: ({ chief, collector, counselor, deputy, principal, isGitIgnored, scriptParserContext, streamer, subpathReferences, workspaces, options, }: BuildOptions) => Promise<{
|
|
24
26
|
graph: ModuleGraph;
|
|
25
27
|
configurationFiles: ConfigurationFiles | undefined;
|
|
26
28
|
entryPaths: Set<string>;
|
package/dist/graph/build.js
CHANGED
|
@@ -8,24 +8,25 @@ import { ConfigurationFiles } from '../session/configuration.js';
|
|
|
8
8
|
import { debugLog, debugLogArray } from '../util/debug.js';
|
|
9
9
|
import { existsSync } from 'node:fs';
|
|
10
10
|
import picomatch from 'picomatch';
|
|
11
|
+
import { isDynamicPattern } from 'tinyglobby';
|
|
11
12
|
import { tryRealpath } from '../util/fs.js';
|
|
12
13
|
import { createManifest } from '../util/package-json.js';
|
|
13
14
|
import { _glob, _syncGlob, prependDirToPattern as prependDir, rebasePattern, removeProductionSuffix, } from '../util/glob.js';
|
|
14
|
-
import { isAlias, isCatalog, isConfig,
|
|
15
|
+
import { isAlias, isCatalog, isConfig, isEntry, isIgnore, isProductionEntry, isProject, toDeferResolveEntry, toDependency, toProductionEntry, } from '../util/input.js';
|
|
15
16
|
import { isAmbientDeclarationFile } from '../typescript/ast-nodes.js';
|
|
16
17
|
import { resolveImportGlobs } from '../typescript/glob-imports.js';
|
|
17
18
|
import { createPublishedTypeDependencyAnalyzer } from '../typescript/get-published-type-dependencies.js';
|
|
18
19
|
import { loadTSConfig } from '../util/load-tsconfig.js';
|
|
19
20
|
import { createFileNode, updateImportMap } from '../util/module-graph.js';
|
|
20
21
|
import { getPackageNameFromModuleSpecifier, isStartsLikePackageName, sanitizeSpecifier } from '../util/modules.js';
|
|
21
|
-
import { perfObserver } from '../util/Performance.js';
|
|
22
|
+
import { perfObserver, timerify } from '../util/Performance.js';
|
|
22
23
|
import { getEntrySpecifiersFromManifest, getManifestImportDependencies } from '../util/package-json.js';
|
|
23
24
|
import { expandIgnorePatterns } from '../util/parse-and-convert-gitignores.js';
|
|
24
25
|
import { dirname, extname, isAbsolute, isInNodeModules, isInternal, join, relative } from '../util/path.js';
|
|
25
26
|
import { extensionAlias } from '../util/resolve.js';
|
|
26
27
|
import { augmentWorkspace, getToSourcePathsHandler, toSourceMappedSpecifiers } from '../util/to-source-path.js';
|
|
27
28
|
import { WorkspaceWorker } from '../WorkspaceWorker.js';
|
|
28
|
-
export async function build({ chief, collector, counselor, deputy, principal, isGitIgnored, scriptParserContext, streamer, workspaces, options, }) {
|
|
29
|
+
export const build = timerify(async function build({ chief, collector, counselor, deputy, principal, isGitIgnored, scriptParserContext, streamer, subpathReferences, workspaces, options, }) {
|
|
29
30
|
const configFilesMap = new Map();
|
|
30
31
|
const configurationFiles = options.isSession ? new ConfigurationFiles(options) : undefined;
|
|
31
32
|
const enabledPluginsStore = new Map();
|
|
@@ -33,7 +34,11 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
33
34
|
const toSourceFilePaths = getToSourcePathsHandler(chief);
|
|
34
35
|
const addIssue = (issue) => collector.addIssue(issue) && options.isSession && collector.retainIssue(issue);
|
|
35
36
|
const externalRefsFromInputs = options.isSession ? new Map() : undefined;
|
|
36
|
-
const
|
|
37
|
+
const resolveInput = createInputHandler(deputy, chief, isGitIgnored, addIssue, externalRefsFromInputs, options);
|
|
38
|
+
const handleInput = (input, workspace, owner = workspace.manifestPath) => {
|
|
39
|
+
subpathReferences.addInput(input, owner);
|
|
40
|
+
return resolveInput(input, workspace);
|
|
41
|
+
};
|
|
37
42
|
const getPublishedTypeDependencies = options.isReportDependencies
|
|
38
43
|
? createPublishedTypeDependencyAnalyzer()
|
|
39
44
|
: undefined;
|
|
@@ -88,9 +93,11 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
88
93
|
const worker = new WorkspaceWorker({
|
|
89
94
|
name,
|
|
90
95
|
dir,
|
|
96
|
+
configKey: workspace.configKey,
|
|
91
97
|
config: baseConfig,
|
|
92
98
|
manifest,
|
|
93
99
|
dependencies,
|
|
100
|
+
allDependencies: deputy.getAllDependencies(name),
|
|
94
101
|
rootManifest,
|
|
95
102
|
handleInput: (input) => handleInput(input, workspace),
|
|
96
103
|
handleConfigLoadError: () => collector.addConfigLoadError(),
|
|
@@ -127,10 +134,15 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
127
134
|
inputs.add(toProductionEntry(tryRealpath(id), { containingFilePath: tsConfigFilePath }));
|
|
128
135
|
}
|
|
129
136
|
const sharedGlobOptions = { cwd: options.cwd, dir, gitignore: options.gitignore };
|
|
130
|
-
const fn = (id) => ({
|
|
137
|
+
const fn = (id) => ({
|
|
138
|
+
pattern: prependDir(name, id),
|
|
139
|
+
id,
|
|
140
|
+
workspaceName: name,
|
|
141
|
+
configKey: workspace.configKey,
|
|
142
|
+
});
|
|
131
143
|
collector.addIgnorePatterns(config.ignore.map(fn));
|
|
132
144
|
collector.addIgnoreFilesPatterns(config.ignoreFiles.map(fn));
|
|
133
|
-
const entrySpecifiersFromManifest = getEntrySpecifiersFromManifest(manifest);
|
|
145
|
+
const entrySpecifiersFromManifest = getEntrySpecifiersFromManifest(manifest, config.isIncludeSubpathExports);
|
|
134
146
|
const label = 'entry paths from package.json';
|
|
135
147
|
for (const filePath of await toSourceFilePaths(entrySpecifiersFromManifest, dir, extensionGlobStr, label)) {
|
|
136
148
|
if (!isGitIgnored(filePath))
|
|
@@ -200,6 +212,7 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
200
212
|
const productionPatterns = createPatternMap();
|
|
201
213
|
const productionPatternsSkipExports = createPatternMap();
|
|
202
214
|
const projectFilePatterns = new Set();
|
|
215
|
+
const developmentFilePaths = new Set();
|
|
203
216
|
const addPattern = (map, group, pattern) => {
|
|
204
217
|
let patterns = map.get(group);
|
|
205
218
|
if (!patterns)
|
|
@@ -252,12 +265,12 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
252
265
|
const ws = (input.containingFilePath && chief.findWorkspaceByFilePath(input.containingFilePath)) || workspace;
|
|
253
266
|
const resolvedFilePath = handleInput(input, ws);
|
|
254
267
|
if (resolvedFilePath) {
|
|
255
|
-
if (
|
|
268
|
+
if (options.isProduction && !input.production) {
|
|
256
269
|
if (!input.optional)
|
|
257
|
-
|
|
270
|
+
developmentFilePaths.add(resolvedFilePath);
|
|
258
271
|
}
|
|
259
272
|
else {
|
|
260
|
-
principal.addEntryPath(resolvedFilePath, { skipExportsAnalysis: true });
|
|
273
|
+
principal.addEntryPath(resolvedFilePath, { skipExportsAnalysis: input.skipExportsAnalysis ?? true });
|
|
261
274
|
}
|
|
262
275
|
}
|
|
263
276
|
}
|
|
@@ -359,8 +372,10 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
359
372
|
for (const hint of hints)
|
|
360
373
|
collector.addConfigurationHint(hint);
|
|
361
374
|
}
|
|
362
|
-
for (const projectPath of productionPaths(projectPaths))
|
|
363
|
-
|
|
375
|
+
for (const projectPath of productionPaths(projectPaths)) {
|
|
376
|
+
if (!developmentFilePaths.has(projectPath))
|
|
377
|
+
principal.addProjectPath(projectPath);
|
|
378
|
+
}
|
|
364
379
|
}
|
|
365
380
|
worker.onDispose();
|
|
366
381
|
perfObserver.addMemoryMark(name);
|
|
@@ -369,8 +384,6 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
369
384
|
const graph = new Map();
|
|
370
385
|
const analyzedFiles = new Set();
|
|
371
386
|
const unreferencedFiles = new Set();
|
|
372
|
-
const entryPaths = new Set();
|
|
373
|
-
const isInternalWorkspace = (packageName) => chief.availableWorkspacePkgNames.has(packageName);
|
|
374
387
|
const analyzeOpts = {
|
|
375
388
|
isFixExports: options.isFixUnusedExports,
|
|
376
389
|
isFixTypes: options.isFixUnusedTypes,
|
|
@@ -382,6 +395,7 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
382
395
|
if (!options.isSession && analyzedFiles.has(filePath))
|
|
383
396
|
return;
|
|
384
397
|
analyzedFiles.add(filePath);
|
|
398
|
+
subpathReferences.release(filePath);
|
|
385
399
|
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
386
400
|
if (workspace) {
|
|
387
401
|
const file = principal.analyzeSourceFile(filePath, sourceText, analyzeOpts, workspace.config.ignoreExportsUsedInFile, parseResult, cachedFile);
|
|
@@ -393,6 +407,7 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
393
407
|
const sanitizedSpecifier = sanitizeSpecifier(specifier);
|
|
394
408
|
if (isStartsLikePackageName(sanitizedSpecifier)) {
|
|
395
409
|
file.imports.external.add({ ...unresolvedImport, specifier: sanitizedSpecifier });
|
|
410
|
+
subpathReferences.add(sanitizedSpecifier, filePath);
|
|
396
411
|
}
|
|
397
412
|
else {
|
|
398
413
|
const candidate = join(dirname(filePath), sanitizedSpecifier);
|
|
@@ -423,6 +438,10 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
423
438
|
if (!isIgnored)
|
|
424
439
|
principal.addEntryPath(filePath, { skipExportsAnalysis: true });
|
|
425
440
|
}
|
|
441
|
+
if (file.imports.subpathImports) {
|
|
442
|
+
for (const specifier of file.imports.subpathImports)
|
|
443
|
+
subpathReferences.add(specifier, filePath);
|
|
444
|
+
}
|
|
426
445
|
const wsDependencies = deputy.getDependencies(workspace.name);
|
|
427
446
|
for (const _import of file.imports.imports) {
|
|
428
447
|
if (!_import.filePath)
|
|
@@ -430,12 +449,11 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
430
449
|
const packageName = getPackageNameFromModuleSpecifier(_import.specifier);
|
|
431
450
|
if (!packageName)
|
|
432
451
|
continue;
|
|
433
|
-
const isWorkspace =
|
|
452
|
+
const isWorkspace = chief.isWorkspacePackageName(packageName);
|
|
434
453
|
if (isWorkspace || wsDependencies.has(packageName)) {
|
|
435
454
|
file.imports.external.add({ ..._import, specifier: packageName });
|
|
436
|
-
if (isWorkspace
|
|
437
|
-
|
|
438
|
-
}
|
|
455
|
+
if (isWorkspace)
|
|
456
|
+
subpathReferences.add(_import.specifier, filePath);
|
|
439
457
|
}
|
|
440
458
|
}
|
|
441
459
|
const manifest = chief.getManifestForWorkspace(workspace.name);
|
|
@@ -462,7 +480,14 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
462
480
|
input.dir ??= dir;
|
|
463
481
|
if (options.isProduction)
|
|
464
482
|
input.production = true;
|
|
465
|
-
|
|
483
|
+
if (input.type === 'entry' && isDynamicPattern(input.specifier)) {
|
|
484
|
+
for (const entryPath of _syncGlob({ patterns: input.specifier, cwd: input.dir })) {
|
|
485
|
+
if (!isGitIgnored(entryPath))
|
|
486
|
+
principal.addEntryPath(entryPath, { skipExportsAnalysis: true });
|
|
487
|
+
}
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
const specifierFilePath = handleInput(input, workspace, filePath);
|
|
466
491
|
if (specifierFilePath)
|
|
467
492
|
principal.addEntryPath(specifierFilePath, { skipExportsAnalysis: true });
|
|
468
493
|
}
|
|
@@ -504,6 +529,7 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
504
529
|
}
|
|
505
530
|
};
|
|
506
531
|
principal.init();
|
|
532
|
+
subpathReferences.reset();
|
|
507
533
|
streamer.cast('Analyzing source files');
|
|
508
534
|
await principal.walkAndAnalyze((filePath, parseResult, sourceText, cachedFile) => {
|
|
509
535
|
analyzeSourceFile(filePath, sourceText, parseResult, cachedFile);
|
|
@@ -516,7 +542,7 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
516
542
|
paths.push(importPath);
|
|
517
543
|
}
|
|
518
544
|
return paths;
|
|
519
|
-
});
|
|
545
|
+
}, (specifier, filePath) => subpathReferences.add(specifier, filePath));
|
|
520
546
|
for (const filePath of principal.getUnreferencedFiles()) {
|
|
521
547
|
if (IS_DTS.test(filePath)) {
|
|
522
548
|
const loaded = principal.fileManager.loadSourceText(filePath);
|
|
@@ -527,8 +553,6 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
527
553
|
}
|
|
528
554
|
unreferencedFiles.add(filePath);
|
|
529
555
|
}
|
|
530
|
-
for (const filePath of principal.entryPaths)
|
|
531
|
-
entryPaths.add(filePath);
|
|
532
556
|
principal.reconcileCache();
|
|
533
557
|
perfObserver.addMemoryMark('build');
|
|
534
558
|
if (externalRefsFromInputs) {
|
|
@@ -542,7 +566,7 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
542
566
|
return {
|
|
543
567
|
graph,
|
|
544
568
|
configurationFiles,
|
|
545
|
-
entryPaths,
|
|
569
|
+
entryPaths: principal.entryPaths,
|
|
546
570
|
analyzedFiles,
|
|
547
571
|
unreferencedFiles,
|
|
548
572
|
analyzeSourceFile: async (filePath) => {
|
|
@@ -552,4 +576,4 @@ export async function build({ chief, collector, counselor, deputy, principal, is
|
|
|
552
576
|
},
|
|
553
577
|
enabledPluginsStore,
|
|
554
578
|
};
|
|
555
|
-
}
|
|
579
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isBuiltin } from 'node:module';
|
|
2
1
|
import { IMPORT_FLAGS, IMPORT_STAR } from '../../constants.js';
|
|
2
|
+
import { isBuiltin } from '../../util/modules.js';
|
|
3
3
|
import { getCachedExportTable, setCachedExportTable } from '../cache.js';
|
|
4
4
|
import { forEachAliasReExport, forEachNamespaceReExport, forEachPassThroughReExport, getStarReExportSources, } from '../visitors.js';
|
|
5
5
|
const originKey = (origin) => origin.filePath + '\0' + origin.identifier;
|