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,33 +1,46 @@
1
+ import { collectPropertyValues } from '../../typescript/ast-helpers.js';
2
+ import { isDirectory } from '../../util/fs.js';
1
3
  import { toConfig, toProductionEntry } from '../../util/input.js';
2
4
  import { join } from '../../util/path.js';
3
5
  import { hasDependency } from '../../util/plugin.js';
4
- import { getPageExtensions } from './resolveFromAST.js';
5
6
  const title = 'Next.js';
6
7
  const enablers = ['next'];
7
8
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
- const config = ['next.config.{js,ts,cjs,mjs}'];
9
+ const config = ['next.config.{js,ts,cjs,mjs,mts}'];
9
10
  const defaultPageExtensions = ['{js,jsx,ts,tsx}'];
10
11
  const productionEntryFilePatterns = [
11
12
  'app/{,[(]*[)]/}{manifest,robots}.{js,ts}',
12
13
  'app/**/sitemap.{js,ts}',
13
14
  'app/**/{icon,apple-icon,opengraph-image,twitter-image}.{js,jsx,ts,tsx}',
14
15
  ];
15
- const getEntryFilePatterns = (pageExtensions = defaultPageExtensions) => {
16
+ const rootOrSrc = '{,src/}';
17
+ const getRouterDirPrefix = (cwd, name) => {
18
+ if (!cwd)
19
+ return rootOrSrc;
20
+ if (isDirectory(cwd, name))
21
+ return '';
22
+ if (isDirectory(cwd, `src/${name}`))
23
+ return 'src/';
24
+ return rootOrSrc;
25
+ };
26
+ const getEntryFilePatterns = (pageExtensions = defaultPageExtensions, cwd) => {
16
27
  const ext = pageExtensions.length === 1 ? pageExtensions[0] : `{${pageExtensions.join(',')}}`;
28
+ const appDirPrefix = getRouterDirPrefix(cwd, 'app');
29
+ const pagesDirPrefix = getRouterDirPrefix(cwd, 'pages');
17
30
  return [
18
- ...productionEntryFilePatterns,
19
- `{instrumentation,instrumentation-client,middleware,proxy}.${ext}`,
20
- `app/global-{error,not-found}.${ext}`,
21
- `app/**/{default,error,forbidden,loading,not-found,unauthorized}.${ext}`,
22
- `app/**/{layout,page,route,template}.${ext}`,
23
- `pages/**/*.${ext}`,
24
- ].flatMap(pattern => [pattern, `src/${pattern}`]);
31
+ ...productionEntryFilePatterns.map(pattern => `${appDirPrefix}${pattern}`),
32
+ `${rootOrSrc}{instrumentation,instrumentation-client,middleware,proxy}.${ext}`,
33
+ `${appDirPrefix}app/global-{error,not-found}.${ext}`,
34
+ `${appDirPrefix}app/**/{default,error,forbidden,loading,not-found,unauthorized}.${ext}`,
35
+ `${appDirPrefix}app/**/{layout,page,route,template}.${ext}`,
36
+ `${pagesDirPrefix}pages/**/*.${ext}`,
37
+ ];
25
38
  };
26
39
  const production = getEntryFilePatterns();
27
40
  const resolveFromAST = (program, { configFileDir }) => {
28
- const pageExtensions = getPageExtensions(program);
41
+ const pageExtensions = [...collectPropertyValues(program, 'pageExtensions')];
29
42
  const extensions = pageExtensions.length > 0 ? pageExtensions : defaultPageExtensions;
30
- const patterns = [...getEntryFilePatterns(extensions), 'next-env.d.ts'];
43
+ const patterns = [...getEntryFilePatterns(extensions, configFileDir), 'next-env.d.ts'];
31
44
  return patterns.map(id => toProductionEntry(join(configFileDir, id)));
32
45
  };
33
46
  const commands = new Set(['dev', 'build', 'start']);
