knip 5.53.0 → 5.54.1

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 (90) hide show
  1. package/dist/IssueFixer.d.ts +1 -1
  2. package/dist/IssueFixer.js +13 -3
  3. package/dist/PrincipalFactory.js +3 -17
  4. package/dist/ProjectPrincipal.d.ts +2 -2
  5. package/dist/ProjectPrincipal.js +14 -3
  6. package/dist/WorkspaceWorker.d.ts +0 -1
  7. package/dist/WorkspaceWorker.js +4 -19
  8. package/dist/cli.js +2 -1
  9. package/dist/graph/build.js +8 -5
  10. package/dist/index.js +15 -4
  11. package/dist/plugins/ava/index.d.ts +1 -2
  12. package/dist/plugins/ava/index.js +2 -7
  13. package/dist/plugins/bun/index.d.ts +2 -2
  14. package/dist/plugins/bun/index.js +2 -2
  15. package/dist/plugins/cucumber/index.d.ts +1 -2
  16. package/dist/plugins/cucumber/index.js +2 -5
  17. package/dist/plugins/cypress/index.d.ts +1 -2
  18. package/dist/plugins/cypress/index.js +6 -9
  19. package/dist/plugins/cypress/types.d.ts +8 -0
  20. package/dist/plugins/eleventy/helpers.d.ts +10 -2
  21. package/dist/plugins/eleventy/index.d.ts +3 -6
  22. package/dist/plugins/eleventy/index.js +11 -16
  23. package/dist/plugins/eleventy/types.d.ts +9 -7
  24. package/dist/plugins/expo/index.d.ts +2 -5
  25. package/dist/plugins/expo/index.js +4 -6
  26. package/dist/plugins/github-action/index.d.ts +2 -2
  27. package/dist/plugins/github-action/index.js +2 -2
  28. package/dist/plugins/index.d.ts +14 -28
  29. package/dist/plugins/jest/index.d.ts +1 -2
  30. package/dist/plugins/jest/index.js +4 -12
  31. package/dist/plugins/karma/index.d.ts +1 -3
  32. package/dist/plugins/karma/index.js +0 -10
  33. package/dist/plugins/ladle/index.d.ts +1 -2
  34. package/dist/plugins/ladle/index.js +4 -7
  35. package/dist/plugins/metro/index.d.ts +2 -3
  36. package/dist/plugins/metro/index.js +17 -14
  37. package/dist/plugins/mocha/index.d.ts +1 -2
  38. package/dist/plugins/mocha/index.js +2 -6
  39. package/dist/plugins/msw/index.d.ts +2 -2
  40. package/dist/plugins/msw/index.js +2 -2
  41. package/dist/plugins/netlify/index.d.ts +1 -2
  42. package/dist/plugins/netlify/index.js +4 -7
  43. package/dist/plugins/node/index.d.ts +2 -2
  44. package/dist/plugins/node/index.js +2 -2
  45. package/dist/plugins/nuxt/index.d.ts +2 -2
  46. package/dist/plugins/nuxt/index.js +2 -2
  47. package/dist/plugins/playwright/index.d.ts +1 -3
  48. package/dist/plugins/playwright/index.js +5 -7
  49. package/dist/plugins/playwright-ct/index.d.ts +0 -1
  50. package/dist/plugins/playwright-ct/index.js +1 -2
  51. package/dist/plugins/postcss/index.js +3 -1
  52. package/dist/plugins/preconstruct/index.d.ts +1 -1
  53. package/dist/plugins/preconstruct/index.js +2 -2
  54. package/dist/plugins/react-cosmos/index.d.ts +1 -2
  55. package/dist/plugins/react-cosmos/index.js +4 -6
  56. package/dist/plugins/react-router/index.d.ts +2 -2
  57. package/dist/plugins/react-router/index.js +2 -2
  58. package/dist/plugins/relay/index.d.ts +2 -2
  59. package/dist/plugins/relay/index.js +2 -2
  60. package/dist/plugins/rspack/index.js +2 -3
  61. package/dist/plugins/size-limit/index.d.ts +2 -1
  62. package/dist/plugins/size-limit/index.js +10 -0
  63. package/dist/plugins/storybook/index.d.ts +1 -2
  64. package/dist/plugins/storybook/index.js +2 -5
  65. package/dist/plugins/svelte/index.d.ts +2 -1
  66. package/dist/plugins/svelte/index.js +7 -0
  67. package/dist/plugins/vite/index.d.ts +0 -1
  68. package/dist/plugins/vite/index.js +1 -2
  69. package/dist/plugins/vitest/index.d.ts +1 -3
  70. package/dist/plugins/vitest/index.js +38 -24
  71. package/dist/plugins/vitest/types.d.ts +12 -0
  72. package/dist/plugins/vue/index.js +2 -5
  73. package/dist/plugins/webpack/index.d.ts +1 -5
  74. package/dist/plugins/webpack/index.js +36 -17
  75. package/dist/plugins/wrangler/index.d.ts +2 -2
  76. package/dist/plugins/wrangler/index.js +2 -2
  77. package/dist/plugins.js +1 -1
  78. package/dist/schema/configuration.d.ts +8 -8
  79. package/dist/types/cli.d.ts +1 -0
  80. package/dist/types/config.d.ts +0 -2
  81. package/dist/types/project.d.ts +0 -1
  82. package/dist/util/cli-arguments.d.ts +2 -1
  83. package/dist/util/cli-arguments.js +2 -0
  84. package/dist/util/glob-core.d.ts +5 -6
  85. package/dist/util/glob-core.js +30 -31
  86. package/dist/util/input.d.ts +7 -1
  87. package/dist/util/input.js +7 -0
  88. package/dist/version.d.ts +1 -1
  89. package/dist/version.js +1 -1
  90. package/package.json +5 -3
