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.
Files changed (231) 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/bun.js +2 -2
  21. package/dist/binaries/resolvers/index.d.ts +1 -0
  22. package/dist/binaries/resolvers/index.js +2 -0
  23. package/dist/binaries/resolvers/npm.js +7 -5
  24. package/dist/binaries/resolvers/npx.js +15 -12
  25. package/dist/binaries/resolvers/nub.js +2 -2
  26. package/dist/binaries/resolvers/vp.d.ts +2 -0
  27. package/dist/binaries/resolvers/vp.js +52 -0
  28. package/dist/binaries/util.d.ts +13 -1
  29. package/dist/binaries/util.js +35 -1
  30. package/dist/cli.js +10 -84
  31. package/dist/compilers/scss.js +2 -1
  32. package/dist/configuration-hints.d.ts +16 -0
  33. package/dist/configuration-hints.js +64 -0
  34. package/dist/constants.d.ts +2 -1
  35. package/dist/constants.js +37 -0
  36. package/dist/graph/SubpathReferences.d.ts +33 -0
  37. package/dist/graph/SubpathReferences.js +114 -0
  38. package/dist/graph/analyze.d.ts +4 -1
  39. package/dist/graph/analyze.js +16 -5
  40. package/dist/graph/build.d.ts +3 -1
  41. package/dist/graph/build.js +47 -23
  42. package/dist/graph-explorer/operations/resolve-export-origins.js +1 -1
  43. package/dist/plugins/angular/index.js +10 -17
  44. package/dist/plugins/aws-cdk/index.d.ts +3 -0
  45. package/dist/plugins/aws-cdk/index.js +32 -0
  46. package/dist/plugins/aws-cdk/types.d.ts +5 -0
  47. package/dist/plugins/aws-cdk/types.js +1 -0
  48. package/dist/plugins/babel/index.d.ts +1 -1
  49. package/dist/plugins/babel/index.js +25 -6
  50. package/dist/plugins/babel/types.d.ts +1 -0
  51. package/dist/plugins/bun/index.js +8 -7
  52. package/dist/plugins/c8/index.js +17 -4
  53. package/dist/plugins/changesets/index.js +3 -2
  54. package/dist/plugins/commitizen/index.js +6 -3
  55. package/dist/plugins/commitlint/index.js +10 -11
  56. package/dist/plugins/cypress/index.js +4 -2
  57. package/dist/plugins/danger/index.js +1 -1
  58. package/dist/plugins/docusaurus/helpers.js +6 -6
  59. package/dist/plugins/docusaurus/index.js +2 -2
  60. package/dist/plugins/electron-forge/index.js +2 -2
  61. package/dist/plugins/electron-vite/index.js +2 -2
  62. package/dist/plugins/eleventy/index.js +3 -2
  63. package/dist/plugins/eslint/helpers.js +4 -3
  64. package/dist/plugins/eslint/resolveFromAST.js +2 -2
  65. package/dist/plugins/evalite/index.d.ts +3 -0
  66. package/dist/plugins/evalite/index.js +26 -0
  67. package/dist/plugins/flue/index.js +2 -2
  68. package/dist/plugins/gatsby/index.js +1 -1
  69. package/dist/plugins/github-action/index.js +2 -2
  70. package/dist/plugins/github-actions/index.js +2 -2
  71. package/dist/plugins/graphql-codegen/index.js +13 -9
  72. package/dist/plugins/index.d.ts +5 -0
  73. package/dist/plugins/index.js +10 -0
  74. package/dist/plugins/jest/index.js +5 -5
  75. package/dist/plugins/knex/index.js +2 -2
  76. package/dist/plugins/laravel-vite-plugin/resolveFromAST.js +2 -2
  77. package/dist/plugins/lunaria/index.js +5 -2
  78. package/dist/plugins/markdownlint/index.js +8 -2
  79. package/dist/plugins/marko/index.js +2 -2
  80. package/dist/plugins/marko/taglibs.d.ts +1 -1
  81. package/dist/plugins/marko/taglibs.js +4 -28
  82. package/dist/plugins/mdx/index.d.ts +2 -1
  83. package/dist/plugins/mdx/index.js +7 -4
  84. package/dist/plugins/mdxlint/index.js +18 -15
  85. package/dist/plugins/mikro-orm/index.d.ts +3 -0
  86. package/dist/plugins/mikro-orm/index.js +77 -0
  87. package/dist/plugins/mikro-orm/types.d.ts +21 -0
  88. package/dist/plugins/mikro-orm/types.js +1 -0
  89. package/dist/plugins/msw/index.js +6 -3
  90. package/dist/plugins/msw/types.d.ts +1 -1
  91. package/dist/plugins/netlify/index.js +7 -3
  92. package/dist/plugins/next/index.js +63 -9
  93. package/dist/plugins/next/types.d.ts +5 -0
  94. package/dist/plugins/next-mdx/resolveFromAST.js +15 -10
  95. package/dist/plugins/nitro/index.js +5 -6
  96. package/dist/plugins/node/index.js +4 -4
  97. package/dist/plugins/npm-package-json-lint/index.js +10 -3
  98. package/dist/plugins/nuxt/index.js +18 -10
  99. package/dist/plugins/nuxt/types.d.ts +4 -0
  100. package/dist/plugins/nx/index.js +6 -3
  101. package/dist/plugins/openclaw/index.js +11 -11
  102. package/dist/plugins/oxlint/index.js +2 -2
  103. package/dist/plugins/payload/index.js +1 -1
  104. package/dist/plugins/playwright/index.js +3 -3
  105. package/dist/plugins/pm2/index.js +7 -7
  106. package/dist/plugins/prettier/index.js +2 -1
  107. package/dist/plugins/prisma/index.js +2 -2
  108. package/dist/plugins/quasar/resolveFromAST.js +14 -9
  109. package/dist/plugins/react-router/index.js +12 -15
  110. package/dist/plugins/release-it/index.js +6 -2
  111. package/dist/plugins/remix/index.js +3 -3
  112. package/dist/plugins/retry-cli/index.d.ts +3 -0
  113. package/dist/plugins/retry-cli/index.js +14 -0
  114. package/dist/plugins/rollup/index.js +1 -4
  115. package/dist/plugins/rstest/index.js +3 -3
  116. package/dist/plugins/semantic-release/index.js +3 -3
  117. package/dist/plugins/serverless-framework/index.js +10 -8
  118. package/dist/plugins/solidjs-vite-plugin/resolveFromAST.js +2 -2
  119. package/dist/plugins/stencil/resolveFromAST.js +5 -5
  120. package/dist/plugins/storybook/index.js +9 -3
  121. package/dist/plugins/stryker/index.js +2 -2
  122. package/dist/plugins/stylelint/index.js +2 -2
  123. package/dist/plugins/swc/index.js +4 -3
  124. package/dist/plugins/tailwind/index.js +2 -2
  125. package/dist/plugins/tanstack-router/index.js +2 -2
  126. package/dist/plugins/ts-node/index.js +6 -1
  127. package/dist/plugins/turbo/index.js +3 -3
  128. package/dist/plugins/typedoc/index.js +2 -2
  129. package/dist/plugins/typescript/content-mappers.d.ts +1 -1
  130. package/dist/plugins/typescript/index.js +6 -9
  131. package/dist/plugins/unocss/index.js +3 -0
  132. package/dist/plugins/varlock/scan.js +1 -1
  133. package/dist/plugins/vite/helpers.d.ts +1 -0
  134. package/dist/plugins/vite/helpers.js +13 -3
  135. package/dist/plugins/vite/index.js +5 -2
  136. package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +2 -2
  137. package/dist/plugins/vitest/index.js +26 -18
  138. package/dist/plugins/vitest/types.d.ts +1 -0
  139. package/dist/plugins/vue/index.js +1 -1
  140. package/dist/plugins/web-test-runner/index.d.ts +3 -0
  141. package/dist/plugins/web-test-runner/index.js +86 -0
  142. package/dist/plugins/wrangler/index.js +3 -3
  143. package/dist/plugins/yarn/index.js +5 -5
  144. package/dist/plugins.js +2 -5
  145. package/dist/reporters/github-actions.js +3 -7
  146. package/dist/reporters/json.d.ts +1 -0
  147. package/dist/reporters/json.js +1 -0
  148. package/dist/reporters/util/configuration-hints.d.ts +3 -1
  149. package/dist/reporters/util/configuration-hints.js +40 -21
  150. package/dist/reporters/util/util.d.ts +1 -1
  151. package/dist/run-cli.d.ts +2 -0
  152. package/dist/run-cli.js +82 -0
  153. package/dist/run.js +12 -0
  154. package/dist/session/incremental.d.ts +1 -0
  155. package/dist/session/incremental.js +1 -0
  156. package/dist/session/watch.js +2 -1
  157. package/dist/types/PluginNames.d.ts +2 -2
  158. package/dist/types/PluginNames.js +5 -0
  159. package/dist/types/args.d.ts +3 -1
  160. package/dist/types/config.d.ts +17 -10
  161. package/dist/types/configuration.d.ts +45 -0
  162. package/dist/types/configuration.js +1 -0
  163. package/dist/types/issues.d.ts +4 -0
  164. package/dist/types/module-graph.d.ts +1 -0
  165. package/dist/types/options.d.ts +1 -0
  166. package/dist/types/package-json.d.ts +3 -8
  167. package/dist/types/workspace.d.ts +1 -0
  168. package/dist/typescript/get-imports-and-exports.js +18 -6
  169. package/dist/typescript/resolve-module-names.js +7 -45
  170. package/dist/typescript/visitors/calls.d.ts +1 -1
  171. package/dist/typescript/visitors/calls.js +14 -10
  172. package/dist/typescript/visitors/exports.js +16 -26
  173. package/dist/typescript/visitors/imports.d.ts +2 -1
  174. package/dist/typescript/visitors/imports.js +41 -24
  175. package/dist/typescript/visitors/members.d.ts +1 -1
  176. package/dist/typescript/visitors/members.js +38 -24
  177. package/dist/typescript/visitors/shadow.d.ts +2 -0
  178. package/dist/typescript/visitors/shadow.js +25 -0
  179. package/dist/typescript/visitors/walk.d.ts +20 -12
  180. package/dist/typescript/visitors/walk.js +78 -48
  181. package/dist/util/Performance.d.ts +25 -3
  182. package/dist/util/Performance.js +51 -27
  183. package/dist/util/cli-arguments.d.ts +2 -1
  184. package/dist/util/cli-arguments.js +5 -3
  185. package/dist/util/create-input-handler.js +138 -119
  186. package/dist/util/create-options.d.ts +4 -2071
  187. package/dist/util/create-options.js +6 -4
  188. package/dist/util/create-workspace-graph.js +2 -1
  189. package/dist/util/errors.d.ts +5 -2
  190. package/dist/util/errors.js +11 -18
  191. package/dist/util/fs.js +4 -2
  192. package/dist/util/input.d.ts +2 -2
  193. package/dist/util/input.js +2 -2
  194. package/dist/util/is-plugin-name.d.ts +2 -0
  195. package/dist/util/is-plugin-name.js +3 -0
  196. package/dist/util/jiti.d.ts +2 -1
  197. package/dist/util/jiti.js +11 -3
  198. package/dist/util/load-config.d.ts +1 -1
  199. package/dist/util/load-config.js +3 -2
  200. package/dist/util/loader.js +3 -2
  201. package/dist/util/map-workspaces.js +23 -1
  202. package/dist/util/module-graph.js +1 -0
  203. package/dist/util/modules.d.ts +2 -0
  204. package/dist/util/modules.js +78 -0
  205. package/dist/util/package-json.d.ts +12 -5
  206. package/dist/util/package-json.js +54 -26
  207. package/dist/util/parse-and-convert-gitignores.d.ts +2 -2
  208. package/dist/util/parse-and-convert-gitignores.js +5 -5
  209. package/dist/util/parse-configuration.d.ts +2 -0
  210. package/dist/util/parse-configuration.js +66 -0
  211. package/dist/util/plugin.js +8 -12
  212. package/dist/util/resolve.d.ts +1 -0
  213. package/dist/util/resolve.js +3 -2
  214. package/dist/util/scripts.d.ts +0 -5
  215. package/dist/util/scripts.js +1 -32
  216. package/dist/util/to-source-path.d.ts +4 -1
  217. package/dist/util/to-source-path.js +2 -2
  218. package/dist/util/unhandled-rejection.d.ts +8 -0
  219. package/dist/util/unhandled-rejection.js +29 -0
  220. package/dist/util/validation.d.ts +11 -0
  221. package/dist/util/validation.js +68 -0
  222. package/dist/util/watch.d.ts +3 -1
  223. package/dist/util/watch.js +5 -2
  224. package/dist/version.d.ts +1 -1
  225. package/dist/version.js +1 -1
  226. package/package.json +9 -10
  227. package/schema.json +34 -0
  228. package/dist/schema/configuration.d.ts +0 -3103
  229. package/dist/schema/configuration.js +0 -94
  230. package/dist/schema/plugins.d.ts +0 -1019
  231. package/dist/schema/plugins.js +0 -215
