knip 5.47.0 → 5.49.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 (82) hide show
  1. package/dist/ConfigurationChief.d.ts +3 -0
  2. package/dist/ProjectPrincipal.d.ts +2 -2
  3. package/dist/ProjectPrincipal.js +9 -7
  4. package/dist/WorkspaceWorker.d.ts +9 -8
  5. package/dist/WorkspaceWorker.js +100 -72
  6. package/dist/cli.js +2 -2
  7. package/dist/compilers/index.d.ts +31 -0
  8. package/dist/graph/analyze.js +0 -2
  9. package/dist/graph/build.js +62 -33
  10. package/dist/plugins/astro/index.d.ts +1 -0
  11. package/dist/plugins/astro/index.js +3 -1
  12. package/dist/plugins/ava/index.js +1 -1
  13. package/dist/plugins/cucumber/index.js +1 -1
  14. package/dist/plugins/cypress/index.js +1 -1
  15. package/dist/plugins/github-actions/index.js +1 -1
  16. package/dist/plugins/index.d.ts +27 -2
  17. package/dist/plugins/index.js +6 -0
  18. package/dist/plugins/jest/index.js +3 -1
  19. package/dist/plugins/ladle/index.js +1 -1
  20. package/dist/plugins/mocha/index.js +2 -2
  21. package/dist/plugins/next/index.d.ts +3 -2
  22. package/dist/plugins/next/index.js +19 -8
  23. package/dist/plugins/next/resolveFromAST.d.ts +2 -0
  24. package/dist/plugins/next/resolveFromAST.js +15 -0
  25. package/dist/plugins/node/index.js +1 -1
  26. package/dist/plugins/nodemon/index.js +1 -1
  27. package/dist/plugins/nuxt/index.d.ts +1 -1
  28. package/dist/plugins/nuxt/index.js +2 -2
  29. package/dist/plugins/playwright/index.js +1 -3
  30. package/dist/plugins/preconstruct/index.js +1 -1
  31. package/dist/plugins/react-cosmos/index.js +1 -1
  32. package/dist/plugins/react-router/index.js +4 -2
  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 +5 -2
  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/unbuild/index.js +1 -1
  49. package/dist/plugins/vitest/index.js +1 -1
  50. package/dist/reporters/codeowners.js +8 -6
  51. package/dist/reporters/json.js +3 -3
  52. package/dist/schema/configuration.d.ts +172 -1
  53. package/dist/schema/configuration.js +3 -1
  54. package/dist/schema/plugins.d.ts +69 -0
  55. package/dist/schema/plugins.js +3 -0
  56. package/dist/types/PluginNames.d.ts +2 -2
  57. package/dist/types/PluginNames.js +3 -0
  58. package/dist/types/config.d.ts +8 -0
  59. package/dist/typescript/ast-helpers.d.ts +4 -0
  60. package/dist/typescript/ast-helpers.js +62 -0
  61. package/dist/typescript/create-hosts.d.ts +3 -2
  62. package/dist/typescript/create-hosts.js +1 -3
  63. package/dist/util/Performance.js +7 -7
  64. package/dist/util/codeowners.d.ts +2 -0
  65. package/dist/util/codeowners.js +32 -0
  66. package/dist/util/errors.d.ts +1 -1
  67. package/dist/util/errors.js +2 -2
  68. package/dist/util/glob-core.js +1 -1
  69. package/dist/util/input.d.ts +1 -0
  70. package/dist/util/math.d.ts +6 -0
  71. package/dist/util/math.js +11 -0
  72. package/dist/util/object.d.ts +0 -1
  73. package/dist/util/object.js +0 -16
  74. package/dist/util/package-json.d.ts +1 -3
  75. package/dist/util/package-json.js +28 -5
  76. package/dist/util/plugin.d.ts +0 -2
  77. package/dist/util/plugin.js +1 -14
  78. package/dist/util/to-source-path.js +9 -12
  79. package/dist/version.d.ts +1 -1
  80. package/dist/version.js +1 -1
  81. package/package.json +3 -5
  82. package/schema.json +12 -0
@@ -12,8 +12,7 @@ import {} from '../util/tag.js';
12
12
  import { augmentWorkspace, getToSourcePathHandler } from '../util/to-source-path.js';
13
13
  import { loadTSConfig } from '../util/tsconfig-loader.js';
