knip 6.25.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 (138) hide show
  1. package/dist/ConfigurationChief.d.ts +102 -0
  2. package/dist/compilers/index.d.ts +170 -0
  3. package/dist/constants.js +13 -0
  4. package/dist/graph/build.js +8 -3
  5. package/dist/plugins/_vue/auto-import.d.ts +12 -0
  6. package/dist/plugins/_vue/auto-import.js +272 -0
  7. package/dist/plugins/_vue/types.d.ts +38 -0
  8. package/dist/plugins/_vue/types.js +1 -0
  9. package/dist/plugins/astro/index.js +2 -37
  10. package/dist/plugins/astro/resolveFromAST.d.ts +4 -4
  11. package/dist/plugins/astro/resolveFromAST.js +34 -7
  12. package/dist/plugins/electron-vite/index.d.ts +3 -0
  13. package/dist/plugins/electron-vite/index.js +51 -0
  14. package/dist/plugins/electron-vite/types.d.ts +23 -0
  15. package/dist/plugins/electron-vite/types.js +1 -0
  16. package/dist/plugins/esbuild/index.d.ts +3 -0
  17. package/dist/plugins/esbuild/index.js +17 -0
  18. package/dist/plugins/eslint/resolveFromAST.js +18 -21
  19. package/dist/plugins/index.d.ts +17 -0
  20. package/dist/plugins/index.js +34 -0
  21. package/dist/plugins/laravel-vite-plugin/index.d.ts +3 -0
  22. package/dist/plugins/laravel-vite-plugin/index.js +14 -0
  23. package/dist/plugins/laravel-vite-plugin/resolveFromAST.d.ts +2 -0
  24. package/dist/plugins/laravel-vite-plugin/resolveFromAST.js +27 -0
  25. package/dist/plugins/next/index.js +2 -2
  26. package/dist/plugins/next-mdx/index.js +2 -8
  27. package/dist/plugins/next-mdx/resolveFromAST.d.ts +3 -2
  28. package/dist/plugins/next-mdx/resolveFromAST.js +17 -21
  29. package/dist/plugins/nuxt/index.js +5 -68
  30. package/dist/plugins/nuxt/types.d.ts +0 -34
  31. package/dist/plugins/nuxtjs-i18n/index.d.ts +3 -0
  32. package/dist/plugins/nuxtjs-i18n/index.js +12 -0
  33. package/dist/plugins/oclif/index.js +10 -5
  34. package/dist/plugins/orval/index.js +1 -3
  35. package/dist/plugins/orval/resolveFromAST.d.ts +2 -2
  36. package/dist/plugins/orval/resolveFromAST.js +4 -7
  37. package/dist/plugins/oxlint/index.js +23 -2
  38. package/dist/plugins/pnpm/index.js +2 -1
  39. package/dist/plugins/pnpm/types.d.ts +2 -4
  40. package/dist/plugins/quasar/index.d.ts +3 -0
  41. package/dist/plugins/quasar/index.js +15 -0
  42. package/dist/plugins/quasar/resolveFromAST.d.ts +3 -0
  43. package/dist/plugins/quasar/resolveFromAST.js +63 -0
  44. package/dist/plugins/qwik/index.js +1 -25
  45. package/dist/plugins/qwik/resolveFromAST.d.ts +5 -3
  46. package/dist/plugins/qwik/resolveFromAST.js +28 -9
  47. package/dist/plugins/rolldown/index.js +2 -5
  48. package/dist/plugins/rollup/index.js +2 -5
  49. package/dist/plugins/rslib/index.js +2 -5
  50. package/dist/plugins/sst/index.js +1 -5
  51. package/dist/plugins/sst/resolveFromAST.d.ts +1 -1
  52. package/dist/plugins/sst/resolveFromAST.js +1 -1
  53. package/dist/plugins/starlight/index.js +1 -19
  54. package/dist/plugins/starlight/resolveFromAST.d.ts +2 -2
  55. package/dist/plugins/starlight/resolveFromAST.js +12 -8
  56. package/dist/plugins/stencil/index.js +2 -37
  57. package/dist/plugins/stencil/resolveFromAST.d.ts +3 -0
  58. package/dist/plugins/stencil/resolveFromAST.js +36 -0
  59. package/dist/plugins/storybook/index.js +3 -0
  60. package/dist/plugins/sveltekit/index.js +1 -48
  61. package/dist/plugins/sveltekit/resolveFromAST.d.ts +2 -0
  62. package/dist/plugins/sveltekit/resolveFromAST.js +45 -0
  63. package/dist/plugins/tauri/index.d.ts +3 -0
  64. package/dist/plugins/tauri/index.js +42 -0
  65. package/dist/plugins/tauri/types.d.ts +16 -0
  66. package/dist/plugins/tauri/types.js +1 -0
  67. package/dist/plugins/tsdown/index.js +2 -5
  68. package/dist/plugins/tsup/index.js +2 -5
  69. package/dist/plugins/unplugin-auto-import/index.d.ts +3 -0
  70. package/dist/plugins/unplugin-auto-import/index.js +18 -0
  71. package/dist/plugins/unplugin-icons/index.d.ts +3 -0
  72. package/dist/plugins/unplugin-icons/index.js +17 -0
  73. package/dist/plugins/unplugin-vue-components/index.d.ts +3 -0
  74. package/dist/plugins/unplugin-vue-components/index.js +16 -0
  75. package/dist/plugins/unplugin-vue-i18n/index.d.ts +3 -0
  76. package/dist/plugins/unplugin-vue-i18n/index.js +10 -0
  77. package/dist/plugins/unplugin-vue-markdown/index.d.ts +3 -0
  78. package/dist/plugins/unplugin-vue-markdown/index.js +16 -0
  79. package/dist/plugins/unplugin-vue-router/index.d.ts +3 -0
  80. package/dist/plugins/unplugin-vue-router/index.js +14 -0
  81. package/dist/plugins/vite/helpers.d.ts +2 -0
  82. package/dist/plugins/vite/helpers.js +46 -31
  83. package/dist/plugins/vite/index.js +1 -1
  84. package/dist/plugins/vite-plugin-pages/index.d.ts +3 -0
  85. package/dist/plugins/vite-plugin-pages/index.js +26 -0
  86. package/dist/plugins/vite-plugin-pwa/index.d.ts +3 -0
  87. package/dist/plugins/vite-plugin-pwa/index.js +17 -0
  88. package/dist/plugins/vite-plugin-pwa/resolveFromAST.d.ts +4 -0
  89. package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +37 -0
  90. package/dist/plugins/vite-plugin-vue-layouts-next/index.d.ts +3 -0
  91. package/dist/plugins/vite-plugin-vue-layouts-next/index.js +23 -0
  92. package/dist/plugins/vite-plus/index.d.ts +3 -0
  93. package/dist/plugins/vite-plus/index.js +14 -0
  94. package/dist/plugins/vite-plus/resolveFromAST.d.ts +2 -0
  95. package/dist/plugins/vite-plus/resolveFromAST.js +37 -0
  96. package/dist/plugins/vite-pwa-assets-generator/index.d.ts +3 -0
  97. package/dist/plugins/vite-pwa-assets-generator/index.js +12 -0
  98. package/dist/plugins/vitepress/index.js +5 -1
  99. package/dist/plugins/vitest/index.js +4 -0
  100. package/dist/plugins/vitest/types.d.ts +3 -0
  101. package/dist/plugins/vue/index.js +5 -3
  102. package/dist/plugins/yarn/index.js +2 -1
  103. package/dist/plugins/yarn/types.d.ts +2 -4
  104. package/dist/schema/configuration.d.ts +255 -0
  105. package/dist/schema/plugins.d.ts +85 -0
  106. package/dist/schema/plugins.js +17 -0
  107. package/dist/types/PluginNames.d.ts +2 -2
  108. package/dist/types/PluginNames.js +17 -0
  109. package/dist/types/package-json.d.ts +8 -4
  110. package/dist/typescript/ast-helpers.d.ts +7 -2
  111. package/dist/typescript/ast-helpers.js +36 -8
  112. package/dist/typescript/ast-nodes.d.ts +1 -0
  113. package/dist/typescript/ast-nodes.js +8 -0
  114. package/dist/util/cli-arguments.d.ts +1 -1
  115. package/dist/util/cli-arguments.js +1 -1
  116. package/dist/util/create-options.d.ts +170 -0
  117. package/dist/util/resolve.js +4 -1
  118. package/dist/util/to-source-path.js +1 -1
  119. package/dist/version.d.ts +1 -1
  120. package/dist/version.js +1 -1
  121. package/package.json +1 -1
  122. package/schema.json +68 -0
  123. package/dist/plugins/next/resolveFromAST.d.ts +0 -2
  124. package/dist/plugins/next/resolveFromAST.js +0 -2
  125. package/dist/plugins/nuxt/helpers.d.ts +0 -15
  126. package/dist/plugins/nuxt/helpers.js +0 -133
  127. package/dist/plugins/rolldown/resolveFromAST.d.ts +0 -2
  128. package/dist/plugins/rolldown/resolveFromAST.js +0 -4
  129. package/dist/plugins/rollup/resolveFromAST.d.ts +0 -2
  130. package/dist/plugins/rollup/resolveFromAST.js +0 -4
  131. package/dist/plugins/rslib/resolveFromAST.d.ts +0 -2
  132. package/dist/plugins/rslib/resolveFromAST.js +0 -4
  133. package/dist/plugins/tsdown/resolveFromAST.d.ts +0 -2
  134. package/dist/plugins/tsdown/resolveFromAST.js +0 -4
  135. package/dist/plugins/tsup/resolveFromAST.d.ts +0 -2
  136. package/dist/plugins/tsup/resolveFromAST.js +0 -4
  137. package/dist/plugins/vue/compiler.d.ts +0 -3
  138. package/dist/plugins/vue/compiler.js +0 -10