@@ -1,5 +1,10 @@
1
1
  type NextConfig = {
2
2
  pageExtensions?: string[];
3
+ images?: {
4
+ loaderFile?: string;
5
+ };
6
+ cacheHandler?: string;
7
+ cacheHandlers?: Record<string, string | undefined>;
3
8
  turbopack?: {
4
9
  rules?: Record<string, unknown>;
5
10
  resolveAlias?: Record<string, unknown>;
@@ -1,20 +1,25 @@
1
1
  import { findImportedCalls, findProperty, getStringValues } from '../../typescript/ast-helpers.js';
2
+ import { getStringValue } from '../../typescript/ast-nodes.js';
2
3
  import { toDependency, toProductionEntry } from '../../util/input.js';
4
+ import { isInternal } from '../../util/path.js';
5
+ import { toProviderInput } from '../mdx/index.js';
3
6
  export const production = ['{src/,}mdx-components.{js,jsx,ts,tsx}'];
4
- const getMdxPlugins = (program) => {
7
+ export const resolveFromAST = (program, options) => {
8
+ const inputs = production.map(id => toProductionEntry(id));
5
9
  const plugins = new Set();
6
10
  for (const call of findImportedCalls(program, '@next/mdx')) {
7
- const options = findProperty(call.arguments?.[0], 'options');
8
- if (options?.type !== 'ObjectExpression')
11
+ const mdxOptions = findProperty(call.arguments?.[0], 'options');
12
+ if (mdxOptions?.type !== 'ObjectExpression')
9
13
  continue;
10
14
  for (const pluginType of ['remarkPlugins', 'rehypePlugins', 'recmaPlugins']) {
11
- for (const v of getStringValues(findProperty(options, pluginType)))
12
- plugins.add(v);
15
+ for (const id of getStringValues(findProperty(mdxOptions, pluginType)))
16
+ plugins.add(id);
13
17
  }
18
+ const provider = getStringValue(findProperty(mdxOptions, 'providerImportSource'));
19
+ if (provider && !isInternal(provider))
20
+ inputs.push(toProviderInput(provider, options.configFileDir));
14
21
  }
15
- return plugins;
22
+ for (const id of plugins)
23
+ inputs.push(toDependency(id));
24
+ return inputs;
16
25
  };
17
- export const resolveFromAST = program => [
18
- ...production.map(id => toProductionEntry(id)),
19
- ...Array.from(getMdxPlugins(program)).map(id => toDependency(id)),
20
- ];
@@ -1,5 +1,5 @@
1
- import { toDependency, toIgnore, toProductionEntry } from '../../util/input.js';
2
- import { join } from '../../util/path.js';
1
+ import { toDeferResolve, toDependency, toIgnore, toProductionEntry } from '../../util/input.js';
2
+ import { isInternal, join } from '../../util/path.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
4
  const title = 'Nitro';
5
5
  const enablers = ['nitropack', 'nitro'];
@@ -35,11 +35,10 @@ const resolveConfig = async (localConfig) => {
35
35
  'plugins/**/*.ts',
36
36
  ].map(pattern => toProductionEntry(join(srcDir, pattern))),
37
37
  ];
38
- const deps = localConfig.modules?.reduce((acc, id) => {
39
- if (Array.isArray(id) && typeof id[0] === 'string')
40
- acc.push(toDependency(id[0]));
38
+ const deps = localConfig.modules?.reduce((acc, mod) => {
39
+ const id = Array.isArray(mod) ? mod[0] : mod;
41
40
  if (typeof id === 'string')
42
- acc.push(toDependency(id));
41
+ acc.push(isInternal(id) ? toDeferResolve(id) : toDependency(id));
43
42
  return acc;
44
43
  }, []) ?? [];
45
44
  return [...deps, ...patterns];
@@ -1,5 +1,4 @@
1
1
  import { toEntry, toProductionEntry } from '../../util/input.js';
2
- import { getScriptCommands } from '../../util/scripts.js';
3
2
  import { createFsPromisesGlobVisitor } from './visitors/fsPromisesGlob.js';
4
3
  const title = 'Node.js';
5
4
  const isEnabled = () => true;
@@ -10,14 +9,14 @@ const patterns = [
10
9
  '**/test/**/*.{cjs,mjs,js,cts,mts,ts}',
11
10
  ];
12
11
  const hasNodeTestCache = new WeakMap();
13
- const hasNodeTest = (scripts) => {
12
+ const hasNodeTest = (scripts, cwd, getScriptCommands) => {
14
13
  if (!scripts)
15
14
  return false;
16
15
  const cached = hasNodeTestCache.get(scripts);
17
16
  if (cached !== undefined)
18
17
  return cached;
19
18
  const result = Object.values(scripts).some(script => typeof script === 'string' &&
20
- getScriptCommands(script).some(({ binary, args }) => (binary === 'node' || binary === 'nub') && args.includes('--test')));
19
+ getScriptCommands(script, cwd).some(({ binary, args }) => (binary === 'node' || binary === 'nub') && args.includes('--test')));
21
20
  hasNodeTestCache.set(scripts, result);
22
21
  return result;
23
22
  };
@@ -27,7 +26,8 @@ const registerVisitors = ({ ctx, registerVisitor }) => {
27
26
  };
28
27
  const resolve = options => {
29
28
  const entries = entry.map(id => toProductionEntry(id));
30
- if (hasNodeTest(options.manifest.scripts) || hasNodeTest(options.rootManifest?.scripts)) {
29
+ if (hasNodeTest(options.manifest.scripts, options.cwd, options.getScriptCommands) ||
30
+ hasNodeTest(options.rootManifest?.scripts, options.rootCwd, options.getScriptCommands)) {
31
31
  entries.push(...patterns.map(toEntry));
32
32
  }
33
33
  return entries;
@@ -1,4 +1,5 @@
1
- import { toDependency } from '../../util/input.js';
1
+ import { toDeferResolve, toDependency } from '../../util/input.js';
2
+ import { isInternal } from '../../util/path.js';
2
3
  import { hasDependency } from '../../util/plugin.js';
3
4
  import { toCosmiconfig } from '../../util/plugin-config.js';
4
5
  const title = 'npm-package-json-lint';
@@ -6,8 +7,14 @@ const enablers = ['npm-package-json-lint'];
6
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
8
  const packageJsonPath = 'npmpackagejsonlint';
8
9
  const config = ['package.json', ...toCosmiconfig('npmpackagejsonlint')];
9
- const resolveConfig = localConfig => {
10
- return localConfig?.extends ? [localConfig.extends].flat().map(id => toDependency(id)) : [];
10
+ const resolveConfig = (localConfig, options) => {
11
+ if (!localConfig?.extends)
12
+ return [];
13
+ return [localConfig.extends].flat().map(id => {
14
+ if (!isInternal(id))
15
+ return toDependency(id);
16
+ return id.startsWith('./') ? toDeferResolve(id, { dir: options.cwd }) : toDeferResolve(id);
17
+ });
11
18
  };
12
19
  const plugin = {
13
20
  title,
@@ -1,6 +1,6 @@
1
1
  import { isDirectory } from '../../util/fs.js';
2
2
  import { _syncGlob } from '../../util/glob.js';
3
- import { toAlias, toConfig, toDeferResolveProductionEntry, toDependency, toEntry, toIgnore, toProductionDependency, toProductionEntry, } from '../../util/input.js';
3
+ import { toAlias, toConfig, toDeferResolve, toDeferResolveProductionEntry, toDependency, toEntry, toIgnore, toProductionDependency, toProductionEntry, } from '../../util/input.js';
4
4
  import { loadTSConfig } from '../../util/load-tsconfig.js';
5
5
  import { isInternal, join, toAbsolute } from '../../util/path.js';
6
6
  import { hasDependency } from '../../util/plugin.js';
@@ -9,20 +9,21 @@ const title = 'Nuxt';
9
9
  const enablers = ['nuxt', 'nuxt-nightly'];
10
10
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
11
11
  const config = ['nuxt.config.{js,cjs,mjs,ts,cts,mts}'];
12
- const entry = ['app.config.ts', '**/*.d.vue.ts'];
12
+ const scriptExt = '{js,mjs,cjs,jsx,ts,mts,cts,tsx}';
13
+ const entry = [`app.config.${scriptExt}`, '**/*.d.vue.ts'];
13
14
  const app = ['app.{vue,jsx,tsx}', 'error.{vue,jsx,tsx}', 'router.options.ts'];
14
15
  const layout = (dir = 'layouts') => join(dir, '**/*.{vue,jsx,tsx}');
15
- const middleware = (dir = 'middleware') => join(dir, '**/*.ts');
16
+ const middleware = (dir = 'middleware') => [join(dir, `*.${scriptExt}`), join(dir, `*/index.${scriptExt}`)];
16
17
  const pages = (dir = 'pages') => join(dir, '**/*.{vue,jsx,tsx}');
17
- const plugins = (dir = 'plugins') => join(dir, '**/*.ts');
18
+ const plugins = (dir = 'plugins') => [join(dir, `*.${scriptExt}`), join(dir, `*/index.${scriptExt}`)];
18
19
  const modules = 'modules/**/*.{ts,vue}';
19
20
  const server = ['api/**/*.ts', 'middleware/**/*.ts', 'plugins/**/*.ts', 'routes/**/*.ts', 'tasks/**/*.ts'];
20
21
  const production = [
21
22
  ...app,
22
23
  layout(),
23
- middleware(),
24
+ ...middleware(),
24
25
  pages(),
25
- plugins(),
26
+ ...plugins(),
26
27
  modules,
27
28
  ...server.map(id => join('server', id)),
28
29
  ];
@@ -75,9 +76,11 @@ const addAppEntries = (inputs, srcDir, serverDir, config, dir) => {
75
76
  for (const id of app)
76
77
  inputs.push(toProductionEntry(join(srcDir, id)));
77
78
  inputs.push(toProductionEntry(join(srcDir, layout(config.dir?.layouts))));
78
- inputs.push(toProductionEntry(join(srcDir, middleware(config.dir?.middleware))));
79
+ for (const id of middleware(config.dir?.middleware))
80
+ inputs.push(toProductionEntry(join(srcDir, id)));
79
81
  inputs.push(toProductionEntry(join(srcDir, pages(config.dir?.pages))));
80
- inputs.push(toProductionEntry(join(srcDir, plugins(config.dir?.plugins))));
82
+ for (const id of plugins(config.dir?.plugins))
83
+ inputs.push(toProductionEntry(join(srcDir, id)));
81
84
  inputs.push(toProductionEntry(join(srcDir, 'components/global/**/*.{vue,jsx,tsx}')));
82
85
  for (const id of server)
83
86
  inputs.push(toProductionEntry(join(dir, serverDir, id)));
@@ -120,6 +123,11 @@ const resolveConfig = async (localConfig, options) => {
120
123
  if (typeof id === 'string')
121
124
  addModule(id);
122
125
  }
126
+ for (const id of localConfig.plugins ?? []) {
127
+ const src = typeof id === 'string' ? id : id?.src;
128
+ if (typeof src === 'string')
129
+ inputs.push(toDeferResolve(resolveAlias(src, srcDir, cwd), { dir: cwd, production: true }));
130
+ }
123
131
  addAppEntries(inputs, srcDir, serverDir, localConfig, cwd);
124
132
  const sharedDir = toAbsolute(localConfig.dir?.shared ?? 'shared', cwd);
125
133
  inputs.push(toAlias('#shared', sharedDir));
@@ -144,7 +152,7 @@ const resolveConfig = async (localConfig, options) => {
144
152
  for (const cfg of configs)
145
153
  inputs.push(toConfig('nuxt', cfg));
146
154
  else
147
- inputs.push(toDependency(source));
155
+ inputs.push(isInternal(target) ? toDependency(source) : toProductionDependency(source));
148
156
  }
149
157
  for (const layerConfig of findLayerConfigs(cwd)) {
150
158
  inputs.push(toConfig('nuxt', layerConfig));
@@ -154,7 +162,7 @@ const resolveConfig = async (localConfig, options) => {
154
162
  for (const file of _syncGlob({ cwd, patterns: ['.nuxt/module/*.d.ts'] })) {
155
163
  const result = readAndParseFile(file);
156
164
  for (const p of collectLocalImportPaths(file, result))
157
- inputs.push(toProductionEntry(p));
165
+ inputs.push(toDeferResolveProductionEntry(p));
158
166
  }
159
167
  const dir = join(cwd, '.nuxt');
160
168
  const tsConfig = await loadTSConfig(join(dir, 'tsconfig.json'));
@@ -17,6 +17,10 @@ export interface NuxtConfig {
17
17
  autoImport?: boolean;
18
18
  dirs?: string[];
19
19
  };
20
+ plugins?: Array<string | {
21
+ src: string;
22
+ mode?: string;
23
+ }>;
20
24
  extends?: NuxtLayer | NuxtLayer[];
21
25
  components?: Array<string | {
22
26
  path: string;
@@ -1,8 +1,8 @@
1
1
  import { compact } from '../../util/array.js';
2
2
  import { isFile, loadJSON } from '../../util/fs.js';
3
- import { toConfig, toDeferResolveEntry, toDependency } from '../../util/input.js';
3
+ import { toConfig, toDeferResolve, toDeferResolveEntry, toDependency } from '../../util/input.js';
4
4
  import { get } from '../../util/object.js';
5
- import { dirname, join, relative, toAbsolute } from '../../util/path.js';
5
+ import { dirname, isInternal, join, relative, toAbsolute } from '../../util/path.js';
6
6
  import { hasDependency } from '../../util/plugin.js';
7
7
  import { substringBefore } from '../../util/string.js';
8
8
  const title = 'Nx';
@@ -25,7 +25,10 @@ const findNxDependenciesInNxJson = async (localConfig) => {
25
25
  .filter(value => value !== undefined)
26
26
  .map(value => substringBefore(value, ':'))
27
27
  : [];
28
- return compact([...targetsDefault, ...plugins, ...generators]).map(id => toDependency(id));
28
+ return [
29
+ ...compact([...targetsDefault, ...generators]).map(id => toDependency(id)),
30
+ ...compact(plugins).map(id => (isInternal(id) ? toDeferResolve(id) : toDependency(id))),
31
+ ];
29
32
  };
30
33
  const resolveConfig = async (localConfig, options) => {
31
34
  const { configFileName } = options;
@@ -1,12 +1,12 @@
1
1
  import { collectPropertyValues } from '../../typescript/ast-helpers.js';
2
2
  import { _parseFile } from '../../typescript/ast-nodes.js';
3
- import { toProductionEntry } from '../../util/input.js';
3
+ import { toDeferResolveProductionEntry, toProductionEntry } from '../../util/input.js';
4
4
  const title = 'OpenClaw';
5
5
  const enablers = 'This plugin is enabled when `package.json#openclaw` is present.';
6
6
  const isEnabled = ({ manifest }) => Object.hasOwn(manifest, 'openclaw');
7
7
  const config = ['package.json', 'openclaw.plugin.json'];
8
8
  const isLoadConfig = ({ configFileName }) => configFileName === 'package.json';
9
- const toEntries = (value) => (Array.isArray(value) ? value : [value]).flatMap(entry => typeof entry === 'string' ? [toProductionEntry(entry)] : []);
9
+ const toEntries = (value, dir) => (Array.isArray(value) ? value : [value]).flatMap(entry => typeof entry === 'string' ? [toDeferResolveProductionEntry(entry, { dir })] : []);
10
10
  const toHookEntries = (value) => (Array.isArray(value) ? value : [value]).flatMap(entry => {
11
11
  if (typeof entry !== 'string')
12
12
  return [];
@@ -21,15 +21,15 @@ const resolveConfig = (localConfig, options) => {
21
21
  .getInputsFromScripts(assetScripts)
22
22
  .map(input => input.type === 'entry' || input.type === 'deferResolveEntry' ? { ...input, production: true } : input);
23
23
  return [
24
- ...toEntries(localConfig.extensions),
25
- ...toEntries(localConfig.runtimeExtensions),
26
- ...toEntries(localConfig.setupEntry),
27
- ...toEntries(localConfig.runtimeSetupEntry),
28
- ...toEntries(localConfig.providerCatalogEntry),
29
- ...toEntries(localConfig.channel?.configuredState?.specifier),
30
- ...toEntries(localConfig.channel?.persistedAuthState?.specifier),
24
+ ...toEntries(localConfig.extensions, options.cwd),
25
+ ...toEntries(localConfig.runtimeExtensions, options.cwd),
26
+ ...toEntries(localConfig.setupEntry, options.cwd),
27
+ ...toEntries(localConfig.runtimeSetupEntry, options.cwd),
28
+ ...toEntries(localConfig.providerCatalogEntry, options.cwd),
29
+ ...toEntries(localConfig.channel?.configuredState?.specifier, options.cwd),
30
+ ...toEntries(localConfig.channel?.persistedAuthState?.specifier, options.cwd),
31
31
  ...toHookEntries(localConfig.hooks),
32
- ...toEntries(localConfig.build?.staticAssets?.map(asset => asset.source)),
32
+ ...(localConfig.build?.staticAssets ?? []).flatMap(asset => typeof asset.source === 'string' ? [toProductionEntry(asset.source)] : []),
33
33
  ...assetScriptInputs,
34
34
  ];
35
35
  };
@@ -38,7 +38,7 @@ const resolveFromAST = (_, options) => {
38
38
  return [];
39
39
  const sourceText = options.readFile(options.configFilePath).replace(/^\uFEFF/, '');
40
40
  const { program } = _parseFile(`${options.configFilePath}.ts`, `(${sourceText}\n)`);
41
- return Array.from(collectPropertyValues(program, 'providerCatalogEntry'), entry => toProductionEntry(entry));
41
+ return Array.from(collectPropertyValues(program, 'providerCatalogEntry'), entry => toDeferResolveProductionEntry(entry, { dir: options.cwd }));
42
42
  };
43
43
  const plugin = {
44
44
  title,
@@ -1,4 +1,4 @@
1
- import { toConfig, toDependency, toEntry } from '../../util/input.js';
1
+ import { toConfig, toDependency, toDeferResolveEntry } from '../../util/input.js';
2
2
  import { dirname, isInternal, toAbsolute } from '../../util/path.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
4
  import { getInputsFromSettings } from '../eslint/helpers.js';
@@ -17,7 +17,7 @@ const resolveJsPlugins = (jsPlugins, configFilePath) => {
17
17
  if (!isInternal(specifier))
18
18
  inputs.push(toDependency(specifier));
19
19
  else
20
- inputs.push(toEntry(toAbsolute(specifier, dir)));
20
+ inputs.push(toDeferResolveEntry(toAbsolute(specifier, dir)));
21
21
  }
22
22
  return inputs;
23
23
  };
@@ -3,7 +3,7 @@ import { hasDependency } from '../../util/plugin.js';
3
3
  const title = 'Payload CMS';
4
4
  const enablers = ['payload'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
- const config = ['payload.config.ts', 'src/payload.config.ts'];
6
+ const config = ['payload.config.{js,ts}', 'src/payload.config.{js,ts}'];
7
7
  const resolveConfig = async (config) => {
8
8
  const awaitedConfig = await config;
9
9
  const importMapFile = awaitedConfig?.admin?.importMap?.importMapFile;
@@ -1,5 +1,5 @@
1
1
  import { arrayify } from '../../util/array.js';
2
- import { toDeferResolve, toEntry } from '../../util/input.js';
2
+ import { toDeferResolve, toDeferResolveEntry, toEntry } from '../../util/input.js';
3
3
  import { join, toAbsolute } from '../../util/path.js';
4
4
  import { hasDependency } from '../../util/plugin.js';
5
5
  const title = 'Playwright';
@@ -18,9 +18,9 @@ export const resolveConfig = async (localConfig, options) => {
18
18
  const { configFileDir } = options;
19
19
  const inputs = [];
20
20
  for (const id of arrayify(localConfig.globalSetup))
21
- inputs.push(toEntry(toAbsolute(id, configFileDir)));
21
+ inputs.push(toDeferResolveEntry(toAbsolute(id, configFileDir)));
22
22
  for (const id of arrayify(localConfig.globalTeardown))
23
- inputs.push(toEntry(toAbsolute(id, configFileDir)));
23
+ inputs.push(toDeferResolveEntry(toAbsolute(id, configFileDir)));
24
24
  for (const server of [localConfig.webServer].flat()) {
25
25
  if (!server?.command)
26
26
  continue;
@@ -1,27 +1,27 @@
1
- import { toEntry } from '../../util/input.js';
1
+ import { toDeferResolveEntry } from '../../util/input.js';
2
2
  import { isInternal } from '../../util/path.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
4
  const title = 'pm2';
5
5
  const enablers = ['pm2'];
6
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
7
  const config = ['pm2.config.{json,js,cjs,mjs}', 'ecosystem.config.{json,js,cjs,mjs}'];
8
- const addApplicationEntry = (application, entries) => {
8
+ const addApplicationEntry = (application, entries, cwd) => {
9
9
  if (application.script && isInternal(application.script))
10
- entries.push(toEntry(application.script));
10
+ entries.push(toDeferResolveEntry(application.script, { dir: cwd }));
11
11
  };
12
- const resolveConfig = config => {
12
+ const resolveConfig = (config, { cwd }) => {
13
13
  const entries = [];
14
14
  if (Array.isArray(config)) {
15
15
  for (const application of config)
16
- addApplicationEntry(application, entries);
16
+ addApplicationEntry(application, entries, cwd);
17
17
  return entries;
18
18
  }
19
- addApplicationEntry(config, entries);
19
+ addApplicationEntry(config, entries, cwd);
20
20
  if (!config.apps)
21
21
  return entries;
22
22
  const applications = Array.isArray(config.apps) ? config.apps : [config.apps];
23
23
  for (const application of applications)
24
- addApplicationEntry(application, entries);
24
+ addApplicationEntry(application, entries, cwd);
25
25
  return entries;
26
26
  };
27
27
  const plugin = {
@@ -1,4 +1,5 @@
1
1
  import { toDeferResolve, toDependency } from '../../util/input.js';
2
+ import { isInternal } from '../../util/path.js';
2
3
  import { hasDependency } from '../../util/plugin.js';
3
4
  const title = 'Prettier';
4
5
  const enablers = ['prettier'];
@@ -17,7 +18,7 @@ const resolveConfig = config => {
17
18
  if (Array.isArray(options.plugins)) {
18
19
  for (const plugin of options.plugins) {
19
20
  if (typeof plugin === 'string') {
20
- result.add(toDependency(plugin));
21
+ result.add(isInternal(plugin) ? toDeferResolve(plugin) : toDependency(plugin));
21
22
  }
22
23
  }
23
24
  }
@@ -1,5 +1,5 @@
1
1
  import { isDirectory } from '../../util/fs.js';
2
- import { toEntry } from '../../util/input.js';
2
+ import { toDeferResolveEntry, toEntry } from '../../util/input.js';
3
3
  import { join } from '../../util/path.js';
4
4
  import { hasDependency } from '../../util/plugin.js';
5
5
  import compiler from './compiler.js';
@@ -14,7 +14,7 @@ const config = [
14
14
  ];
15
15
  const resolveSchema = (path, cwd) => {
16
16
  if (!isDirectory(cwd, path)) {
17
- return toEntry(path);
17
+ return toDeferResolveEntry(path, { dir: cwd });
18
18
  }
19
19
  return toEntry(join(path, '**/*.prisma'));
20
20
  };
@@ -1,6 +1,6 @@
1
1
  import { findProperty, getFirstPropertyValue, getStringValues, resolveObjectArg, } from '../../typescript/ast-helpers.js';
2
2
  import { getStringValue } from '../../typescript/ast-nodes.js';
3
- import { toDeferResolve, toProductionEntry } from '../../util/input.js';
3
+ import { toDependency, toDeferResolveProductionEntry, toProductionEntry } from '../../util/input.js';
4
4
  import { join } from '../../util/path.js';
5
5
  const sourceFilesEntries = [
6
6
  ['rootComponent', ['src/App.vue']],
@@ -31,7 +31,6 @@ const getConfigObject = (program) => {
31
31
  }
32
32
  }
33
33
  };
34
- const withExtensions = (id) => (id.includes('.') ? id : `${id}.{js,ts}`);
35
34
  export const resolveFromAST = (program, options) => {
36
35
  const { configFileDir } = options;
37
36
  const inputs = [];
@@ -39,9 +38,11 @@ export const resolveFromAST = (program, options) => {
39
38
  const sourceFiles = findProperty(config, 'sourceFiles');
40
39
  for (const [key, defaults] of sourceFilesEntries) {
41
40
  const override = getFirstPropertyValue(sourceFiles, key);
42
- for (const id of override ? [withExtensions(override)] : defaults) {
43
- inputs.push(toProductionEntry(join(configFileDir, id)));
44
- }
41
+ if (override)
42
+ inputs.push(toDeferResolveProductionEntry(join(configFileDir, override)));
43
+ else
44
+ for (const id of defaults)
45
+ inputs.push(toProductionEntry(join(configFileDir, id)));
45
46
  }
46
47
  for (const id of staticEntries)
47
48
  inputs.push(toProductionEntry(join(configFileDir, id)));
@@ -49,15 +50,19 @@ export const resolveFromAST = (program, options) => {
49
50
  if (boot?.type === 'ArrayExpression') {
50
51
  for (const element of boot.elements ?? []) {
51
52
  const id = getStringValue(element) ?? getFirstPropertyValue(element, 'path');
52
- if (id)
53
- inputs.push(toProductionEntry(join(configFileDir, 'src/boot', withExtensions(id))));
53
+ if (!id)
54
+ continue;
55
+ if (id.startsWith('~'))
56
+ inputs.push(toDependency(id.slice(1)));
57
+ else
58
+ inputs.push(toDeferResolveProductionEntry(join(configFileDir, 'src/boot', id)));
54
59
  }
55
60
  }
56
61
  for (const id of getStringValues(findProperty(config, 'css'))) {
57
62
  if (id.startsWith('~'))
58
- inputs.push(toDeferResolve(id.slice(1)));
63
+ inputs.push(toDependency(id.slice(1)));
59
64
  else
60
- inputs.push(toProductionEntry(join(configFileDir, 'src/css', id)));
65
+ inputs.push(toDeferResolveProductionEntry(join(configFileDir, 'src/css', id)));
61
66
  }
62
67
  return inputs;
63
68
  };
@@ -1,6 +1,6 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { _glob } from '../../util/glob.js';
3
- import { toEntry, toProductionDependency, toProductionEntry } from '../../util/input.js';
3
+ import { toDeferResolveProductionEntry, toEntry, toProductionDependency, toProductionEntry } from '../../util/input.js';
4
4
  import { join, toAbsolute } from '../../util/path.js';
5
5
  import { hasDependency, load } from '../../util/plugin.js';
6
6
  import vite from '../vite/index.js';
@@ -8,34 +8,31 @@ const title = 'React Router';
8
8
  const enablers = ['@react-router/dev'];
9
9
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
10
10
  const viteConfig = typeof vite.config === 'function' ? [] : (vite.config ?? []);
11
- const config = ['react-router.config.{js,ts}', ...viteConfig];
11
+ const entryExts = ['js', 'jsx', 'ts', 'tsx', 'mjs', 'mts'];
12
+ const entryExtsGlob = `{${entryExts.join(',')}}`;
13
+ const config = [`react-router.config.${entryExtsGlob}`, ...viteConfig];
12
14
  const resolveConfig = async (localConfig, options) => {
13
15
  const { configFileDir } = options;
14
16
  const appDirectory = localConfig.appDirectory ?? 'app';
15
17
  const appDir = toAbsolute(appDirectory, configFileDir);
16
18
  globalThis.__reactRouterAppDirectory = appDir;
17
19
  let routeConfig = [];
18
- const routesPathTs = join(appDir, 'routes.ts');
19
- const routesPathJs = join(appDir, 'routes.js');
20
- if (existsSync(routesPathTs)) {
21
- routeConfig = await load(routesPathTs);
22
- }
23
- else if (existsSync(routesPathJs)) {
24
- routeConfig = await load(routesPathJs);
25
- }
20
+ const routesPath = entryExts.map(ext => join(appDir, `routes.${ext}`)).find(existsSync);
21
+ if (routesPath)
22
+ routeConfig = await load(routesPath);
26
23
  const mapRoute = (route) => {
27
24
  return [toAbsolute(route.file, appDir), ...(route.children ? route.children.flatMap(mapRoute) : [])];
28
25
  };
29
26
  const routes = routeConfig.flatMap(mapRoute);
30
27
  const resolved = [
31
- toEntry(join(appDir, 'routes.{js,ts}')),
32
- toProductionEntry(join(appDir, 'root.{jsx,tsx}')),
33
- toProductionEntry(join(appDir, 'entry.{client,server}.{js,jsx,ts,tsx}')),
34
- ...routes.map(id => toProductionEntry(id)),
28
+ toEntry(join(appDir, `routes.${entryExtsGlob}`)),
29
+ toProductionEntry(join(appDir, `root.${entryExtsGlob}`)),
30
+ toProductionEntry(join(appDir, `entry.{client,server}.${entryExtsGlob}`)),
31
+ ...routes.map(id => toDeferResolveProductionEntry(id)),
35
32
  ];
36
33
  const serverEntries = await _glob({
37
34
  cwd: appDir,
38
- patterns: ['entry.server.{js,ts,jsx,tsx}'],
35
+ patterns: [`entry.server.${entryExtsGlob}`],
39
36
  });
40
37
  if (serverEntries.length === 0) {
41
38
  resolved.push(toProductionDependency('@react-router/node'));
@@ -1,4 +1,5 @@
1
- import { toDependency } from '../../util/input.js';
1
+ import { toDeferResolve, toDependency } from '../../util/input.js';
2
+ import { isInternal } from '../../util/path.js';
2
3
  import { hasDependency } from '../../util/plugin.js';
3
4
  const title = 'Release It!';
4
5
  const enablers = ['release-it'];
@@ -14,7 +15,10 @@ const resolveConfig = (config, options) => {
14
15
  scripts.push(config.gitlab.releaseNotes);
15
16
  }
16
17
  const inputs = options.getInputsFromScripts(scripts);
17
- return [...plugins.map(id => toDependency(id)), ...inputs];
18
+ return [
19
+ ...plugins.map(id => (isInternal(id) ? toDeferResolve(id, { dir: options.cwd }) : toDependency(id))),
20
+ ...inputs,
21
+ ];
18
22
  };
19
23
  const plugin = {
20
24
  title,
@@ -2,11 +2,11 @@ import { hasDependency } from '../../util/plugin.js';
2
2
  const title = 'Remix';
3
3
  const enablers = ['@remix-run/dev'];
4
4
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
- const entry = ['remix.config.js', 'remix.init/index.js'];
5
+ const entry = ['remix.config.{js,cjs,mjs}', 'remix.init/index.js'];
6
6
  const production = [
7
- 'app/root.tsx',
7
+ 'app/root.{js,jsx,ts,tsx}',
8
8
  'app/entry.{client,server}.{js,jsx,ts,tsx}',
9
- 'app/routes/**/*.{js,ts,tsx}',
9
+ 'app/routes/**/*.{js,jsx,ts,tsx}',
10
10
  'server.{js,ts}',
11
11
  ];
12
12
  const plugin = {
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,14 @@
1
+ import { spawningArgs } from '../../binaries/util.js';
2
+ const title = 'retry-cli';
3
+ const args = {
4
+ binaries: ['retry', 'retry-cli'],
5
+ string: ['factor', 'max-timeout', 'min-timeout', 'retries'],
6
+ boolean: ['help', 'randomize'],
7
+ alias: { factor: ['f'], help: ['h'], 'min-timeout': ['t'], retries: ['n'] },
8
+ fromArgs: spawningArgs,
9
+ };
10
+ const plugin = {
11
+ title,
12
+ args,
13
+ };
14
+ export default plugin;
@@ -7,11 +7,8 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
7
  const config = ['rollup.config.{js,cjs,mjs,ts}'];
8
8
  const args = {
9
9
  alias: { plugin: ['p'] },
10
- string: ['config'],
11
10
  config: ['config'],
12
- args: (args) => args
13
- .filter((arg, index) => !(arg === '--config' && (args[index + 1] === undefined || args[index + 1].startsWith('-'))))
14
- .map(arg => (arg.startsWith('--watch.onEnd') ? `--_exec${arg.slice(13)}` : arg)),
11
+ args: (args) => args.map(arg => (arg.startsWith('--watch.onEnd') ? `--_exec${arg.slice(13)}` : arg)),
15
12
  fromArgs: ['_exec'],
16
13
  resolve: ['plugin', 'configPlugin'],
17
14
  };
@@ -1,7 +1,7 @@
1
1
  import { arrayify } from '../../util/array.js';
2
2
  import { findFileWithExtensions } from '../../util/fs.js';
3
3
  import { _dirGlob, _glob, negate } from '../../util/glob.js';
4
- import { toAlias, toConfig, toDeferResolve, toDependency, toEntry } from '../../util/input.js';
4
+ import { toAlias, toConfig, toDeferResolve, toDeferResolveEntry, toDependency, toEntry, } from '../../util/input.js';
5
5
  import { dirname, join, toAbsolute } from '../../util/path.js';
6
6
  import { hasDependency, load } from '../../util/plugin.js';
7
7
  import { createRstestMockVisitor } from './visitors/mock.js';
@@ -39,7 +39,7 @@ const resolveConfig = async (localConfig, options) => {
39
39
  ? include
40
40
  : await _glob({ cwd, patterns: [...include, ...exclude.map(pattern => negate(toPattern(pattern)))] });
41
41
  for (const entry of entries)
42
- inputs.push(toEntry(entry));
42
+ inputs.push(exclude.length === 0 ? toEntry(entry) : toDeferResolveEntry(entry));
43
43
  }
44
44
  const env = project.testEnvironment;
45
45
  inputs.push(...getEnvironmentDependency(typeof env === 'string' ? env : env?.name));
@@ -94,7 +94,7 @@ const resolveConfig = async (localConfig, options) => {
94
94
  inputs.push(toConfig('rstest', filePath));
95
95
  continue;
96
96
  }
97
- inputs.push(toEntry(filePath));
97
+ inputs.push(toDeferResolveEntry(filePath));
98
98
  if (project.projects)
99
99
  await addProjects(project.projects, dirname(filePath));
100
100
  else