knip 5.1.2 → 5.1.3

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 (179) hide show
  1. package/dist/ConfigurationChief.d.ts +3 -3
  2. package/dist/ConfigurationValidator.d.ts +21 -21
  3. package/dist/ProjectPrincipal.d.ts +1 -1
  4. package/dist/ProjectPrincipal.js +3 -5
  5. package/dist/WorkspaceWorker.d.ts +2 -2
  6. package/dist/WorkspaceWorker.js +61 -44
  7. package/dist/binaries/index.js +2 -2
  8. package/dist/binaries/resolvers/index.d.ts +12 -12
  9. package/dist/compilers/index.d.ts +6 -7
  10. package/dist/compilers/index.js +0 -3
  11. package/dist/constants.d.ts +1 -2
  12. package/dist/constants.js +8 -4
  13. package/dist/plugins/_template/index.d.ts +10 -9
  14. package/dist/plugins/_template/index.js +16 -30
  15. package/dist/plugins/angular/index.d.ts +8 -6
  16. package/dist/plugins/angular/index.js +17 -22
  17. package/dist/plugins/astro/index.d.ts +7 -7
  18. package/dist/plugins/astro/index.js +14 -17
  19. package/dist/plugins/ava/index.d.ts +9 -7
  20. package/dist/plugins/ava/index.js +19 -21
  21. package/dist/plugins/babel/helpers.js +1 -1
  22. package/dist/plugins/babel/index.d.ts +7 -7
  23. package/dist/plugins/babel/index.js +15 -26
  24. package/dist/plugins/capacitor/index.d.ts +7 -6
  25. package/dist/plugins/capacitor/index.js +11 -18
  26. package/dist/plugins/changesets/index.d.ts +7 -6
  27. package/dist/plugins/changesets/index.js +14 -21
  28. package/dist/plugins/changesets/types.d.ts +3 -0
  29. package/dist/plugins/changesets/types.js +1 -0
  30. package/dist/plugins/commitizen/index.d.ts +8 -7
  31. package/dist/plugins/commitizen/index.js +13 -21
  32. package/dist/plugins/commitlint/index.d.ts +9 -6
  33. package/dist/plugins/commitlint/index.js +11 -19
  34. package/dist/plugins/cspell/index.d.ts +7 -6
  35. package/dist/plugins/cspell/index.js +12 -20
  36. package/dist/plugins/cypress/index.d.ts +7 -7
  37. package/dist/plugins/cypress/index.js +13 -21
  38. package/dist/plugins/drizzle/index.d.ts +7 -6
  39. package/dist/plugins/drizzle/index.js +13 -16
  40. package/dist/plugins/eleventy/index.d.ts +11 -9
  41. package/dist/plugins/eleventy/index.js +35 -41
  42. package/dist/plugins/eslint/helpers.d.ts +3 -5
  43. package/dist/plugins/eslint/helpers.js +10 -15
  44. package/dist/plugins/eslint/index.d.ts +10 -8
  45. package/dist/plugins/eslint/index.js +15 -29
  46. package/dist/plugins/gatsby/index.d.ts +8 -7
  47. package/dist/plugins/gatsby/index.js +15 -22
  48. package/dist/plugins/github-actions/index.d.ts +6 -6
  49. package/dist/plugins/github-actions/index.js +15 -25
  50. package/dist/plugins/graphql-codegen/index.d.ts +8 -7
  51. package/dist/plugins/graphql-codegen/index.js +15 -23
  52. package/dist/plugins/husky/index.d.ts +6 -6
  53. package/dist/plugins/husky/index.js +10 -16
  54. package/dist/plugins/jest/index.d.ts +9 -7
  55. package/dist/plugins/jest/index.js +50 -31
  56. package/dist/plugins/lefthook/index.d.ts +6 -6
  57. package/dist/plugins/lefthook/index.js +19 -24
  58. package/dist/plugins/lint-staged/index.d.ts +8 -7
  59. package/dist/plugins/lint-staged/index.js +16 -23
  60. package/dist/plugins/linthtml/index.d.ts +8 -7
  61. package/dist/plugins/linthtml/index.js +16 -24
  62. package/dist/plugins/markdownlint/index.d.ts +7 -6
  63. package/dist/plugins/markdownlint/index.js +12 -17
  64. package/dist/plugins/mocha/index.d.ts +9 -7
  65. package/dist/plugins/mocha/index.js +19 -22
  66. package/dist/plugins/msw/index.d.ts +8 -7
  67. package/dist/plugins/msw/index.js +12 -15
  68. package/dist/plugins/netlify/index.d.ts +9 -7
  69. package/dist/plugins/netlify/index.js +23 -27
  70. package/dist/plugins/next/index.d.ts +6 -7
  71. package/dist/plugins/next/index.js +10 -18
  72. package/dist/plugins/node-test-runner/index.d.ts +5 -6
  73. package/dist/plugins/node-test-runner/index.js +6 -18
  74. package/dist/plugins/npm-package-json-lint/index.d.ts +8 -7
  75. package/dist/plugins/npm-package-json-lint/index.js +12 -19
  76. package/dist/plugins/nx/index.d.ts +7 -6
  77. package/dist/plugins/nx/index.js +18 -27
  78. package/dist/plugins/nyc/index.d.ts +7 -6
  79. package/dist/plugins/nyc/index.js +11 -17
  80. package/dist/plugins/playwright/index.d.ts +11 -13
  81. package/dist/plugins/playwright/index.js +23 -30
  82. package/dist/plugins/playwright-ct/index.d.ts +8 -7
  83. package/dist/plugins/playwright-ct/index.js +12 -24
  84. package/dist/plugins/postcss/index.d.ts +7 -6
  85. package/dist/plugins/postcss/index.js +12 -21
  86. package/dist/plugins/prettier/index.d.ts +7 -6
  87. package/dist/plugins/prettier/index.js +14 -20
  88. package/dist/plugins/release-it/index.d.ts +8 -7
  89. package/dist/plugins/release-it/index.js +18 -27
  90. package/dist/plugins/remark/index.d.ts +8 -7
  91. package/dist/plugins/remark/index.js +13 -28
  92. package/dist/plugins/remix/index.d.ts +6 -7
  93. package/dist/plugins/remix/index.js +10 -20
  94. package/dist/plugins/rollup/index.d.ts +5 -6
  95. package/dist/plugins/rollup/index.js +8 -16
  96. package/dist/plugins/semantic-release/index.d.ts +8 -7
  97. package/dist/plugins/semantic-release/index.js +13 -25
  98. package/dist/plugins/sentry/index.d.ts +5 -6
  99. package/dist/plugins/sentry/index.js +8 -16
  100. package/dist/plugins/storybook/index.d.ts +10 -8
  101. package/dist/plugins/storybook/index.js +28 -35
  102. package/dist/plugins/stryker/index.d.ts +7 -6
  103. package/dist/plugins/stryker/index.js +10 -18
  104. package/dist/plugins/stylelint/index.d.ts +7 -6
  105. package/dist/plugins/stylelint/index.js +13 -23
  106. package/dist/plugins/svelte/index.d.ts +7 -8
  107. package/dist/plugins/svelte/index.js +13 -23
  108. package/dist/plugins/tailwind/index.d.ts +5 -6
  109. package/dist/plugins/tailwind/index.js +8 -14
  110. package/dist/plugins/tsup/index.d.ts +7 -6
  111. package/dist/plugins/tsup/index.js +14 -21
  112. package/dist/plugins/typedoc/index.d.ts +10 -7
  113. package/dist/plugins/typedoc/index.js +14 -24
  114. package/dist/plugins/typescript/index.d.ts +8 -7
  115. package/dist/plugins/typescript/index.js +31 -25
  116. package/dist/plugins/unbuild/index.d.ts +7 -6
  117. package/dist/plugins/unbuild/index.js +12 -17
  118. package/dist/plugins/vercel-og/index.d.ts +5 -6
  119. package/dist/plugins/vercel-og/index.js +8 -16
  120. package/dist/plugins/vite/index.d.ts +9 -7
  121. package/dist/plugins/vite/index.js +13 -18
  122. package/dist/plugins/vitest/index.d.ts +11 -9
  123. package/dist/plugins/vitest/index.js +62 -49
  124. package/dist/plugins/vue/index.d.ts +7 -6
  125. package/dist/plugins/vue/index.js +14 -26
  126. package/dist/plugins/webpack/index.d.ts +7 -6
  127. package/dist/plugins/webpack/index.js +17 -20
  128. package/dist/plugins/wireit/index.d.ts +8 -7
  129. package/dist/plugins/wireit/index.js +12 -20
  130. package/dist/plugins/yorkie/index.d.ts +8 -7
  131. package/dist/plugins/yorkie/index.js +13 -21
  132. package/dist/plugins.d.ts +3 -0
  133. package/dist/plugins.js +14 -0
  134. package/dist/reporters/index.d.ts +5 -5
  135. package/dist/types/config.d.ts +1 -1
  136. package/dist/types/package-json.d.ts +12 -13
  137. package/dist/types/plugins.d.ts +20 -14
  138. package/dist/types/util.d.ts +0 -13
  139. package/dist/typescript/SourceFileManager.js +3 -0
  140. package/dist/typescript/createHosts.js +4 -3
  141. package/dist/typescript/resolveModuleNames.js +26 -41
  142. package/dist/typescript/visitors/dynamic-imports/importCall.d.ts +1 -1
  143. package/dist/typescript/visitors/dynamic-imports/importType.d.ts +1 -1
  144. package/dist/typescript/visitors/dynamic-imports/index.d.ts +1 -1
  145. package/dist/typescript/visitors/dynamic-imports/jsDocType.d.ts +1 -1
  146. package/dist/typescript/visitors/dynamic-imports/propertyAccessCall.d.ts +1 -1
  147. package/dist/typescript/visitors/dynamic-imports/requireCall.d.ts +1 -1
  148. package/dist/typescript/visitors/exports/exportAssignment.d.ts +1 -1
  149. package/dist/typescript/visitors/exports/exportDeclaration.d.ts +1 -1
  150. package/dist/typescript/visitors/exports/exportKeyword.d.ts +1 -1
  151. package/dist/typescript/visitors/exports/index.d.ts +1 -1
  152. package/dist/typescript/visitors/exports/moduleExportsAccessExpression.d.ts +1 -1
  153. package/dist/typescript/visitors/imports/importDeclaration.d.ts +1 -1
  154. package/dist/typescript/visitors/imports/importEqualsDeclaration.d.ts +1 -1
  155. package/dist/typescript/visitors/imports/index.d.ts +1 -1
  156. package/dist/typescript/visitors/imports/reExportDeclaration.d.ts +1 -1
  157. package/dist/typescript/visitors/scripts/bun.d.ts +1 -1
  158. package/dist/typescript/visitors/scripts/execa.d.ts +1 -1
  159. package/dist/typescript/visitors/scripts/index.d.ts +1 -1
  160. package/dist/typescript/visitors/scripts/zx.d.ts +1 -1
  161. package/dist/util/Performance.d.ts +1 -4
  162. package/dist/util/Performance.js +5 -1
  163. package/dist/util/fs.js +0 -3
  164. package/dist/util/loader.d.ts +0 -2
  165. package/dist/util/loader.js +8 -16
  166. package/dist/util/object.d.ts +1 -1
  167. package/dist/util/path.d.ts +0 -3
  168. package/dist/util/path.js +0 -1
  169. package/dist/util/plugin.d.ts +4 -1
  170. package/dist/util/plugin.js +28 -1
  171. package/dist/util/require.d.ts +1 -0
  172. package/dist/util/require.js +13 -0
  173. package/dist/util/tsconfig-loader.js +1 -2
  174. package/dist/util/type.d.ts +1 -1
  175. package/dist/version.d.ts +1 -1
  176. package/dist/version.js +1 -1
  177. package/package.json +5 -1
  178. package/dist/plugins/eslint/fallback.d.ts +0 -1
  179. package/dist/plugins/eslint/fallback.js +0 -18