@@ -26,7 +26,9 @@ import { default as dependencyCruiser } from './dependency-cruiser/index.js';
26
26
  import { default as docusaurus } from './docusaurus/index.js';
27
27
  import { default as dotenv } from './dotenv/index.js';
28
28
  import { default as drizzle } from './drizzle/index.js';
29
+ import { default as electronVite } from './electron-vite/index.js';
29
30
  import { default as eleventy } from './eleventy/index.js';
31
+ import { default as esbuild } from './esbuild/index.js';
30
32
  import { default as eslint } from './eslint/index.js';
31
33
  import { default as eve } from './eve/index.js';
32
34
  import { default as execa } from './execa/index.js';
@@ -46,6 +48,7 @@ import { default as jest } from './jest/index.js';
46
48
  import { default as karma } from './karma/index.js';
47
49
  import { default as knex } from './knex/index.js';
48
50
  import { default as ladle } from './ladle/index.js';
51
+ import { default as laravelVitePlugin } from './laravel-vite-plugin/index.js';
49
52
  import { default as lefthook } from './lefthook/index.js';
50
53
  import { default as lintStaged } from './lint-staged/index.js';
51
54
  import { default as linthtml } from './linthtml/index.js';
@@ -73,6 +76,7 @@ import { default as nodeModulesInspector } from './node-modules-inspector/index.
73
76
  import { default as nodemon } from './nodemon/index.js';
