knip 6.24.0 → 6.26.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 (203) hide show
  1. package/dist/ConfigurationChief.d.ts +115 -1
  2. package/dist/ConfigurationChief.js +3 -0
  3. package/dist/ProjectPrincipal.d.ts +2 -0
  4. package/dist/ProjectPrincipal.js +4 -1
  5. package/dist/binaries/bash-parser.js +55 -83
  6. package/dist/binaries/index.js +3 -0
  7. package/dist/compilers/index.d.ts +199 -5
  8. package/dist/constants.d.ts +5 -1
  9. package/dist/constants.js +18 -0
  10. package/dist/graph/analyze.js +37 -2
  11. package/dist/graph/build.js +17 -3
  12. package/dist/graph-explorer/explorer.d.ts +1 -0
  13. package/dist/graph-explorer/explorer.js +2 -0
  14. package/dist/graph-explorer/operations/find-all-cycles.d.ts +3 -0
  15. package/dist/graph-explorer/operations/find-all-cycles.js +43 -0
  16. package/dist/graph-explorer/operations/find-cycles.js +3 -9
  17. package/dist/graph-explorer/utils.d.ts +10 -1
  18. package/dist/graph-explorer/utils.js +53 -0
  19. package/dist/plugins/_vue/auto-import.d.ts +12 -0
  20. package/dist/plugins/_vue/auto-import.js +272 -0
  21. package/dist/plugins/_vue/types.d.ts +38 -0
  22. package/dist/plugins/_vue/types.js +1 -0
  23. package/dist/plugins/astro/index.js +2 -37
  24. package/dist/plugins/astro/resolveFromAST.d.ts +4 -4
  25. package/dist/plugins/astro/resolveFromAST.js +34 -7
  26. package/dist/plugins/bun/index.js +28 -14
  27. package/dist/plugins/electron-vite/index.d.ts +3 -0
  28. package/dist/plugins/electron-vite/index.js +51 -0
  29. package/dist/plugins/electron-vite/types.d.ts +23 -0
  30. package/dist/plugins/electron-vite/types.js +1 -0
  31. package/dist/plugins/esbuild/index.d.ts +3 -0
  32. package/dist/plugins/esbuild/index.js +17 -0
  33. package/dist/plugins/eslint/resolveFromAST.js +18 -21
  34. package/dist/plugins/eve/index.d.ts +3 -0
  35. package/dist/plugins/eve/index.js +22 -0
  36. package/dist/plugins/execa/visitors/execa.js +10 -18
  37. package/dist/plugins/fumadocs/index.d.ts +3 -0
  38. package/dist/plugins/fumadocs/index.js +18 -0
  39. package/dist/plugins/graphql-codegen/index.js +9 -7
  40. package/dist/plugins/index.d.ts +19 -0
  41. package/dist/plugins/index.js +38 -0
  42. package/dist/plugins/jest/index.js +13 -3
  43. package/dist/plugins/laravel-vite-plugin/index.d.ts +3 -0
  44. package/dist/plugins/laravel-vite-plugin/index.js +14 -0
  45. package/dist/plugins/laravel-vite-plugin/resolveFromAST.d.ts +2 -0
  46. package/dist/plugins/laravel-vite-plugin/resolveFromAST.js +27 -0
  47. package/dist/plugins/next/index.js +25 -12
  48. package/dist/plugins/next-mdx/index.js +2 -8
  49. package/dist/plugins/next-mdx/resolveFromAST.d.ts +3 -2
  50. package/dist/plugins/next-mdx/resolveFromAST.js +17 -21
  51. package/dist/plugins/node/index.js +4 -1
  52. package/dist/plugins/nuxt/index.js +5 -68
  53. package/dist/plugins/nuxt/types.d.ts +0 -34
  54. package/dist/plugins/nuxtjs-i18n/index.d.ts +3 -0
  55. package/dist/plugins/nuxtjs-i18n/index.js +12 -0
  56. package/dist/plugins/oclif/index.js +10 -5
  57. package/dist/plugins/orval/index.js +1 -3
  58. package/dist/plugins/orval/resolveFromAST.d.ts +2 -2
  59. package/dist/plugins/orval/resolveFromAST.js +4 -7
  60. package/dist/plugins/oxlint/index.js +23 -2
  61. package/dist/plugins/pnpm/index.js +22 -1
  62. package/dist/plugins/pnpm/types.d.ts +4 -0
  63. package/dist/plugins/pnpm/types.js +1 -0
  64. package/dist/plugins/prettier/index.js +19 -3
  65. package/dist/plugins/prettier/types.d.ts +6 -1
  66. package/dist/plugins/quasar/index.d.ts +3 -0
  67. package/dist/plugins/quasar/index.js +15 -0
  68. package/dist/plugins/quasar/resolveFromAST.d.ts +3 -0
  69. package/dist/plugins/quasar/resolveFromAST.js +63 -0
  70. package/dist/plugins/qwik/index.js +1 -25
  71. package/dist/plugins/qwik/resolveFromAST.d.ts +5 -3
  72. package/dist/plugins/qwik/resolveFromAST.js +28 -9
  73. package/dist/plugins/rolldown/index.js +2 -5
  74. package/dist/plugins/rollup/index.js +2 -5
  75. package/dist/plugins/rslib/index.js +2 -5
  76. package/dist/plugins/rspack/index.js +5 -0
  77. package/dist/plugins/serverless-framework/index.js +12 -1
  78. package/dist/plugins/serverless-framework/types.d.ts +5 -2
  79. package/dist/plugins/sst/index.js +1 -5
  80. package/dist/plugins/sst/resolveFromAST.d.ts +1 -1
  81. package/dist/plugins/sst/resolveFromAST.js +1 -1
  82. package/dist/plugins/starlight/index.js +1 -19
  83. package/dist/plugins/starlight/resolveFromAST.d.ts +2 -2
  84. package/dist/plugins/starlight/resolveFromAST.js +12 -8
  85. package/dist/plugins/stencil/index.js +2 -37
  86. package/dist/plugins/stencil/resolveFromAST.d.ts +3 -0
  87. package/dist/plugins/stencil/resolveFromAST.js +36 -0
  88. package/dist/plugins/storybook/index.js +10 -0
  89. package/dist/plugins/sveltekit/index.js +1 -48
  90. package/dist/plugins/sveltekit/resolveFromAST.d.ts +2 -0
  91. package/dist/plugins/sveltekit/resolveFromAST.js +45 -0
  92. package/dist/plugins/tauri/index.d.ts +3 -0
  93. package/dist/plugins/tauri/index.js +42 -0
  94. package/dist/plugins/tauri/types.d.ts +16 -0
  95. package/dist/plugins/tauri/types.js +1 -0
  96. package/dist/plugins/tsdown/index.js +2 -5
  97. package/dist/plugins/tsup/index.js +2 -5
  98. package/dist/plugins/typedoc/index.js +9 -3
  99. package/dist/plugins/typedoc/types.d.ts +2 -0
  100. package/dist/plugins/unplugin-auto-import/index.d.ts +3 -0
  101. package/dist/plugins/unplugin-auto-import/index.js +18 -0
  102. package/dist/plugins/unplugin-icons/index.d.ts +3 -0
  103. package/dist/plugins/unplugin-icons/index.js +17 -0
  104. package/dist/plugins/unplugin-vue-components/index.d.ts +3 -0
  105. package/dist/plugins/unplugin-vue-components/index.js +16 -0
  106. package/dist/plugins/unplugin-vue-i18n/index.d.ts +3 -0
  107. package/dist/plugins/unplugin-vue-i18n/index.js +10 -0
  108. package/dist/plugins/unplugin-vue-markdown/index.d.ts +3 -0
  109. package/dist/plugins/unplugin-vue-markdown/index.js +16 -0
  110. package/dist/plugins/unplugin-vue-router/index.d.ts +3 -0
  111. package/dist/plugins/unplugin-vue-router/index.js +14 -0
  112. package/dist/plugins/vite/helpers.d.ts +2 -0
  113. package/dist/plugins/vite/helpers.js +46 -31
  114. package/dist/plugins/vite/index.js +1 -1
  115. package/dist/plugins/vite/visitors/importMetaGlob.js +1 -8
  116. package/dist/plugins/vite-plugin-pages/index.d.ts +3 -0
  117. package/dist/plugins/vite-plugin-pages/index.js +26 -0
  118. package/dist/plugins/vite-plugin-pwa/index.d.ts +3 -0
  119. package/dist/plugins/vite-plugin-pwa/index.js +17 -0
  120. package/dist/plugins/vite-plugin-pwa/resolveFromAST.d.ts +4 -0
  121. package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +37 -0
  122. package/dist/plugins/vite-plugin-vue-layouts-next/index.d.ts +3 -0
  123. package/dist/plugins/vite-plugin-vue-layouts-next/index.js +23 -0
  124. package/dist/plugins/vite-plus/index.d.ts +3 -0
  125. package/dist/plugins/vite-plus/index.js +14 -0
  126. package/dist/plugins/vite-plus/resolveFromAST.d.ts +2 -0
  127. package/dist/plugins/vite-plus/resolveFromAST.js +37 -0
  128. package/dist/plugins/vite-pwa-assets-generator/index.d.ts +3 -0
  129. package/dist/plugins/vite-pwa-assets-generator/index.js +12 -0
  130. package/dist/plugins/vitepress/index.js +5 -1
  131. package/dist/plugins/vitest/index.js +4 -0
  132. package/dist/plugins/vitest/types.d.ts +3 -0
  133. package/dist/plugins/vue/index.js +5 -3
  134. package/dist/plugins/webpack/visitors/requireContext.js +2 -13
  135. package/dist/plugins/yarn/index.js +14 -4
  136. package/dist/plugins/yarn/types.d.ts +8 -0
  137. package/dist/plugins/yarn/types.js +1 -0
  138. package/dist/plugins/zx/visitors/zx.js +4 -4
  139. package/dist/reporters/cycles.d.ts +3 -0
  140. package/dist/reporters/cycles.js +79 -0
  141. package/dist/reporters/index.d.ts +1 -0
  142. package/dist/reporters/index.js +2 -0
  143. package/dist/reporters/json.d.ts +3 -0
  144. package/dist/reporters/json.js +2 -1
  145. package/dist/reporters/util/util.d.ts +3 -1
  146. package/dist/reporters/util/util.js +5 -1
  147. package/dist/schema/configuration.d.ts +295 -6
  148. package/dist/schema/configuration.js +6 -0
  149. package/dist/schema/plugins.d.ts +95 -0
  150. package/dist/schema/plugins.js +19 -0
  151. package/dist/types/PluginNames.d.ts +2 -2
  152. package/dist/types/PluginNames.js +19 -0
  153. package/dist/types/config.d.ts +9 -0
  154. package/dist/types/issues.d.ts +3 -0
  155. package/dist/types/module-graph.d.ts +7 -0
  156. package/dist/types/package-json.d.ts +8 -1
  157. package/dist/typescript/ast-helpers.d.ts +7 -2
  158. package/dist/typescript/ast-helpers.js +36 -8
  159. package/dist/typescript/ast-nodes.d.ts +4 -1
  160. package/dist/typescript/ast-nodes.js +17 -1
  161. package/dist/typescript/get-imports-and-exports.js +10 -0
  162. package/dist/typescript/glob-imports.d.ts +3 -0
  163. package/dist/typescript/glob-imports.js +49 -0
  164. package/dist/typescript/resolve-module-names.d.ts +2 -0
  165. package/dist/typescript/resolve-module-names.js +35 -1
  166. package/dist/typescript/visitors/calls.js +4 -6
  167. package/dist/typescript/visitors/imports.js +8 -8
  168. package/dist/typescript/visitors/script-visitors.js +4 -4
  169. package/dist/typescript/visitors/walk.js +2 -3
  170. package/dist/util/cli-arguments.d.ts +2 -1
  171. package/dist/util/cli-arguments.js +5 -3
  172. package/dist/util/create-options.d.ts +202 -5
  173. package/dist/util/create-options.js +4 -1
  174. package/dist/util/get-included-issue-types.d.ts +1 -0
  175. package/dist/util/get-included-issue-types.js +4 -2
  176. package/dist/util/issue-initializers.js +1 -1
  177. package/dist/util/load-tsconfig.js +17 -4
  178. package/dist/util/module-graph.js +1 -0
  179. package/dist/util/modules.js +25 -4
  180. package/dist/util/resolve.js +4 -1
  181. package/dist/util/scripts.d.ts +7 -0
  182. package/dist/util/scripts.js +75 -0
  183. package/dist/util/to-source-path.js +1 -1
  184. package/dist/version.d.ts +1 -1
  185. package/dist/version.js +1 -1
  186. package/package.json +1 -1
  187. package/schema.json +108 -1
  188. package/dist/plugins/next/resolveFromAST.d.ts +0 -2
  189. package/dist/plugins/next/resolveFromAST.js +0 -2
  190. package/dist/plugins/nuxt/helpers.d.ts +0 -15
  191. package/dist/plugins/nuxt/helpers.js +0 -133
  192. package/dist/plugins/rolldown/resolveFromAST.d.ts +0 -2
  193. package/dist/plugins/rolldown/resolveFromAST.js +0 -4
  194. package/dist/plugins/rollup/resolveFromAST.d.ts +0 -2
  195. package/dist/plugins/rollup/resolveFromAST.js +0 -4
  196. package/dist/plugins/rslib/resolveFromAST.d.ts +0 -2
  197. package/dist/plugins/rslib/resolveFromAST.js +0 -4
  198. package/dist/plugins/tsdown/resolveFromAST.d.ts +0 -2
  199. package/dist/plugins/tsdown/resolveFromAST.js +0 -4
  200. package/dist/plugins/tsup/resolveFromAST.d.ts +0 -2
  201. package/dist/plugins/tsup/resolveFromAST.js +0 -4
  202. package/dist/plugins/vue/compiler.d.ts +0 -3
  203. package/dist/plugins/vue/compiler.js +0 -10
