knip 6.44.2 → 6.45.1

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.
Files changed (226) hide show
  1. package/dist/ConfigurationChief.d.ts +23 -1033
  2. package/dist/ConfigurationChief.js +71 -15
  3. package/dist/DependencyDeputy.d.ts +10 -6
  4. package/dist/DependencyDeputy.js +51 -27
  5. package/dist/IssueCollector.d.ts +14 -11
  6. package/dist/IssueCollector.js +25 -20
  7. package/dist/IssueFixer.js +1 -1
  8. package/dist/PackagePeeker.d.ts +6 -0
  9. package/dist/PackagePeeker.js +43 -14
  10. package/dist/ProjectPrincipal.d.ts +6 -3
  11. package/dist/ProjectPrincipal.js +83 -32
  12. package/dist/WorkspaceWorker.d.ts +5 -1
  13. package/dist/WorkspaceWorker.js +39 -22
  14. package/dist/binaries/bash-parser.js +1 -7
  15. package/dist/binaries/command.d.ts +3 -3
  16. package/dist/binaries/command.js +6 -2
  17. package/dist/binaries/fallback.js +1 -1
  18. package/dist/binaries/plugins.d.ts +4 -1
  19. package/dist/binaries/plugins.js +66 -18
  20. package/dist/binaries/resolvers/npm.js +7 -5
  21. package/dist/binaries/resolvers/npx.js +8 -40
  22. package/dist/binaries/util.d.ts +13 -1
  23. package/dist/binaries/util.js +35 -1
  24. package/dist/cli.js +10 -84
  25. package/dist/configuration-hints.d.ts +16 -0
  26. package/dist/configuration-hints.js +64 -0
  27. package/dist/constants.d.ts +2 -1
  28. package/dist/constants.js +2 -0
  29. package/dist/graph/SubpathReferences.d.ts +33 -0
  30. package/dist/graph/SubpathReferences.js +114 -0
  31. package/dist/graph/analyze.d.ts +4 -1
  32. package/dist/graph/analyze.js +16 -5
  33. package/dist/graph/build.d.ts +3 -1
  34. package/dist/graph/build.js +47 -23
  35. package/dist/graph-explorer/operations/resolve-export-origins.js +1 -1
  36. package/dist/plugins/angular/index.js +10 -17
  37. package/dist/plugins/aws-cdk/index.d.ts +3 -0
  38. package/dist/plugins/aws-cdk/index.js +32 -0
  39. package/dist/plugins/aws-cdk/types.d.ts +5 -0
  40. package/dist/plugins/aws-cdk/types.js +1 -0
  41. package/dist/plugins/babel/index.d.ts +1 -1
  42. package/dist/plugins/babel/index.js +19 -5
  43. package/dist/plugins/bun/index.js +8 -7
  44. package/dist/plugins/c8/index.js +17 -4
  45. package/dist/plugins/changesets/index.js +3 -2
  46. package/dist/plugins/commitizen/index.js +6 -3
  47. package/dist/plugins/commitlint/index.js +10 -11
  48. package/dist/plugins/cypress/index.js +4 -2
  49. package/dist/plugins/danger/index.js +1 -1
  50. package/dist/plugins/docusaurus/helpers.js +6 -6
  51. package/dist/plugins/docusaurus/index.js +2 -2
  52. package/dist/plugins/electron-forge/index.js +2 -2
  53. package/dist/plugins/electron-vite/index.js +2 -2
  54. package/dist/plugins/eleventy/index.js +3 -2
  55. package/dist/plugins/eslint/helpers.js +4 -3
  56. package/dist/plugins/eslint/resolveFromAST.js +2 -2
  57. package/dist/plugins/evalite/index.d.ts +3 -0
  58. package/dist/plugins/evalite/index.js +26 -0
  59. package/dist/plugins/flue/index.js +2 -2
  60. package/dist/plugins/github-action/index.js +2 -2
  61. package/dist/plugins/github-actions/index.js +2 -2
  62. package/dist/plugins/graphql-codegen/index.js +13 -9
  63. package/dist/plugins/index.d.ts +5 -0
  64. package/dist/plugins/index.js +10 -0
  65. package/dist/plugins/jest/index.js +5 -5
  66. package/dist/plugins/knex/index.js +2 -2
  67. package/dist/plugins/laravel-vite-plugin/resolveFromAST.js +2 -2
  68. package/dist/plugins/lunaria/index.js +5 -2
  69. package/dist/plugins/markdownlint/index.js +8 -2
  70. package/dist/plugins/marko/index.js +2 -2
  71. package/dist/plugins/marko/taglibs.d.ts +1 -1
  72. package/dist/plugins/marko/taglibs.js +4 -28
  73. package/dist/plugins/mdx/index.d.ts +2 -1
  74. package/dist/plugins/mdx/index.js +7 -4
  75. package/dist/plugins/mdxlint/index.js +18 -15
  76. package/dist/plugins/mikro-orm/index.d.ts +3 -0
  77. package/dist/plugins/mikro-orm/index.js +77 -0
  78. package/dist/plugins/mikro-orm/types.d.ts +21 -0
  79. package/dist/plugins/mikro-orm/types.js +1 -0
  80. package/dist/plugins/msw/index.js +6 -3
  81. package/dist/plugins/msw/types.d.ts +1 -1
  82. package/dist/plugins/netlify/index.js +7 -3
  83. package/dist/plugins/next/index.js +63 -9
  84. package/dist/plugins/next/types.d.ts +5 -0
  85. package/dist/plugins/next-mdx/resolveFromAST.js +15 -10
  86. package/dist/plugins/nitro/index.js +5 -6
  87. package/dist/plugins/node/index.js +4 -4
  88. package/dist/plugins/npm-package-json-lint/index.js +10 -3
  89. package/dist/plugins/nuxt/index.js +18 -10
  90. package/dist/plugins/nuxt/types.d.ts +4 -0
  91. package/dist/plugins/nx/index.js +6 -3
  92. package/dist/plugins/openclaw/index.js +11 -11
  93. package/dist/plugins/oxlint/index.js +2 -2
  94. package/dist/plugins/panda-css/index.js +5 -0
  95. package/dist/plugins/payload/index.js +1 -1
  96. package/dist/plugins/playwright/index.js +3 -3
  97. package/dist/plugins/pm2/index.js +7 -7
  98. package/dist/plugins/prettier/index.js +2 -1
  99. package/dist/plugins/prisma/index.js +2 -2
  100. package/dist/plugins/quasar/resolveFromAST.js +14 -9
  101. package/dist/plugins/react-router/index.js +2 -2
  102. package/dist/plugins/release-it/index.js +6 -2
  103. package/dist/plugins/remix/index.js +3 -3
  104. package/dist/plugins/retry-cli/index.d.ts +3 -0
  105. package/dist/plugins/retry-cli/index.js +14 -0
  106. package/dist/plugins/rollup/index.js +1 -4
  107. package/dist/plugins/rstest/index.js +3 -3
  108. package/dist/plugins/semantic-release/index.js +3 -3
  109. package/dist/plugins/serverless-framework/index.js +10 -8
  110. package/dist/plugins/solidjs-vite-plugin/resolveFromAST.js +2 -2
  111. package/dist/plugins/stencil/resolveFromAST.js +5 -5
  112. package/dist/plugins/stryker/index.js +2 -2
  113. package/dist/plugins/swc/index.js +4 -3
  114. package/dist/plugins/tailwind/index.js +2 -2
  115. package/dist/plugins/tanstack-router/index.js +2 -2
  116. package/dist/plugins/ts-node/index.js +6 -1
  117. package/dist/plugins/turbo/index.js +3 -3
  118. package/dist/plugins/typedoc/index.js +2 -2
  119. package/dist/plugins/typescript/content-mappers.d.ts +1 -1
  120. package/dist/plugins/typescript/index.js +6 -9
  121. package/dist/plugins/varlock/scan.js +1 -1
  122. package/dist/plugins/vite/helpers.d.ts +1 -0
  123. package/dist/plugins/vite/helpers.js +13 -3
  124. package/dist/plugins/vite/index.js +5 -2
  125. package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +2 -2
  126. package/dist/plugins/vitest/index.js +14 -16
  127. package/dist/plugins/vue/index.js +1 -1
  128. package/dist/plugins/web-test-runner/index.d.ts +3 -0
  129. package/dist/plugins/web-test-runner/index.js +86 -0
  130. package/dist/plugins/webdriver-io/index.js +22 -17
  131. package/dist/plugins/webdriver-io/types.d.ts +3 -2
  132. package/dist/plugins/wrangler/index.js +3 -3
  133. package/dist/plugins/yarn/index.js +5 -5
  134. package/dist/plugins.js +2 -5
  135. package/dist/reporters/github-actions.js +3 -7
  136. package/dist/reporters/json.d.ts +1 -0
  137. package/dist/reporters/json.js +1 -0
  138. package/dist/reporters/util/configuration-hints.d.ts +3 -1
  139. package/dist/reporters/util/configuration-hints.js +40 -21
  140. package/dist/reporters/util/util.d.ts +1 -1
  141. package/dist/run-cli.d.ts +2 -0
  142. package/dist/run-cli.js +82 -0
  143. package/dist/run.js +12 -0
  144. package/dist/session/incremental.d.ts +1 -0
  145. package/dist/session/incremental.js +1 -0
  146. package/dist/session/index.d.ts +1 -0
  147. package/dist/session/index.js +1 -0
  148. package/dist/session/watch.js +2 -1
  149. package/dist/types/PluginNames.d.ts +2 -2
  150. package/dist/types/PluginNames.js +5 -0
  151. package/dist/types/args.d.ts +3 -1
  152. package/dist/types/config.d.ts +17 -10
  153. package/dist/types/configuration.d.ts +45 -0
  154. package/dist/types/configuration.js +1 -0
  155. package/dist/types/issues.d.ts +4 -0
  156. package/dist/types/module-graph.d.ts +1 -0
  157. package/dist/types/options.d.ts +1 -0
  158. package/dist/types/package-json.d.ts +3 -8
  159. package/dist/types/workspace.d.ts +1 -0
  160. package/dist/typescript/ast-nodes.js +47 -1
  161. package/dist/typescript/get-imports-and-exports.js +18 -6
  162. package/dist/typescript/resolve-module-names.js +7 -45
  163. package/dist/typescript/visitors/calls.d.ts +1 -1
  164. package/dist/typescript/visitors/calls.js +14 -10
  165. package/dist/typescript/visitors/exports.js +16 -26
  166. package/dist/typescript/visitors/imports.d.ts +2 -1
  167. package/dist/typescript/visitors/imports.js +41 -24
  168. package/dist/typescript/visitors/members.d.ts +1 -1
  169. package/dist/typescript/visitors/members.js +38 -24
  170. package/dist/typescript/visitors/shadow.d.ts +2 -0
  171. package/dist/typescript/visitors/shadow.js +25 -0
  172. package/dist/typescript/visitors/walk.d.ts +20 -12
  173. package/dist/typescript/visitors/walk.js +78 -48
  174. package/dist/util/Performance.d.ts +25 -3
  175. package/dist/util/Performance.js +51 -27
  176. package/dist/util/cli-arguments.d.ts +2 -1
  177. package/dist/util/cli-arguments.js +4 -2
  178. package/dist/util/create-input-handler.js +138 -119
  179. package/dist/util/create-options.d.ts +4 -2071
  180. package/dist/util/create-options.js +6 -4
  181. package/dist/util/create-workspace-graph.js +2 -1
  182. package/dist/util/errors.d.ts +5 -2
  183. package/dist/util/errors.js +11 -18
  184. package/dist/util/fs.js +4 -2
  185. package/dist/util/get-included-issue-types.js +1 -0
  186. package/dist/util/input.d.ts +2 -2
  187. package/dist/util/input.js +2 -2
  188. package/dist/util/is-plugin-name.d.ts +2 -0
  189. package/dist/util/is-plugin-name.js +3 -0
  190. package/dist/util/jiti.d.ts +2 -1
  191. package/dist/util/jiti.js +10 -3
  192. package/dist/util/load-config.d.ts +1 -1
  193. package/dist/util/load-config.js +3 -2
  194. package/dist/util/loader.js +3 -2
  195. package/dist/util/map-workspaces.js +23 -1
  196. package/dist/util/module-graph.js +1 -0
  197. package/dist/util/modules.d.ts +2 -0
  198. package/dist/util/modules.js +78 -0
  199. package/dist/util/package-json.d.ts +12 -5
  200. package/dist/util/package-json.js +54 -26
  201. package/dist/util/parse-and-convert-gitignores.d.ts +2 -2
  202. package/dist/util/parse-and-convert-gitignores.js +5 -5
  203. package/dist/util/parse-configuration.d.ts +2 -0
  204. package/dist/util/parse-configuration.js +66 -0
  205. package/dist/util/plugin.js +8 -12
  206. package/dist/util/regex.js +10 -1
  207. package/dist/util/resolve.d.ts +1 -0
  208. package/dist/util/resolve.js +3 -2
  209. package/dist/util/scripts.d.ts +0 -5
  210. package/dist/util/scripts.js +1 -32
  211. package/dist/util/to-source-path.d.ts +4 -1
  212. package/dist/util/to-source-path.js +2 -2
  213. package/dist/util/unhandled-rejection.d.ts +8 -0
  214. package/dist/util/unhandled-rejection.js +29 -0
  215. package/dist/util/validation.d.ts +11 -0
  216. package/dist/util/validation.js +68 -0
  217. package/dist/util/watch.d.ts +3 -1
  218. package/dist/util/watch.js +5 -2
  219. package/dist/version.d.ts +1 -1
  220. package/dist/version.js +1 -1
  221. package/package.json +6 -7
  222. package/schema.json +34 -0
  223. package/dist/schema/configuration.d.ts +0 -3103
  224. package/dist/schema/configuration.js +0 -94
  225. package/dist/schema/plugins.d.ts +0 -1019
  226. package/dist/schema/plugins.js +0 -215