@@ -1,22 +1,13 @@
1
- import { timerify } from '../../util/Performance.js';
2
- import { hasDependency, load } from '../../util/plugin.js';
3
- import { toEntryPattern, toProductionEntryPattern } from '../../util/protocols.js';
1
+ import { hasDependency } from '#p/util/plugin.js';
4
2
  import { findWebpackDependenciesFromConfig } from '../webpack/index.js';
5
- const NAME = 'Vue';
6
- const ENABLERS = ['vue'];
7
- const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
- const CONFIG_FILE_PATTERNS = ['vue.config.{js,ts}'];
9
- const ENTRY_FILE_PATTERNS = [];
10
- const PRODUCTION_ENTRY_FILE_PATTERNS = [];
11
- const findPluginDependencies = async (configFilePath, options) => {
12
- const { config, isProduction, cwd, manifest } = options;
13
- const localConfig = await load(configFilePath);
14
- const deps = config.entry
15
- ? config.entry.map(toProductionEntryPattern)
16
- : [...ENTRY_FILE_PATTERNS.map(toEntryPattern), ...PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern)];
17
- if (isProduction || !localConfig)
18
- return deps;
19
- if (localConfig.configureWebpack) {
3
+ const title = 'Vue';
4
+ const enablers = ['vue'];
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
+ const config = ['vue.config.{js,ts}'];
7
+ const resolveConfig = async (config, options) => {
8
+ const { cwd, isProduction, manifest } = options;
9
+ const deps = [];
10
+ if (config.configureWebpack) {
20
11
  const baseConfig = {
21
12
  mode: 'development',
22
13
  entry: {},
@@ -24,9 +15,7 @@ const findPluginDependencies = async (configFilePath, options) => {
24
15
  plugins: [],
25
16
  module: { rules: [] },
26
17
  };
27
- const modifiedConfig = typeof localConfig.configureWebpack === 'function'
28
- ? localConfig.configureWebpack(baseConfig)
29
- : localConfig.configureWebpack;
18
+ const modifiedConfig = typeof config.configureWebpack === 'function' ? config.configureWebpack(baseConfig) : config.configureWebpack;
30
19
  const { dependencies } = await findWebpackDependenciesFromConfig({
31
20
  config: modifiedConfig ?? baseConfig,
32
21
  cwd,
@@ -40,11 +29,10 @@ const findPluginDependencies = async (configFilePath, options) => {
40
29
  }
41
30
  return deps;
42
31
  };
43
- const findDependencies = timerify(findPluginDependencies);
44
32
  export default {
45
- NAME,
46
- ENABLERS,
33
+ title,
34
+ enablers,
47
35
  isEnabled,
48
- CONFIG_FILE_PATTERNS,
49
- findDependencies,
36
+ config,
37
+ resolveConfig,
50
38
  };
@@ -1,5 +1,5 @@
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
1
2
  import type { WebpackConfig } from './types.js';
2
- import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
3
3
  export declare const findWebpackDependenciesFromConfig: ({ config, cwd }: {
4
4
  config: WebpackConfig;
5
5
  cwd: string;
@@ -8,10 +8,11 @@ export declare const findWebpackDependenciesFromConfig: ({ config, cwd }: {
8
8
  entryPatterns: Set<string>;
9
9
  }>;
10
10
  declare const _default: {
11
- NAME: string;
12
- ENABLERS: string[];
13
- isEnabled: IsPluginEnabledCallback;
14
- CONFIG_FILE_PATTERNS: string[];
15
- findDependencies: GenericPluginCallback;
11
+ title: string;
12
+ enablers: string[];
13
+ isEnabled: IsPluginEnabled;
14
+ config: string[];
15
+ production: string[];
16
+ resolveConfig: ResolveConfig<WebpackConfig>;
16
17
  };
17
18
  export default _default;
@@ -1,13 +1,13 @@
1
- import { compact } from '../../util/array.js';
2
- import { isInternal, join, relative } from '../../util/path.js';
3
- import { timerify } from '../../util/Performance.js';
4
- import { hasDependency, load } from '../../util/plugin.js';
5
- import { toEntryPattern, toProductionEntryPattern } from '../../util/protocols.js';
1
+ import { compact } from '#p/util/array.js';
2
+ import { isInternal, join, relative } from '#p/util/path.js';
3
+ import { hasDependency } from '#p/util/plugin.js';
4
+ import { toEntryPattern, toProductionEntryPattern } from '#p/util/protocols.js';
6
5
  import { getDependenciesFromConfig } from '../babel/index.js';
7
- const NAME = 'Webpack';
8
- const ENABLERS = ['webpack', 'webpack-cli'];
9
- const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
10
- const CONFIG_FILE_PATTERNS = ['webpack.config*.{js,ts,mjs,cjs,mts,cts}'];
6
+ const title = 'Webpack';
7
+ const enablers = ['webpack', 'webpack-cli'];
8
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
9
+ const config = ['webpack.config*.{js,ts,mjs,cjs,mts,cts}'];
10
+ const production = [];
11
11
  const hasBabelOptions = (use) => Boolean(use) &&
12
12
  typeof use !== 'string' &&
13
13
  'loader' in use &&
@@ -87,12 +87,9 @@ export const findWebpackDependenciesFromConfig = async ({ config, cwd }) => {
87
87
  }
88
88
  return { dependencies, entryPatterns };
89
89
  };
90
- const findWebpackDependencies = async (configFilePath, options) => {
91
- const { manifest, isProduction, cwd } = options;
92
- const localConfig = await load(configFilePath);
93
- if (!localConfig)
94
- return [];
95
- const { dependencies, entryPatterns } = await findWebpackDependenciesFromConfig({ config: localConfig, cwd });
90
+ const resolveConfig = async (localConfig, options) => {
91
+ const { cwd, isProduction, manifest } = options;
92
+ const { entryPatterns, dependencies } = await findWebpackDependenciesFromConfig({ config: localConfig, cwd });
96
93
  if (isProduction)
97
94
  return [...entryPatterns];
98
95
  const scripts = Object.values(manifest.scripts ?? {});
@@ -100,11 +97,11 @@ const findWebpackDependencies = async (configFilePath, options) => {
100
97
  const webpackDevServer = scripts.some(script => script?.includes('webpack serve')) ? ['webpack-dev-server'] : [];
101
98
  return compact([...entryPatterns, ...dependencies, ...webpackCLI, ...webpackDevServer]);
102
99
  };
103
- const findDependencies = timerify(findWebpackDependencies);
104
100
  export default {
105
- NAME,
106
- ENABLERS,
101
+ title,
102
+ enablers,
107
103
  isEnabled,
108
- CONFIG_FILE_PATTERNS,
109
- findDependencies,
104
+ config,
105
+ production,
106
+ resolveConfig,
110
107
  };
@@ -1,10 +1,11 @@
1
- import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
1
+ import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
2
+ import type { WireitConfig } from './types.js';
2
3
  declare const _default: {
3
- NAME: string;
4
- ENABLERS: string[];
5
- isEnabled: IsPluginEnabledCallback;
6
- PACKAGE_JSON_PATH: string;
7
- CONFIG_FILE_PATTERNS: string[];
8
- findDependencies: GenericPluginCallback;
4
+ readonly title: "Wireit";
5
+ readonly enablers: string[];
6
+ readonly isEnabled: IsPluginEnabled;
7
+ readonly packageJsonPath: "wireit";
8
+ readonly config: string[];
9
+ readonly resolveConfig: ResolveConfig<WireitConfig>;
9
10
  };
10
11
  export default _default;
@@ -1,27 +1,19 @@
1
- import { timerify } from '../../util/Performance.js';
2
- import { getDependenciesFromScripts, hasDependency } from '../../util/plugin.js';
3
- const NAME = 'Wireit';
4
- const ENABLERS = ['wireit'];
5
- const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
- const PACKAGE_JSON_PATH = 'wireit';
7
- const CONFIG_FILE_PATTERNS = ['package.json'];
8
- const findWireItDependencies = async (_configFilePath, options) => {
9
- const { manifest, isProduction } = options;
10
- if (isProduction)
11
- return [];
12
- const localConfig = manifest[PACKAGE_JSON_PATH];
13
- if (!localConfig)
14
- return [];
1
+ import { getDependenciesFromScripts, hasDependency } from '#p/util/plugin.js';
2
+ const title = 'Wireit';
3
+ const enablers = ['wireit'];
4
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
+ const packageJsonPath = 'wireit';
6
+ const config = ['package.json'];
7
+ const resolveConfig = (localConfig, options) => {
15
8
  const scripts = Object.values(localConfig).flatMap(({ command: script }) => (script ? [script] : []));
16
9
  const scriptDependencies = getDependenciesFromScripts(scripts, options);
17
10
  return scriptDependencies;
18
11
  };
19
- const findDependencies = timerify(findWireItDependencies);
20
12
  export default {
21
- NAME,
22
- ENABLERS,
13
+ title,
14
+ enablers,
23
15
  isEnabled,
24
- PACKAGE_JSON_PATH,
25
- CONFIG_FILE_PATTERNS,
26
- findDependencies,
16
+ packageJsonPath,
17
+ config,
18
+ resolveConfig,
27
19
  };
@@ -1,10 +1,11 @@
1
- import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
1
+ import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
2
+ import type { LintStagedConfig } from '../lint-staged/types.js';
2
3
  declare const _default: {
3
- NAME: string;
4
- ENABLERS: string[];
5
- isEnabled: IsPluginEnabledCallback;
6
- PACKAGE_JSON_PATH: string;
7
- CONFIG_FILE_PATTERNS: string[];
8
- findDependencies: GenericPluginCallback;
4
+ readonly title: "yorkie";
5
+ readonly enablers: string[];
6
+ readonly isEnabled: IsPluginEnabled;
7
+ readonly packageJsonPath: "gitHooks";
8
+ readonly config: string[];
9
+ readonly resolveConfig: ResolveConfig<LintStagedConfig>;
9
10
  };
10
11
  export default _default;
@@ -1,30 +1,22 @@
1
- import { timerify } from '../../util/Performance.js';
2
- import { getDependenciesFromScripts, hasDependency } from '../../util/plugin.js';
3
- const NAME = 'yorkie';
4
- const ENABLERS = ['yorkie'];
5
- const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
- const PACKAGE_JSON_PATH = 'gitHooks';
7
- const CONFIG_FILE_PATTERNS = ['package.json'];
8
- const findPluginDependencies = async (configFilePath, options) => {
9
- const { manifest, isProduction } = options;
10
- if (isProduction)
11
- return [];
12
- const localConfig = manifest[PACKAGE_JSON_PATH];
13
- if (!localConfig)
14
- return [];
1
+ import { getDependenciesFromScripts, hasDependency } from '#p/util/plugin.js';
2
+ const title = 'yorkie';
3
+ const enablers = ['yorkie'];
4
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
+ const packageJsonPath = 'gitHooks';
6
+ const config = ['package.json'];
7
+ const resolveConfig = (config, options) => {
15
8
  const dependencies = new Set();
16
- for (const script of Object.values(localConfig).flat()) {
9
+ for (const script of Object.values(config).flat()) {
17
10
  const scripts = [script].flat();
18
11
  getDependenciesFromScripts(scripts, options).forEach(identifier => dependencies.add(identifier));
19
12
  }
20
13
  return ['yorkie', ...dependencies];
21
14
  };
22
- const findDependencies = timerify(findPluginDependencies);
23
15
  export default {
24
- NAME,
25
- ENABLERS,
16
+ title,
17
+ enablers,
26
18
  isEnabled,
27
- PACKAGE_JSON_PATH,
28
- CONFIG_FILE_PATTERNS,
29
- findDependencies,
19
+ packageJsonPath,
20
+ config,
21
+ resolveConfig,
30
22
  };
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from './types/plugins.js';
2
+ declare const plugins: Record<"astro" | "svelte" | "vue" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "msw" | "netlify" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "vite" | "vitest" | "webpack" | "wireit" | "yorkie" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "vercelOg", Plugin>;
3
+ export { plugins };
@@ -0,0 +1,14 @@
1
+ import * as originalPlugins from './plugins/index.js';
2
+ import parsedArgValues from './util/cli-arguments.js';
3
+ import { timerify } from './util/Performance.js';
4
+ const { performance: isEnabled = false } = parsedArgValues;
5
+ const plugins = (isEnabled ? {} : originalPlugins);
6
+ const methods = ['resolve', 'resolveConfig', 'resolveEntryPaths'];
7
+ if (isEnabled) {
8
+ for (const [name, plugin] of Object.entries(originalPlugins)) {
9
+ plugins[name] = plugin;
10
+ methods.forEach(method => method in plugin &&
11
+ (plugins[name][method] = timerify(plugin[method], `${method} (${plugin.title})`)));
12
+ }
13
+ }
14
+ export { plugins };
@@ -1,8 +1,8 @@
1
1
  declare const _default: {
2
- symbols: ({ report, issues, configurationHints, noConfigHints, isShowProgress }: import("src/index.js").ReporterOptions) => void;
3
- compact: ({ report, issues, isShowProgress }: import("src/index.js").ReporterOptions) => void;
4
- codeowners: ({ report, issues, isShowProgress, options }: import("src/index.js").ReporterOptions) => void;
5
- json: ({ report, issues, options }: import("src/index.js").ReporterOptions) => Promise<void>;
6
- markdown: ({ report, issues }: import("src/index.js").ReporterOptions) => void;
2
+ symbols: ({ report, issues, configurationHints, noConfigHints, isShowProgress }: import("#p/index.ts").ReporterOptions) => void;
3
+ compact: ({ report, issues, isShowProgress }: import("#p/index.ts").ReporterOptions) => void;
4
+ codeowners: ({ report, issues, isShowProgress, options }: import("#p/index.ts").ReporterOptions) => void;
5
+ json: ({ report, issues, options }: import("#p/index.ts").ReporterOptions) => Promise<void>;
6
+ markdown: ({ report, issues }: import("#p/index.ts").ReporterOptions) => void;
7
7
  };
8
8
  export default _default;
@@ -6,7 +6,7 @@ import type { SyncCompilers, AsyncCompilers } from '../compilers/types.js';
6
6
  export type RawConfiguration = z.infer<typeof ConfigurationValidator>;
7
7
  export type RawPluginConfiguration = z.infer<typeof pluginSchema>;
8
8
  type NormalizedGlob = string[];
9
- type IgnorePatterns = (string | RegExp)[];
9
+ export type IgnorePatterns = (string | RegExp)[];
10
10
  export type PluginName = keyof typeof Plugins;
11
11
  export type PluginMap = typeof Plugins;
12
12
  export type EnsuredPluginConfiguration = {
@@ -1,5 +1,5 @@
1
1
  import type { PluginMap } from './config.js';
2
- import type { LiteralUnion, MergeUnion } from './util.js';
2
+ import type { LiteralUnion } from './util.js';
3
3
  type Dependency = Record<string, string>;
4
4
  type ExportCondition = LiteralUnion<'import' | 'require' | 'node' | 'node-addons' | 'deno' | 'browser' | 'electron' | 'react-native' | 'default', string>;
5
5
  type Exports = null | string | string[] | {
@@ -7,19 +7,18 @@ type Exports = null | string | string[] | {
7
7
  } | {
8
8
  [key: string]: Exports;
9
9
  };
10
- type ExtractKeys<T, K extends string> = T extends {
11
- PACKAGE_JSON_PATH: infer P;
12
- } ? P extends `${infer First}.${infer Second}` ? {
13
- [K1 in First]?: {
14
- [K2 in Second]?: unknown;
15
- };
16
- } : {
17
- [P in T['PACKAGE_JSON_PATH'] & string]?: unknown;
18
- } : Record<K, unknown>;
19
- type PluginKeys = {
20
- [K in keyof PluginMap]: ExtractKeys<PluginMap[K], K>;
10
+ type PackageJsonPath<T> = T extends {
11
+ packageJsonPath: infer P;
12
+ } ? (P extends string ? P : never) : never;
13
+ type WithPackageJsonPathAsKey<T> = {
14
+ [K in keyof T]: PackageJsonPath<T[K]> extends never ? K : PackageJsonPath<T[K]>;
15
+ };
16
+ type PluginConfigs<P> = {
17
+ [K in keyof P as WithPackageJsonPathAsKey<P>[K]]: unknown;
18
+ };
19
+ type Plugins = PluginConfigs<PluginMap> & {
20
+ plugin: unknown;
21
21
  };
22
- type Plugins = MergeUnion<PluginKeys[keyof PluginMap]>;
23
22
  export type Scripts = Record<string, string>;
24
23
  export type PackageJson = {
25
24
  name?: string;
@@ -1,4 +1,4 @@
1
- import type { EnsuredPluginConfiguration, WorkspaceConfiguration } from './config.js';
1
+ import type { EnsuredPluginConfiguration, IgnorePatterns, WorkspaceConfiguration } from './config.js';
2
2
  import type { PackageJson } from './package-json.js';
3
3
  import type { DependencySet } from './workspace.js';
4
4
  export interface BaseOptions {
@@ -6,29 +6,35 @@ export interface BaseOptions {
6
6
  manifestScriptNames: Set<string>;
7
7
  dependencies: DependencySet;
8
8
  }
9
- type IsPluginEnabledCallbackOptions = {
9
+ type IsPluginEnabledOptions = {
10
10
  cwd: string;
11
11
  manifest: PackageJson;
12
12
  dependencies: Set<string>;
13
13
  config: WorkspaceConfiguration;
14
14
  };
15
- export type IsPluginEnabledCallback = (options: IsPluginEnabledCallbackOptions) => boolean | Promise<boolean>;
16
- export interface GenericPluginCallbackOptions extends BaseOptions {
15
+ export type IsPluginEnabled = (options: IsPluginEnabledOptions) => boolean | Promise<boolean>;
16
+ export interface PluginOptions extends BaseOptions {
17
17
  manifest: PackageJson;
18
18
  config: EnsuredPluginConfiguration;
19
+ configFileDir: string;
20
+ configFileName: string;
19
21
  isProduction: boolean;
20
22
  enabledPlugins: string[];
21
23
  }
22
- export type GenericPluginCallback = (configFilePath: string, options: GenericPluginCallbackOptions) => Promise<string[]> | string[];
24
+ export type ResolveEntryPaths<T = any> = (config: T, options: PluginOptions) => Promise<string[]> | string[];
25
+ export type ResolveConfig<T = any> = (config: T, options: PluginOptions) => Promise<string[]> | string[];
26
+ export type Resolve = (options: PluginOptions) => Promise<string[]> | string[];
23
27
  export interface Plugin {
24
- NAME: string;
25
- ENABLERS: string[];
26
- PACKAGE_JSON_PATH?: string;
27
- isEnabled: IsPluginEnabledCallback;
28
- CONFIG_FILE_PATTERNS?: string[];
29
- ENTRY_FILE_PATTERNS?: string[];
30
- PRODUCTION_ENTRY_FILE_PATTERNS?: string[];
31
- PROJECT_FILE_PATTERNS?: string[];
32
- findDependencies: GenericPluginCallback;
28
+ title: string;
29
+ enablers: IgnorePatterns | string;
30
+ packageJsonPath?: string;
31
+ isEnabled: IsPluginEnabled;
32
+ config?: string[];
33
+ entry?: string[];
34
+ production?: string[];
35
+ project?: string[];
36
+ resolveEntryPaths?: ResolveEntryPaths;
37
+ resolveConfig?: ResolveConfig;
38
+ resolve?: Resolve;
33
39
  }
34
40
  export {};
@@ -1,16 +1,3 @@
1
1
  type Primitive = null | undefined | string | number | boolean | symbol | bigint;
2
2
  export type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
3
- type CommonKeys<T extends object> = keyof T;
4
- type AllKeys<T> = T extends unknown ? keyof T : never;
5
- type Subtract<A, C> = A extends C ? never : A;
6
- type NonCommonKeys<T extends object> = Subtract<AllKeys<T>, CommonKeys<T>>;
7
- type PickType<T, K extends AllKeys<T>> = T extends {
8
- [k in K]?: unknown;
9
- } ? T[K] : undefined;
10
- type PickTypeOf<T, K extends string | number | symbol> = K extends AllKeys<T> ? PickType<T, K> : never;
11
- export type MergeUnion<T extends object> = {
12
- [k in CommonKeys<T>]: PickTypeOf<T, k>;
13
- } & {
14
- [k in NonCommonKeys<T>]?: PickTypeOf<T, k>;
15
- };
16
3
  export {};
@@ -1,4 +1,5 @@
1
1
  import ts from 'typescript';
2
+ import { FOREIGN_FILE_EXTENSIONS } from '../constants.js';
2
3
  import { debugLog } from '../util/debug.js';
3
4
  import { extname, isInNodeModules, isInternal } from '../util/path.js';
4
5
  export class SourceFileManager {
@@ -19,6 +20,8 @@ export class SourceFileManager {
19
20
  return sourceFile;
20
21
  }
21
22
  getSourceFile(filePath) {
23
+ if (FOREIGN_FILE_EXTENSIONS.has(extname(filePath)))
24
+ return undefined;
22
25
  if (this.isSkipLibs && isInNodeModules(filePath))
23
26
  return undefined;
24
27
  if (this.sourceFileCache.has(filePath))
@@ -2,15 +2,16 @@ import { EOL } from 'node:os';
2
2
  import path from 'node:path';
3
3
  import ts from 'typescript';
4
4
  import { getCompilerExtensions } from '../compilers/index.js';
5
+ import { FOREIGN_FILE_EXTENSIONS } from '../constants.js';
5
6
  import { createCustomModuleResolver } from './resolveModuleNames.js';
6
7
  import { SourceFileManager } from './SourceFileManager.js';
7
8
  import { createCustomSys } from './sys.js';
8
9
  const libLocation = path.dirname(ts.getDefaultLibFilePath({}));
9
10
  export const createHosts = ({ cwd, compilerOptions, entryPaths, compilers, isSkipLibs }) => {
10
11
  const fileManager = new SourceFileManager({ compilers, isSkipLibs });
11
- const virtualFileExtensions = getCompilerExtensions(compilers);
12
- const sys = createCustomSys(cwd, virtualFileExtensions);
13
- const resolveModuleNames = createCustomModuleResolver(sys, compilerOptions, virtualFileExtensions);
12
+ const compilerExtensions = [...getCompilerExtensions(compilers), ...FOREIGN_FILE_EXTENSIONS];
13
+ const sys = createCustomSys(cwd, compilerExtensions);
14
+ const resolveModuleNames = createCustomModuleResolver(sys, compilerOptions, compilerExtensions);
14
15
  const languageServiceHost = {
15
16
  getCompilationSettings: () => compilerOptions,
16
17
  getScriptFileNames: () => Array.from(entryPaths),
@@ -2,7 +2,7 @@ import { existsSync } from 'node:fs';
2
2
  import { isBuiltin } from 'node:module';
3
3
  import ts from 'typescript';
4
4
  import { sanitizeSpecifier } from '../util/modules.js';
5
- import { basename, dirname, extname, format, isAbsolute, isInNodeModules, isInternal, join } from '../util/path.js';
5
+ import { dirname, extname, isAbsolute, isInNodeModules, isInternal, join } from '../util/path.js';
6
6
  import { isDeclarationFileExtension } from './ast-helpers.js';
7
7
  import { ensureRealFilePath, isVirtualFilePath } from './utils.js';
8
8
  const resolutionCache = new Map();
@@ -17,27 +17,6 @@ const fileExists = (name, containingFile) => {
17
17
  };
18
18
  }
19
19
  };
20
- const DTS_EXTENSIONS_MAP = {
21
- [ts.Extension.Dts]: ts.Extension.Js,
22
- [ts.Extension.Dmts]: ts.Extension.Mjs,
23
- [ts.Extension.Dcts]: ts.Extension.Cjs,
24
- };
25
- const jsMatchingDeclarationFileExists = (resolveDtsFileName, dtsExtension) => {
26
- const extension = DTS_EXTENSIONS_MAP[dtsExtension];
27
- const resolvedFileName = format({
28
- ext: extension,
29
- dir: dirname(resolveDtsFileName),
30
- name: basename(resolveDtsFileName, dtsExtension),
31
- });
32
- if (existsSync(resolvedFileName)) {
33
- return {
34
- resolvedFileName,
35
- extension,
36
- isExternalLibraryImport: false,
37
- resolvedUsingTsExtension: false,
38
- };
39
- }
40
- };
41
20
  export function createCustomModuleResolver(customSys, compilerOptions, virtualFileExtensions) {
42
21
  function resolveModuleNames(moduleNames, containingFile) {
43
22
  return moduleNames.map(moduleName => {
@@ -53,40 +32,46 @@ export function createCustomModuleResolver(customSys, compilerOptions, virtualFi
53
32
  }
54
33
  function resolveModuleName(name, containingFile) {
55
34
  const sanitizedSpecifier = sanitizeSpecifier(name);
56
- if (isBuiltin(sanitizedSpecifier))
57
- return undefined;
58
- if (isInNodeModules(name))
35
+ if (isBuiltin(sanitizedSpecifier) || isInNodeModules(name))
59
36
  return undefined;
60
37
  const tsResolvedModule = ts.resolveModuleName(sanitizedSpecifier, containingFile, compilerOptions, ts.sys).resolvedModule;
61
- if (!tsResolvedModule) {
62
- const extension = extname(sanitizedSpecifier);
63
- if (extension && !virtualFileExtensions.includes(extension)) {
64
- const module = fileExists(sanitizedSpecifier, containingFile);
65
- if (module)
66
- return module;
67
- }
68
- }
69
38
  if (tsResolvedModule &&
70
39
  isDeclarationFileExtension(tsResolvedModule.extension) &&
71
40
  isInternal(tsResolvedModule.resolvedFileName)) {
72
- {
73
- const module = jsMatchingDeclarationFileExists(tsResolvedModule.resolvedFileName, tsResolvedModule.extension);
74
- if (module)
75
- return module;
41
+ if (tsResolvedModule.extension === '.d.mts') {
42
+ const resolvedFileName = tsResolvedModule.resolvedFileName.replace(/\.d\.mts$/, '.mjs');
43
+ return { resolvedFileName, extension: '.mjs', isExternalLibraryImport: false, resolvedUsingTsExtension: false };
44
+ }
45
+ if (tsResolvedModule.extension === '.d.cts') {
46
+ const resolvedFileName = tsResolvedModule.resolvedFileName.replace(/\.d\.cts$/, '.cjs');
47
+ return { resolvedFileName, extension: '.cjs', isExternalLibraryImport: false, resolvedUsingTsExtension: false };
48
+ }
49
+ const base = tsResolvedModule.resolvedFileName.replace(/\.d\.ts$/, '');
50
+ const baseExt = extname(base);
51
+ if (baseExt && virtualFileExtensions.includes(baseExt)) {
52
+ const resolvedFileName = ensureRealFilePath(base, virtualFileExtensions);
53
+ return {
54
+ resolvedFileName,
55
+ extension: ts.Extension.Js,
56
+ isExternalLibraryImport: false,
57
+ resolvedUsingTsExtension: false,
58
+ };
76
59
  }
77
- {
78
- const module = fileExists(sanitizedSpecifier, containingFile);
60
+ for (const ext of ['.js', '.jsx']) {
61
+ const module = fileExists(base + ext, containingFile);
79
62
  if (module)
80
63
  return module;
81
64
  }
82
- }
83
- if (virtualFileExtensions.length === 0)
84
65
  return tsResolvedModule;
66
+ }
85
67
  if (tsResolvedModule && !isVirtualFilePath(tsResolvedModule.resolvedFileName, virtualFileExtensions)) {
86
68
  return tsResolvedModule;
87
69
  }
88
70
  const customResolvedModule = ts.resolveModuleName(sanitizedSpecifier, containingFile, compilerOptions, customSys).resolvedModule;
89
71
  if (!customResolvedModule || !isVirtualFilePath(customResolvedModule.resolvedFileName, virtualFileExtensions)) {
72
+ const module = fileExists(sanitizedSpecifier, containingFile);
73
+ if (module)
74
+ return module;
90
75
  return customResolvedModule;
91
76
  }
92
77
  const resolvedFileName = ensureRealFilePath(customResolvedModule.resolvedFileName, virtualFileExtensions);
@@ -1,3 +1,3 @@
1
1
  import ts from 'typescript';
2
- declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/imports.js").ImportNode | import("src/types/imports.js").ImportNode[] | undefined;
2
+ declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => import("#p/types/imports.ts").ImportNode | import("#p/types/imports.ts").ImportNode[] | undefined;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import ts from 'typescript';
2
- declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/imports.js").ImportNode | import("src/types/imports.js").ImportNode[] | undefined;
2
+ declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => import("#p/types/imports.ts").ImportNode | import("#p/types/imports.ts").ImportNode[] | undefined;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import ts from 'typescript';
2
- declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/imports.js").ImportNode | import("src/types/imports.js").ImportNode[] | undefined)[];
2
+ declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => import("#p/types/imports.ts").ImportNode | import("#p/types/imports.ts").ImportNode[] | undefined)[];
3
3
  export default _default;
@@ -1,4 +1,4 @@
1
1
  import ts from 'typescript';
2
2
  import type { ImportNode } from '../../../types/imports.js';
3
- declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => ImportNode | ImportNode[] | undefined;
3
+ declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => ImportNode | ImportNode[] | undefined;
4
4
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import ts from 'typescript';
2
- declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/imports.js").ImportNode | import("src/types/imports.js").ImportNode[] | undefined;
2
+ declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => import("#p/types/imports.ts").ImportNode | import("#p/types/imports.ts").ImportNode[] | undefined;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import ts from 'typescript';
2
- declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/imports.js").ImportNode | import("src/types/imports.js").ImportNode[] | undefined;
2
+ declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => import("#p/types/imports.ts").ImportNode | import("#p/types/imports.ts").ImportNode[] | undefined;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import ts from 'typescript';
2
- declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined;
2
+ declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import ts from 'typescript';
2
- declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("src/types/exports.js").ExportNode | import("src/types/exports.js").ExportNode[] | undefined;
2
+ declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import ts from 'typescript';
2
- declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("src/typescript/getImportsAndExports.js").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined;
2
+ declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined;
3
3
  export default _default;