14
14
  export async function build({ cacheLocation, chief, collector, cwd, deputy, factory, gitignore, isCache, isFixExports, isFixTypes, isGitIgnored, isIsolateWorkspaces, isProduction, isSkipLibs, isStrict, isWatch, report, streamer, tags, tsConfigFile, workspaces, }) {
15
- const allConfigFilePaths = new Set();
16
- const allConfigFilesMap = new Map();
15
+ const configFilesMap = new Map();
17
16
  const enabledPluginsStore = new Map();
18
17
  const toSourceFilePath = getToSourcePathHandler(chief);
19
18
  const getReferencedInternalFilePath = getReferencedInputsHandler(collector, deputy, chief, isGitIgnored);
@@ -55,10 +54,10 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
55
54
  negatedWorkspacePatterns: chief.getNegatedWorkspacePatterns(name),
56
55
  ignoredWorkspacePatterns: chief.getIgnoredWorkspacesFor(name),
57
56
  enabledPluginsInAncestors: ancestors.flatMap(ancestor => enabledPluginsStore.get(ancestor) ?? []),
57
+ getSourceFile: (filePath) => principal.backend.fileManager.getSourceFile(filePath),
58
58
  isCache,
59
59
  cacheLocation,
60
- allConfigFilePaths,
61
- allConfigFilesMap,
60
+ configFilesMap,
62
61
  });
63
62
  await worker.init();
64
63
  const inputs = new Set();
@@ -70,13 +69,10 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
70
69
  const ignore = worker.getIgnorePatterns();
71
70
  const sharedGlobOptions = { cwd, dir, gitignore };
72
71
  collector.addIgnorePatterns(ignore.map(pattern => join(cwd, pattern)));
73
- const entryPathsFromManifest = await getEntryPathsFromManifest(manifest, { ...sharedGlobOptions, ignore });
74
- for (const id of entryPathsFromManifest.map(id => toProductionEntry(id)))
75
- inputs.add(id);
76
- const inputsFromPlugins = await worker.runPlugins();
77
- for (const id of inputsFromPlugins)
78
- inputs.add(id);
79
- enabledPluginsStore.set(name, worker.enabledPlugins);
72
+ const entryPathsFromManifest = await getEntryPathsFromManifest(manifest, { cwd: dir, ignore });
73
+ for (const filePath of entryPathsFromManifest) {
74
+ inputs.add(toProductionEntry(toSourceFilePath(filePath) ?? filePath));
75
+ }
80
76
  const principal = factory.createPrincipal({
81
77
  cwd: dir,
82
78
  paths: config.paths,
@@ -91,16 +87,34 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
91
87
  isCache,
92
88
  cacheLocation,
93
89
  });
94
- const entryFilePatterns = new Set();
95
- const productionEntryFilePatterns = new Set();
90
+ const inputsFromPlugins = await worker.runPlugins();
91
+ for (const id of inputsFromPlugins)
92
+ inputs.add(Object.assign(id, { skipExportsAnalysis: true }));
93
+ enabledPluginsStore.set(name, worker.enabledPlugins);
94
+ const entryPatterns = new Set();
95
+ const entryPatternsSkipExports = new Set();
96
+ const productionPatterns = new Set();
97
+ const productionPatternsSkipExports = new Set();
96
98
  const projectFilePatterns = new Set();