@@ -1,14 +1,13 @@
1
- import { findCallArg, getPropertyValues } from '../../typescript/ast-helpers.js';
2
- export const getSrcDir = (program) => {
1
+ import { findCallArg, getFirstPropertyValue, getPropertyValues } from '../../typescript/ast-helpers.js';
2
+ import { toEntry, toIgnore, toProductionEntry } from '../../util/input.js';
3
+ export const entry = ['src/entry.dev.tsx'];
4
+ export const production = ['src/root.tsx', 'src/entry.*.tsx'];
5
+ export const routeProduction = ['src/routes/**/*.{tsx,ts,md,mdx}'];
6
+ const getSrcDir = (program) => {
3
7
  const arg = findCallArg(program, 'qwikVite');
4
- if (arg) {
5
- const values = getPropertyValues(arg, 'srcDir');
6
- if (values.size > 0)
7
- return Array.from(values)[0];
8
- }
9
- return 'src';
8
+ return (arg && getFirstPropertyValue(arg, 'srcDir')) ?? 'src';
10
9
  };
11
- export const getRoutesDirs = (program, srcDir) => {
10
+ const getRoutesDirs = (program, srcDir) => {
12
11
  const arg = findCallArg(program, 'qwikCity');
13
12
  if (arg) {
14
13
  const values = Array.from(getPropertyValues(arg, 'routesDir')).filter(Boolean);
@@ -17,3 +16,23 @@ export const getRoutesDirs = (program, srcDir) => {
17
16
  }
18
17
  return [`${srcDir}/routes`];
19
18
  };
19
+ export const resolveFromAST = program => {
20
+ const srcDir = getSrcDir(program);
21
+ const routesDirs = getRoutesDirs(program, srcDir);
22
+ const setSrcDir = (pattern) => pattern.replace(/^src\//, `${srcDir}/`);
23
+ const setRoutesDir = (pattern, routesDir) => pattern.replace(/^src\/routes\//, `${routesDir}/`);
24
+ const routeEntries = [];
25
+ for (const routesDir of routesDirs) {
26
+ for (const pattern of routeProduction) {
27
+ routeEntries.push(toProductionEntry(setRoutesDir(pattern, routesDir)));
28
+ }
29
+ }
30
+ return [
31
+ ...entry.map(setSrcDir).map(path => toEntry(path)),
32
+ ...production.map(setSrcDir).map(path => toProductionEntry(path)),
33
+ ...routeEntries,
34
+ toIgnore('@qwik-city-plan', 'unlisted'),
35
+ toIgnore('@qwik-city-sw-register', 'unlisted'),
36
+ toIgnore('@qwik-client-manifest', 'unlisted'),
37
+ ];
38
+ };
@@ -1,14 +1,11 @@
1
+ import { collectPropertyValues } from '../../typescript/ast-helpers.js';
1
2
  import { toProductionEntry } from '../../util/input.js';
2
3
  import { hasDependency } from '../../util/plugin.js';
3
- import { getInputFromAST } from './resolveFromAST.js';
4
4
  const title = 'Rolldown';
5
5
  const enablers = ['rolldown'];
6
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
7
  const config = ['rolldown.config.{js,cjs,mjs,ts,cts,mts}'];
8
- const resolveFromAST = program => {
9
- const inputs = getInputFromAST(program);
10
- return [...inputs].map(id => toProductionEntry(id));
11
- };
8
+ const resolveFromAST = program => [...collectPropertyValues(program, 'input')].map(id => toProductionEntry(id));
12
9
  const plugin = {
13
10
  title,
14
11
  enablers,
@@ -1,6 +1,6 @@
1
+ import { collectPropertyValues } from '../../typescript/ast-helpers.js';
1
2
  import { toProductionEntry } from '../../util/input.js';
2
3
  import { hasDependency } from '../../util/plugin.js';
3
- import { getInputFromAST } from './resolveFromAST.js';
4
4
  const title = 'Rollup';
5
5
  const enablers = ['rollup'];
6
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -11,10 +11,7 @@ const args = {
11
11
  fromArgs: ['_exec'],
12
12
  resolve: ['plugin', 'configPlugin'],
13
13
  };
14
- const resolveFromAST = program => {
15
- const inputs = getInputFromAST(program);
16
- return [...inputs].map(id => toProductionEntry(id));
17
- };
14
+ const resolveFromAST = program => [...collectPropertyValues(program, 'input')].map(id => toProductionEntry(id));
18
15
  const plugin = {
19
16
  title,
20
17
  enablers,
@@ -1,14 +1,11 @@
1
+ import { collectPropertyValues } from '../../typescript/ast-helpers.js';
1
2
  import { toProductionEntry } from '../../util/input.js';
2
3
  import { hasDependency } from '../../util/plugin.js';
3
- import { getEntryFromAST } from './resolveFromAST.js';
4
4
  const title = 'Rslib';
5
5
  const enablers = ['@rslib/core'];
6
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
7
  const config = ['rslib*.config.{mjs,ts,js,cjs,mts,cts}'];
8
- const resolveFromAST = program => {
9
- const entries = getEntryFromAST(program);
10
- return [...entries].map(id => toProductionEntry(id, { allowIncludeExports: true }));
11
- };
8
+ const resolveFromAST = program => [...collectPropertyValues(program, 'entry')].map(id => toProductionEntry(id, { allowIncludeExports: true }));
12
9
  const plugin = {
13
10
  title,
14
11
  enablers,
@@ -1,5 +1,6 @@
1
1
  import { hasDependency } from '../../util/plugin.js';
2
2
  import { findWebpackDependenciesFromConfig } from '../webpack/index.js';
3
+ import { createRequireContextVisitor } from '../webpack/visitors/requireContext.js';
3
4
  const title = 'Rspack';
4
5
  const enablers = ['@rspack/core'];
5
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -8,11 +9,15 @@ const resolveConfig = async (localConfig, options) => {
8
9
  const inputs = await findWebpackDependenciesFromConfig(localConfig, options);
9
10
  return inputs.filter(input => !input.specifier.startsWith('builtin:'));
10
11
  };
12
+ const registerVisitors = ({ ctx, registerVisitor }) => {
13
+ registerVisitor(createRequireContextVisitor(ctx));
14
+ };
11
15
  const plugin = {
12
16
  title,
13
17
  enablers,
14
18
  isEnabled,
15
19
  config,
16
20
  resolveConfig,
21
+ registerVisitors,
17
22
  };
18
23
  export default plugin;
@@ -1,3 +1,4 @@
1
+ import { arrayify } from '../../util/array.js';
1
2
  import { toDependency, toProductionEntry } from '../../util/input.js';
2
3
  import { isInternal, join } from '../../util/path.js';
3
4
  import { hasDependency } from '../../util/plugin.js';
@@ -10,13 +11,23 @@ const handlerToEntry = (handler) => {
10
11
  return toProductionEntry(`${handler.slice(0, dot)}.{js,ts}`);
11
12
  };
12
13
  const pluginToInput = (plugin, dir) => isInternal(plugin) ? toProductionEntry(join(dir, plugin)) : toDependency(plugin);
14
+ const getInjectEntries = (esbuild, dir) => esbuild && typeof esbuild === 'object' ? arrayify(esbuild.inject).map(id => toProductionEntry(join(dir, id))) : [];
13
15
  const resolveConfig = async (config, options) => {
14
16
  const functions = config.functions
15
17
  ? Object.values(config.functions).flatMap(fn => (fn.handler ? [handlerToEntry(fn.handler)] : []))
16
18
  : [];
17
19
  const plugins = config.plugins?.filter((plugin) => typeof plugin === 'string') ?? [];
18
20
  const esbuild = config.custom?.esbuild || config.build?.esbuild ? [toDependency('esbuild', { optional: true })] : [];
19
- return [...functions, ...plugins.map(plugin => pluginToInput(plugin, options.configFileDir)), ...esbuild];
21
+ const injectEntries = [
22
+ ...getInjectEntries(config.custom?.esbuild, options.configFileDir),
23
+ ...getInjectEntries(config.build?.esbuild, options.configFileDir),
24
+ ];
25
+ return [
26
+ ...functions,
27
+ ...plugins.map(plugin => pluginToInput(plugin, options.configFileDir)),
28
+ ...esbuild,
29
+ ...injectEntries,
30
+ ];
20
31
  };
21
32
  const plugin = {
22
33
  title,
@@ -1,13 +1,16 @@
1
1
  export type PluginConfig = {
2
2
  build?: {
3
- esbuild?: unknown;
3
+ esbuild?: EsbuildConfig;
4
4
  };
5
5
  custom?: {
6
- esbuild?: unknown;
6
+ esbuild?: EsbuildConfig;
7
7
  };
8
8
  functions?: Record<string, ServerlessFunction>;
9
9
  plugins?: unknown[];
10
10
  };
11
+ export type EsbuildConfig = {
12
+ inject?: string[];
13
+ } | boolean;
11
14
  type ServerlessFunction = {
12
15
  handler?: string;
13
16
  };
@@ -1,13 +1,9 @@
1
1
  import { hasDependency } from '../../util/plugin.js';
2
- import { getInputsFromHandlers } from './resolveFromAST.js';
2
+ import { resolveFromAST } from './resolveFromAST.js';
3
3
  const title = 'SST';
4
4
  const enablers = ['sst'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  const config = ['sst.config.ts'];
7
- const resolveFromAST = (program, options) => {
8
- const inputs = getInputsFromHandlers(program, options);
9
- return inputs;
10
- };
11
7
  const plugin = {
12
8
  title,
13
9
  enablers,
@@ -1,2 +1,2 @@
1
1
  import type { ResolveFromAST } from '../../types/config.ts';
2
- export declare const getInputsFromHandlers: ResolveFromAST;
2
+ export declare const resolveFromAST: ResolveFromAST;
@@ -4,7 +4,7 @@ import { _parseFile } from '../../typescript/ast-nodes.js';
4
4
  import { toDeferResolveProductionEntry } from '../../util/input.js';
5
5
  import { dirname } from '../../util/path.js';
6
6
  import { _resolveSync } from '../../util/resolve.js';
7
- export const getInputsFromHandlers = (program, options) => {
7
+ export const resolveFromAST = (program, options) => {
8
8
  const entries = new Set();
9
9
  const addHandlers = (values) => {
10
10
  for (const specifier of values)
@@ -1,27 +1,9 @@
1
- import { findCallArg, getDefaultImportName, getImportMap, getPropertyValues } from '../../typescript/ast-helpers.js';
2
- import { toProductionEntry } from '../../util/input.js';
3
1
  import { hasDependency } from '../../util/plugin.js';
4
2
  import { config } from '../astro/index.js';
5
- import { getComponentPathsFromSourceFile } from './resolveFromAST.js';
3
+ import { resolveFromAST } from './resolveFromAST.js';
6
4
  const title = 'Starlight';
7
5
  const enablers = ['@astrojs/starlight'];
8
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
9
- const resolveFromAST = program => {
10
- const componentPaths = getComponentPathsFromSourceFile(program);
11
- const inputs = Array.from(componentPaths).map(id => toProductionEntry(id));
12
- const importMap = getImportMap(program);
13
- const starlightImportName = getDefaultImportName(importMap, '@astrojs/starlight');
14
- if (starlightImportName) {
15
- const starlightConfig = findCallArg(program, starlightImportName);
16
- if (starlightConfig) {
17
- const customCssPaths = getPropertyValues(starlightConfig, 'customCss');
18
- for (const id of customCssPaths) {
19
- inputs.push(toProductionEntry(id));
20
- }
21
- }
22
- }
23
- return inputs;
24
- };
25
7
  const plugin = {
26
8
  title,
27
9
  enablers,
@@ -1,2 +1,2 @@
1
- import type { Program } from 'oxc-parser';
2
- export declare const getComponentPathsFromSourceFile: (program: Program) => Set<string>;
1
+ import type { ResolveFromAST } from '../../types/config.ts';
2
+ export declare const resolveFromAST: ResolveFromAST;
@@ -1,9 +1,13 @@
1
- import { findCallArg, getDefaultImportName, getImportMap, getPropertyValues } from '../../typescript/ast-helpers.js';
2
- export const getComponentPathsFromSourceFile = (program) => {
3
- const importMap = getImportMap(program);
4
- const starlightImportName = getDefaultImportName(importMap, '@astrojs/starlight');
5
- if (!starlightImportName)
6
- return new Set();
7
- const arg = findCallArg(program, starlightImportName);
8
- return arg ? getPropertyValues(arg, 'components') : new Set();
1
+ import { findImportedCallArg, getPropertyValues } from '../../typescript/ast-helpers.js';
2
+ import { toProductionEntry } from '../../util/input.js';
3
+ export const resolveFromAST = program => {
4
+ const starlightConfig = findImportedCallArg(program, '@astrojs/starlight');
5
+ if (!starlightConfig)
6
+ return [];
7
+ const inputs = [];
8
+ for (const id of getPropertyValues(starlightConfig, 'components'))
9
+ inputs.push(toProductionEntry(id));
10
+ for (const id of getPropertyValues(starlightConfig, 'customCss'))
11
+ inputs.push(toProductionEntry(id));
12
+ return inputs;
9
13
  };
@@ -1,17 +1,15 @@
1
- import { Visitor } from 'oxc-parser';
2
1
  import scss from '../../compilers/scss.js';
3
2
  import { IMPORT_FLAGS } from '../../constants.js';
4
- import { toConfig, toEntry, toProductionEntry } from '../../util/input.js';
3
+ import { getPropertyValues } from '../../typescript/ast-helpers.js';
5
4
  import { dirname, join } from '../../util/path.js';
6
5
  import { hasDependency } from '../../util/plugin.js';
7
- import { collectPropertyValues, getPropertyValues } from '../../typescript/ast-helpers.js';
8
6
  import { createCustomElementVisitor } from '../_custom-elements/custom-element-visitor.js';
7
+ import { entry, resolveFromAST } from './resolveFromAST.js';
9
8
  const title = 'Stencil';
10
9
  const enablers = ['@stencil/core'];
11
10
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
12
11
  const config = ['stencil.config.{ts,js}'];
13
12
  const production = ['src/**/*.tsx'];
14
- const entry = ['**/*.spec.{ts,tsx}', '**/*.e2e.{ts,tsx}'];
15
13
  const isStencilSpecifier = (specifier) => specifier === '@stencil/core';
16
14
  const registerCompilers = ({ hasDependency, registerCompiler }) => {
17
15
  if (hasDependency('@stencil/sass'))
@@ -57,39 +55,6 @@ const registerVisitors = ({ ctx, registerVisitor }) => {
57
55
  }
58
56
  }
59
57
  };
60
- const resolveFromAST = program => {
61
- const inputs = [];
62
- const srcDirs = collectPropertyValues(program, 'srcDir');
63
- const srcDir = srcDirs.size > 0 ? [...srcDirs][0] : 'src';
64
- inputs.push(toProductionEntry(`${srcDir}/**/*.tsx`));
65
- for (const pattern of entry)
66
- inputs.push(toEntry(pattern));
67
- for (const script of collectPropertyValues(program, 'globalScript')) {
68
- inputs.push(toProductionEntry(script));
69
- }
70
- for (const style of collectPropertyValues(program, 'globalStyle')) {
71
- inputs.push(toProductionEntry(style));
72
- }
73
- new Visitor({
74
- ObjectExpression(node) {
75
- const typeValues = getPropertyValues(node, 'type');
76
- if (!typeValues.has('global-style'))
77
- return;
78
- for (const input of getPropertyValues(node, 'input'))
79
- inputs.push(toProductionEntry(input));
80
- },
81
- }).visit(program);
82
- for (const tsconfig of collectPropertyValues(program, 'tsconfig')) {
83
- inputs.push(toConfig('typescript', tsconfig));
84
- }
85
- for (const setup of collectPropertyValues(program, 'setupFilesAfterEnv')) {
86
- inputs.push(toEntry(setup));
87
- }
88
- for (const setup of collectPropertyValues(program, 'setupFiles')) {
89
- inputs.push(toEntry(setup));
90
- }
91
- return inputs;
92
- };
93
58
  const plugin = {
94
59
  title,
95
60
  enablers,
@@ -0,0 +1,3 @@
1
+ import type { ResolveFromAST } from '../../types/config.ts';
2
+ export declare const entry: string[];
3
+ export declare const resolveFromAST: ResolveFromAST;
@@ -0,0 +1,36 @@
1
+ import { Visitor } from 'oxc-parser';
2
+ import { collectFirstPropertyValue, collectPropertyValues, getPropertyValues } from '../../typescript/ast-helpers.js';
3
+ import { toConfig, toEntry, toProductionEntry } from '../../util/input.js';
4
+ export const entry = ['**/*.spec.{ts,tsx}', '**/*.e2e.{ts,tsx}'];
5
+ export const resolveFromAST = program => {
6
+ const inputs = [];
7
+ const srcDir = collectFirstPropertyValue(program, 'srcDir') ?? 'src';
8
+ inputs.push(toProductionEntry(`${srcDir}/**/*.tsx`));
9
+ for (const pattern of entry)
10
+ inputs.push(toEntry(pattern));
11
+ for (const script of collectPropertyValues(program, 'globalScript')) {
12
+ inputs.push(toProductionEntry(script));
13
+ }
14
+ for (const style of collectPropertyValues(program, 'globalStyle')) {
15
+ inputs.push(toProductionEntry(style));
16
+ }
17
+ new Visitor({
18
+ ObjectExpression(node) {
19
+ const typeValues = getPropertyValues(node, 'type');
20
+ if (!typeValues.has('global-style'))
21
+ return;
22
+ for (const input of getPropertyValues(node, 'input'))
23
+ inputs.push(toProductionEntry(input));
24
+ },
25
+ }).visit(program);
26
+ for (const tsconfig of collectPropertyValues(program, 'tsconfig')) {
27
+ inputs.push(toConfig('typescript', tsconfig));
28
+ }
29
+ for (const setup of collectPropertyValues(program, 'setupFilesAfterEnv')) {
30
+ inputs.push(toEntry(setup));
31
+ }
32
+ for (const setup of collectPropertyValues(program, 'setupFiles')) {
33
+ inputs.push(toEntry(setup));
34
+ }
35
+ return inputs;
36
+ };
@@ -1,6 +1,8 @@
1
+ import MDX from '../../compilers/mdx.js';
1
2
  import { toConfig, toDeferResolve, toDependency, toEntry } from '../../util/input.js';
2
3
  import { join, relative } from '../../util/path.js';
3
4
  import { hasDependency } from '../../util/plugin.js';
5
+ import { getBabelInputs } from '../vite/helpers.js';
4
6
  const title = 'Storybook';
5
7
  const enablers = [/^@storybook\//, '@nrwl/storybook'];
6
8
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -54,6 +56,12 @@ const resolveConfig = async (localConfig, options) => {
54
56
  ...configs,
55
57
  ];
56
58
  };
59
+ const registerCompilers = ({ registerCompiler, hasDependency }) => {
60
+ if (hasDependency('@storybook/addon-docs') || hasDependency('@storybook/addon-essentials')) {
61
+ registerCompiler({ extension: '.mdx', compiler: MDX.compiler });
62
+ }
63
+ };
64
+ const resolveFromAST = getBabelInputs;
57
65
  const plugin = {
58
66
  title,
59
67
  enablers,
@@ -62,5 +70,7 @@ const plugin = {
62
70
  entry,
63
71
  project,
64
72
  resolveConfig,
73
+ resolveFromAST,
74
+ registerCompilers,
65
75
  };
66
76
  export default plugin;
@@ -1,57 +1,10 @@
1
- import { _syncGlob } from '../../util/glob.js';
2
- import { toAlias, toIgnore, toProductionEntry } from '../../util/input.js';
3
1
  import { hasDependency } from '../../util/plugin.js';
4
2
  import { config as viteConfig } from '../vite/index.js';
5
- import { collectPropertyValues, findCallArg, findProperty, getPropertyValues, hasImportSpecifier, } from '../../typescript/ast-helpers.js';
6
- import { _parseFile } from '../../typescript/ast-nodes.js';
3
+ import { resolveFromAST } from './resolveFromAST.js';
7
4
  const title = 'SvelteKit';
8
5
  const enablers = ['@sveltejs/kit'];
9
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
10
7
  const config = ['svelte.config.js', ...viteConfig];
11
- const production = [
12
- 'src/routes/**/+{page,server,page.server,error,layout,layout.server}{,@*}.{js,ts,svelte}',
13
- 'src/hooks.{server,client}.{js,ts}',
14
- 'src/params/*.{js,ts}',
15
- 'src/service-worker.{js,ts}',
16
- 'src/service-worker/index.{js,ts}',
17
- 'src/instrumentation.server.{js,ts}',
18
- ];
19
- const isConfigInViteConfig = (dir, readFile) => {
20
- for (const filePath of _syncGlob({ cwd: dir, patterns: viteConfig })) {
21
- const text = readFile(filePath);
22
- if (text && findCallArg(_parseFile(filePath, text).program, 'sveltekit'))
23
- return true;
24
- }
25
- return false;
26
- };
27
- const getLibFromViteConfig = (program) => {
28
- const call = findCallArg(program, 'sveltekit');
29
- const files = call ? findProperty(call, 'files') : undefined;
30
- const values = files ? getPropertyValues(files, 'lib') : new Set();
31
- return values.size > 0 ? Array.from(values)[0] : 'src/lib';
32
- };
33
- const getLibFromSvelteConfig = (program) => {
34
- const values = collectPropertyValues(program, 'lib');
35
- return values.size > 0 ? Array.from(values)[0] : 'src/lib';
36
- };
37
- const toInputs = (lib) => [
38
- ...production.map(pattern => toProductionEntry(pattern)),
39
- toAlias('$lib', [`./${lib}`]),
40
- toAlias('$lib/*', [`./${lib}/*`]),
41
- toIgnore('\\$app/.+', 'unresolved'),
42
- toIgnore('\\$env/.+', 'unresolved'),
43
- toIgnore('\\$service-worker', 'unresolved'),
44
- ];
45
- const resolveFromAST = (program, options) => {
46
- if (options.configFileName.startsWith('vite.config')) {
47
- if (!hasImportSpecifier(program, '@sveltejs/kit/vite', 'sveltekit'))
48
- return [];
49
- return toInputs(getLibFromViteConfig(program));
50
- }
51
- if (isConfigInViteConfig(options.configFileDir, options.readFile))
52
- return [];
53
- return toInputs(getLibFromSvelteConfig(program));
54
- };
55
8
  const plugin = {
56
9
  title,
57
10
  enablers,
@@ -0,0 +1,2 @@
1
+ import type { ResolveFromAST } from '../../types/config.ts';
2
+ export declare const resolveFromAST: ResolveFromAST;
@@ -0,0 +1,45 @@
1
+ import { collectFirstPropertyValue, findCallArg, findProperty, getFirstPropertyValue, hasImportSpecifier, } from '../../typescript/ast-helpers.js';
2
+ import { _parseFile } from '../../typescript/ast-nodes.js';
3
+ import { _syncGlob } from '../../util/glob.js';
4
+ import { toAlias, toIgnore, toProductionEntry } from '../../util/input.js';
5
+ import { config as viteConfig } from '../vite/index.js';
6
+ const production = [
7
+ 'src/routes/**/+{page,server,page.server,error,layout,layout.server}{,@*}.{js,ts,svelte}',
8
+ 'src/hooks.{server,client}.{js,ts}',
9
+ 'src/params/*.{js,ts}',
10
+ 'src/service-worker.{js,ts}',
11
+ 'src/service-worker/index.{js,ts}',
12
+ 'src/instrumentation.server.{js,ts}',
13
+ ];
14
+ const isConfigInViteConfig = (dir, readFile) => {
15
+ for (const filePath of _syncGlob({ cwd: dir, patterns: viteConfig })) {
16
+ const text = readFile(filePath);
17
+ if (text && findCallArg(_parseFile(filePath, text).program, 'sveltekit'))
18
+ return true;
19
+ }
20
+ return false;
21
+ };
22
+ const getLibFromViteConfig = (program) => {
23
+ const call = findCallArg(program, 'sveltekit');
24
+ const files = call ? findProperty(call, 'files') : undefined;
25
+ return (files && getFirstPropertyValue(files, 'lib')) ?? 'src/lib';
26
+ };
27
+ const getLibFromSvelteConfig = (program) => collectFirstPropertyValue(program, 'lib') ?? 'src/lib';
28
+ const toInputs = (lib) => [
29
+ ...production.map(pattern => toProductionEntry(pattern)),
30
+ toAlias('$lib', [`./${lib}`]),
31
+ toAlias('$lib/*', [`./${lib}/*`]),
32
+ toIgnore('\\$app/.+', 'unresolved'),
33
+ toIgnore('\\$env/.+', 'unresolved'),
34
+ toIgnore('\\$service-worker', 'unresolved'),
35
+ ];
36
+ export const resolveFromAST = (program, options) => {
37
+ if (options.configFileName.startsWith('vite.config')) {
38
+ if (!hasImportSpecifier(program, '@sveltejs/kit/vite', 'sveltekit'))
39
+ return [];
40
+ return toInputs(getLibFromViteConfig(program));
41
+ }
42
+ if (isConfigInViteConfig(options.configFileDir, options.readFile))
43
+ return [];
44
+ return toInputs(getLibFromSvelteConfig(program));
45
+ };
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,42 @@
1
+ import { join } from '../../util/path.js';
2
+ import { hasDependency } from '../../util/plugin.js';
3
+ const title = 'Tauri';
4
+ const enablers = ['@tauri-apps/cli'];
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
+ const config = [
7
+ 'src-tauri/tauri.conf.{json,json5}',
8
+ 'src-tauri/tauri.{macos,linux,windows,android,ios}.conf.{json,json5}',
9
+ 'src-tauri/Tauri.toml',
10
+ 'src-tauri/Tauri.{macos,linux,windows,android,ios}.toml',
11
+ 'tauri.conf.{json,json5}',
12
+ ];
13
+ const resolveConfig = async (localConfig, options) => {
14
+ const build = localConfig.build;
15
+ const commands = [
16
+ build?.beforeDevCommand ?? build?.['before-dev-command'],
17
+ build?.beforeBuildCommand ?? build?.['before-build-command'],
18
+ build?.beforeBundleCommand ?? build?.['before-bundle-command'],
19
+ ];
20
+ const inputs = [];
21
+ for (const command of commands) {
22
+ if (!command)
23
+ continue;
24
+ const script = typeof command === 'string' ? command : command.script;
25
+ if (!script)
26
+ continue;
27
+ const dir = typeof command === 'string' || !command.cwd ? options.cwd : join(options.cwd, command.cwd);
28
+ const manifest = options.getManifest(dir) ?? options.manifest;
29
+ for (const input of options.getInputsFromScripts(script, { knownBinsOnly: true, cwd: dir, manifest })) {
30
+ inputs.push({ ...input, dir });
31
+ }
32
+ }
33
+ return inputs;
34
+ };
35
+ const plugin = {
36
+ title,
37
+ enablers,
38
+ isEnabled,
39
+ config,
40
+ resolveConfig,
41
+ };
42
+ export default plugin;
@@ -0,0 +1,16 @@
1
+ type BeforeCommand = string | {
2
+ script?: string;
3
+ cwd?: string;
4
+ wait?: boolean;
5
+ };
6
+ export interface TauriConfig {
7
+ build?: {
8
+ beforeDevCommand?: BeforeCommand;
9
+ beforeBuildCommand?: BeforeCommand;
10
+ beforeBundleCommand?: BeforeCommand;
11
+ 'before-dev-command'?: BeforeCommand;
12
+ 'before-build-command'?: BeforeCommand;
13
+ 'before-bundle-command'?: BeforeCommand;
14
+ };
15
+ }
16
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
+ import { collectPropertyValues } from '../../typescript/ast-helpers.js';
1
2
  import { toProductionEntry } from '../../util/input.js';
2
3
  import { hasDependency } from '../../util/plugin.js';
3
- import { getEntryFromAST } from './resolveFromAST.js';
4
4
  const title = 'tsdown';
5
5
  const enablers = ['tsdown'];
6
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -26,10 +26,7 @@ const resolveConfig = async (config) => {
26
26
  .map(id => toProductionEntry(id, { allowIncludeExports: true }));
27
27
  return entryPatterns;
28
28
  };
29
- const resolveFromAST = program => {
30
- const entries = getEntryFromAST(program);
31
- return [...entries].map(id => toProductionEntry(id, { allowIncludeExports: true }));
32
- };
29
+ const resolveFromAST = program => [...collectPropertyValues(program, 'entry')].map(id => toProductionEntry(id, { allowIncludeExports: true }));
33
30
  const args = {
34
31
  config: true,
35
32
  };
@@ -1,6 +1,6 @@
1
+ import { collectPropertyValues } from '../../typescript/ast-helpers.js';
1
2
  import { toProductionEntry } from '../../util/input.js';
2
3
  import { hasDependency } from '../../util/plugin.js';
3
- import { getEntryFromAST } from './resolveFromAST.js';
4
4
  const title = 'tsup';
5
5
  const enablers = ['tsup'];
6
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -21,10 +21,7 @@ const resolveConfig = async (config) => {
21
21
  .map(id => toProductionEntry(id, { allowIncludeExports: true }));
22
22
  return entryPatterns;
23
23
  };
24
- const resolveFromAST = program => {
25
- const entries = getEntryFromAST(program);
26
- return [...entries].map(id => toProductionEntry(id, { allowIncludeExports: true }));
27
- };
24
+ const resolveFromAST = program => [...collectPropertyValues(program, 'entry')].map(id => toProductionEntry(id, { allowIncludeExports: true }));
28
25
  const args = {
29
26
  config: true,
30
27
  };
@@ -1,4 +1,5 @@
1
- import { toDeferResolve } from '../../util/input.js';
1
+ import { toDeferResolve, toEntry } from '../../util/input.js';
2
+ import { join } from '../../util/path.js';
2
3
  import { hasDependency } from '../../util/plugin.js';
3
4
  const title = 'TypeDoc';
4
5
  const enablers = ['typedoc'];
@@ -12,11 +13,16 @@ const config = [
12
13
  'package.json',
13
14
  'tsconfig.json',
14
15
  ];
15
- const resolveConfig = config => {
16
+ const resolveConfig = (config, options) => {
16
17
  const cfg = 'typedocOptions' in config ? config.typedocOptions : config;
17
18
  const plugins = cfg?.plugin ?? [];
18
19
  const themes = cfg?.theme ?? [];
19
- return [...plugins, ...themes].map(id => toDeferResolve(id));
20
+ const inputs = [...plugins, ...themes].map(id => toDeferResolve(id));
21
+ for (const file of [cfg?.customCss, cfg?.customJs]) {
22
+ if (file)
23
+ inputs.push(toEntry(join(options.configFileDir, file)));
24
+ }
25
+ return inputs;
20
26
  };
21
27
  const args = {
22
28
  resolve: ['plugin', 'theme'],