@@ -3,7 +3,7 @@ const title = 'Node.js';
3
3
  const isEnabled = () => true;
4
4
  const config = ['package.json'];
5
5
  const packageJsonPath = (id) => id;
6
- const resolveEntryPaths = localConfig => {
6
+ const resolveConfig = localConfig => {
7
7
  const scripts = localConfig.scripts;
8
8
  const entries = [toProductionEntry('server.js')];
9
9
  if (scripts && Object.keys(scripts).some(script => /(?<=^|\s)node\s(.*)--test/.test(scripts[script]))) {
@@ -23,6 +23,6 @@ export default {
23
23
  isEnabled,
24
24
  packageJsonPath,
25
25
  config,
26
- resolveEntryPaths,
26
+ resolveConfig,
27
27
  args,
28
28
  };
@@ -1,4 +1,4 @@
1
- import type { IsPluginEnabled, ResolveEntryPaths } from '../../types/config.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
2
2
  import type { NuxtConfig } from './types.js';
3
3
  export declare const docs: {
4
4
  note: string;
@@ -9,6 +9,6 @@ declare const _default: {
9
9
  isEnabled: IsPluginEnabled;
10
10
  config: string[];
11
11
  production: string[];
12
- resolveEntryPaths: ResolveEntryPaths<NuxtConfig>;
12
+ resolveConfig: ResolveConfig<NuxtConfig>;
13
13
  };
14
14
  export default _default;
@@ -21,7 +21,7 @@ const production = [
21
21
  'server/middleware/**/*.ts',
22
22
  'server/plugins/**/*.ts',
23
23
  ];
24
- const resolveEntryPaths = async (localConfig) => {
24
+ const resolveConfig = async (localConfig) => {
25
25
  const srcDir = localConfig.srcDir ?? '.';
26
26
  const patterns = [
27
27
  'app.{vue,jsx,tsx}',
@@ -45,5 +45,5 @@ export default {
45
45
  isEnabled,
46
46
  config,
47
47
  production,
48
- resolveEntryPaths,
48
+ resolveConfig,
49
49
  };
@@ -1,7 +1,6 @@
1
- import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '../../types/config.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
2
2
  import type { PlaywrightTestConfig } from './types.js';
3
3
  export declare const entry: string[];
4
- export declare const resolveEntryPaths: ResolveEntryPaths<PlaywrightTestConfig>;
5
4
  export declare const resolveConfig: ResolveConfig<PlaywrightTestConfig>;
6
5
  declare const _default: {
7
6
  title: string;
@@ -10,7 +9,6 @@ declare const _default: {
10
9
  config: string[];
11
10
  entry: string[];
12
11
  resolveConfig: ResolveConfig<PlaywrightTestConfig>;
13
- resolveEntryPaths: ResolveEntryPaths<PlaywrightTestConfig>;
14
12
  args: {
15
13
  binaries: string[];
16
14
  positional: boolean;
@@ -13,19 +13,18 @@ const toEntryPatterns = (testMatch, cwd, configDir, localConfig, rootConfig) =>
13
13
  return patterns.map(pattern => toEntry(join(dir, pattern)));
14
14
  };
15
15
  const builtinReporters = ['dot', 'line', 'list', 'junit', 'html', 'blob', 'json', 'github'];
16
- export const resolveEntryPaths = async (localConfig, options) => {
16
+ export const resolveConfig = async (localConfig, options) => {
17
17
  const { cwd, configFileDir } = options;
18
18
  const projects = localConfig.projects ? [localConfig, ...localConfig.projects] : [localConfig];
19
- return projects.flatMap(config => toEntryPatterns(config.testMatch ?? entry, cwd, configFileDir, config, localConfig));
20
- };
21
- export const resolveConfig = async (config) => {
22
- const reporters = [config.reporter].flat().flatMap(reporter => {
19
+ const reporters = [localConfig.reporter].flat().flatMap(reporter => {
23
20
  const name = typeof reporter === 'string' ? reporter : reporter?.[0];
24
21
  if (!name || builtinReporters.includes(name))
25
22
  return [];
26
23
  return [name];
27
24
  });
28
- return [...reporters].map(toDeferResolve);
25
+ return projects
26
+ .flatMap(config => toEntryPatterns(config.testMatch ?? entry, cwd, configFileDir, config, localConfig))
27
+ .concat(reporters.map(toDeferResolve));
29
28
  };
30
29
  const args = {
31
30
  binaries: ['playwright'],
@@ -40,6 +39,5 @@ export default {
40
39
  config,
41
40
  entry,
42
41
  resolveConfig,
43
- resolveEntryPaths,
44
42
  args,
45
43
  };
@@ -5,7 +5,6 @@ declare const _default: {
5
5
  isEnabled: IsPluginEnabled;
6
6
  config: string[];
7
7
  entry: string[];
8
- resolveEntryPaths: import("../../types/config.js").ResolveEntryPaths<import("../playwright/types.js").PlaywrightTestConfig>;
9
8
  resolveConfig: import("../../types/config.js").ResolveConfig<import("../playwright/types.js").PlaywrightTestConfig>;
10
9
  };
11
10
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import { hasDependency } from '../../util/plugin.js';
2
- import { entry, resolveConfig, resolveEntryPaths } from '../playwright/index.js';
2
+ import { entry, resolveConfig } from '../playwright/index.js';
3
3
  const title = 'Playwright for components';
4
4
  const enablers = [/^@playwright\/experimental-ct-/];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -10,6 +10,5 @@ export default {
10
10
  isEnabled,
11
11
  config,
12
12
  entry,
13
- resolveEntryPaths,
14
13
  resolveConfig,
15
14
  };
@@ -20,7 +20,9 @@ const resolveConfig = config => {
20
20
  })
21
21
  : [];
22
22
  const inputs = plugins.map(toDeferResolve);
23
- return plugins.includes('tailwindcss') ? [...inputs, toDependency('postcss')] : inputs;
23
+ return ['tailwindcss', '@tailwindcss/postcss'].some(tailwindPlugin => plugins.includes(tailwindPlugin))
24
+ ? [...inputs, toDependency('postcss')]
25
+ : inputs;
24
26
  };
25
27
  export default {
26
28
  title,
@@ -5,6 +5,6 @@ declare const _default: {
5
5
  enablers: string[];
6
6
  isEnabled: IsPluginEnabled;
7
7
  config: string[];
8
- resolveEntryPaths: ResolveConfig<PreconstructConfig>;
8
+ resolveConfig: ResolveConfig<PreconstructConfig>;
9
9
  };
10
10
  export default _default;
@@ -4,7 +4,7 @@ const title = 'Preconstruct';
4
4
  const enablers = ['@preconstruct/cli'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  const config = ['package.json'];
7
- const resolveEntryPaths = async (config) => {
7
+ const resolveConfig = async (config) => {
8
8
  return (config.entrypoints ?? []).map(id => toProductionEntry(id, { allowIncludeExports: true }));
9
9
  };
10
10
  export default {
@@ -12,5 +12,5 @@ export default {
12
12
  enablers,
13
13
  isEnabled,
14
14
  config,
15
- resolveEntryPaths,
15
+ resolveConfig,
16
16
  };
@@ -1,4 +1,4 @@
1
- import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '../../types/config.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
2
2
  import type { ReactCosmosConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -7,6 +7,5 @@ declare const _default: {
7
7
  config: string[];
8
8
  entry: string[];
9
9
  resolveConfig: ResolveConfig<ReactCosmosConfig>;
10
- resolveEntryPaths: ResolveEntryPaths<ReactCosmosConfig>;
11
10
  };
12
11
  export default _default;
@@ -9,17 +9,16 @@ const ext = '{js,jsx,ts,tsx,md,mdx}';
9
9
  const fixtureEntry = [`**/*.fixture.${ext}`, `__fixtures__/**/*.${ext}`, `**/fixture.${ext}`];
10
10
  const decoratorEntry = ['**/cosmos.decorator.{jsx,tsx}'];
11
11
  const entry = [...fixtureEntry, ...decoratorEntry];
12
- const resolveEntryPaths = async (localConfig) => {
12
+ const resolveConfig = async (localConfig) => {
13
13
  const { fixturesDir, fixtureFileSuffix } = localConfig;
14
14
  const entries = [
15
15
  join(fixturesDir ?? '__fixtures__', `**/*.${ext}`),
16
16
  join(fixturesDir ?? '', `**/*.${fixtureFileSuffix ?? 'fixture'}.${ext}`),
17
17
  join(fixturesDir ?? '', `**/${fixtureFileSuffix ?? 'fixture'}.${ext}`),
18
18
  ];
19
- return [...entries, ...decoratorEntry].map(id => toEntry(id));
20
- };
21
- const resolveConfig = async (localConfig) => {
22
- return (localConfig?.plugins ?? []).map(toDeferResolve);
19
+ return [...entries, ...decoratorEntry]
20
+ .map(id => toEntry(id))
21
+ .concat((localConfig?.plugins ?? []).map(toDeferResolve));
23
22
  };
24
23
  export default {
25
24
  title,
@@ -28,5 +27,4 @@ export default {
28
27
  config,
29
28
  entry,
30
29
  resolveConfig,
31
- resolveEntryPaths,
32
30
  };
@@ -1,10 +1,10 @@
1
- import type { IsPluginEnabled, ResolveEntryPaths } from '../../types/config.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
2
2
  import type { PluginConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
5
5
  enablers: string[];
6
6
  isEnabled: IsPluginEnabled;
7
7
  config: string[];
8
- resolveEntryPaths: ResolveEntryPaths<PluginConfig>;
8
+ resolveConfig: ResolveConfig<PluginConfig>;
9
9
  };
10
10
  export default _default;
@@ -7,7 +7,7 @@ const title = 'React Router';
7
7
  const enablers = ['@react-router/dev'];
8
8
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
9
9
  const config = ['react-router.config.{js,ts}', ...vite.config];
10
- const resolveEntryPaths = async (localConfig, options) => {
10
+ const resolveConfig = async (localConfig, options) => {
11
11
  const { configFileDir } = options;
12
12
  const appDirectory = localConfig.appDirectory ?? 'app';
13
13
  const appDir = join(configFileDir, appDirectory);
@@ -39,5 +39,5 @@ export default {
39
39
  enablers,
40
40
  isEnabled,
41
41
  config,
42
- resolveEntryPaths,
42
+ resolveConfig,
43
43
  };
@@ -1,11 +1,11 @@
1
- import type { IsPluginEnabled, ResolveEntryPaths } from '../../types/config.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
2
2
  import type { RelayConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
5
5
  enablers: string[];
6
6
  isEnabled: IsPluginEnabled;
7
7
  config: string[];
8
- resolveEntryPaths: ResolveEntryPaths<RelayConfig>;
8
+ resolveConfig: ResolveConfig<RelayConfig>;
9
9
  args: {
10
10
  binaries: string[];
11
11
  args: (args: string[]) => string[];
@@ -6,7 +6,7 @@ const title = 'Relay';
6
6
  const enablers = ['vite-plugin-relay', '@swc/plugin-relay', 'babel-plugin-relay'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
8
  const config = ['relay.config.json', 'relay.config.js'];
9
- const resolveEntryPaths = async (config) => {
9
+ const resolveConfig = async (config) => {
10
10
  const projects = 'projects' in config ? Object.values(config.projects) : [config];
11
11
  return projects.map(project => {
12
12
  const artifactDirectory = project.artifactDirectory;
@@ -26,6 +26,6 @@ export default {
26
26
  enablers,
27
27
  isEnabled,
28
28
  config,
29
- resolveEntryPaths,
29
+ resolveConfig,
30
30
  args,
31
31
  };
@@ -5,9 +5,8 @@ const enablers = ['@rspack/core'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  const config = ['rspack.config*.{js,ts,mjs,cjs}'];
7
7
  const resolveConfig = async (localConfig, options) => {
8
- const { cwd } = options;
9
- const inputs = await findWebpackDependenciesFromConfig({ config: localConfig, cwd });
10
- return Array.from(inputs).filter(input => !input.specifier.startsWith('builtin:'));
8
+ const inputs = await findWebpackDependenciesFromConfig(localConfig, options);
9
+ return inputs.filter(input => !input.specifier.startsWith('builtin:'));
11
10
  };
12
11
  export default {
13
12
  title,
@@ -1,8 +1,9 @@
1
- import type { IsPluginEnabled } from '../../types/config.js';
1
+ import type { IsPluginEnabled, Resolve } from '../../types/config.js';
2
2
  declare const _default: {
3
3
  title: string;
4
4
  enablers: string[];
5
5
  isEnabled: IsPluginEnabled;
6
6
  config: string[];
7
+ resolve: Resolve;
7
8
  };
8
9
  export default _default;
@@ -1,3 +1,4 @@
1
+ import { toDependency } from '../../util/input.js';
1
2
  import { toLilconfig } from '../../util/plugin-config.js';
2
3
  import { hasDependency } from '../../util/plugin.js';
3
4
  const title = 'size-limit';
@@ -7,9 +8,18 @@ const config = [
7
8
  'package.json',
8
9
  ...toLilconfig('size-limit', { configDir: false, additionalExtensions: ['ts', 'mts', 'cts'], rcSuffix: '' }),
9
10
  ];
11
+ const resolve = options => {
12
+ const allDeps = [
13
+ ...Object.keys(options.manifest.dependencies || {}),
14
+ ...Object.keys(options.manifest.devDependencies || {}),
15
+ ];
16
+ const sizeLimitDeps = allDeps.filter(dep => dep.startsWith('@size-limit/'));
17
+ return sizeLimitDeps.map(dep => toDependency(dep));
18
+ };
10
19
  export default {
11
20
  title,
12
21
  enablers,
13
22
  isEnabled,
14
23
  config,
24
+ resolve,
15
25
  };
@@ -1,4 +1,4 @@
1
- import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '../../types/config.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
2
2
  import type { StorybookConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -7,7 +7,6 @@ declare const _default: {
7
7
  config: string[];
8
8
  entry: string[];
9
9
  project: string[];
10
- resolveEntryPaths: ResolveEntryPaths<StorybookConfig>;
11
10
  resolveConfig: ResolveConfig<StorybookConfig>;
12
11
  };
13
12
  export default _default;
@@ -9,7 +9,7 @@ const stories = ['**/*.@(mdx|stories.@(mdx|js|jsx|mjs|ts|tsx))'];
9
9
  const restEntry = ['.storybook/{manager,preview}.{js,jsx,ts,tsx}'];
10
10
  const entry = [...restEntry, ...stories];
11
11
  const project = ['.storybook/**/*.{js,jsx,ts,tsx,mts}'];
12
- const resolveEntryPaths = async (localConfig, options) => {
12
+ const resolveConfig = async (localConfig, options) => {
13
13
  const { cwd, configFileDir } = options;
14
14
  const strs = typeof localConfig?.stories === 'function' ? await localConfig.stories(stories) : localConfig?.stories;
15
15
  const relativePatterns = strs?.map(pattern => {
@@ -21,9 +21,6 @@ const resolveEntryPaths = async (localConfig, options) => {
21
21
  ...(options.config.entry ?? restEntry),
22
22
  ...(relativePatterns && relativePatterns.length > 0 ? relativePatterns : stories),
23
23
  ];
24
- return patterns.map(id => toEntry(id));
25
- };
26
- const resolveConfig = async (localConfig) => {
27
24
  const addons = localConfig.addons?.map(addon => (typeof addon === 'string' ? addon : addon.name)) ?? [];
28
25
  const builder = localConfig?.core?.builder &&
29
26
  (typeof localConfig.core.builder === 'string' ? localConfig.core.builder : localConfig.core.builder.name);
@@ -35,6 +32,7 @@ const resolveConfig = async (localConfig) => {
35
32
  const framework = typeof localConfig.framework === 'string' ? localConfig.framework : localConfig.framework?.name;
36
33
  const frameworks = framework ? [framework] : [];
37
34
  return [
35
+ ...patterns.map(id => toEntry(id)),
38
36
  ...addons.map(toDeferResolve),
39
37
  ...builderPackages.map(id => toDependency(id)),
40
38
  ...frameworks.map(id => toDependency(id)),
@@ -47,6 +45,5 @@ export default {
47
45
  config,
48
46
  entry,
49
47
  project,
50
- resolveEntryPaths,
51
48
  resolveConfig,
52
49
  };
@@ -1,9 +1,10 @@
1
- import type { IsPluginEnabled } from '../../types/config.js';
1
+ import type { IsPluginEnabled, Resolve } from '../../types/config.js';
2
2
  declare const _default: {
3
3
  title: string;
4
4
  enablers: string[];
5
5
  isEnabled: IsPluginEnabled;
6
6
  entry: string[];
7
7
  production: string[];
8
+ resolve: Resolve;
8
9
  };
9
10
  export default _default;
@@ -1,3 +1,5 @@
1
+ import { toAlias } from '../../util/input.js';
2
+ import { join } from '../../util/path.js';
1
3
  import { hasDependency } from '../../util/plugin.js';
2
4
  import { config as viteConfig } from '../vite/index.js';
3
5
  const title = 'Svelte';
@@ -9,10 +11,15 @@ const production = [
9
11
  'src/hooks.{server,client}.{js,ts}',
10
12
  'src/params/*.{js,ts}',
11
13
  ];
14
+ const resolve = options => {
15
+ const alias = toAlias('$app/*', [join(options.cwd, 'node_modules/@sveltejs/kit/src/runtime/app/*')]);
16
+ return [alias];
17
+ };
12
18
  export default {
13
19
  title,
14
20
  enablers,
15
21
  isEnabled,
16
22
  entry,
17
23
  production,
24
+ resolve,
18
25
  };
@@ -5,7 +5,6 @@ declare const _default: {
5
5
  enablers: string[];
6
6
  isEnabled: IsPluginEnabled;
7
7
  config: string[];
8
- resolveEntryPaths: import("../../types/config.js").ResolveEntryPaths<import("../vitest/types.js").ViteConfigOrFn | import("../vitest/types.js").VitestWorkspaceConfig>;
9
8
  resolveConfig: import("../../types/config.js").ResolveConfig<import("../vitest/types.js").ViteConfigOrFn | import("../vitest/types.js").VitestWorkspaceConfig>;
10
9
  };
11
10
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import { hasDependency } from '../../util/plugin.js';
2
- import { resolveConfig, resolveEntryPaths } from '../vitest/index.js';
2
+ import { resolveConfig } from '../vitest/index.js';
3
3
  const title = 'Vite';
4
4
  const enablers = ['vite', 'vitest'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -9,6 +9,5 @@ export default {
9
9
  enablers,
10
10
  isEnabled,
11
11
  config,
12
- resolveEntryPaths,
13
12
  resolveConfig,
14
13
  };
@@ -1,6 +1,5 @@
1
- import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '../../types/config.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
2
2
  import type { ViteConfigOrFn, VitestWorkspaceConfig } from './types.js';
3
- export declare const resolveEntryPaths: ResolveEntryPaths<ViteConfigOrFn | VitestWorkspaceConfig>;
4
3
  export declare const resolveConfig: ResolveConfig<ViteConfigOrFn | VitestWorkspaceConfig>;
5
4
  declare const _default: {
6
5
  title: string;
@@ -8,7 +7,6 @@ declare const _default: {
8
7
  isEnabled: IsPluginEnabled;
9
8
  config: string[];
10
9
  entry: string[];
11
- resolveEntryPaths: ResolveEntryPaths<ViteConfigOrFn | VitestWorkspaceConfig>;
12
10
  resolveConfig: ResolveConfig<ViteConfigOrFn | VitestWorkspaceConfig>;
13
11
  args: {
14
12
  config: boolean;
@@ -1,5 +1,5 @@
1
- import { toDeferResolve, toDependency, toEntry } from '../../util/input.js';
2
- import { join } from '../../util/path.js';
1
+ import { toAlias, toDeferResolve, toDependency, toEntry } from '../../util/input.js';
2
+ import { join, toPosix } from '../../util/path.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
4
  import { getEnvPackageName, getExternalReporters } from './helpers.js';
5
5
  const title = 'Vitest';
@@ -14,7 +14,7 @@ const hasScriptWithCoverage = (scripts) => scripts
14
14
  })
15
15
  : false;
16
16
  const findConfigDependencies = (localConfig, options) => {
17
- const { manifest, configFileDir } = options;
17
+ const { manifest, cwd: dir } = options;
18
18
  const testConfig = localConfig.test;
19
19
  if (!testConfig)
20
20
  return [];
@@ -22,7 +22,6 @@ const findConfigDependencies = (localConfig, options) => {
22
22
  const reporters = getExternalReporters(testConfig.reporters);
23
23
  const hasCoverageEnabled = (testConfig.coverage && testConfig.coverage.enabled !== false) || hasScriptWithCoverage(manifest.scripts);
24
24
  const coverage = hasCoverageEnabled ? [`@vitest/coverage-${testConfig.coverage?.provider ?? 'v8'}`] : [];
25
- const dir = join(configFileDir, testConfig.root ?? '.');
26
25
  const setupFiles = [testConfig.setupFiles ?? []].flat().map(specifier => ({ ...toDeferResolve(specifier), dir }));
27
26
  const globalSetup = [testConfig.globalSetup ?? []].flat().map(specifier => ({ ...toDeferResolve(specifier), dir }));
28
27
  const workspaceDependencies = [];
@@ -57,32 +56,48 @@ const getConfigs = async (localConfig) => {
57
56
  }
58
57
  return configs;
59
58
  };
60
- export const resolveEntryPaths = async (localConfig, options) => {
59
+ export const resolveConfig = async (localConfig, options) => {
61
60
  const inputs = new Set();
62
61
  inputs.add(toEntry(join(options.cwd, 'src/vite-env.d.ts')));
63
62
  const configs = await getConfigs(localConfig);
64
- for (const cfg of configs) {
65
- const dir = join(options.configFileDir, cfg.test?.root ?? '.');
66
- if (cfg.test?.include) {
67
- for (const dependency of cfg.test.include)
68
- dependency[0] !== '!' && inputs.add(toEntry(join(dir, dependency)));
63
+ const addStar = (value) => (value.endsWith('*') ? value : join(value, '*').replace(/\/\*\*$/, '/*'));
64
+ const addAliases = (aliasOptions) => {
65
+ for (const [alias, value] of Object.entries(aliasOptions)) {
66
+ if (!value)
67
+ continue;
68
+ const prefixes = [value]
69
+ .flat()
70
+ .filter(value => typeof value === 'string')
71
+ .map(prefix => {
72
+ if (toPosix(prefix).startsWith(options.cwd))
73
+ return prefix;
74
+ return join(options.cwd, prefix);
75
+ });
76
+ if (alias.length > 1)
77
+ inputs.add(toAlias(alias, prefixes));
78
+ inputs.add(toAlias(addStar(alias), prefixes.map(addStar)));
69
79
  }
70
- else {
71
- for (const dependency of options.config.entry ?? entry)
72
- inputs.add(toEntry(join(dir, dependency)));
73
- }
74
- }
75
- return Array.from(inputs);
76
- };
77
- export const resolveConfig = async (localConfig, options) => {
78
- const inputs = new Set();
79
- const configs = await getConfigs(localConfig);
80
+ };
80
81
  for (const cfg of configs) {
82
+ const dir = join(options.cwd, cfg.test?.root ?? '.');
83
+ if (cfg.test) {
84
+ if (cfg.test?.include) {
85
+ for (const dependency of cfg.test.include)
86
+ dependency[0] !== '!' && inputs.add(toEntry(join(dir, dependency)));
87
+ }
88
+ else {
89
+ for (const dependency of options.config.entry ?? entry)
90
+ inputs.add(toEntry(join(dir, dependency)));
91
+ }
92
+ if (cfg.test.alias)
93
+ addAliases(cfg.test.alias);
94
+ }
95
+ if (cfg.resolve?.alias)
96
+ addAliases(cfg.resolve.alias);
81
97
  for (const dependency of findConfigDependencies(cfg, options))
82
98
  inputs.add(dependency);
83
- const entry = cfg.build?.lib?.entry ?? [];
84
- const dir = join(options.configFileDir, cfg.test?.root ?? '.');
85
- const deps = (typeof entry === 'string' ? [entry] : Object.values(entry))
99
+ const _entry = cfg.build?.lib?.entry ?? [];
100
+ const deps = (typeof _entry === 'string' ? [_entry] : Object.values(_entry))
86
101
  .map(specifier => join(dir, specifier))
87
102
  .map(id => toEntry(id));
88
103
  for (const dependency of deps)
@@ -99,7 +114,6 @@ export default {
99
114
  isEnabled,
100
115
  config,
101
116
  entry,
102
- resolveEntryPaths,
103
117
  resolveConfig,
104
118
  args,
105
119
  };
@@ -1,3 +1,11 @@
1
+ interface Alias {
2
+ find: string | RegExp;
3
+ replacement: string;
4
+ customResolver?: any;
5
+ }
6
+ export type AliasOptions = readonly Alias[] | {
7
+ [find: string]: string;
8
+ };
1
9
  interface VitestConfig {
2
10
  test: {
3
11
  include: string[];
@@ -15,6 +23,7 @@ interface VitestConfig {
15
23
  workspace: never;
16
24
  };
17
25
  })[];
26
+ alias?: AliasOptions;
18
27
  };
19
28
  }
20
29
  export interface ViteConfig extends VitestConfig {
@@ -26,6 +35,9 @@ export interface ViteConfig extends VitestConfig {
26
35
  };
27
36
  };
28
37
  };
38
+ resolve?: {
39
+ alias?: AliasOptions;
40
+ };
29
41
  }
30
42
  export type COMMAND = 'dev' | 'serve' | 'build';
31
43
  export type MODE = 'development' | 'production';
@@ -6,7 +6,7 @@ const enablers = ['vue'];
6
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
7
  const config = ['vue.config.{js,ts}'];
8
8
  const resolveConfig = async (config, options) => {
9
- const { cwd, manifest } = options;
9
+ const { manifest } = options;
10
10
  const inputs = [];
11
11
  if (config.configureWebpack) {
12
12
  const baseConfig = {
@@ -17,10 +17,7 @@ const resolveConfig = async (config, options) => {
17
17
  module: { rules: [] },
18
18
  };
19
19
  const modifiedConfig = typeof config.configureWebpack === 'function' ? config.configureWebpack(baseConfig) : config.configureWebpack;
20
- const inputsFromConfig = await findWebpackDependenciesFromConfig({
21
- config: modifiedConfig ?? baseConfig,
22
- cwd,
23
- });
20
+ const inputsFromConfig = await findWebpackDependenciesFromConfig(modifiedConfig ?? baseConfig, options);
24
21
  for (const input of inputsFromConfig)
25
22
  inputs.push(input);
26
23
  }
@@ -1,10 +1,6 @@
1
1
  import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
2
- import { type Input } from '../../util/input.js';
3
2
  import type { WebpackConfig } from './types.js';
4
- export declare const findWebpackDependenciesFromConfig: ({ config, cwd }: {
5
- config: WebpackConfig;
6
- cwd: string;
7
- }) => Promise<Set<Input>>;
3
+ export declare const findWebpackDependenciesFromConfig: ResolveConfig<WebpackConfig>;
8
4
  declare const _default: {
9
5
  title: string;
10
6
  enablers: string[];