97
99
  for (const input of inputs) {
98
100
  const specifier = input.specifier;
99
101
  if (isEntry(input)) {
100
- entryFilePatterns.add(isAbsolute(specifier) ? relative(dir, specifier) : specifier);
102
+ const relativePath = isAbsolute(specifier) ? relative(dir, specifier) : specifier;
103
+ if (!input.skipExportsAnalysis) {
104
+ entryPatterns.add(relativePath);
105
+ }
106
+ else {
107
+ entryPatternsSkipExports.add(relativePath);
108
+ }
101
109
  }
102
110
  else if (isProductionEntry(input)) {
103
- productionEntryFilePatterns.add(isAbsolute(specifier) ? relative(dir, specifier) : specifier);
111
+ const relativePath = isAbsolute(specifier) ? relative(dir, specifier) : specifier;
112
+ if (!input.skipExportsAnalysis) {
113
+ productionPatterns.add(relativePath);
114
+ }
115
+ else {
116
+ productionPatternsSkipExports.add(relativePath);
117
+ }
104
118
  }
105
119
  else if (isProject(input)) {
106
120
  projectFilePatterns.add(isAbsolute(specifier) ? relative(dir, specifier) : specifier);
@@ -110,11 +124,11 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
110
124
  const resolvedFilePath = getReferencedInternalFilePath(input, ws);
111
125
  if (resolvedFilePath) {
112
126
  if (isDeferResolveProductionEntry(input)) {
113
- productionEntryFilePatterns.add(resolvedFilePath);
127
+ productionPatternsSkipExports.add(resolvedFilePath);
114
128
  }
115
129
  else if (isDeferResolveEntry(input)) {
116
130
  if (!isProduction || !input.optional)
117
- entryFilePatterns.add(resolvedFilePath);
131
+ entryPatternsSkipExports.add(resolvedFilePath);
118
132
  }
119
133
  else {
120
134
  principal.addEntryPath(resolvedFilePath, { skipExportsAnalysis: true });
@@ -123,21 +137,27 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
123
137
  }
124
138
  }
125
139
  if (isProduction) {
126
- const negatedEntryPatterns = Array.from(entryFilePatterns).map(negate);
140
+ const negatedEntryPatterns = [...entryPatterns, ...entryPatternsSkipExports].map(negate);
127
141
  {
128
- const label = 'entry';
142
+ const label = 'entry paths';
129
143
  const patterns = worker.getProductionEntryFilePatterns(negatedEntryPatterns);
130
144
  const workspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, gitignore: false, label });
131
145
  principal.addEntryPaths(workspaceEntryPaths);
132
146
  }
133
147
  {
134
- const label = 'production plugin entry';
135
- const patterns = Array.from(productionEntryFilePatterns);
148
+ const label = 'production entry paths from plugins (skip exports analysis)';
149
+ const patterns = Array.from(productionPatternsSkipExports);
136
150
  const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, label });
137
151
  principal.addEntryPaths(pluginWorkspaceEntryPaths, { skipExportsAnalysis: true });
138
152
  }
139
153
  {
140
- const label = 'project';
154
+ const label = 'production entry paths from plugins';
155
+ const patterns = Array.from(productionPatterns);
156
+ const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, label });
157
+ principal.addEntryPaths(pluginWorkspaceEntryPaths);
158
+ }
159
+ {
160
+ const label = 'project paths';
141
161
  const patterns = worker.getProductionProjectFilePatterns(negatedEntryPatterns);
142
162
  const workspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns, label });
143
163
  for (const projectPath of workspaceProjectPaths)
@@ -146,33 +166,42 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
146
166
  }
147
167
  else {
148
168
  {
149
- const label = 'entry';
169
+ const label = 'entry paths';
150
170
  const patterns = worker.getEntryFilePatterns();
151
171
  const workspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, gitignore: false, label });
152
172
  principal.addEntryPaths(workspaceEntryPaths);
153
173
  }
154
174
  {
155
- const label = 'project';
156
- const patterns = worker.getProjectFilePatterns([...productionEntryFilePatterns, ...projectFilePatterns]);
157
- const workspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns, label });
158
- for (const projectPath of workspaceProjectPaths)
159
- principal.addProjectPath(projectPath);
175
+ const label = 'entry paths from plugins (skip exports analysis)';
176
+ const patterns = worker.getPluginEntryFilePatterns([
177
+ ...entryPatternsSkipExports,
178
+ ...productionPatternsSkipExports,
179
+ ]);
180
+ const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, label });
181
+ principal.addEntryPaths(pluginWorkspaceEntryPaths, { skipExportsAnalysis: true });
160
182
  }
161
183
  {
162
- const label = 'plugin entry';
163
- const patterns = worker.getPluginEntryFilePatterns([...entryFilePatterns, ...productionEntryFilePatterns]);
184
+ const label = 'entry paths from plugins';
185
+ const patterns = worker.getPluginEntryFilePatterns([...entryPatterns, ...productionPatterns]);
164
186
  const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, label });
165
- principal.addEntryPaths(pluginWorkspaceEntryPaths, { skipExportsAnalysis: true });
187
+ principal.addEntryPaths(pluginWorkspaceEntryPaths);
188
+ }
189
+ {
190
+ const label = 'project paths';
191
+ const patterns = worker.getProjectFilePatterns([...productionPatternsSkipExports, ...projectFilePatterns]);
192
+ const workspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns, label });
193
+ for (const projectPath of workspaceProjectPaths)
194
+ principal.addProjectPath(projectPath);
166
195
  }
167
196
  {
168
- const label = 'plugin project';
197
+ const label = 'project paths from plugins';
169
198
  const patterns = worker.getPluginProjectFilePatterns();
170
199
  const pluginWorkspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns, label });
171
200
  for (const projectPath of pluginWorkspaceProjectPaths)