74
77
  import { default as npmPackageJsonLint } from './npm-package-json-lint/index.js';
75
78
  import { default as nuxt } from './nuxt/index.js';
79
+ import { default as nuxtjsI18n } from './nuxtjs-i18n/index.js';
76
80
  import { default as nx } from './nx/index.js';
77
81
  import { default as nyc } from './nyc/index.js';
78
82
  import { default as oclif } from './oclif/index.js';
@@ -94,6 +98,7 @@ import { default as postcss } from './postcss/index.js';
94
98
  import { default as preconstruct } from './preconstruct/index.js';
95
99
  import { default as prettier } from './prettier/index.js';
96
100
  import { default as prisma } from './prisma/index.js';
101
+ import { default as quasar } from './quasar/index.js';
97
102
  import { default as qwik } from './qwik/index.js';
98
103
  import { default as raycast } from './raycast/index.js';
99
104
  import { default as reactCosmos } from './react-cosmos/index.js';
@@ -132,6 +137,7 @@ import { default as syncpack } from './syncpack/index.js';
132
137
  import { default as tailwind } from './tailwind/index.js';
133
138
  import { default as tanstackRouter } from './tanstack-router/index.js';
134
139
  import { default as taskfile } from './taskfile/index.js';
140
+ import { default as tauri } from './tauri/index.js';
135
141
  import { default as travis } from './travis/index.js';
136
142
  import { default as tsNode } from './ts-node/index.js';
137
143
  import { default as tsdown } from './tsdown/index.js';