package/dist/run.js CHANGED
@@ -6,6 +6,7 @@ import { ConsoleStreamer } from './ConsoleStreamer.js';
6
6
  import { DependencyDeputy } from './DependencyDeputy.js';
7
7
  import { analyze } from './graph/analyze.js';
8
8
  import { build } from './graph/build.js';
9
+ import { SubpathReferences } from './graph/SubpathReferences.js';
9
10
  import { IssueCollector } from './IssueCollector.js';
10
11
  import { ProjectPrincipal } from './ProjectPrincipal.js';
11
12
  import { debugLogObject } from './util/debug.js';
@@ -61,6 +62,13 @@ export const run = async (options) => {
61
62
  const toSourceFilePath = getModuleSourcePathHandler(chief);
62
63
  const findWorkspacePackageTarget = getWorkspacePackageTargetHandler(chief);
63
64
  const principal = new ProjectPrincipal(options, toSourceFilePath, findWorkspacePackageTarget, filePath => chief.findWorkspaceByFilePath(filePath)?.name);
65
+ const subpathReferences = new SubpathReferences({
66
+ chief,
67
+ principal,
68
+ workspaces,
69
+ findWorkspacePackageTarget,
70
+ isGitIgnored,
71
+ });
64
72
  collector.setWorkspaceFilter(chief.workspaceFilePathFilter);
65
73
  collector.setSelectedWorkspaces(chief.selectedWorkspaces);
66
74
  collector.setIgnoreIssues(chief.getIgnoreIssues());
@@ -75,6 +83,7 @@ export const run = async (options) => {
75
83
  isGitIgnored,
76
84
  scriptParserContext,
77
85
  streamer,
86
+ subpathReferences,
78
87
  workspaces,
79
88
  options,
80
89
  });
