knip 5.46.5 → 5.48.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 (79) hide show
  1. package/dist/ConfigurationChief.d.ts +4 -0
  2. package/dist/ProjectPrincipal.d.ts +2 -2
  3. package/dist/ProjectPrincipal.js +9 -7
  4. package/dist/WorkspaceWorker.d.ts +10 -9
  5. package/dist/WorkspaceWorker.js +101 -74
  6. package/dist/binaries/package-manager/pnpm.js +1 -0
  7. package/dist/cli.js +2 -2
  8. package/dist/compilers/index.d.ts +41 -0
  9. package/dist/graph/analyze.js +0 -2
  10. package/dist/graph/build.js +13 -10
  11. package/dist/plugins/astro/index.d.ts +1 -0
  12. package/dist/plugins/astro/index.js +3 -1
  13. package/dist/plugins/ava/index.js +1 -1
  14. package/dist/plugins/github-action/index.d.ts +9 -0
  15. package/dist/plugins/github-action/index.js +28 -0
  16. package/dist/plugins/github-actions/index.d.ts +2 -1
  17. package/dist/plugins/github-actions/index.js +1 -1
  18. package/dist/plugins/husky/index.js +1 -1
  19. package/dist/plugins/index.d.ts +34 -2
  20. package/dist/plugins/index.js +8 -0
  21. package/dist/plugins/jest/index.js +3 -1
  22. package/dist/plugins/karma/helpers.js +4 -4
  23. package/dist/plugins/lint-staged/index.js +2 -0
  24. package/dist/plugins/next/index.d.ts +3 -2
  25. package/dist/plugins/next/index.js +19 -8
  26. package/dist/plugins/next/resolveFromAST.d.ts +2 -0
  27. package/dist/plugins/next/resolveFromAST.js +15 -0
  28. package/dist/plugins/nodemon/index.js +1 -1
  29. package/dist/plugins/nuxt/index.d.ts +1 -1
  30. package/dist/plugins/nuxt/index.js +2 -2
  31. package/dist/plugins/playwright/index.js +1 -3
  32. package/dist/plugins/react-router/index.js +3 -1
  33. package/dist/plugins/sst/index.d.ts +9 -0
  34. package/dist/plugins/sst/index.js +17 -0
  35. package/dist/plugins/sst/resolveFromAST.d.ts +2 -0
  36. package/dist/plugins/sst/resolveFromAST.js +47 -0
  37. package/dist/plugins/starlight/index.d.ts +9 -0
  38. package/dist/plugins/starlight/index.js +18 -0
  39. package/dist/plugins/starlight/resolveFromAST.d.ts +2 -0
  40. package/dist/plugins/starlight/resolveFromAST.js +20 -0
  41. package/dist/plugins/storybook/index.js +4 -1
  42. package/dist/plugins/tanstack-router/index.d.ts +12 -0
  43. package/dist/plugins/tanstack-router/index.js +46 -0
  44. package/dist/plugins/tanstack-router/resolveFromAST.d.ts +2 -0
  45. package/dist/plugins/tanstack-router/resolveFromAST.js +28 -0
  46. package/dist/plugins/tanstack-router/types.d.ts +7 -0
  47. package/dist/plugins/tanstack-router/types.js +1 -0
  48. package/dist/plugins/vitest/index.js +12 -1
  49. package/dist/plugins/vitest/types.d.ts +5 -0
  50. package/dist/plugins/vue/index.js +2 -2
  51. package/dist/plugins/webpack/index.js +2 -2
  52. package/dist/reporters/codeowners.js +8 -6
  53. package/dist/reporters/json.js +3 -3
  54. package/dist/schema/configuration.d.ts +228 -1
  55. package/dist/schema/configuration.js +3 -1
  56. package/dist/schema/plugins.d.ts +92 -0
  57. package/dist/schema/plugins.js +4 -0
  58. package/dist/types/PluginNames.d.ts +2 -2
  59. package/dist/types/PluginNames.js +4 -0
  60. package/dist/types/config.d.ts +8 -0
  61. package/dist/typescript/ast-helpers.d.ts +4 -0
  62. package/dist/typescript/ast-helpers.js +62 -0
  63. package/dist/typescript/create-hosts.d.ts +3 -2
  64. package/dist/typescript/create-hosts.js +1 -3
  65. package/dist/util/Performance.js +7 -7
  66. package/dist/util/codeowners.d.ts +2 -0
  67. package/dist/util/codeowners.js +32 -0
  68. package/dist/util/errors.d.ts +1 -1
  69. package/dist/util/errors.js +2 -2
  70. package/dist/util/input.d.ts +3 -2
  71. package/dist/util/input.js +2 -1
  72. package/dist/util/math.d.ts +6 -0
  73. package/dist/util/math.js +11 -0
  74. package/dist/util/plugin.d.ts +0 -2
  75. package/dist/util/plugin.js +1 -14
  76. package/dist/version.d.ts +1 -1
  77. package/dist/version.js +1 -1
  78. package/package.json +4 -6
  79. package/schema.json +16 -0