172
201
  principal.addProjectPath(projectPath);
173
202
  }
174
203
  {
175
- const label = 'plugin configuration';
204
+ const label = 'plugin configuration paths (skip exports analysis)';
176
205
  const patterns = worker.getPluginConfigPatterns();
177
206
  const configurationEntryPaths = await _glob({ ...sharedGlobOptions, patterns, label });
178
207
  principal.addEntryPaths(configurationEntryPaths, { skipExportsAnalysis: true });
@@ -3,6 +3,7 @@ declare const _default: {
3
3
  title: string;
4
4
  enablers: string[];
5
5
  isEnabled: IsPluginEnabled;
6
+ config: string[];
6
7
  entry: string[];
7
8
  production: string[];
8
9
  resolve: Resolve;
@@ -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(id => toEntry(id));
23
23
  };
24
24
  const resolveConfig = async (localConfig, options) => {
25
25
  if (typeof localConfig === 'function')
@@ -6,7 +6,7 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  const config = ['cucumber.{json,yaml,yml,js,cjs,mjs}'];
7
7
  const entry = ['features/**/*.@(js|cjs|mjs)'];
8
8
  const resolveEntryPaths = config => {
9
- return (config?.import ? config.import : []).map(toEntry);
9
+ return (config?.import ? config.import : []).map(id => toEntry(id));
10
10
  };
11
11
  const resolveConfig = config => {
12
12
  const formatters = config?.format ? config.format : [];
@@ -19,7 +19,7 @@ const resolveEntryPaths = async (localConfig) => {
19
19
  return [
20
20
  ...(specPatterns.length > 0 ? specPatterns : TEST_FILE_PATTERNS),
21
21
  ...(supportFiles.length > 0 ? supportFiles : SUPPORT_FILE_PATTERNS),
22
- ].map(toEntry);
22
+ ].map(id => toEntry(id));
23
23
  };
24
24
  const resolveConfig = async (config, options) => {
25
25
  const inputs = await resolveDependencies(config, options);
@@ -41,7 +41,7 @@ const resolveConfig = async (config, options) => {
41
41
  }
42
42
  }
43
43
  }
44
- return [...inputs, ...getActionDependencies(config, options).map(toEntry)];
44
+ return [...inputs, ...getActionDependencies(config, options).map(id => toEntry(id))];
45
45
  };