@@ -141,10 +147,21 @@ import { default as typedoc } from './typedoc/index.js';
141
147
  import { default as typescript } from './typescript/index.js';
142
148
  import { default as unbuild } from './unbuild/index.js';
143
149
  import { default as unocss } from './unocss/index.js';
150
+ import { default as unpluginAutoImport } from './unplugin-auto-import/index.js';
151
+ import { default as unpluginIcons } from './unplugin-icons/index.js';
152
+ import { default as unpluginVueComponents } from './unplugin-vue-components/index.js';
153
+ import { default as unpluginVueI18n } from './unplugin-vue-i18n/index.js';
154
+ import { default as unpluginVueMarkdown } from './unplugin-vue-markdown/index.js';
155
+ import { default as unpluginVueRouter } from './unplugin-vue-router/index.js';
144
156
  import { default as vercel } from './vercel/index.js';
145
157
  import { default as vercelOg } from './vercel-og/index.js';
146
158
  import { default as vike } from './vike/index.js';
147
159
  import { default as vite } from './vite/index.js';
160
+ import { default as vitePluginPages } from './vite-plugin-pages/index.js';
161
+ import { default as vitePluginPwa } from './vite-plugin-pwa/index.js';
162
+ import { default as vitePluginVueLayoutsNext } from './vite-plugin-vue-layouts-next/index.js';
163
+ import { default as vitePlus } from './vite-plus/index.js';
164
+ import { default as vitePwaAssetsGenerator } from './vite-pwa-assets-generator/index.js';
148
165
  import { default as vitepress } from './vitepress/index.js';
149
166
  import { default as vitest } from './vitest/index.js';
150
167
  import { default as vue } from './vue/index.js';