@@ -1,15 +1,9 @@
1
- import { toDependency, toProductionEntry } from '../../util/input.js';
2
1
  import { hasDependency } from '../../util/plugin.js';
3
- import { getMdxPlugins } from './resolveFromAST.js';
2
+ import { production, resolveFromAST } from './resolveFromAST.js';
4
3
  const title = 'Next.js MDX';
5
4
  const enablers = ['@next/mdx'];
6
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
- const config = ['next.config.{js,ts,cjs,mjs}'];
8
- const production = ['{src/,}mdx-components.{js,jsx,ts,tsx}'];
9
- const resolveFromAST = program => {
10
- const mdxPlugins = getMdxPlugins(program);
11
- return [...production.map(id => toProductionEntry(id)), ...Array.from(mdxPlugins).map(id => toDependency(id))];
12
- };
6
+ const config = ['next.config.{js,ts,cjs,mjs,mts}'];
13
7
  const plugin = {
14
8
  title,
15
9
  enablers,
@@ -1,2 +1,3 @@
1
- import type { Program } from 'oxc-parser';
2
- export declare const getMdxPlugins: (program: Program) => Set<string>;
1
+ import type { ResolveFromAST } from '../../types/config.ts';
2
+ export declare const production: string[];
3
+ export declare const resolveFromAST: ResolveFromAST;
@@ -1,24 +1,20 @@
1
- import { Visitor } from 'oxc-parser';
2
- import { findProperty, getDefaultImportName, getImportMap, getStringValues } from '../../typescript/ast-helpers.js';
3
- export const getMdxPlugins = (program) => {
1
+ import { findImportedCalls, findProperty, getStringValues } from '../../typescript/ast-helpers.js';
2
+ import { toDependency, toProductionEntry } from '../../util/input.js';
3
+ export const production = ['{src/,}mdx-components.{js,jsx,ts,tsx}'];
4
+ const getMdxPlugins = (program) => {
4
5
  const plugins = new Set();
5
- const importMap = getImportMap(program);
6
- const mdxImportName = getDefaultImportName(importMap, '@next/mdx');
7
- if (!mdxImportName)
8
- return plugins;
9
- const visitor = new Visitor({
10
- CallExpression(node) {
11
- if (node.callee?.type !== 'Identifier' || node.callee.name !== mdxImportName)
12
- return;
13
- const options = findProperty(node.arguments?.[0], 'options');
14
- if (options?.type !== 'ObjectExpression')
15
- return;
16
- for (const pluginType of ['remarkPlugins', 'rehypePlugins', 'recmaPlugins']) {
17
- for (const v of getStringValues(findProperty(options, pluginType)))
18
- plugins.add(v);
19
- }
20
- },
21
- });
22
- visitor.visit(program);
6
+ for (const call of findImportedCalls(program, '@next/mdx')) {
7
+ const options = findProperty(call.arguments?.[0], 'options');
8
+ if (options?.type !== 'ObjectExpression')
9
+ continue;
10
+ for (const pluginType of ['remarkPlugins', 'rehypePlugins', 'recmaPlugins']) {
11
+ for (const v of getStringValues(findProperty(options, pluginType)))
12
+ plugins.add(v);
13
+ }
14
+ }
23
15
  return plugins;
24
16
  };
17
+ export const resolveFromAST = program => [
18
+ ...production.map(id => toProductionEntry(id)),
19
+ ...Array.from(getMdxPlugins(program)).map(id => toDependency(id)),
20
+ ];
@@ -1,4 +1,5 @@
1
1
  import { toEntry, toProductionEntry } from '../../util/input.js';
2
+ import { getScriptCommands } from '../../util/scripts.js';
2
3
  const title = 'Node.js';
3
4
  const isEnabled = () => true;
4
5
  const patterns = [
@@ -7,7 +8,9 @@ const patterns = [
7
8
  '**/test.{cjs,mjs,js,cts,mts,ts}',
8
9
  '**/test/**/*.{cjs,mjs,js,cts,mts,ts}',
9
10
  ];
10
- const hasNodeTest = (scripts) => scripts && Object.values(scripts).some(script => /(?<=^|\s)(node|nub)\s(.*)--test/.test(script));
11
+ const hasNodeTest = (scripts) => scripts &&
12
+ Object.values(scripts).some(script => typeof script === 'string' &&
13
+ getScriptCommands(script).some(({ binary, args }) => (binary === 'node' || binary === 'nub') && args.includes('--test')));
11
14
  const entry = ['server.js'];
12
15
  const resolve = options => {
13
16
  const entries = entry.map(id => toProductionEntry(id));
@@ -4,7 +4,7 @@ import { toAlias, toConfig, toDeferResolveProductionEntry, toDependency, toEntry
4
4
  import { loadTSConfig } from '../../util/load-tsconfig.js';
5
5
  import { join } from '../../util/path.js';
6
6
  import { hasDependency } from '../../util/plugin.js';
7
- import { buildAutoImportMap, collectIdentifiers, collectLocalImportPaths, collectTemplateInfo, getVueSfc, readAndParseFile, toKebabCase, } from './helpers.js';
7
+ import { buildAutoImportMap, collectLocalImportPaths, createAutoImportMaps, createTsCompiler, createVueCompiler, readAndParseFile, } from '../_vue/auto-import.js';
8
8
  const title = 'Nuxt';
9
9
  const enablers = ['nuxt', 'nuxt-nightly'];
10
10
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -62,9 +62,7 @@ const addAppEntries = (inputs, srcDir, serverDir, config, dir) => {
62
62
  const findLayerConfigs = (cwd) => _syncGlob({ cwd, patterns: [`layers/*/${config.at(0)}`] });
63
63
  const registerCompilers = async ({ cwd, hasDependency, registerCompiler }) => {
64
64
  if (hasDependency('nuxt') || hasDependency('nuxt-nightly')) {
65
- const vueSfc = getVueSfc(cwd);
66
- const importMap = new Map();
67
- const componentMap = new Map();
65
+ const maps = createAutoImportMaps();
68
66
  const definitionFiles = [
69
67
  '.nuxt/imports.d.ts',
70
68
  '.nuxt/components.d.ts',
@@ -73,71 +71,10 @@ const registerCompilers = async ({ cwd, hasDependency, registerCompiler }) => {
73
71
  ];
74
72
  for (const file of definitionFiles) {
75
73
  const path = join(cwd, file);
76
- const result = readAndParseFile(path);
77
- const maps = buildAutoImportMap(path, result);
78
- for (const [id, specifier] of maps.importMap)
79
- importMap.set(id, specifier);
80
- for (const [id, components] of maps.componentMap) {
81
- const store = componentMap.get(id);
82
- if (store)
83
- store.push(...components);
84
- else
85
- componentMap.set(id, components);
86
- }
74
+ buildAutoImportMap(path, readAndParseFile(path), maps, file.endsWith('components.d.ts'));
87
75
  }
88
- const getSyntheticImports = (identifiers, templateTags) => {
89
- if (importMap.size === 0 && (!templateTags || componentMap.size === 0))
90
- return [];
91
- const syntheticImports = [];
92
- for (const [name, specifier] of importMap) {
93
- if (identifiers.has(name))
94
- syntheticImports.push(`import { ${name} } from '${specifier}';`);
95
- }
96
- if (templateTags) {
97
- for (const [name, specifiers] of componentMap) {
98
- const kebab = toKebabCase(name);
99
- if (templateTags.has(name) ||
100
- templateTags.has(kebab) ||
101
- templateTags.has(`Lazy${name}`) ||
102
- templateTags.has(`lazy-${kebab}`)) {
103
- syntheticImports.push(`import { default as ${name} } from '${specifiers[0]}';`);
104
- for (let i = 1; i < specifiers.length; i++)
105
- syntheticImports.push(`import '${specifiers[i]}';`);
106
- }
107
- }
108
- }
109
- return syntheticImports;
110
- };
111
- const compiler = (source, path) => {
112
- const { descriptor } = vueSfc.parse(source, path);
113
- const scripts = [];
114
- if (descriptor.script?.content)
115
- scripts.push(descriptor.script.content);
116
- if (descriptor.scriptSetup?.content)
117
- scripts.push(descriptor.scriptSetup.content);
118
- const identifiers = scripts.length === 0 ? new Set() : collectIdentifiers(scripts.join('\n'), path);
119
- let templateTags;
120
- if (descriptor.template?.ast) {
121
- const info = collectTemplateInfo(descriptor.template.ast);
122
- templateTags = info.tags;
123
- for (const id of info.identifiers)
124
- identifiers.add(id);
125
- }
126
- const synthetic = getSyntheticImports(identifiers, templateTags);
127
- scripts.push(...synthetic);
128
- return scripts.join(';\n');
129
- };
130
- const tsCompiler = (source, path) => {
131
- if (path.endsWith('.d.ts') || path.endsWith('.config.ts'))
132
- return source;
133
- const identifiers = collectIdentifiers(source, path);
134
- const syntheticImports = getSyntheticImports(identifiers);
135
- if (syntheticImports.length === 0)
136
- return source;
137
- return `${source}\n${syntheticImports.join('\n')}`;
138
- };
139
- registerCompiler({ extension: '.vue', compiler });
140
- registerCompiler({ extension: '.ts', compiler: tsCompiler });
76
+ registerCompiler({ extension: '.vue', compiler: createVueCompiler(maps, cwd) });
77
+ registerCompiler({ extension: '.ts', compiler: createTsCompiler(maps) });
141
78
  }
142
79
  };
143
80
  const resolveConfig = async (localConfig, options) => {
@@ -25,37 +25,3 @@ export interface NuxtConfig {
25
25
  css?: string[];
26
26
  alias?: Record<string, string>;
27
27
  }
28
- interface TemplateExpressionNode {
29
- content: string;
30
- isStatic: boolean;
31
- }
32
- interface TemplateAstProp {
33
- type: number;
34
- exp?: TemplateExpressionNode;
35
- arg?: TemplateExpressionNode;
36
- }
37
- export interface TemplateAstNode {
38
- type?: number;
39
- tag?: string;
40
- props?: TemplateAstProp[];
41
- content?: TemplateExpressionNode;
42
- children?: TemplateAstNode[];
43
- }
44
- interface Descriptor {
45
- script: {
46
- content: string;
47
- } | null;
48
- scriptSetup: {
49
- content: string;
50
- } | null;
51
- template: {
52
- content: string;
53
- ast?: TemplateAstNode;
54
- } | null;
55
- }
56
- export type VueSfc = {
57
- parse: (source: string, path: string) => {
58
- descriptor: Descriptor;
59
- };
60
- };
61
- export {};
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,12 @@
1
+ import { hasDependency } from '../../util/plugin.js';
2
+ const title = '@nuxtjs/i18n';
3
+ const enablers = ['@nuxtjs/i18n'];
4
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
+ const entry = ['i18n.config.{js,mjs,ts}', 'i18n/i18n.config.{js,mjs,ts}'];
6
+ const plugin = {
7
+ title,
8
+ enablers,
9
+ isEnabled,
10
+ entry,
11
+ };
12
+ export default plugin;
@@ -1,19 +1,24 @@
1
- import { toDependency } from '../../util/input.js';
1
+ import { toDependency, toProductionEntry } from '../../util/input.js';
2
2
  import { hasDependency } from '../../util/plugin.js';
3
3
  const title = 'oclif';
4
- const enablers = ['oclif'];
4
+ const enablers = ['oclif', '@oclif/core'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  const config = ['package.json'];
7
+ const production = ['{,src/}commands/**/*.{js,mjs,cjs,jsx,ts,tsx,mts,cts}'];
7
8
  const resolveConfig = async (config) => {
8
- const plugins = config?.plugins ?? [];
9
- const devPlugins = config?.devPlugins ?? [];
10
- return [...plugins, ...devPlugins].map(id => toDependency(id));
9
+ if (!config)
10
+ return [];
11
+ const inputs = production.map(id => toProductionEntry(id));
12
+ for (const id of [...(config.plugins ?? []), ...(config.devPlugins ?? [])])
13
+ inputs.push(toDependency(id));
14
+ return inputs;
11
15
  };
12
16
  const plugin = {
13
17
  title,
14
18
  enablers,
15
19
  isEnabled,
16
20
  config,
21
+ production,
17
22
  resolveConfig,
18
23
  };
19
24
  export default plugin;
@@ -1,11 +1,9 @@
1
- import { toEntry } from '../../util/input.js';
2
1
  import { hasDependency } from '../../util/plugin.js';
3
- import { getInputsFromAST } from './resolveFromAST.js';
2
+ import { resolveFromAST } from './resolveFromAST.js';
4
3
  const title = 'orval';
5
4
  const enablers = ['orval'];
6
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
6
  const config = ['orval.config.{js,mjs,ts,mts}'];
8
- const resolveFromAST = program => [...getInputsFromAST(program)].map(id => toEntry(id));
9
7
  const plugin = {
10
8
  title,
11
9
  enablers,
@@ -1,2 +1,2 @@
1
- import type { Program } from 'oxc-parser';
2
- export declare const getInputsFromAST: (program: Program) => Set<string>;
1
+ import type { ResolveFromAST } from '../../types/config.ts';
2
+ export declare const resolveFromAST: ResolveFromAST;
@@ -1,11 +1,8 @@
1
1
  import { collectPropertyValues } from '../../typescript/ast-helpers.js';
2
+ import { toEntry } from '../../util/input.js';
2
3
  const PATH_KEY = 'path';
3
4
  const TRANSFORMER_KEY = 'transformer';
4
- export const getInputsFromAST = (program) => {
5
- const values = new Set();
6
- for (const v of collectPropertyValues(program, PATH_KEY))
7
- values.add(v);
8
- for (const v of collectPropertyValues(program, TRANSFORMER_KEY))
9
- values.add(v);
10
- return values;
5
+ export const resolveFromAST = program => {
6
+ const values = [...collectPropertyValues(program, PATH_KEY), ...collectPropertyValues(program, TRANSFORMER_KEY)];
7
+ return values.map(id => toEntry(id));
11
8
  };
@@ -1,10 +1,13 @@
1
+ import { Visitor } from 'oxc-parser';
2
+ import { findProperty, getPropertyValues } from '../../typescript/ast-helpers.js';
1
3
  import { toDependency, toEntry } from '../../util/input.js';
2
4
  import { isInternal } from '../../util/path.js';
3
5
  import { hasDependency } from '../../util/plugin.js';
4
6
  const title = 'Oxlint';
5
- const enablers = ['oxlint'];
7
+ const enablers = ['oxlint', 'vite-plus'];
6
8
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
- const config = ['.oxlintrc.json', 'oxlint.config.ts'];
9
+ const config = ['.oxlintrc.json', 'oxlint.config.ts', 'vite.config.{js,mjs,ts,cjs,mts,cts}'];
10
+ const isViteConfig = (configFileName) => configFileName.startsWith('vite.config.');
8
11
  const args = {
9
12
  config: true,
10
13
  };
@@ -19,6 +22,7 @@ const resolveJsPlugins = (jsPlugins) => {
19
22
  }
20
23
  return inputs;
21
24
  };
25
+ const isLoadConfig = ({ configFileName }) => !isViteConfig(configFileName);
22
26
  const resolveConfig = config => {
23
27
  const inputs = resolveJsPlugins(config.jsPlugins);
24
28
  for (const override of config.overrides ?? []) {
@@ -27,12 +31,29 @@ const resolveConfig = config => {
27
31
  }
28
32
  return inputs;
29
33
  };
34
+ const resolveFromAST = (program, options) => {
35
+ if (!isViteConfig(options.configFileName))
36
+ return [];
37
+ const jsPlugins = new Set();
38
+ const visitor = new Visitor({
39
+ ObjectExpression(node) {
40
+ const lint = findProperty(node, 'lint');
41
+ if (lint?.type === 'ObjectExpression')
42
+ for (const specifier of getPropertyValues(lint, 'jsPlugins'))
43
+ jsPlugins.add(specifier);
44
+ },
45
+ });
46
+ visitor.visit(program);
47
+ return resolveJsPlugins([...jsPlugins]);
48
+ };
30
49
  const plugin = {
31
50
  title,
32
51
  enablers,
33
52
  isEnabled,
34
53
  config,
54
+ isLoadConfig,
35
55
  resolveConfig,
56
+ resolveFromAST,
36
57
  args,
37
58
  };
38
59
  export default plugin;
@@ -1,12 +1,33 @@
1
1
  import { isFile } from '../../util/fs.js';
2
+ import { toDependency, toEntry } from '../../util/input.js';
2
3
  const title = 'pnpm';
4
+ const enablers = 'This plugin is enabled when a `pnpm-lock.yaml` or `pnpm-workspace.yaml` file is found in the root directory, or when `pnpm@` is specified in the `packageManager` field of `package.json`.';
3
5
  const isEnabled = async ({ cwd, manifest }) => manifest.packageManager?.startsWith('pnpm@') || isFile(cwd, 'pnpm-lock.yaml') || isFile(cwd, 'pnpm-workspace.yaml');
4
6
  const isRootOnly = true;
5
- const config = ['.pnpmfile.cjs'];
7
+ const entry = ['.pnpmfile.{cjs,mjs}'];
8
+ const config = ['package.json', 'pnpm-workspace.yaml'];
9
+ const resolveConfig = config => {
10
+ const inputs = entry.map(toEntry);
11
+ const packageExtensions = config?.pnpm?.packageExtensions || config?.packageExtensions;
12
+ if (packageExtensions) {
13
+ for (const extension of Object.values(packageExtensions)) {
14
+ if (extension.peerDependencies) {
15
+ for (const dep of Object.keys(extension.peerDependencies)) {
16
+ const optional = extension.peerDependenciesMeta?.[dep]?.optional === true;
17
+ inputs.push(optional ? toDependency(dep, { optional: true }) : toDependency(dep));
18
+ }
19
+ }
20
+ }
21
+ }
22
+ return inputs;
23
+ };
6
24
  const plugin = {
7
25
  title,
26
+ enablers,
8
27
  isEnabled,
9
28
  isRootOnly,
29
+ entry,
10
30
  config,
31
+ resolveConfig,
11
32
  };
12
33
  export default plugin;
@@ -0,0 +1,4 @@
1
+ import type { PackageExtensions, PackageJson } from '../../types/package-json.ts';
2
+ export type PnpmConfig = PackageJson & {
3
+ packageExtensions?: PackageExtensions;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -12,9 +12,25 @@ const config = [
12
12
  const resolveConfig = config => {
13
13
  if (typeof config === 'string')
14
14
  return [toDeferResolve(config)];
15
- return Array.isArray(config.plugins)
16
- ? config.plugins.filter((plugin) => typeof plugin === 'string').map(id => toDependency(id))
17
- : [];
15
+ const result = new Set();
16
+ const processOptions = (options) => {
17
+ if (Array.isArray(options.plugins)) {
18
+ for (const plugin of options.plugins) {
19
+ if (typeof plugin === 'string') {
20
+ result.add(toDependency(plugin));
21
+ }
22
+ }
23
+ }
24
+ };
25
+ processOptions(config);
26
+ if (config.overrides) {
27
+ for (const override of config.overrides) {
28
+ if (override.options) {
29
+ processOptions(override.options);
30
+ }
31
+ }
32
+ }
33
+ return Array.from(result);
18
34
  };
19
35
  const args = {
20
36
  config: true,
@@ -1,4 +1,4 @@
1
- export type PrettierConfig = {
1
+ export type PrettierOptions = {
2
2
  plugins?: (string | {
3
3
  parsers?: Record<string, unknown>;
4
4
  printers?: Record<string, unknown>;
@@ -6,3 +6,8 @@ export type PrettierConfig = {
6
6
  options?: Record<string, unknown>;
7
7
  })[];
8
8
  };
9
+ export type PrettierConfig = PrettierOptions & {
10
+ overrides?: {
11
+ options?: PrettierOptions;
12
+ }[];
13
+ };
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,15 @@
1
+ import { hasDependency } from '../../util/plugin.js';
2
+ import { production, resolveFromAST } from './resolveFromAST.js';
3
+ const title = 'Quasar';
4
+ const enablers = ['@quasar/app', '@quasar/app-vite', '@quasar/app-webpack'];
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
+ const config = ['quasar.config.{js,cjs,mjs,ts}', 'quasar.conf.js'];
7
+ const plugin = {
8
+ title,
9
+ enablers,
10
+ isEnabled,
11
+ config,
12
+ production,
13
+ resolveFromAST,
14
+ };
15
+ export default plugin;
@@ -0,0 +1,3 @@
1
+ import type { ResolveFromAST } from '../../types/config.ts';
2
+ export declare const production: string[];
3
+ export declare const resolveFromAST: ResolveFromAST;
@@ -0,0 +1,63 @@
1
+ import { findProperty, getFirstPropertyValue, getStringValues, resolveObjectArg, } from '../../typescript/ast-helpers.js';
2
+ import { getStringValue } from '../../typescript/ast-nodes.js';
3
+ import { toDeferResolve, toProductionEntry } from '../../util/input.js';
4
+ import { join } from '../../util/path.js';
5
+ const sourceFilesEntries = [
6
+ ['rootComponent', ['src/App.vue']],
7
+ ['router', ['src/router/index.{js,ts}']],
8
+ ['store', ['src/stores/index.{js,ts}', 'src/store/index.{js,ts}']],
9
+ ['pwaRegisterServiceWorker', ['src-pwa/register-service-worker.{js,ts}', 'src-pwa/register-sw.{js,ts}']],
10
+ ['pwaServiceWorker', ['src-pwa/custom-service-worker.{js,ts}', 'src-pwa/sw/custom-sw.{js,ts}']],
11
+ ['electronMain', ['src-electron/electron-main.{js,ts}']],
12
+ ];
13
+ const staticEntries = [
14
+ 'src-electron/electron-preload.{js,ts}',
15
+ 'src-ssr/server.{js,ts}',
16
+ 'src-ssr/middlewares/*.{js,ts}',
17
+ 'src-bex/**/*.{js,ts}',
18
+ ];
19
+ export const production = [...sourceFilesEntries.flatMap(([, defaults]) => defaults), ...staticEntries];
20
+ const getConfigObject = (program) => {
21
+ for (const node of program.body ?? []) {
22
+ if (node.type === 'ExportDefaultDeclaration') {
23
+ const decl = node.declaration;
24
+ return decl?.type === 'CallExpression' ? resolveObjectArg(decl.arguments?.[0]) : resolveObjectArg(decl);
25
+ }
26
+ if (node.type === 'ExpressionStatement' && node.expression?.type === 'AssignmentExpression') {
27
+ const { left, right } = node.expression;
28
+ if (left?.type === 'MemberExpression' && left.object?.name === 'module' && left.property?.name === 'exports') {
29
+ return right?.type === 'CallExpression' ? resolveObjectArg(right.arguments?.[0]) : resolveObjectArg(right);
30
+ }
31
+ }
32
+ }
33
+ };
34
+ const withExtensions = (id) => (id.includes('.') ? id : `${id}.{js,ts}`);
35
+ export const resolveFromAST = (program, options) => {
36
+ const { configFileDir } = options;
37
+ const inputs = [];
38
+ const config = getConfigObject(program);
39
+ const sourceFiles = findProperty(config, 'sourceFiles');
40
+ for (const [key, defaults] of sourceFilesEntries) {
41
+ const override = getFirstPropertyValue(sourceFiles, key);
42
+ for (const id of override ? [withExtensions(override)] : defaults) {
43
+ inputs.push(toProductionEntry(join(configFileDir, id)));
44
+ }
45
+ }
46
+ for (const id of staticEntries)
47
+ inputs.push(toProductionEntry(join(configFileDir, id)));
48
+ const boot = findProperty(config, 'boot');
49
+ if (boot?.type === 'ArrayExpression') {
50
+ for (const element of boot.elements ?? []) {
51
+ const id = getStringValue(element) ?? getFirstPropertyValue(element, 'path');
52
+ if (id)
53
+ inputs.push(toProductionEntry(join(configFileDir, 'src/boot', withExtensions(id))));
54
+ }
55
+ }
56
+ for (const id of getStringValues(findProperty(config, 'css'))) {
57
+ if (id.startsWith('~'))
58
+ inputs.push(toDeferResolve(id.slice(1)));
59
+ else
60
+ inputs.push(toProductionEntry(join(configFileDir, 'src/css', id)));
61
+ }
62
+ return inputs;
63
+ };
@@ -1,34 +1,10 @@
1
1
  import MDX from '../../compilers/mdx.js';
2
- import { toEntry, toIgnore, toProductionEntry } from '../../util/input.js';
3
2
  import { hasDependency } from '../../util/plugin.js';
4
3
  import { config } from '../vite/index.js';
5
- import { getRoutesDirs, getSrcDir } from './resolveFromAST.js';
4
+ import { entry, production, resolveFromAST, routeProduction } from './resolveFromAST.js';
6
5
  const title = 'Qwik';
7
6
  const enablers = ['@builder.io/qwik'];
8
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
9
- const entry = ['src/entry.dev.tsx'];
10
- const production = ['src/root.tsx', 'src/entry.*.tsx'];
11
- const routeProduction = ['src/routes/**/*.{tsx,ts,md,mdx}'];
12
- const resolveFromAST = program => {
13
- const srcDir = getSrcDir(program);
14
- const routesDirs = getRoutesDirs(program, srcDir);
15
- const setSrcDir = (pattern) => pattern.replace(/^src\//, `${srcDir}/`);
16
- const setRoutesDir = (pattern, routesDir) => pattern.replace(/^src\/routes\//, `${routesDir}/`);
17
- const routeEntries = [];
18
- for (const routesDir of routesDirs) {
19
- for (const pattern of routeProduction) {
20
- routeEntries.push(toProductionEntry(setRoutesDir(pattern, routesDir)));
21
- }
22
- }
23
- return [
24
- ...entry.map(setSrcDir).map(path => toEntry(path)),
25
- ...production.map(setSrcDir).map(path => toProductionEntry(path)),
26
- ...routeEntries,
27
- toIgnore('@qwik-city-plan', 'unlisted'),
28
- toIgnore('@qwik-city-sw-register', 'unlisted'),
29
- toIgnore('@qwik-client-manifest', 'unlisted'),
30
- ];
31
- };
32
8
  const registerCompilers = ({ registerCompiler, hasDependency }) => {
33
9
  if (hasDependency('@builder.io/qwik-city')) {
34
10
  registerCompiler({ extension: '.mdx', compiler: MDX.compiler });
@@ -1,3 +1,5 @@
1
- import type { Program } from 'oxc-parser';
2
- export declare const getSrcDir: (program: Program) => string;
3
- export declare const getRoutesDirs: (program: Program, srcDir: string) => string[];
1
+ import type { ResolveFromAST } from '../../types/config.ts';
2
+ export declare const entry: string[];
3
+ export declare const production: string[];
4
+ export declare const routeProduction: string[];
5
+ export declare const resolveFromAST: ResolveFromAST;