@@ -86,7 +95,9 @@ export const run = async (options) => {
86
95
  deputy,
87
96
  entryPaths,
88
97
  graph,
98
+ isGitIgnored,
89
99
  streamer,
100
+ subpathReferences,
90
101
  unreferencedFiles,
91
102
  options,
92
103
  });
@@ -98,6 +109,7 @@ export const run = async (options) => {
98
109
  session = await getSessionHandler(options, {
99
110
  analyzedFiles,
100
111
  analyzeSourceFile,
112
+ subpathReferences,
101
113
  chief,
102
114
  collector,
103
115
  analyze: reAnalyze,
@@ -30,6 +30,7 @@ export declare const getFileTopology: (file: FileNode) => {
30
30
  modifiers: number;
31
31
  jsDocTags: Set<string> | undefined;
32
32
  }[];
33
+ subpathImports: Set<string> | undefined;
33
34
  externalRefs: Set<import("../types/module-graph.ts").ExternalRef>;
34
35
  exports: {
35
36
  identifier: string;
@@ -41,6 +41,7 @@ export const getFileTopology = (file) => {
41
41
  imports: facts(file.imports.imports),
42
42
  external: facts(file.imports.external),
43
43
  unresolved: facts(file.imports.unresolved),
44
+ subpathImports: file.imports.subpathImports,
44
45
  externalRefs: file.imports.externalRefs,
45
46
  exports,
46
47
  skipExports: file.skipExports,
@@ -9,4 +9,5 @@ export { createOptions, type MainOptions } from '../util/create-options.ts';
9
9
  export { buildFileDescriptor, type FileDescriptorOptions } from './file-descriptor.ts';
10
10
  export { buildPackageJsonDescriptor, type PackageJsonFile } from './package-json-descriptor.ts';
11
11
  export { createSession, type Session } from './session.ts';
12
+ export { version } from '../version.ts';
12
13
  export type { ContentionDetails, ContentionKind, ContentionOrigin, ContentionSite, Export, File, SourceLocation, } from './types.ts';
@@ -5,3 +5,4 @@ export { createOptions } from '../util/create-options.js';
5
5
  export { buildFileDescriptor } from './file-descriptor.js';
6
6
  export { buildPackageJsonDescriptor } from './package-json-descriptor.js';
7
7
  export { createSession } from './session.js';
8
+ export { version } from '../version.js';
@@ -6,6 +6,7 @@ import { hasErrorCause } from '../util/errors.js';
6
6
  import { isFile } from '../util/fs.js';
7
7
  import { logError } from '../util/log.js';
8
8
  import { toPosix } from '../util/path.js';
9
+ import { hasUnhandledRejection } from '../util/unhandled-rejection.js';
9
10
  import { createSession } from './session.js';
10
11
  export const watchSession = async (options) => {
11
12
  const streamer = new ConsoleStreamer(options);
@@ -29,7 +30,7 @@ export const watchSession = async (options) => {
29
30
  session.handleFileChanges([{ type, filePath: path }]).then(update => {
30
31
  if (!update)
31
32
  return;
32
- process.exitCode = 0;
33
+ process.exitCode = hasUnhandledRejection() ? 2 : 0;
33
34
  report(update.duration);
34
35
  }, onError);
35
36
  });
@@ -1,2 +1,2 @@
1
- export type PluginName = 'angular' | 'astro' | 'astro-db' | 'astro-markdoc' | 'astro-og-canvas' | 'ava' | 'babel' | 'biome' | 'borp' | 'buf' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'catalyst' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'electron-forge' | 'electron-vite' | 'eleventy' | 'esbuild' | 'eslint' | 'eve' | 'execa' | 'expo' | 'expo-router' | 'expressive-code' | 'fast' | 'filesystem-routing' | 'flue' | 'fumadocs' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jasmine' | 'jest' | 'karma' | 'knex' | 'kysely-codegen' | 'ladle' | 'laravel-vite-plugin' | 'lefthook' | 'lingui' | 'lint-staged' | 'linthtml' | 'lit' | 'lockfile-lint' | 'lost-pixel' | 'lunaria' | 'markdownlint' | 'marko' | 'mastra' | 'mcp' | 'mdx' | 'mdxlint' | 'metro' | 'mise' | 'mocha' | 'moonrepo' | 'msw' | 'nano-spawn' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'nitro' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nuxtjs-i18n' | 'nx' | 'nyc' | 'oclif' | 'openapi-ts' | 'openclaw' | 'orval' | 'osls' | 'oxfmt' | 'oxlint' | 'panda-css' | 'parcel' | 'payload' | 'pino' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'pre-commit' | 'preconstruct' | 'prettier' | 'prisma' | 'purgecss' | 'quasar' | 'qwik' | 'railway' | 'raycast' | 'react-cosmos' | 'react-email' | 'react-native' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rolldown' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'sanity' | 'semantic-release' | 'sentry' | 'serverless-framework' | 'simple-git-hooks' | 'size-limit' | 'solidjs-vite-plugin' | 'sst' | 'starlight' | 'stencil' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'sveltejs-package' | 'sveltekit' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'tauri' | 'temporal' | 'textlint' | 'travis' | 'ts-node' | 'tsd' | 'tsdown' | 'tsrs' | 'tsup' | 'tsx' | 'turbo' | 'typedoc' | 'typescript' | 'typescript-content-mapper' | 'unbuild' | 'unocss' | 'unplugin-auto-import' | 'unplugin-icons' | 'unplugin-vue-components' | 'unplugin-vue-i18n' | 'unplugin-vue-markdown' | 'unplugin-vue-router' | 'varlock' | 'vercel' | 'vercel-og' | 'vike' | 'vite' | 'vite-plugin-pages' | 'vite-plugin-pwa' | 'vite-plugin-vue-layouts-next' | 'vite-plus' | 'vite-pwa-assets-generator' | 'vitepress' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'wxt' | 'xo' | 'yarn' | 'yorkie' | 'zx';
2
- export declare const pluginNames: readonly ['angular', 'astro', 'astro-db', 'astro-markdoc', 'astro-og-canvas', 'ava', 'babel', 'biome', 'borp', 'buf', 'bumpp', 'bun', 'c8', 'capacitor', 'catalyst', 'changelogen', 'changelogithub', 'changesets', 'commitizen', 'commitlint', 'convex', 'create-typescript-app', 'cspell', 'cucumber', 'cypress', 'danger', 'dependency-cruiser', 'docusaurus', 'dotenv', 'drizzle', 'electron-forge', 'electron-vite', 'eleventy', 'esbuild', 'eslint', 'eve', 'execa', 'expo', 'expo-router', 'expressive-code', 'fast', 'filesystem-routing', 'flue', 'fumadocs', 'gatsby', 'github-action', 'github-actions', 'glob', 'graphql-codegen', 'hardhat', 'husky', 'i18next-parser', 'jasmine', 'jest', 'karma', 'knex', 'kysely-codegen', 'ladle', 'laravel-vite-plugin', 'lefthook', 'lingui', 'lint-staged', 'linthtml', 'lit', 'lockfile-lint', 'lost-pixel', 'lunaria', 'markdownlint', 'marko', 'mastra', 'mcp', 'mdx', 'mdxlint', 'metro', 'mise', 'mocha', 'moonrepo', 'msw', 'nano-spawn', 'nano-staged', 'nest', 'netlify', 'next', 'next-intl', 'next-mdx', 'nitro', 'node', 'node-modules-inspector', 'nodemon', 'npm-package-json-lint', 'nuxt', 'nuxtjs-i18n', 'nx', 'nyc', 'oclif', 'openapi-ts', 'openclaw', 'orval', 'osls', 'oxfmt', 'oxlint', 'panda-css', 'parcel', 'payload', 'pino', 'playwright', 'playwright-ct', 'playwright-test', 'plop', 'pm2', 'pnpm', 'postcss', 'pre-commit', 'preconstruct', 'prettier', 'prisma', 'purgecss', 'quasar', 'qwik', 'railway', 'raycast', 'react-cosmos', 'react-email', 'react-native', 'react-router', 'relay', 'release-it', 'remark', 'remix', 'rolldown', 'rollup', 'rsbuild', 'rslib', 'rspack', 'rstest', 'sanity', 'semantic-release', 'sentry', 'serverless-framework', 'simple-git-hooks', 'size-limit', 'solidjs-vite-plugin', 'sst', 'starlight', 'stencil', 'storybook', 'stryker', 'stylelint', 'svelte', 'sveltejs-package', 'sveltekit', 'svgo', 'svgr', 'swc', 'syncpack', 'tailwind', 'tanstack-router', 'taskfile', 'tauri', 'temporal', 'textlint', 'travis', 'ts-node', 'tsd', 'tsdown', 'tsrs', 'tsup', 'tsx', 'turbo', 'typedoc', 'typescript', 'typescript-content-mapper', 'unbuild', 'unocss', 'unplugin-auto-import', 'unplugin-icons', 'unplugin-vue-components', 'unplugin-vue-i18n', 'unplugin-vue-markdown', 'unplugin-vue-router', 'varlock', 'vercel', 'vercel-og', 'vike', 'vite', 'vite-plugin-pages', 'vite-plugin-pwa', 'vite-plugin-vue-layouts-next', 'vite-plus', 'vite-pwa-assets-generator', 'vitepress', 'vitest', 'vue', 'webdriver-io', 'webpack', 'wireit', 'wrangler', 'wxt', 'xo', 'yarn', 'yorkie', 'zx'];
1
+ export type PluginName = 'angular' | 'astro' | 'astro-db' | 'astro-markdoc' | 'astro-og-canvas' | 'ava' | 'aws-cdk' | 'babel' | 'biome' | 'borp' | 'buf' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'catalyst' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'electron-forge' | 'electron-vite' | 'eleventy' | 'esbuild' | 'eslint' | 'evalite' | 'eve' | 'execa' | 'expo' | 'expo-router' | 'expressive-code' | 'fast' | 'filesystem-routing' | 'flue' | 'fumadocs' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jasmine' | 'jest' | 'karma' | 'knex' | 'kysely-codegen' | 'ladle' | 'laravel-vite-plugin' | 'lefthook' | 'lingui' | 'lint-staged' | 'linthtml' | 'lit' | 'lockfile-lint' | 'lost-pixel' | 'lunaria' | 'markdownlint' | 'marko' | 'mastra' | 'mcp' | 'mdx' | 'mdxlint' | 'metro' | 'mikro-orm' | 'mise' | 'mocha' | 'moonrepo' | 'msw' | 'nano-spawn' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'nitro' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nuxtjs-i18n' | 'nx' | 'nyc' | 'oclif' | 'openapi-ts' | 'openclaw' | 'orval' | 'osls' | 'oxfmt' | 'oxlint' | 'panda-css' | 'parcel' | 'payload' | 'pino' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'pre-commit' | 'preconstruct' | 'prettier' | 'prisma' | 'purgecss' | 'quasar' | 'qwik' | 'railway' | 'raycast' | 'react-cosmos' | 'react-email' | 'react-native' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'retry-cli' | 'rolldown' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'sanity' | 'semantic-release' | 'sentry' | 'serverless-framework' | 'simple-git-hooks' | 'size-limit' | 'solidjs-vite-plugin' | 'sst' | 'starlight' | 'stencil' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'sveltejs-package' | 'sveltekit' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'tauri' | 'temporal' | 'textlint' | 'travis' | 'ts-node' | 'tsd' | 'tsdown' | 'tsrs' | 'tsup' | 'tsx' | 'turbo' | 'typedoc' | 'typescript' | 'typescript-content-mapper' | 'unbuild' | 'unocss' | 'unplugin-auto-import' | 'unplugin-icons' | 'unplugin-vue-components' | 'unplugin-vue-i18n' | 'unplugin-vue-markdown' | 'unplugin-vue-router' | 'varlock' | 'vercel' | 'vercel-og' | 'vike' | 'vite' | 'vite-plugin-pages' | 'vite-plugin-pwa' | 'vite-plugin-vue-layouts-next' | 'vite-plus' | 'vite-pwa-assets-generator' | 'vitepress' | 'vitest' | 'vue' | 'web-test-runner' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'wxt' | 'xo' | 'yarn' | 'yorkie' | 'zx';
2
+ export declare const pluginNames: readonly ['angular', 'astro', 'astro-db', 'astro-markdoc', 'astro-og-canvas', 'ava', 'aws-cdk', 'babel', 'biome', 'borp', 'buf', 'bumpp', 'bun', 'c8', 'capacitor', 'catalyst', 'changelogen', 'changelogithub', 'changesets', 'commitizen', 'commitlint', 'convex', 'create-typescript-app', 'cspell', 'cucumber', 'cypress', 'danger', 'dependency-cruiser', 'docusaurus', 'dotenv', 'drizzle', 'electron-forge', 'electron-vite', 'eleventy', 'esbuild', 'eslint', 'evalite', 'eve', 'execa', 'expo', 'expo-router', 'expressive-code', 'fast', 'filesystem-routing', 'flue', 'fumadocs', 'gatsby', 'github-action', 'github-actions', 'glob', 'graphql-codegen', 'hardhat', 'husky', 'i18next-parser', 'jasmine', 'jest', 'karma', 'knex', 'kysely-codegen', 'ladle', 'laravel-vite-plugin', 'lefthook', 'lingui', 'lint-staged', 'linthtml', 'lit', 'lockfile-lint', 'lost-pixel', 'lunaria', 'markdownlint', 'marko', 'mastra', 'mcp', 'mdx', 'mdxlint', 'metro', 'mikro-orm', 'mise', 'mocha', 'moonrepo', 'msw', 'nano-spawn', 'nano-staged', 'nest', 'netlify', 'next', 'next-intl', 'next-mdx', 'nitro', 'node', 'node-modules-inspector', 'nodemon', 'npm-package-json-lint', 'nuxt', 'nuxtjs-i18n', 'nx', 'nyc', 'oclif', 'openapi-ts', 'openclaw', 'orval', 'osls', 'oxfmt', 'oxlint', 'panda-css', 'parcel', 'payload', 'pino', 'playwright', 'playwright-ct', 'playwright-test', 'plop', 'pm2', 'pnpm', 'postcss', 'pre-commit', 'preconstruct', 'prettier', 'prisma', 'purgecss', 'quasar', 'qwik', 'railway', 'raycast', 'react-cosmos', 'react-email', 'react-native', 'react-router', 'relay', 'release-it', 'remark', 'remix', 'retry-cli', 'rolldown', 'rollup', 'rsbuild', 'rslib', 'rspack', 'rstest', 'sanity', 'semantic-release', 'sentry', 'serverless-framework', 'simple-git-hooks', 'size-limit', 'solidjs-vite-plugin', 'sst', 'starlight', 'stencil', 'storybook', 'stryker', 'stylelint', 'svelte', 'sveltejs-package', 'sveltekit', 'svgo', 'svgr', 'swc', 'syncpack', 'tailwind', 'tanstack-router', 'taskfile', 'tauri', 'temporal', 'textlint', 'travis', 'ts-node', 'tsd', 'tsdown', 'tsrs', 'tsup', 'tsx', 'turbo', 'typedoc', 'typescript', 'typescript-content-mapper', 'unbuild', 'unocss', 'unplugin-auto-import', 'unplugin-icons', 'unplugin-vue-components', 'unplugin-vue-i18n', 'unplugin-vue-markdown', 'unplugin-vue-router', 'varlock', 'vercel', 'vercel-og', 'vike', 'vite', 'vite-plugin-pages', 'vite-plugin-pwa', 'vite-plugin-vue-layouts-next', 'vite-plus', 'vite-pwa-assets-generator', 'vitepress', 'vitest', 'vue', 'web-test-runner', 'webdriver-io', 'webpack', 'wireit', 'wrangler', 'wxt', 'xo', 'yarn', 'yorkie', 'zx'];
@@ -5,6 +5,7 @@ export const pluginNames = [
5
5
  'astro-markdoc',
6
6
  'astro-og-canvas',
7
7
  'ava',
8
+ 'aws-cdk',
8
9
  'babel',
9
10
  'biome',
10
11
  'borp',
@@ -34,6 +35,7 @@ export const pluginNames = [
34
35
  'eleventy',
35
36
  'esbuild',
36
37
  'eslint',
38
+ 'evalite',
37
39
  'eve',
38
40
  'execa',
39
41
  'expo',
@@ -73,6 +75,7 @@ export const pluginNames = [
73
75
  'mdx',
74
76
  'mdxlint',
75
77
  'metro',
78
+ 'mikro-orm',
76
79
  'mise',
77
80
  'mocha',
78
81
  'moonrepo',
@@ -128,6 +131,7 @@ export const pluginNames = [
128
131
  'release-it',
129
132
  'remark',
130
133
  'remix',
134
+ 'retry-cli',
131
135
  'rolldown',
132
136
  'rollup',
133
137
  'rsbuild',
@@ -192,6 +196,7 @@ export const pluginNames = [
192
196
  'vitepress',
193
197
  'vitest',
194
198
  'vue',
199
+ 'web-test-runner',
195
200
  'webdriver-io',
196
201
  'webpack',
197
202
  'wireit',
@@ -12,7 +12,9 @@ export type Args = {
12
12
  nodeImportArgs?: boolean;
13
13
  config?: ConfigArg;
14
14
  args?: (args: string[]) => string[];
15
- fromArgs?: string[] | ((parsed: ParsedArgs, args: string[]) => string[]);
15
+ fromArgs?: string[] | ((parsed: ParsedArgs, args: string[], options: {
16
+ cwd: string;
17
+ }) => string[]);
16
18
  resolveInputs?: (parsed: ParsedArgs, options: {
17
19
  cwd: string;
18
20
  args: string[];
@@ -1,13 +1,11 @@
1
1
  import type { Program, VisitorObject } from 'oxc-parser';
2
2
  import type { Word } from 'unbash';
3
- import type { z } from 'zod/mini';
4
3
  import type { Compiler, HasDependency, RawCompilers } from '../compilers/types.ts';
5
- import type { knipConfigurationSchema, workspaceConfigurationSchema } from '../schema/configuration.ts';
6
- import type { pluginSchema } from '../schema/plugins.ts';
7
4
  import type { ParsedCLIArgs } from '../util/cli-arguments.ts';
8
5
  import type { Input } from '../util/input.ts';
9
6
  import type { Manifest } from '../util/package-json.ts';
10
7
  import type { Args } from './args.ts';
8
+ import type { RawConfiguration } from './configuration.ts';
11
9
  import type { IssueType, SymbolType } from './issues.ts';
12
10
  import type { Tags } from './options.ts';
13
11
  import type { PluginName } from './PluginNames.ts';
@@ -21,23 +19,28 @@ export interface GetInputsFromScriptsOptions extends BaseOptions {
21
19
  }
22
20
  export type GetInputsFromScripts<T = GetInputsFromScriptsOptions> = (npmScripts: string | string[] | Set<string>, options: T) => Input[];
23
21
  export type GetInputsFromScriptsPartial = (npmScripts: string | string[] | Set<string>, options?: Partial<GetInputsFromScriptsOptions>) => Input[];
22
+ export interface ScriptCommand {
23
+ binary: string;
24
+ args: string[];
25
+ }
26
+ export type GetScriptCommands = (script: string, cwd?: string) => ScriptCommand[];
24
27
  export type ScriptArg = string | Word;
25
28
  export type FromArgs = (args: ScriptArg[], options?: Partial<GetInputsFromScriptsOptions>) => Input[];
26
29
  export interface BinaryResolverOptions extends GetInputsFromScriptsOptions {
27
30
  fromArgs: FromArgs;
28
31
  }
29
32
  export type BinaryResolver = (binary: string, words: Word[], options: BinaryResolverOptions) => Input[];
30
- export type RawConfiguration = z.infer<typeof knipConfigurationSchema>;
33
+ export type { RawConfiguration, RawPluginConfiguration, WorkspaceProjectConfig } from './configuration.ts';
31
34
  export type RawConfigurationOrFn = RawConfiguration | ((options: ParsedCLIArgs) => RawConfiguration | Promise<RawConfiguration>);
32
- export type RawPluginConfiguration = z.infer<typeof pluginSchema>;
33
- export type WorkspaceProjectConfig = z.infer<typeof workspaceConfigurationSchema>;
34
35
  export type IgnorePatterns = (string | RegExp)[];
35
36
  type IgnorableExport = Exclude<SymbolType, 'unknown'>;
36
- export type IgnoreExportsUsedInFile = boolean | Partial<Record<IgnorableExport, boolean>>;
37
+ export type IgnoreExportsUsedInFile = boolean | {
38
+ [K in IgnorableExport]?: boolean | undefined;
39
+ };
37
40
  export type IgnoreIssues = Record<string, IssueType[]>;
38
41
  export type CyclesConfig = {
39
- allow?: string[][];
40
- dynamicImports?: boolean;
42
+ allow?: string[][] | undefined;
43
+ dynamicImports?: boolean | undefined;
41
44
  };
42
45
  export type GetImportsAndExportsOptions = {
43
46
  skipTypeOnly: boolean;
@@ -59,6 +62,7 @@ export interface Configuration {
59
62
  ignoreUnresolved: IgnorePatterns;
60
63
  ignoreWorkspaces: string[];
61
64
  isIncludeEntryExports: boolean;
65
+ isIncludeSubpathExports: boolean;
62
66
  compilers: RawCompilers;
63
67
  rootPluginConfigs: Partial<PluginsConfiguration>;
64
68
  }
@@ -77,6 +81,7 @@ interface BaseWorkspaceConfiguration {
77
81
  ignoreGlobalBinaries: boolean;
78
82
  ignoreExportsUsedInFile: IgnoreExportsUsedInFile;
79
83
  isIncludeEntryExports: boolean;
84
+ isIncludeSubpathExports: boolean;
80
85
  }
81
86
  type PluginConfiguration = EnsuredPluginConfiguration | boolean;
82
87
  export type PluginsConfiguration = Record<PluginName, PluginConfiguration>;
@@ -94,6 +99,7 @@ type IsPluginEnabledOptions = {
94
99
  manifest: Manifest;
95
100
  dependencies: Set<string>;
96
101
  config: WorkspaceConfiguration;
102
+ getScriptCommands: GetScriptCommands;
97
103
  };
98
104
  export type IsPluginEnabled = (options: IsPluginEnabledOptions) => boolean | Promise<boolean>;
99
105
  export interface PluginOptions extends BaseOptions {
@@ -106,6 +112,7 @@ export interface PluginOptions extends BaseOptions {
106
112
  isProduction: boolean;
107
113
  enabledPlugins: string[];
108
114
  getInputsFromScripts: GetInputsFromScriptsPartial;
115
+ getScriptCommands: GetScriptCommands;
109
116
  }
110
117
  type PluginSetup = () => Promise<void> | void;
111
118
  export type IsLoadConfig = (options: PluginOptions, dependencies: Set<string>) => boolean;
@@ -134,6 +141,7 @@ export type ResolveFromAST = (program: Program, options: PluginOptions & {
134
141
  }) => Input[];
135
142
  type RegisterCompilersOptions = {
136
143
  cwd: string;
144
+ dependencies: Set<string>;
137
145
  hasDependency: HasDependency;
138
146
  registerCompiler: RegisterCompiler;
139
147
  };
@@ -185,4 +193,3 @@ export interface Plugin {
185
193
  }
186
194
  export type PluginMap = Record<PluginName, Plugin>;
187
195
  export type Entries = [PluginName, Plugin][];
188
- export {};
@@ -0,0 +1,45 @@
1
+ import type { Compiler } from '../compilers/types.ts';
2
+ import type { CyclesConfig, IgnoreExportsUsedInFile, IgnoreIssues, IgnorePatterns } from './config.ts';
3
+ import type { IssueType, Rules } from './issues.ts';
4
+ import type { PluginName } from './PluginNames.ts';
5
+ type Glob = string | string[];
6
+ export type RawPluginConfiguration = boolean | Glob | {
7
+ config?: Glob | undefined;
8
+ entry?: Glob | undefined;
9
+ project?: Glob | undefined;
10
+ };
11
+ type RawPluginsConfiguration = {
12
+ [K in PluginName]?: RawPluginConfiguration | undefined;
13
+ };
14
+ export interface RawConfiguration extends RawPluginsConfiguration {
15
+ $schema?: string | undefined;
16
+ rules?: Partial<Rules> | undefined;
17
+ entry?: Glob | undefined;
18
+ project?: Glob | undefined;
19
+ paths?: Record<string, string[]> | undefined;
20
+ ignore?: Glob | undefined;
21
+ ignoreFiles?: Glob | undefined;
22
+ ignoreBinaries?: IgnorePatterns | undefined;
23
+ ignoreGlobalBinaries?: boolean | undefined;
24
+ ignoreDependencies?: IgnorePatterns | undefined;
25
+ ignoreMembers?: IgnorePatterns | undefined;
26
+ ignoreUnresolved?: IgnorePatterns | undefined;
27
+ ignoreExportsUsedInFile?: IgnoreExportsUsedInFile | undefined;
28
+ ignoreIssues?: IgnoreIssues | undefined;
29
+ cycles?: CyclesConfig | undefined;
30
+ ignoreWorkspaces?: string[] | undefined;
31
+ includeEntryExports?: boolean | undefined;
32
+ includeSubpathExports?: boolean | undefined;
33
+ compilers?: Record<string, Compiler | true> | undefined;
34
+ asyncCompilers?: Record<string, Compiler> | undefined;
35
+ tags?: string[] | undefined;
36
+ treatConfigHintsAsErrors?: boolean | undefined;
37
+ treatTagHintsAsErrors?: boolean | undefined;
38
+ preprocessor?: Glob | undefined;
39
+ preprocessorOptions?: Record<string, unknown> | undefined;
40
+ include?: IssueType[] | undefined;
41
+ exclude?: IssueType[] | undefined;
42
+ workspaces?: Record<string, WorkspaceProjectConfig> | undefined;
43
+ }
44
+ export type WorkspaceProjectConfig = Pick<RawConfiguration, 'entry' | 'project' | 'paths' | 'ignore' | 'ignoreFiles' | 'ignoreBinaries' | 'ignoreGlobalBinaries' | 'ignoreDependencies' | 'ignoreMembers' | 'ignoreUnresolved' | 'ignoreExportsUsedInFile' | 'ignoreIssues' | 'includeEntryExports' | 'includeSubpathExports'> & RawPluginsConfiguration;
45
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -28,6 +28,7 @@ export interface Issue {
28
28
  export type IssueRecords = Record<string, Record<string, Issue>>;
29
29
  export type Issues = {
30
30
  files: IssueRecords;
31
+ subpaths: IssueRecords;
31
32
  dependencies: IssueRecords;
32
33
  devDependencies: IssueRecords;
33
34
  optionalPeerDependencies: IssueRecords;
@@ -82,11 +83,14 @@ export type IssueSeverity = 'error' | 'warn' | 'off';
82
83
  export type Rules = Record<IssueType, IssueSeverity>;
83
84
  export type ConfigurationHints = Map<string, ConfigurationHint>;
84
85
  export type ConfigurationHintType = 'ignore' | 'ignoreFiles' | 'ignoreBinaries' | 'ignoreDependencies' | 'ignoreUnresolved' | 'workspaces' | 'ignoreWorkspaces' | 'entry-redundant' | 'project-redundant' | 'entry-top-level' | 'project-top-level' | 'entry-empty' | 'project-empty' | 'project-extension-unregistered' | 'project-extension-excluded' | 'package-entry' | 'top-level-unconfigured' | 'workspace-unconfigured';
86
+ export type UnusedIgnorePatternReason = 'no-issues' | 'gitignored' | 'no-matches';
85
87
  export type ConfigurationHint = {
86
88
  type: ConfigurationHintType;
87
89
  identifier: string | RegExp;
88
90
  filePath?: string;
89
91
  workspaceName?: string;
92
+ configKey?: string;
93
+ reason?: UnusedIgnorePatternReason;
90
94
  size?: number;
91
95
  };
92
96
  type TagHints = Set<TagHint>;
@@ -70,6 +70,7 @@ export type FileNode = {
70
70
  readonly programFiles: Set<FilePath>;
71
71
  readonly entryFiles: Set<FilePath>;
72
72
  readonly imports: Imports;
73
+ readonly subpathImports: Set<string> | undefined;
73
74
  };
74
75
  exports: ExportMap;
75
76
  duplicates: Iterable<Array<IssueSymbol>>;
@@ -13,6 +13,7 @@ export interface Options {
13
13
  isFix: boolean;
14
14
  isFormat: boolean;
15
15
  isIncludeEntryExports: boolean;
16
+ isIncludeSubpathExports: boolean;
16
17
  isProduction: boolean;
17
18
  isRemoveFiles: boolean;
18
19
  isSession: boolean;
@@ -1,15 +1,9 @@
1
1
  import type { PluginMap, WorkspaceConfiguration } from './config.ts';
2
- type Primitive = null | undefined | string | number | boolean | symbol | bigint;
3
- type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
4
- type C = 'import' | 'require' | 'node' | 'node-addons' | 'deno' | 'browser' | 'electron' | 'react-native' | 'default';
5
- type ExportCondition = LiteralUnion<C, string>;
6
- type Exports = null | string | string[] | {
7
- [key in ExportCondition]: Exports;
8
- } | {
2
+ export type Exports = null | string | string[] | {
9
3
  [key: string]: Exports;
10
4
  };
11
5
  type Imports = {
12
- [key: `#${string}`]: Exports;
6
+ [key: string]: Exports;
13
7
  };
14
8
  type PackageJsonPath<T> = T extends {
15
9
  packageJsonPath: infer P;
@@ -86,5 +80,6 @@ export type WorkspacePackage = {
86
80
  manifest: PackageJson;
87
81
  manifestPath: string;
88
82
  manifestStr: string;
83
+ aliases: Map<string, string>;
89
84
  };
90
85
  export {};
@@ -19,6 +19,7 @@ type WorkspaceManifest = {
19
19
  unusedIgnoreDependencies: Set<string | RegExp>;
20
20
  unusedIgnoreBinaries: Set<string | RegExp>;
21
21
  unusedIgnoreUnresolved: Set<string | RegExp>;
22
+ ignoreConfigKeys: Record<'ignoreDependencies' | 'ignoreBinaries' | 'ignoreUnresolved', Map<string | RegExp, string | undefined>>;
22
23
  };
23
24
  export type WorkspaceManifests = Map<string, WorkspaceManifest>;
24
25
  export type HostDependencies = Map<string, Array<{
@@ -491,7 +491,7 @@ export const collectAugmentationRefs = (node) => {
491
491
  export function extractEnumMembers(decl, options, lineStarts, getJSDocTags) {
492
492
  if (!decl.body?.members)
493
493
  return [];
494
- return decl.body.members.map((member) => {
494
+ const members = decl.body.members.map((member) => {
495
495
  const name = member.id.type === 'Identifier'
496
496
  ? member.id.name
497
497
  : member.id.type === 'Literal'
@@ -517,4 +517,50 @@ export function extractEnumMembers(decl, options, lineStarts, getJSDocTags) {
517
517
  flags: 0,
518
518
  };
519
519
  });
520
+ markEnumMemberRefs(decl.body.members, members);
521
+ return members;
520
522
  }
523
+ const markEnumMemberRefs = (enumMembers, members) => {
524
+ let byIdentifier;
525
+ const visit = (node) => {
526
+ const type = node?.type;
527
+ if (!type)
528
+ return;
529
+ if (type === 'Identifier') {
530
+ const member = byIdentifier?.get(node.name);
531
+ if (member)
532
+ member.hasRefsInFile = true;
533
+ return;
534
+ }
535
+ if (type === 'MemberExpression' && !node.computed) {
536
+ visit(node.object);
537
+ return;
538
+ }
539
+ const keys = visitorKeys[type];
540
+ if (!keys)
541
+ return;
542
+ for (const key of keys) {
543
+ const val = node[key];
544
+ if (!val)
545
+ continue;
546
+ if (Array.isArray(val)) {
547
+ for (const item of val)
548
+ if (item)
549
+ visit(item);
550
+ }
551
+ else
552
+ visit(val);
553
+ }
554
+ };
555
+ for (const member of enumMembers) {
556
+ const initializer = member.initializer;
557
+ if (!initializer || initializer.type === 'Literal')
558
+ continue;
559
+ if (!byIdentifier) {
560
+ byIdentifier = new Map();
561
+ for (const m of members)
562
+ byIdentifier.set(m.identifier, m);
563
+ }
564
+ visit(initializer);
565
+ }
566
+ };
@@ -1,7 +1,6 @@
1
- import { isBuiltin } from 'node:module';
2
1
  import { IMPORT_FLAGS, IMPORT_STAR, LOADER_DEFAULT, OPAQUE, PROTOCOL_VIRTUAL, SIDE_EFFECTS } from '../constants.js';
3
2
  import { addNsValue, addValue, createImports } from '../util/module-graph.js';
4
- import { getPackageNameFromFilePath, getPackageNameFromModuleSpecifier, isStartsLikePackageName, sanitizeSpecifier, } from '../util/modules.js';
3
+ import { getPackageNameFromFilePath, getPackageNameFromModuleSpecifier, getSubpathImport, isBuiltin, isStartsLikePackageName, sanitizeSpecifier, } from '../util/modules.js';
5
4
  import { timerify } from '../util/Performance.js';
6
5
  import { dirname, isInNodeModules, resolve } from '../util/path.js';
7
6
  import { shouldIgnore } from '../util/tag.js';
@@ -20,6 +19,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
20
19
  const programFiles = new Set();
21
20
  const entryFiles = new Set();
22
21
  const imports = new Set();
22
+ let subpathImports;
23
23
  const exports = new Map();
24
24
  const aliasedExports = new Map();
25
25
  const specifierExportNames = new Set();
@@ -28,12 +28,12 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
28
28
  const handledImportExpressions = new Set();
29
29
  const caughtImportExpressions = new Set();
30
30
  const importAliases = new Map();
31
- const addImportAlias = (aliasName, id, importFilePath) => {
31
+ const addImportAlias = (aliasName, id, _import) => {
32
32
  const aliases = importAliases.get(aliasName);
33
33
  if (aliases)
34
- aliases.add({ id, filePath: importFilePath });
34
+ aliases.add({ id, import: _import });
35
35
  else
36
- importAliases.set(aliasName, new Set([{ id, filePath: importFilePath }]));
36
+ importAliases.set(aliasName, new Set([{ id, import: _import }]));
37
37
  };
38
38
  const localImportMap = new Map();
39
39
  let builtinImports;
@@ -119,6 +119,9 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
119
119
  return _import;
120
120
  }
121
121
  const module = preResolvedModule ?? resolveModule(specifier, filePath);
122
+ const subpathImport = getSubpathImport(specifier);
123
+ if (subpathImport)
124
+ (subpathImports ??= new Set()).add(subpathImport);
122
125
  if (modifiers & IMPORT_FLAGS.AUGMENT &&
123
126
  (!module || module.isExternalLibraryImport || isInNodeModules(module.resolvedFileName))) {
124
127
  return;
@@ -366,7 +369,16 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
366
369
  }
367
370
  return {
368
371
  skipExports,
369
- imports: { internal, external, externalRefs: new Set(), programFiles, entryFiles, imports, unresolved },
372
+ imports: {
373
+ internal,
374
+ external,
375
+ externalRefs: new Set(),
376
+ programFiles,
377
+ entryFiles,
378
+ imports,
379
+ unresolved,
380
+ subpathImports,
381
+ },
370
382
  exports,
371
383
  duplicates: [...aliasedExports.values()],
372
384
  scripts,
@@ -1,8 +1,8 @@
1
1
  import { existsSync } from 'node:fs';
2
- import { isBuiltin } from 'node:module';
3
2
  import { DEFAULT_EXTENSIONS, DTS_EXTENSIONS, IS_DTS } from '../constants.js';
4
3
  import { isFile } from '../util/fs.js';
5
- import { getPackageNameFromFilePath, getPackageNameFromModuleSpecifier, sanitizeSpecifier } from '../util/modules.js';
4
+ import { getPackageNameFromFilePath, getPackageNameFromModuleSpecifier, isBuiltin, sanitizeSpecifier, } from '../util/modules.js';
5
+ import { expandPackageTarget, getPackageTargetPaths, toPackagePath } from '../util/package-json.js';
6
6
  import { timerify } from '../util/Performance.js';
7
7
  import { dirname, extname, isAbsolute, isInNodeModules, join, toPosix } from '../util/path.js';
8
8
  import { _createSyncModuleResolver, _resolveModuleSync, resolvePackageManifestPath } from '../util/resolve.js';
@@ -33,46 +33,6 @@ function pickStringTarget(value) {
33
33
  return s;
34
34
  }
35
35
  }
36
- const invalidSegments = /(^|\\|\/)((\.|%2e)(\.|%2e)?|node_modules)(\\|\/|$)/i;
37
- const expandPackageTarget = (target, patternMatch) => {
38
- if (!target?.startsWith('./') || invalidSegments.test(target.slice(2)))
39
- return;
40
- if (!target.includes('*'))
41
- return target;
42
- if (patternMatch === undefined || invalidSegments.test(patternMatch))
43
- return;
44
- return target.replaceAll('*', patternMatch);
45
- };
46
- const toPackagePath = (dir, target) => {
47
- const candidate = join(dir, target);
48
- return candidate.startsWith(`${dir}/`) ? candidate : undefined;
49
- };
50
- function pickExistingPackageTarget(value, dir, patternMatch, moduleExtensions) {
51
- if (typeof value === 'string') {
52
- const target = expandPackageTarget(value, patternMatch);
53
- if (!target || IS_DTS.test(target) || !moduleExtensions.has(extname(target)))
54
- return;
55
- const candidate = toPackagePath(dir, target);
56
- return candidate && isFile(candidate) ? candidate : undefined;
57
- }
58
- if (!value || typeof value !== 'object')
59
- return;
60
- if (Array.isArray(value)) {
61
- for (const item of value) {
62
- const target = pickExistingPackageTarget(item, dir, patternMatch, moduleExtensions);
63
- if (target)
64
- return target;
65
- }
66
- return;
67
- }
68
- for (const [condition, child] of Object.entries(value)) {
69
- if (condition === 'types')
70
- continue;
71
- const target = pickExistingPackageTarget(child, dir, patternMatch, moduleExtensions);
72
- if (target)
73
- return target;
74
- }
75
- }
76
36
  const moduleResolutionCaches = [];
77
37
  export function clearModuleResolutionCaches() {
78
38
  for (const cache of moduleResolutionCaches)
@@ -167,6 +127,7 @@ export function createCustomModuleResolver(compilerOptions, customCompilerExtens
167
127
  }
168
128
  return resolvedFileName;
169
129
  }
130
+ const isModuleFile = (filePath) => !IS_DTS.test(filePath) && moduleExtensions.has(extname(filePath)) && isFile(filePath);
170
131
  function toResult(specifier, containingFile, resolvedFileName) {
171
132
  const mapped = toSourcePath(resolvedFileName);
172
133
  const isExternalLibraryImport = mapped === resolvedFileName && isInNodeModules(resolvedFileName);
@@ -247,9 +208,10 @@ export function createCustomModuleResolver(compilerOptions, customCompilerExtens
247
208
  if (sourcePath)
248
209
  return toResult(specifier, containingFile, sourcePath);
249
210
  }
250
- const existingTarget = pickExistingPackageTarget(workspaceTarget.target, workspaceTarget.dir, workspaceTarget.patternMatch, moduleExtensions);
251
- if (existingTarget)
252
- return toResult(specifier, containingFile, existingTarget);
211
+ for (const targetPath of getPackageTargetPaths(workspaceTarget.target, workspaceTarget.dir, workspaceTarget.patternMatch, false)) {
212
+ if (isModuleFile(targetPath))
213
+ return toResult(specifier, containingFile, targetPath);
214
+ }
253
215
  }
254
216
  const candidate = isAbsolute(specifier) ? specifier : join(dirname(containingFile), specifier);
255
217
  if (existsSync(candidate)) {
@@ -1,5 +1,5 @@
1
1
  import type { CallExpression, NewExpression, VariableDeclarator } from 'oxc-parser';
2
- import { type WalkState } from './walk.ts';
2
+ import type { WalkState } from './walk.ts';
3
3
  export declare function trackCustomElementRegistry(node: VariableDeclarator, s: WalkState): void;
4
4
  export declare function handleCallExpression(node: CallExpression, s: WalkState): void;
5
5
  export declare function handleNewExpression(node: NewExpression, s: WalkState): void;