46
46
  export default {
47
47
  title,
@@ -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;
@@ -322,8 +323,9 @@ export declare const Plugins: {
322
323
  title: string;
323
324
  enablers: string[];
324
325
  isEnabled: import("../types/config.js").IsPluginEnabled;
325
- entry: string[];
326
+ config: string[];
326
327
  production: string[];
328
+ resolveFromAST: import("../types/config.js").ResolveFromAST;
327
329
  };
328
330
  node: {
329
331
  title: string;
@@ -359,7 +361,7 @@ export declare const Plugins: {
359
361
  title: string;
360
362
  enablers: string[];
361
363
  isEnabled: import("../types/config.js").IsPluginEnabled;
362
- entry: string[];
364
+ config: string[];
363
365
  production: string[];
364
366
  resolveEntryPaths: import("../types/config.js").ResolveEntryPaths<import("./nuxt/types.js").NuxtConfig>;
365
367
  };
@@ -536,6 +538,20 @@ export declare const Plugins: {
536
538
  isEnabled: import("../types/config.js").IsPluginEnabled;
537
539
  config: string[];
538
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
+ };
539
555
  storybook: {
540
556
  title: string;
541
557
  enablers: (string | RegExp)[];
@@ -579,6 +595,15 @@ export declare const Plugins: {
579
595
  isEnabled: import("../types/config.js").IsPluginEnabled;
580
596
  entry: string[];
581
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
+ };
582
607
  travis: {
583
608
  title: string;
584
609
  enablers: string;
@@ -64,12 +64,15 @@ import { default as semanticRelease } from './semantic-release/index.js';
64
64
  import { default as sentry } from './sentry/index.js';
65
65
  import { default as simpleGitHooks } from './simple-git-hooks/index.js';
66
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';
67
69
  import { default as storybook } from './storybook/index.js';
68
70
  import { default as stryker } from './stryker/index.js';
69
71
  import { default as stylelint } from './stylelint/index.js';
70
72
  import { default as svelte } from './svelte/index.js';
71
73
  import { default as syncpack } from './syncpack/index.js';
72
74
  import { default as tailwind } from './tailwind/index.js';
75
+ import { default as tanstackRouter } from './tanstack-router/index.js';
73
76
  import { default as travis } from './travis/index.js';
74
77
  import { default as tsNode } from './ts-node/index.js';
75
78
  import { default as tsup } from './tsup/index.js';
@@ -157,12 +160,15 @@ export const Plugins = {
157
160
  sentry,
158
161
  'simple-git-hooks': simpleGitHooks,
159
162
  'size-limit': sizeLimit,
163
+ sst,
164
+ starlight,
160
165
  storybook,
161
166
  stryker,
162
167
  stylelint,
163
168
  svelte,
164
169
  syncpack,
165
170
  tailwind,
171
+ 'tanstack-router': tanstackRouter,
166
172
  travis,
167
173
  'ts-node': tsNode,
168
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(id => toEntry(id));
85
+ return entry.map(id => toEntry(id));
84
86
  };
85
87
  const resolveConfig = async (localConfig, options) => {
86
88
  const { configFileDir } = options;
@@ -14,7 +14,7 @@ const resolveEntryPaths = (localConfig, options) => {
14
14
  const localStories = typeof localConfig.stories === 'string' ? [localConfig.stories] : localConfig.stories;
15
15
  const viteConfig = localConfig.viteConfig ? [toAbsolute(localConfig.viteConfig, options.cwd)] : [];
16
16
  const patterns = [...restEntry, ...(localStories ?? stories), ...viteConfig];
17
- return patterns.map(toEntry);
17
+ return patterns.map(id => toEntry(id));
18
18
  };
19
19
  const resolveConfig = async (localConfig, options) => {
20
20
  if (localConfig.viteConfig) {
@@ -7,11 +7,11 @@ const config = ['.mocharc.{js,cjs,json,jsonc,yml,yaml}', 'package.json'];
7
7
  const entry = ['**/test/*.{js,cjs,mjs}'];
8
8
  const resolveEntryPaths = localConfig => {
9
9
  const entryPatterns = localConfig.spec ? [localConfig.spec].flat() : [];
10
- return [...entryPatterns].map(toEntry);
10
+ return [...entryPatterns].map(id => toEntry(id));
11
11
  };
12
12
  const resolveConfig = localConfig => {
13
13
  const require = localConfig.require ? [localConfig.require].flat() : [];
14
- return [...require].map(toEntry);
14
+ return [...require].map(id => toEntry(id));
15
15
  };
16
16
  const args = {
17
17
  nodeImportArgs: true,
@@ -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
+ };
@@ -8,7 +8,7 @@ const resolveEntryPaths = localConfig => {
8
8
  const entries = [toProductionEntry('server.js')];
9
9
  if (scripts && Object.keys(scripts).some(script => /(?<=^|\s)node\s(.*)--test/.test(scripts[script]))) {
10
10
  const patterns = ['**/*{.,-,_}test.?(c|m)js', '**/test-*.?(c|m)js', '**/test.?(c|m)js', '**/test/**/*.?(c|m)js'];
11
- entries.push(...patterns.map(toEntry));
11
+ entries.push(...patterns.map(id => toEntry(id)));
12
12
  }
13
13
  return entries;
14
14
  };
@@ -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 => {
@@ -5,7 +5,7 @@ const enablers = ['@preconstruct/cli'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  const config = ['package.json'];
7
7
  const resolveEntryPaths = async (config) => {
8
- return (config.entrypoints ?? []).map(toEntry);
8
+ return (config.entrypoints ?? []).map(id => toEntry(id));
9
9
  };
10
10
  export default {
11
11
  title,
@@ -16,7 +16,7 @@ const resolveEntryPaths = async (localConfig) => {
16
16
  join(fixturesDir ?? '', `**/*.${fixtureFileSuffix ?? 'fixture'}.${ext}`),
17
17
  join(fixturesDir ?? '', `**/${fixtureFileSuffix ?? 'fixture'}.${ext}`),
18
18
  ];
19
- return [...entries, ...decoratorEntry].map(toEntry);
19
+ return [...entries, ...decoratorEntry].map(id => toEntry(id));
20
20
  };
21
21
  const resolveConfig = async (localConfig) => {
22
22
  return (localConfig?.plugins ?? []).map(toDeferResolve);
@@ -24,13 +24,15 @@ 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}'),
31
33
  join(appDir, 'entry.{client,server}.{js,jsx,ts,tsx}'),
32
34
  ...routes,
33
- ].map(toEntry);
35
+ ].map(id => toEntry(id));
34
36
  };
35
37
  export default {
36
38
  title,
@@ -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;