@@ -186,7 +203,9 @@ export const Plugins = {
186
203
  docusaurus,
187
204
  dotenv,
188
205
  drizzle,
206
+ 'electron-vite': electronVite,
189
207
  eleventy,
208
+ esbuild,
190
209
  eslint,
191
210
  eve,
192
211
  execa,
@@ -206,6 +225,7 @@ export const Plugins = {
206
225
  karma,
207
226
  knex,
208
227
  ladle,
228
+ 'laravel-vite-plugin': laravelVitePlugin,
209
229
  lefthook,
210
230
  'lint-staged': lintStaged,
211
231
  linthtml,
@@ -233,6 +253,7 @@ export const Plugins = {
233
253
  nodemon,
234
254
  'npm-package-json-lint': npmPackageJsonLint,
235
255
  nuxt,
256
+ 'nuxtjs-i18n': nuxtjsI18n,
236
257
  nx,
237
258
  nyc,
238
259
  oclif,
@@ -254,6 +275,7 @@ export const Plugins = {
254
275
  preconstruct,
255
276
  prettier,
256
277
  prisma,
278
+ quasar,
257
279
  qwik,
258
280
  raycast,
259
281
  'react-cosmos': reactCosmos,
@@ -292,6 +314,7 @@ export const Plugins = {
292
314
  tailwind,
293
315
  'tanstack-router': tanstackRouter,
294
316
  taskfile,
317
+ tauri,
295
318
  travis,
296
319
  'ts-node': tsNode,
297
320
  tsdown,
@@ -301,10 +324,21 @@ export const Plugins = {
301
324
  typescript,
302
325
  unbuild,
303
326
  unocss,
327
+ 'unplugin-auto-import': unpluginAutoImport,
328
+ 'unplugin-icons': unpluginIcons,
329
+ 'unplugin-vue-components': unpluginVueComponents,
330
+ 'unplugin-vue-i18n': unpluginVueI18n,
331
+ 'unplugin-vue-markdown': unpluginVueMarkdown,
332
+ 'unplugin-vue-router': unpluginVueRouter,
304
333
  vercel,
305
334
  'vercel-og': vercelOg,
306
335
  vike,
307
336
  vite,
337
+ 'vite-plugin-pages': vitePluginPages,
338
+ 'vite-plugin-pwa': vitePluginPwa,
339
+ 'vite-plugin-vue-layouts-next': vitePluginVueLayoutsNext,
340
+ 'vite-plus': vitePlus,
341
+ 'vite-pwa-assets-generator': vitePwaAssetsGenerator,
308
342
  vitepress,
309
343
  vitest,
310
344
  vue,
@@ -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 { hasDependency } from '../../util/plugin.js';
2
+ import { resolveFromAST } from './resolveFromAST.js';
3
+ const title = 'laravel-vite-plugin';
4
+ const enablers = ['laravel-vite-plugin'];
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
+ const config = ['vite.config.{js,mjs,ts,cjs,mts,cts}'];
7
+ const plugin = {
8
+ title,
9
+ enablers,
10
+ isEnabled,
11
+ config,
12
+ resolveFromAST,
13
+ };
14
+ export default plugin;
@@ -0,0 +1,2 @@
1
+ import type { ResolveFromAST } from '../../types/config.ts';
2
+ export declare const resolveFromAST: ResolveFromAST;
@@ -0,0 +1,27 @@
1
+ import { findImportedCalls, findProperty, getStringValues } from '../../typescript/ast-helpers.js';
2
+ import { getStringValue } from '../../typescript/ast-nodes.js';
3
+ import { toProductionEntry } from '../../util/input.js';
4
+ import { join } from '../../util/path.js';
5
+ const enablers = ['laravel-vite-plugin'];
6
+ const addStringOrArray = (values, node) => {
7
+ const single = getStringValue(node);
8
+ if (single !== undefined)
9
+ values.add(single);
10
+ for (const value of getStringValues(node))
11
+ values.add(value);
12
+ };
13
+ export const resolveFromAST = (program, options) => {
14
+ const inputs = [];
15
+ for (const call of findImportedCalls(program, enablers)) {
16
+ const arg = call.arguments?.[0];
17
+ if (!arg)
18
+ continue;
19
+ const specifiers = new Set();
20
+ addStringOrArray(specifiers, arg);
21
+ addStringOrArray(specifiers, findProperty(arg, 'input'));
22
+ addStringOrArray(specifiers, findProperty(arg, 'ssr'));
23
+ for (const id of specifiers)
24
+ inputs.push(toProductionEntry(join(options.configFileDir, id)));
25
+ }
26
+ return inputs;
27
+ };
@@ -1,8 +1,8 @@
1
+ import { collectPropertyValues } from '../../typescript/ast-helpers.js';
1
2
  import { isDirectory } from '../../util/fs.js';
2
3
  import { toConfig, toProductionEntry } from '../../util/input.js';
3
4
  import { join } from '../../util/path.js';
4
5
  import { hasDependency } from '../../util/plugin.js';
5
- import { getPageExtensions } from './resolveFromAST.js';
6
6
  const title = 'Next.js';
7
7
  const enablers = ['next'];
8
8
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -38,7 +38,7 @@ const getEntryFilePatterns = (pageExtensions = defaultPageExtensions, cwd) => {
38
38
  };
39
39
  const production = getEntryFilePatterns();
40
40
  const resolveFromAST = (program, { configFileDir }) => {
41
- const pageExtensions = getPageExtensions(program);
41
+ const pageExtensions = [...collectPropertyValues(program, 'pageExtensions')];
42
42
  const extensions = pageExtensions.length > 0 ? pageExtensions : defaultPageExtensions;
43
43
  const patterns = [...getEntryFilePatterns(extensions, configFileDir), 'next-env.d.ts'];
44
44
  return patterns.map(id => toProductionEntry(join(configFileDir, id)));
@@ -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
+ ];
@@ -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;
@@ -13,7 +13,8 @@ const resolveConfig = config => {
13
13
  for (const extension of Object.values(packageExtensions)) {
14
14
  if (extension.peerDependencies) {
15
15
  for (const dep of Object.keys(extension.peerDependencies)) {
16
- inputs.push(toDependency(dep));
16
+ const optional = extension.peerDependenciesMeta?.[dep]?.optional === true;
17
+ inputs.push(optional ? toDependency(dep, { optional: true }) : toDependency(dep));
17
18
  }
18
19
  }
19
20
  }
@@ -1,6 +1,4 @@
1
- import type { Dependencies, PackageJson } from '../../types/package-json.ts';
1
+ import type { PackageExtensions, PackageJson } from '../../types/package-json.ts';
2
2
  export type PnpmConfig = PackageJson & {
3
- packageExtensions?: Record<string, {
4
- peerDependencies?: Dependencies;
5
- }>;
3
+ packageExtensions?: PackageExtensions;
6
4
  };
@@ -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
+ };