@@ -3,7 +3,8 @@ import { hasDependency } from '../../util/plugin.js';
3
3
  const title = 'Astro';
4
4
  const enablers = ['astro'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
- const entry = ['astro.config.{js,cjs,mjs,ts}', 'src/content/config.ts', 'src/content.config.ts'];
6
+ const config = ['astro.config.{js,cjs,mjs,ts}'];
7
+ const entry = ['src/content/config.ts', 'src/content.config.ts'];
7
8
  const production = [
8
9
  'src/pages/**/*.{astro,mdx,js,ts}',
9
10
  'src/content/**/*.mdx',
@@ -24,6 +25,7 @@ export default {
24
25
  title,
25
26
  enablers,
26
27
  isEnabled,
28
+ config,
27
29
  entry,
28
30
  production,
29
31
  resolve,
@@ -19,7 +19,7 @@ const entry = [
19
19
  const resolveEntryPaths = localConfig => {
20
20
  if (typeof localConfig === 'function')
21
21
  localConfig = localConfig();
22
- return (localConfig?.files ?? []).map(toEntry);
22
+ return (localConfig?.files ?? entry).map(toEntry);
23
23
  };
24
24
  const resolveConfig = async (localConfig, options) => {
25
25
  if (typeof localConfig === 'function')
@@ -0,0 +1,9 @@
1
+ import type { IsPluginEnabled, ResolveEntryPaths } from '../../types/config.js';
2
+ declare const _default: {
3
+ title: string;
4
+ enablers: string[];
5
+ isEnabled: IsPluginEnabled;
6
+ config: string[];
7
+ resolveEntryPaths: ResolveEntryPaths;
8
+ };
9
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import { toEntry, toProject } from '../../util/input.js';
2
+ import { relative } from '../../util/path.js';
3
+ import { hasDependency } from '../../util/plugin.js';
4
+ import { getActionDependencies } from '../github-actions/index.js';
5
+ const title = 'GitHub Action';
6
+ const enablers = ['@actions/core'];
7
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
+ const config = ['action.{yml,yaml}'];
9
+ const isAssumeArtifact = (specifier) => /^(dist|build)\//.test(specifier);
10
+ const resolveEntryPaths = async (config, options) => {
11
+ const inputs = [];
12
+ const filePaths = getActionDependencies(config, options);
13
+ for (const filePath of new Set(filePaths)) {
14
+ const relativePath = relative(options.cwd, filePath);
15
+ if (isAssumeArtifact(relativePath))
16
+ inputs.push(toProject(`!${relativePath}`));
17
+ else
18
+ inputs.push(toEntry(relativePath));
19
+ }
20
+ return inputs;
21
+ };
22
+ export default {
23
+ title,
24
+ enablers,
25
+ isEnabled,
26
+ config,
27
+ resolveEntryPaths,
28
+ };
@@ -1,4 +1,5 @@
1
- import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
1
+ import type { IsPluginEnabled, PluginOptions, ResolveConfig } from '../../types/config.js';
2
+ export declare const getActionDependencies: (config: any, options: PluginOptions) => string[];
2
3
  declare const _default: {
3
4
  title: string;
4
5
  enablers: string;
@@ -8,7 +8,7 @@ const isEnabled = async ({ cwd }) => Boolean(await _firstGlob({ cwd, patterns: [
8
8
  const isRootOnly = true;
9
9
  const config = ['.github/workflows/*.{yml,yaml}', '.github/**/action.{yml,yaml}'];
10
10
  const isString = (value) => typeof value === 'string';
11
- const getActionDependencies = (config, options) => {
11
+ export const getActionDependencies = (config, options) => {
12
12
  const { configFileDir, configFileName } = options;
13
13
  const isActionManifest = configFileName === 'action.yml' || configFileName === 'action.yaml';
14
14
  if (!(isActionManifest && config?.runs?.using?.startsWith('node')))
@@ -8,7 +8,7 @@ const isRootOnly = true;
8
8
  const gitHookPaths = getGitHookPaths('.husky', false);
9
9
  const config = [...gitHookPaths, 'package.json'];
10
10
  const resolveConfig = (script, options) => {
11
- if (!script)
11
+ if (!script || options.isProduction)
12
12
  return [];
13
13
  if (options.configFileName === 'package.json') {
14
14
  const hooks = script.hooks;
@@ -10,6 +10,7 @@ export declare const Plugins: {
10
10
  title: string;
11
11
  enablers: string[];
12
12
  isEnabled: import("../types/config.js").IsPluginEnabled;
13
+ config: string[];
13
14
  entry: string[];
14
15
  production: string[];
15
16
  resolve: import("../types/config.js").Resolve;
@@ -151,6 +152,13 @@ export declare const Plugins: {
151
152
  production: string[];
152
153
  resolveConfig: import("../types/config.js").ResolveConfig<import("./gatsby/types.js").GatsbyConfig | import("./gatsby/types.js").GatsbyNode>;
153
154
  };
155
+ 'github-action': {
156
+ title: string;
157
+ enablers: string[];
158
+ isEnabled: import("../types/config.js").IsPluginEnabled;
159
+ config: string[];
160
+ resolveEntryPaths: import("../types/config.js").ResolveEntryPaths;
161
+ };
154
162
  'github-actions': {
155
163
  title: string;
156
164
  enablers: string;
@@ -315,8 +323,9 @@ export declare const Plugins: {
315
323
  title: string;
316
324
  enablers: string[];
317
325
  isEnabled: import("../types/config.js").IsPluginEnabled;
318
- entry: string[];
326
+ config: string[];
319
327
  production: string[];
328
+ resolveFromAST: import("../types/config.js").ResolveFromAST;
320
329
  };
321
330
  node: {
322
331
  title: string;
@@ -352,7 +361,7 @@ export declare const Plugins: {
352
361
  title: string;
353
362
  enablers: string[];
354
363
  isEnabled: import("../types/config.js").IsPluginEnabled;
355
- entry: string[];
364
+ config: string[];
356
365
  production: string[];
357
366
  resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("./nuxt/types.js").NuxtConfig>;
358
367
  };
@@ -529,6 +538,20 @@ export declare const Plugins: {
529
538
  isEnabled: import("../types/config.js").IsPluginEnabled;
530
539
  config: string[];
531
540
  };
541
+ sst: {
542
+ title: string;
543
+ enablers: string[];
544
+ isEnabled: import("../types/config.js").IsPluginEnabled;
545
+ config: string[];
546
+ resolveFromAST: import("../types/config.js").ResolveFromAST;
547
+ };
548
+ starlight: {
549
+ title: string;
550
+ enablers: string[];
551
+ isEnabled: import("../types/config.js").IsPluginEnabled;
552
+ config: string[];
553
+ resolveFromAST: import("../types/config.js").ResolveFromAST;
554
+ };
532
555
  storybook: {
533
556
  title: string;
534
557
  enablers: (string | RegExp)[];
@@ -572,6 +595,15 @@ export declare const Plugins: {
572
595
  isEnabled: import("../types/config.js").IsPluginEnabled;
573
596
  entry: string[];
574
597
  };
598
+ 'tanstack-router': {
599
+ title: string;
600
+ enablers: string[];
601
+ isEnabled: import("../types/config.js").IsPluginEnabled;
602
+ config: string[];
603
+ production: string[];
604
+ resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("./tanstack-router/types.js").TanstackRouterConfig>;
605
+ resolveFromAST: import("../types/config.js").ResolveFromAST;
606
+ };
575
607
  travis: {
576
608
  title: string;
577
609
  enablers: string;
@@ -17,6 +17,7 @@ import { default as eleventy } from './eleventy/index.js';
17
17
  import { default as eslint } from './eslint/index.js';
18
18
  import { default as expo } from './expo/index.js';
19
19
  import { default as gatsby } from './gatsby/index.js';
20
+ import { default as githubAction } from './github-action/index.js';
20
21
  import { default as githubActions } from './github-actions/index.js';
21
22
  import { default as glob } from './glob/index.js';
22
23
  import { default as graphqlCodegen } from './graphql-codegen/index.js';
@@ -63,12 +64,15 @@ import { default as semanticRelease } from './semantic-release/index.js';
63
64
  import { default as sentry } from './sentry/index.js';
64
65
  import { default as simpleGitHooks } from './simple-git-hooks/index.js';
65
66
  import { default as sizeLimit } from './size-limit/index.js';
67
+ import { default as sst } from './sst/index.js';
68
+ import { default as starlight } from './starlight/index.js';
66
69
  import { default as storybook } from './storybook/index.js';
67
70
  import { default as stryker } from './stryker/index.js';
68
71
  import { default as stylelint } from './stylelint/index.js';
69
72
  import { default as svelte } from './svelte/index.js';
70
73
  import { default as syncpack } from './syncpack/index.js';
71
74
  import { default as tailwind } from './tailwind/index.js';
75
+ import { default as tanstackRouter } from './tanstack-router/index.js';
72
76
  import { default as travis } from './travis/index.js';
73
77
  import { default as tsNode } from './ts-node/index.js';
74
78
  import { default as tsup } from './tsup/index.js';
@@ -109,6 +113,7 @@ export const Plugins = {
109
113
  eslint,
110
114
  expo,
111
115
  gatsby,
116
+ 'github-action': githubAction,
112
117
  'github-actions': githubActions,
113
118
  glob,
114
119
  'graphql-codegen': graphqlCodegen,
@@ -155,12 +160,15 @@ export const Plugins = {
155
160
  sentry,
156
161
  'simple-git-hooks': simpleGitHooks,
157
162
  'size-limit': sizeLimit,
163
+ sst,
164
+ starlight,
158
165
  storybook,
159
166
  stryker,
160
167
  stylelint,
161
168
  svelte,
162
169
  syncpack,
163
170
  tailwind,
171
+ 'tanstack-router': tanstackRouter,
164
172
  travis,
165
173
  'ts-node': tsNode,
166
174
  tsup,
@@ -80,7 +80,9 @@ const resolveEntryPaths = async (localConfig, options) => {
80
80
  localConfig = await localConfig();
81
81
  const rootDir = localConfig.rootDir ?? configFileDir;
82
82
  const replaceRootDir = (name) => name.replace(/<rootDir>/, rootDir);
83
- return (localConfig.testMatch ?? []).map(replaceRootDir).map(toEntry);
83
+ if (localConfig.testMatch)
84
+ return localConfig.testMatch.map(replaceRootDir).map(toEntry);
85
+ return entry.map(id => toEntry(id));
84
86
  };
85
87
  const resolveConfig = async (localConfig, options) => {
86
88
  const { configFileDir } = options;
@@ -1,19 +1,19 @@
1
- import { toDeferResolveEntry, toDevDependency } from '../../util/input.js';
1
+ import { toDeferResolveEntry, toDependency } from '../../util/input.js';
2
2
  import { isInternal } from '../../util/path.js';
3
3
  export const configFiles = ['karma.conf.js', 'karma.conf.ts', '.config/karma.conf.js', '.config/karma.conf.ts'];
4
4
  export const inputsFromFrameworks = (frameworks) => frameworks.map(framework => {
5
- return toDevDependency(framework === 'jasmine' ? 'jasmine-core' : framework);
5
+ return toDependency(framework === 'jasmine' ? 'jasmine-core' : framework);
6
6
  });
7
7
  export const inputsFromPlugins = (plugins, devDependencies) => {
8
8
  if (!plugins) {
9
9
  const karmaPluginDevDeps = Object.keys(devDependencies ?? {}).filter(name => name.startsWith('karma-'));
10
- return karmaPluginDevDeps.map(karmaPluginDevDep => toDevDependency(karmaPluginDevDep));
10
+ return karmaPluginDevDeps.map(karmaPluginDevDep => toDependency(karmaPluginDevDep));
11
11
  }
12
12
  return plugins
13
13
  .map(plugin => {
14
14
  if (typeof plugin !== 'string')
15
15
  return;
16
- return isInternal(plugin) ? toDeferResolveEntry(plugin) : toDevDependency(plugin);
16
+ return isInternal(plugin) ? toDeferResolveEntry(plugin) : toDependency(plugin);
17
17
  })
18
18
  .filter(input => !!input);
19
19
  };
@@ -12,6 +12,8 @@ const config = [
12
12
  ...toLilconfig('lintstaged'),
13
13
  ];
14
14
  const resolveConfig = async (config, options) => {
15
+ if (options.isProduction)
16
+ return [];
15
17
  if (typeof config === 'function')
16
18
  config = config();
17
19
  if (!config)
@@ -1,9 +1,10 @@
1
- import type { IsPluginEnabled } from '../../types/config.js';
1
+ import type { IsPluginEnabled, ResolveFromAST } from '../../types/config.js';
2
2
  declare const _default: {
3
3
  title: string;
4
4
  enablers: string[];
5
5
  isEnabled: IsPluginEnabled;
6
- entry: string[];
6
+ config: string[];
7
7
  production: string[];
8
+ resolveFromAST: ResolveFromAST;
8
9
  };
9
10
  export default _default;
@@ -1,9 +1,12 @@
1
+ import { toProductionEntry } from '../../util/input.js';
1
2
  import { hasDependency } from '../../util/plugin.js';
3
+ import { getPageExtensions } from './resolveFromAST.js';
2
4
  const title = 'Next.js';
3
5
  const enablers = ['next'];
4
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
- const entry = ['next.config.{js,ts,cjs,mjs}'];
6
- const productionEntryFilePatternsWithoutSrc = [
7
+ const config = ['next.config.{js,ts,cjs,mjs}'];
8
+ const defaultPageExtensions = ['{js,jsx,ts,tsx}'];
9
+ const productionEntryFilePatterns = [
7
10
  '{instrumentation,middleware}.{js,ts}',
8
11
  'app/global-error.{js,jsx,ts,tsx}',
9
12
  'app/**/{error,layout,loading,not-found,page,template,default}.{js,jsx,ts,tsx}',
@@ -11,16 +14,24 @@ const productionEntryFilePatternsWithoutSrc = [
11
14
  'app/{manifest,sitemap,robots}.{js,ts}',
12
15
  'app/**/{icon,apple-icon}.{js,jsx,ts,tsx}',
13
16
  'app/**/{opengraph,twitter}-image.{js,jsx,ts,tsx}',
14
- 'pages/**/*.{js,jsx,ts,tsx}',
15
- ];
16
- const production = [
17
- ...productionEntryFilePatternsWithoutSrc,
18
- ...productionEntryFilePatternsWithoutSrc.map(pattern => `src/${pattern}`),
19
17
  ];
18
+ const getEntryFilePatterns = (pageExtensions = defaultPageExtensions) => {
19
+ const pages = pageExtensions.map(ext => `pages/**/*.${ext}`);
20
+ const patterns = [...productionEntryFilePatterns, ...pages];
21
+ return [...patterns, ...patterns.map(pattern => `src/${pattern}`)];
22
+ };
23
+ const production = getEntryFilePatterns();
24
+ const resolveFromAST = sourceFile => {
25
+ const pageExtensions = getPageExtensions(sourceFile);
26
+ const extensions = pageExtensions.length > 0 ? pageExtensions : defaultPageExtensions;
27
+ const patterns = getEntryFilePatterns(extensions);
28
+ return patterns.map(id => toProductionEntry(id));
29
+ };
20
30
  export default {
21
31
  title,
22
32
  enablers,
23
33
  isEnabled,
24
- entry,
34
+ config,
25
35
  production,
36
+ resolveFromAST,
26
37
  };
@@ -0,0 +1,2 @@
1
+ import ts from 'typescript';
2
+ export declare const getPageExtensions: (sourceFile: ts.SourceFile) => string[];
@@ -0,0 +1,15 @@
1
+ import ts from 'typescript';
2
+ import { getPropertyValues } from '../../typescript/ast-helpers.js';
3
+ export const getPageExtensions = (sourceFile) => {
4
+ const pageExtensions = new Set();
5
+ function visit(node) {
6
+ if (ts.isObjectLiteralExpression(node)) {
7
+ const values = getPropertyValues(node, 'pageExtensions');
8
+ for (const value of values)
9
+ pageExtensions.add(value);
10
+ }
11
+ ts.forEachChild(node, visit);
12
+ }
13
+ visit(sourceFile);
14
+ return Array.from(pageExtensions);
15
+ };
@@ -1,6 +1,6 @@
1
1
  const title = 'nodemon';
2
2
  const args = {
3
- positional: true,
3
+ positional: false,
4
4
  nodeImportArgs: true,
5
5
  string: ['exec'],
6
6
  fromArgs: ['exec'],
@@ -7,7 +7,7 @@ declare const _default: {
7
7
  title: string;
8
8
  enablers: string[];
9
9
  isEnabled: IsPluginEnabled;
10
- entry: string[];
10
+ config: string[];
11
11
  production: string[];
12
12
  resolveEntryPaths: ResolveEntryPaths<NuxtConfig>;
13
13
  };
@@ -9,7 +9,7 @@ const isEnabled = ({ dependencies }) => {
9
9
  globalThis.defineNuxtConfig = (c) => c;
10
10
  return isEnabled;
11
11
  };
12
- const entry = ['nuxt.config.{js,mjs,ts}'];
12
+ const config = ['nuxt.config.{js,mjs,ts}'];
13
13
  const production = [
14
14
  'app.{vue,jsx,tsx}',
15
15
  'error.{vue,jsx,tsx}',
@@ -43,7 +43,7 @@ export default {
43
43
  title,
44
44
  enablers,
45
45
  isEnabled,
46
- entry,
46
+ config,
47
47
  production,
48
48
  resolveEntryPaths,
49
49
  };
@@ -7,8 +7,6 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
7
  const config = ['playwright.config.{js,ts,mjs}'];
8
8
  export const entry = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
9
9
  const toEntryPatterns = (testMatch, cwd, configDir, localConfig, rootConfig) => {
10
- if (!testMatch)
11
- return [];
12
10
  const testDir = localConfig.testDir ?? rootConfig.testDir;
13
11
  const dir = relative(cwd, testDir ? join(configDir, testDir) : configDir);
14
12
  const patterns = [testMatch].flat().filter((p) => typeof p === 'string');
@@ -18,7 +16,7 @@ const builtinReporters = ['dot', 'line', 'list', 'junit', 'html', 'blob', 'json'
18
16
  export const resolveEntryPaths = async (localConfig, options) => {
19
17
  const { cwd, configFileDir } = options;
20
18
  const projects = localConfig.projects ? [localConfig, ...localConfig.projects] : [localConfig];
21
- return projects.flatMap(config => toEntryPatterns(config.testMatch, cwd, configFileDir, config, localConfig));
19
+ return projects.flatMap(config => toEntryPatterns(config.testMatch ?? entry, cwd, configFileDir, config, localConfig));
22
20
  };
23
21
  export const resolveConfig = async (config) => {
24
22
  const reporters = [config.reporter].flat().flatMap(reporter => {
@@ -24,7 +24,9 @@ const resolveEntryPaths = async (localConfig, options) => {
24
24
  const mapRoute = (route) => {
25
25
  return [join(appDir, route.file), ...(route.children ? route.children.flatMap(mapRoute) : [])];
26
26
  };
27
- const routes = routeConfig.flatMap(mapRoute);
27
+ const routes = routeConfig
28
+ .flatMap(mapRoute)
29
+ .map(route => route.replace(/[$^*+?()\[\]]/g, '\\$&'));
28
30
  return [
29
31
  join(appDir, 'routes.{js,ts}'),
30
32
  join(appDir, 'root.{jsx,tsx}'),
@@ -0,0 +1,9 @@
1
+ import type { IsPluginEnabled, ResolveFromAST } from '../../types/config.js';
2
+ declare const _default: {
3
+ title: string;
4
+ enablers: string[];
5
+ isEnabled: IsPluginEnabled;
6
+ config: string[];
7
+ resolveFromAST: ResolveFromAST;
8
+ };
9
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import { hasDependency } from '../../util/plugin.js';
2
+ import { getInputsFromHandlers } from './resolveFromAST.js';
3
+ const title = 'SST';
4
+ const enablers = ['sst'];
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
+ const config = ['sst.config.ts'];
7
+ const resolveFromAST = (sourceFile, options) => {
8
+ const inputs = getInputsFromHandlers(sourceFile, options);
9
+ return inputs;
10
+ };
11
+ export default {
12
+ title,
13
+ enablers,
14
+ isEnabled,
15
+ config,
16
+ resolveFromAST,
17
+ };
@@ -0,0 +1,2 @@
1
+ import type { ResolveFromAST } from '../../types/config.js';
2
+ export declare const getInputsFromHandlers: ResolveFromAST;
@@ -0,0 +1,47 @@
1
+ import ts from 'typescript';
2
+ import { getImportMap, getPropertyValues } from '../../typescript/ast-helpers.js';
3
+ import { toDeferResolveProductionEntry } from '../../util/input.js';
4
+ export const getInputsFromHandlers = (sourceFile, options) => {
5
+ const { getSourceFile, getReferencedInternalFilePath } = options;
6
+ const entries = new Set();
7
+ const importMap = getImportMap(sourceFile);
8
+ function addHandlerSpecifiers(node) {
9
+ if (ts.isObjectLiteralExpression(node)) {
10
+ const specifiers = getPropertyValues(node, 'handler');
11
+ for (const specifier of specifiers)
12
+ entries.add(specifier.substring(0, specifier.lastIndexOf('.')));
13
+ }
14
+ ts.forEachChild(node, addHandlerSpecifiers);
15
+ }
16
+ function visit(node) {
17
+ if (ts.isCallExpression(node)) {
18
+ if (ts.isPropertyAccessExpression(node.expression)) {
19
+ if (node.expression.name.text === 'stack') {
20
+ const arg = node.arguments[0];
21
+ if (ts.isIdentifier(arg)) {
22
+ const importPath = importMap.get(arg.text);
23
+ if (importPath) {
24
+ const input = toDeferResolveProductionEntry(importPath, { containingFilePath: options.configFilePath });
25
+ const resolvedPath = getReferencedInternalFilePath(input);
26
+ if (resolvedPath) {
27
+ const stackFile = getSourceFile(resolvedPath);
28
+ if (stackFile)
29
+ ts.forEachChild(stackFile, addHandlerSpecifiers);
30
+ }
31
+ }
32
+ }
33
+ }
34
+ if (node.expression.name.text === 'route' && node.arguments.length >= 2) {
35
+ const handlerArg = node.arguments[1];
36
+ if (ts.isStringLiteral(handlerArg)) {
37
+ entries.add(handlerArg.text);
38
+ }
39
+ }
40
+ }
41
+ }
42
+ ts.forEachChild(node, visit);
43
+ }
44
+ ts.forEachChild(sourceFile, addHandlerSpecifiers);
45
+ ts.forEachChild(sourceFile, visit);
46
+ return Array.from(entries).map(specifier => toDeferResolveProductionEntry(specifier, { containingFilePath: options.configFilePath }));
47
+ };
@@ -0,0 +1,9 @@
1
+ import type { IsPluginEnabled, ResolveFromAST } from '../../types/config.js';
2
+ declare const _default: {
3
+ title: string;
4
+ enablers: string[];
5
+ isEnabled: IsPluginEnabled;
6
+ config: string[];
7
+ resolveFromAST: ResolveFromAST;
8
+ };
9
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import { toProductionEntry } from '../../util/input.js';
2
+ import { hasDependency } from '../../util/plugin.js';
3
+ import { getComponentPathsFromSourceFile } from './resolveFromAST.js';
4
+ const title = 'Starlight';
5
+ const enablers = ['@astrojs/starlight'];
6
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
+ const config = ['astro.config.{js,cjs,mjs,ts}'];
8
+ const resolveFromAST = (sourceFile) => {
9
+ const componentPaths = getComponentPathsFromSourceFile(sourceFile);
10
+ return Array.from(componentPaths).map(id => toProductionEntry(id));
11
+ };
12
+ export default {
13
+ title,
14
+ enablers,
15
+ isEnabled,
16
+ config,
17
+ resolveFromAST,
18
+ };
@@ -0,0 +1,2 @@
1
+ import ts from 'typescript';
2
+ export declare const getComponentPathsFromSourceFile: (sourceFile: ts.SourceFile) => Set<string>;
@@ -0,0 +1,20 @@
1
+ import ts from 'typescript';
2
+ import { getDefaultImportName, getImportMap, getPropertyValues } from '../../typescript/ast-helpers.js';
3
+ export const getComponentPathsFromSourceFile = (sourceFile) => {
4
+ const componentPaths = new Set();
5
+ const importMap = getImportMap(sourceFile);
6
+ const starlightImportName = getDefaultImportName(importMap, '@astrojs/starlight');
7
+ function visit(node) {
8
+ if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === starlightImportName) {
9
+ const starlightConfig = node.arguments[0];
10
+ if (ts.isObjectLiteralExpression(starlightConfig)) {
11
+ const values = getPropertyValues(starlightConfig, 'components');
12
+ for (const value of values)
13
+ componentPaths.add(value);
14
+ }
15
+ }
16
+ ts.forEachChild(node, visit);
17
+ }
18
+ visit(sourceFile);
19
+ return componentPaths;
20
+ };
@@ -17,7 +17,10 @@ const resolveEntryPaths = async (localConfig, options) => {
17
17
  return relative(cwd, join(configFileDir, pattern));
18
18
  return relative(cwd, join(configFileDir, pattern.directory, pattern.files ?? stories[0]));
19
19
  });
20
- const patterns = [...restEntry, ...(relativePatterns && relativePatterns.length > 0 ? relativePatterns : stories)];
20
+ const patterns = [
21
+ ...(options.config.entry ?? restEntry),
22
+ ...(relativePatterns && relativePatterns.length > 0 ? relativePatterns : stories),
23
+ ];
21
24
  return patterns.map(toEntry);
22
25
  };
23
26
  const resolveConfig = async (localConfig) => {
@@ -0,0 +1,12 @@
1
+ import type { IsPluginEnabled, ResolveEntryPaths, ResolveFromAST } from '../../types/config.js';
2
+ import type { TanstackRouterConfig } from './types.js';
3
+ declare const _default: {
4
+ title: string;
5
+ enablers: string[];
6
+ isEnabled: IsPluginEnabled;
7
+ config: string[];
8
+ production: string[];
9
+ resolveEntryPaths: ResolveEntryPaths<TanstackRouterConfig>;
10
+ resolveFromAST: ResolveFromAST;
11
+ };
12
+ export default _default;
@@ -0,0 +1,46 @@
1
+ import { toEntry } from '../../util/input.js';
2
+ import { extname, join } from '../../util/path.js';
3
+ import { hasDependency } from '../../util/plugin.js';
4
+ import { getCustomConfig } from './resolveFromAST.js';
5
+ const title = 'tanstack-router';
6
+ const enablers = ['@tanstack/react-router', '@tanstack/router-plugin', '@tanstack/router-cli'];
7
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
+ const config = [
9
+ 'tsr.config.json',
10
+ 'vite.config.{js,mjs,ts,cjs,mts,cts}',
11
+ 'rs{pack,build}.config.{js,mjs,ts,cjs,mts,cts}',
12
+ 'webpack.config.{js,mjs,ts,cjs,mts,cts}',
13
+ ];
14
+ const production = ['./src/routeTree.gen.ts', './src/routes/**/*.{ts,tsx}', '!src/routes/**/-*/**'];
15
+ const getEntryPatterns = (config) => {
16
+ const dir = config.routesDirectory ?? 'src/routes';
17
+ const entries = [
18
+ toEntry(join(config.generatedRouteTree ?? './src/routeTree.gen.ts')),
19
+ toEntry(join(dir, '**', `${config.routeFilePrefix ?? ''}*`)),
20
+ toEntry(join(`!${dir}`, '**', `${config.routeFileIgnorePrefix ?? '-'}*`)),
21
+ ];
22
+ if (config.routeFileIgnorePattern) {
23
+ entries.push(toEntry(join(`!${dir}`, '**', `*${config.routeFileIgnorePattern}*`)));
24
+ }
25
+ return entries;
26
+ };
27
+ const resolveEntryPaths = (localConfig, options) => {
28
+ if (extname(options.configFileName) !== '.json')
29
+ return [];
30
+ return getEntryPatterns(localConfig);
31
+ };
32
+ const resolveFromAST = (sourceFile, options) => {
33
+ if (extname(options.configFileName) === '.json')
34
+ return [];
35
+ const resolvedConfig = getCustomConfig(sourceFile);
36
+ return getEntryPatterns(resolvedConfig);
37
+ };
38
+ export default {
39
+ title,
40
+ enablers,
41
+ isEnabled,
42
+ config,
43
+ production,
44
+ resolveEntryPaths,
45
+ resolveFromAST,
46
+ };
@@ -0,0 +1,2 @@
1
+ import ts from 'typescript';
2
+ export declare const getCustomConfig: (sourceFile: ts.SourceFile) => Record<string, string>;