knip 5.86.0 → 5.87.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 (57) hide show
  1. package/dist/ConfigurationChief.d.ts +6 -0
  2. package/dist/DependencyDeputy.js +3 -0
  3. package/dist/binaries/bash-parser.js +3 -3
  4. package/dist/binaries/resolvers/find.js +19 -0
  5. package/dist/binaries/{package-manager → resolvers}/index.d.ts +1 -0
  6. package/dist/binaries/{package-manager → resolvers}/index.js +2 -0
  7. package/dist/binaries/{package-manager → resolvers}/pnpm.js +1 -0
  8. package/dist/binaries/resolvers/yarn.d.ts +2 -0
  9. package/dist/compilers/index.d.ts +10 -0
  10. package/dist/graph/analyze.js +2 -0
  11. package/dist/graph/build.js +3 -1
  12. package/dist/plugins/babel/index.js +3 -0
  13. package/dist/plugins/changesets/index.js +8 -1
  14. package/dist/plugins/changesets/types.d.ts +1 -0
  15. package/dist/plugins/index.d.ts +1 -0
  16. package/dist/plugins/index.js +2 -0
  17. package/dist/plugins/nx/index.js +10 -8
  18. package/dist/plugins/nx/types.d.ts +1 -0
  19. package/dist/plugins/openapi-ts/index.js +0 -9
  20. package/dist/plugins/oxfmt/index.d.ts +3 -0
  21. package/dist/plugins/oxfmt/index.js +16 -0
  22. package/dist/plugins/oxlint/index.js +1 -1
  23. package/dist/schema/configuration.d.ts +15 -0
  24. package/dist/schema/plugins.d.ts +5 -0
  25. package/dist/schema/plugins.js +1 -0
  26. package/dist/types/PluginNames.d.ts +2 -2
  27. package/dist/types/PluginNames.js +1 -0
  28. package/dist/typescript/resolve-module-names.js +2 -2
  29. package/dist/util/Performance.d.ts +3 -5
  30. package/dist/util/Performance.js +35 -18
  31. package/dist/util/create-input-handler.js +2 -2
  32. package/dist/util/create-options.d.ts +10 -0
  33. package/dist/util/glob-core.js +34 -9
  34. package/dist/util/modules.js +1 -2
  35. package/dist/util/path.js +1 -1
  36. package/dist/util/resolve.d.ts +2 -3
  37. package/dist/util/resolve.js +4 -3
  38. package/dist/util/watch.js +4 -2
  39. package/dist/version.d.ts +1 -1
  40. package/dist/version.js +1 -1
  41. package/package.json +1 -1
  42. package/schema.json +4 -0
  43. package/dist/plugins/openapi-ts/types.d.ts +0 -8
  44. package/dist/plugins/openapi-ts/types.js +0 -1
  45. /package/dist/binaries/{package-manager → resolvers}/bun.d.ts +0 -0
  46. /package/dist/binaries/{package-manager → resolvers}/bun.js +0 -0
  47. /package/dist/binaries/{package-manager → resolvers}/bunx.d.ts +0 -0
  48. /package/dist/binaries/{package-manager → resolvers}/bunx.js +0 -0
  49. /package/dist/binaries/{package-manager/npm.d.ts → resolvers/find.d.ts} +0 -0
  50. /package/dist/binaries/{package-manager/npx.d.ts → resolvers/npm.d.ts} +0 -0
  51. /package/dist/binaries/{package-manager → resolvers}/npm.js +0 -0
  52. /package/dist/binaries/{package-manager/pnpm.d.ts → resolvers/npx.d.ts} +0 -0
  53. /package/dist/binaries/{package-manager → resolvers}/npx.js +0 -0
  54. /package/dist/binaries/{package-manager/yarn.d.ts → resolvers/pnpm.d.ts} +0 -0
  55. /package/dist/binaries/{package-manager → resolvers}/pnpx.d.ts +0 -0
  56. /package/dist/binaries/{package-manager → resolvers}/pnpx.js +0 -0
  57. /package/dist/binaries/{package-manager → resolvers}/yarn.js +0 -0
@@ -411,6 +411,11 @@ export declare class ConfigurationChief {
411
411
  entry?: string | string[] | undefined;
412
412
  project?: string | string[] | undefined;
413
413
  } | undefined;
414
+ oxfmt?: string | boolean | string[] | {
415
+ config?: string | string[] | undefined;
416
+ entry?: string | string[] | undefined;
417
+ project?: string | string[] | undefined;
418
+ } | undefined;
414
419
  oxlint?: string | boolean | string[] | {
415
420
  config?: string | string[] | undefined;
416
421
  entry?: string | string[] | undefined;
@@ -837,6 +842,7 @@ export declare class ConfigurationChief {
837
842
  nyc?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
838
843
  oclif?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
839
844
  "openapi-ts"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
845
+ oxfmt?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
840
846
  oxlint?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
841
847
  parcel?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
842
848
  payload?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
@@ -228,9 +228,12 @@ export class DependencyDeputy {
228
228
  const position = peeker.getLocation('devDependencies', symbol);
229
229
  devDependencyIssues.push({ type: 'devDependencies', filePath, workspace, symbol, fixes: [], ...position });
230
230
  }
231
+ const manifest = this._manifests.get(workspace);
231
232
  for (const symbol of this.getOptionalPeerDependencies(workspace)) {
232
233
  if (!isReferencedDependency(symbol))
233
234
  continue;
235
+ if (manifest.dependencies.includes(symbol) || manifest.devDependencies.includes(symbol))
236
+ continue;
234
237
  const pos = peeker.getLocation('optionalPeerDependencies', symbol);
235
238
  optionalPeerDependencyIssues.push({
236
239
  type: 'optionalPeerDependencies',
@@ -6,7 +6,7 @@ import { extractBinary, isValidBinary } from "../util/modules.js";
6
6
  import { relative } from "../util/path.js";
7
7
  import { truncate } from "../util/string.js";
8
8
  import { resolve as fallbackResolve } from "./fallback.js";
9
- import PackageManagerResolvers from "./package-manager/index.js";
9
+ import KnownResolvers from "./resolvers/index.js";
10
10
  import { resolve as resolverFromPlugins } from "./plugins.js";
11
11
  import { parseNodeArgs } from "./util.js";
12
12
  const spawningBinaries = ['cross-env', 'retry-cli'];
@@ -79,8 +79,8 @@ export const getDependenciesFromScript = (script, options) => {
79
79
  .filter(args => args.require)
80
80
  .flatMap(arg => arg.require)
81
81
  .map(id => toDeferResolve(id));
82
- if (binary in PackageManagerResolvers) {
83
- const resolver = PackageManagerResolvers[binary];
82
+ if (binary in KnownResolvers) {
83
+ const resolver = KnownResolvers[binary];
84
84
  return resolver(binary, args, { ...options, fromArgs });
85
85
  }
86
86
  if (pluginArgsMap.has(binary)) {
@@ -0,0 +1,19 @@
1
+ import { toBinary } from "../../util/input.js";
2
+ const execFlags = new Set(['-exec', '-execdir']);
3
+ const execTerminators = new Set([';', '\\;', '+']);
4
+ export const resolve = (binary, args, { fromArgs }) => {
5
+ const execIdx = args.findIndex(a => execFlags.has(a));
6
+ if (execIdx >= 0) {
7
+ const cmdWords = [];
8
+ for (let i = execIdx + 1; i < args.length; i++) {
9
+ const v = args[i];
10
+ if (execTerminators.has(v))
11
+ break;
12
+ if (v !== '{}')
13
+ cmdWords.push(v);
14
+ }
15
+ if (cmdWords.length > 0)
16
+ return [toBinary(binary), ...fromArgs(cmdWords)];
17
+ }
18
+ return [toBinary(binary)];
19
+ };
@@ -1,6 +1,7 @@
1
1
  declare const _default: {
2
2
  bun: import("../../types/config.ts").BinaryResolver;
3
3
  bunx: import("../../types/config.ts").BinaryResolver;
4
+ find: import("../../types/config.ts").BinaryResolver;
4
5
  npm: import("../../types/config.ts").BinaryResolver;
5
6
  npx: import("../../types/config.ts").BinaryResolver;
6
7
  pnpm: import("../../types/config.ts").BinaryResolver;
@@ -1,5 +1,6 @@
1
1
  import * as bun from "./bun.js";
2
2
  import * as bunx from "./bunx.js";
3
+ import * as find from "./find.js";
3
4
  import * as npm from "./npm.js";
4
5
  import * as npx from "./npx.js";
5
6
  import * as pnpm from "./pnpm.js";
@@ -8,6 +9,7 @@ import * as yarn from "./yarn.js";
8
9
  export default {
9
10
  bun: bun.resolve,
10
11
  bunx: bunx.resolve,
12
+ find: find.resolve,
11
13
  npm: npm.resolve,
12
14
  npx: npx.resolve,
13
15
  pnpm: pnpm.resolve,
@@ -35,6 +35,7 @@ const commands = [
35
35
  'patch-commit',
36
36
  'patch-remove',
37
37
  'patch',
38
+ 'pkg',
38
39
  'prepare',
39
40
  'prune',
40
41
  'publish',
@@ -0,0 +1,2 @@
1
+ import type { BinaryResolver } from '../../types/config.ts';
2
+ export declare const resolve: BinaryResolver;
@@ -360,6 +360,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
360
360
  entry?: string | string[] | undefined;
361
361
  project?: string | string[] | undefined;
362
362
  } | undefined;
363
+ oxfmt?: string | boolean | string[] | {
364
+ config?: string | string[] | undefined;
365
+ entry?: string | string[] | undefined;
366
+ project?: string | string[] | undefined;
367
+ } | undefined;
363
368
  oxlint?: string | boolean | string[] | {
364
369
  config?: string | string[] | undefined;
365
370
  entry?: string | string[] | undefined;
@@ -1051,6 +1056,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
1051
1056
  entry?: string | string[] | undefined;
1052
1057
  project?: string | string[] | undefined;
1053
1058
  } | undefined;
1059
+ oxfmt?: string | boolean | string[] | {
1060
+ config?: string | string[] | undefined;
1061
+ entry?: string | string[] | undefined;
1062
+ project?: string | string[] | undefined;
1063
+ } | undefined;
1054
1064
  oxlint?: string | boolean | string[] | {
1055
1065
  config?: string | string[] | undefined;
1056
1066
  entry?: string | string[] | undefined;
@@ -2,6 +2,7 @@ import { createGraphExplorer } from "../graph-explorer/explorer.js";
2
2
  import { getIssueType, hasStrictlyEnumReferences } from "../graph-explorer/utils.js";
3
3
  import traceReporter from "../reporters/trace.js";
4
4
  import { getPackageNameFromModuleSpecifier } from "../util/modules.js";
5
+ import { perfObserver } from "../util/Performance.js";
5
6
  import { findMatch } from "../util/regex.js";
6
7
  import { getShouldIgnoreHandler, getShouldIgnoreTagHandler } from "../util/tag.js";
7
8
  export const analyze = async ({ analyzedFiles, counselor, chief, collector, deputy, entryPaths, factory, graph, streamer, unreferencedFiles, options, }) => {
@@ -245,6 +246,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
245
246
  collector.addConfigurationHint(hint);
246
247
  };
247
248
  await analyzeGraph();
249
+ perfObserver.addMemoryMark('analyze');
248
250
  if (options.isTrace) {
249
251
  traceReporter({ graph, explorer, options, workspaceFilePathFilter: chief.workspaceFilePathFilter });
250
252
  }
@@ -371,6 +371,7 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
371
371
  }
372
372
  }
373
373
  };
374
+ perfObserver.addMemoryMark('init');
374
375
  for (let i = 0; i < principals.length; ++i) {
375
376
  const principal = principals[i];
376
377
  if (!principal)
@@ -400,7 +401,7 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
400
401
  factory.deletePrincipal(principal, options.cwd);
401
402
  principals[i] = undefined;
402
403
  }
403
- perfObserver.addMemoryMark(factory.getPrincipalCount());
404
+ perfObserver.addMemoryMark(`P${factory.getPrincipalCount()}`);
404
405
  }
405
406
  if (!options.isWatch && !options.isSession && options.isSkipLibs && !options.isIsolateWorkspaces) {
406
407
  for (const principal of principals) {
@@ -409,6 +410,7 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
409
410
  }
410
411
  principals.length = 0;
411
412
  }
413
+ perfObserver.addMemoryMark('build');
412
414
  if (externalRefsFromInputs) {
413
415
  for (const [filePath, refs] of externalRefsFromInputs) {
414
416
  if (!graph.has(filePath))
@@ -15,6 +15,9 @@ export const getDependenciesFromConfig = (config) => {
15
15
  return compact([
16
16
  ...presets.map(id => toDeferResolve(id)),
17
17
  ...plugins.map(id => toDeferResolve(id)),
18
+ ...(plugins.includes('@babel/plugin-transform-runtime')
19
+ ? [toDeferResolve('@babel/runtime', { optional: true })]
20
+ : []),
18
21
  ...nested,
19
22
  ...overrides,
20
23
  ]);
@@ -1,4 +1,5 @@
1
1
  import { toDependency } from "../../util/input.js";
2
+ import { getPackageNameFromFilePath } from "../../util/modules.js";
2
3
  import { hasDependency } from "../../util/plugin.js";
3
4
  const title = 'Changesets';
4
5
  const enablers = ['@changesets/cli'];
@@ -6,11 +7,17 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
7
  const isRootOnly = true;
7
8
  const config = ['.changeset/config.json'];
8
9
  const resolveConfig = config => {
9
- return (Array.isArray(config.changelog)
10
+ const inputs = (Array.isArray(config.changelog)
10
11
  ? [config.changelog[0]]
11
12
  : typeof config.changelog === 'string'
12
13
  ? [config.changelog]
13
14
  : []).map(id => toDependency(id));
15
+ if (config.$schema?.includes('node_modules/')) {
16
+ const packageName = getPackageNameFromFilePath(config.$schema);
17
+ if (packageName)
18
+ inputs.push(toDependency(packageName));
19
+ }
20
+ return inputs;
14
21
  };
15
22
  const plugin = {
16
23
  title,
@@ -1,3 +1,4 @@
1
1
  export type ChangesetsConfig = {
2
+ $schema?: string;
2
3
  changelog: string | string[];
3
4
  };
@@ -75,6 +75,7 @@ export declare const Plugins: {
75
75
  nyc: import("../types/config.ts").Plugin;
76
76
  oclif: import("../types/config.ts").Plugin;
77
77
  'openapi-ts': import("../types/config.ts").Plugin;
78
+ oxfmt: import("../types/config.ts").Plugin;
78
79
  oxlint: import("../types/config.ts").Plugin;
79
80
  parcel: import("../types/config.ts").Plugin;
80
81
  payload: import("../types/config.ts").Plugin;
@@ -69,6 +69,7 @@ import { default as nx } from "./nx/index.js";
69
69
  import { default as nyc } from "./nyc/index.js";
70
70
  import { default as oclif } from "./oclif/index.js";
71
71
  import { default as openapiTs } from "./openapi-ts/index.js";
72
+ import { default as oxfmt } from "./oxfmt/index.js";
72
73
  import { default as oxlint } from "./oxlint/index.js";
73
74
  import { default as parcel } from "./parcel/index.js";
74
75
  import { default as payload } from "./payload/index.js";
@@ -208,6 +209,7 @@ export const Plugins = {
208
209
  nyc,
209
210
  oclif,
210
211
  'openapi-ts': openapiTs,
212
+ oxfmt,
211
213
  oxlint,
212
214
  parcel,
213
215
  payload,
@@ -1,5 +1,6 @@
1
1
  import { compact } from "../../util/array.js";
2
2
  import { toConfig, toDependency } from "../../util/input.js";
3
+ import { join } from "../../util/path.js";
3
4
  import { hasDependency } from "../../util/plugin.js";
4
5
  const title = 'Nx';
5
6
  const enablers = ['nx', /^@nrwl\//, /^@nx\//];
@@ -34,18 +35,19 @@ const resolveConfig = async (localConfig, options) => {
34
35
  .map(target => target?.executor)
35
36
  .filter(executor => executor && !executor.startsWith('.'))
36
37
  .map(executor => executor?.split(':')[0]);
37
- const scripts = targets
38
+ const inputs = targets
38
39
  .filter(target => target.executor === 'nx:run-commands' || target.command)
39
40
  .flatMap(target => {
41
+ let commands = [];
40
42
  if (target.command)
41
- return [target.command];
42
- if (target.options?.command)
43
- return [target.options.command];
44
- if (target.options?.commands)
45
- return target.options.commands.map(commandConfig => typeof commandConfig === 'string' ? commandConfig : commandConfig.command);
46
- return [];
43
+ commands = [target.command];
44
+ else if (target.options?.command)
45
+ commands = [target.options.command];
46
+ else if (target.options?.commands)
47
+ commands = target.options.commands.map(commandConfig => typeof commandConfig === 'string' ? commandConfig : commandConfig.command);
48
+ const cwd = target.options?.cwd ? join(options.cwd, target.options.cwd) : undefined;
49
+ return options.getInputsFromScripts(commands, { cwd });
47
50
  });
48
- const inputs = options.getInputsFromScripts(scripts);
49
51
  const configInputs = targets.flatMap(target => {
50
52
  const opts = target.options;
51
53
  if (!opts)
@@ -8,6 +8,7 @@ export interface NxProjectConfiguration {
8
8
  commands?: Array<string | {
9
9
  command: string;
10
10
  }>;
11
+ cwd?: string;
11
12
  eslintConfig?: string;
12
13
  jestConfig?: string;
13
14
  tsConfig?: string;
@@ -1,22 +1,13 @@
1
- import { toDependency } from "../../util/input.js";
2
1
  import { hasDependency } from "../../util/plugin.js";
3
2
  import { toC12config } from "../../util/plugin-config.js";
4
3
  const title = 'openapi-ts';
5
4
  const enablers = ['@hey-api/openapi-ts'];
6
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
6
  const config = ['package.json', ...toC12config('openapi-ts')];
8
- const resolveConfig = config => {
9
- const configs = Array.isArray(config) ? config : [config];
10
- return configs.flatMap(config => (config.plugins ?? [])
11
- .map(plugin => (typeof plugin === 'string' ? plugin : plugin.name))
12
- .filter((name) => typeof name === 'string')
13
- .map(id => toDependency(id)));
14
- };
15
7
  const plugin = {
16
8
  title,
17
9
  enablers,
18
10
  isEnabled,
19
11
  config,
20
- resolveConfig,
21
12
  };
22
13
  export default plugin;
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,16 @@
1
+ import { hasDependency } from "../../util/plugin.js";
2
+ const title = 'Oxfmt';
3
+ const enablers = ['oxfmt'];
4
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
+ const config = ['.oxfmtrc.json', '.oxfmtrc.jsonc'];
6
+ const args = {
7
+ config: true,
8
+ };
9
+ const plugin = {
10
+ title,
11
+ enablers,
12
+ isEnabled,
13
+ config,
14
+ args,
15
+ };
16
+ export default plugin;
@@ -2,7 +2,7 @@ import { hasDependency } from "../../util/plugin.js";
2
2
  const title = 'Oxlint';
3
3
  const enablers = ['oxlint'];
4
4
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
- const config = ['.oxlintrc.json'];
5
+ const config = ['.oxlintrc.json', 'oxlint.config.ts'];
6
6
  const args = {
7
7
  config: true,
8
8
  };
@@ -357,6 +357,11 @@ export declare const workspaceConfigurationSchema: z.ZodMiniObject<{
357
357
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
358
358
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
359
359
  }, z.core.$strip>]>>;
360
+ oxfmt: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
361
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
362
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
363
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
364
+ }, z.core.$strip>]>>;
360
365
  oxlint: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
361
366
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
362
367
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1059,6 +1064,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1059
1064
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1060
1065
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1061
1066
  }, z.core.$strip>]>>;
1067
+ oxfmt: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1068
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1069
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1070
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1071
+ }, z.core.$strip>]>>;
1062
1072
  oxlint: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1063
1073
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1064
1074
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1750,6 +1760,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1750
1760
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1751
1761
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1752
1762
  }, z.core.$strip>]>>;
1763
+ oxfmt: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1764
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1765
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1766
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1767
+ }, z.core.$strip>]>>;
1753
1768
  oxlint: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1754
1769
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1755
1770
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -361,6 +361,11 @@ export declare const pluginsSchema: z.ZodMiniObject<{
361
361
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
362
362
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
363
363
  }, z.core.$strip>]>;
364
+ oxfmt: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
365
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
366
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
367
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
368
+ }, z.core.$strip>]>;
364
369
  oxlint: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
365
370
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
366
371
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -81,6 +81,7 @@ export const pluginsSchema = z.object({
81
81
  nyc: pluginSchema,
82
82
  oclif: pluginSchema,
83
83
  'openapi-ts': pluginSchema,
84
+ oxfmt: pluginSchema,
84
85
  oxlint: pluginSchema,
85
86
  parcel: pluginSchema,
86
87
  payload: pluginSchema,
@@ -1,2 +1,2 @@
1
- export type PluginName = 'angular' | 'astro' | 'astro-db' | 'astro-og-canvas' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'execa' | 'expo' | 'expressive-code' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'knex' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'nitro' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'openapi-ts' | 'oxlint' | 'parcel' | 'payload' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'qwik' | 'react-cosmos' | 'react-native' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'sveltekit' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitepress' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie' | 'zx';
2
- export declare const pluginNames: readonly ["angular", "astro", "astro-db", "astro-og-canvas", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "execa", "expo", "expressive-code", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "knex", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "next-intl", "next-mdx", "nitro", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "openapi-ts", "oxlint", "parcel", "payload", "playwright", "playwright-ct", "playwright-test", "plop", "pm2", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "qwik", "react-cosmos", "react-native", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "sveltekit", "svgo", "svgr", "swc", "syncpack", "tailwind", "tanstack-router", "taskfile", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitepress", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie", "zx"];
1
+ export type PluginName = 'angular' | 'astro' | 'astro-db' | 'astro-og-canvas' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'execa' | 'expo' | 'expressive-code' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'knex' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'nitro' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'openapi-ts' | 'oxfmt' | 'oxlint' | 'parcel' | 'payload' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'qwik' | 'react-cosmos' | 'react-native' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'sveltekit' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitepress' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie' | 'zx';
2
+ export declare const pluginNames: readonly ["angular", "astro", "astro-db", "astro-og-canvas", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "execa", "expo", "expressive-code", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "knex", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "next-intl", "next-mdx", "nitro", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "openapi-ts", "oxfmt", "oxlint", "parcel", "payload", "playwright", "playwright-ct", "playwright-test", "plop", "pm2", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "qwik", "react-cosmos", "react-native", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "sveltekit", "svgo", "svgr", "swc", "syncpack", "tailwind", "tanstack-router", "taskfile", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitepress", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie", "zx"];
@@ -70,6 +70,7 @@ export const pluginNames = [
70
70
  'nyc',
71
71
  'oclif',
72
72
  'openapi-ts',
73
+ 'oxfmt',
73
74
  'oxlint',
74
75
  'parcel',
75
76
  'payload',
@@ -5,7 +5,7 @@ import { DEFAULT_EXTENSIONS } from "../constants.js";
5
5
  import { sanitizeSpecifier } from "../util/modules.js";
6
6
  import { timerify } from "../util/Performance.js";
7
7
  import { dirname, extname, isAbsolute, isInNodeModules, join } from "../util/path.js";
8
- import { _createSyncModuleResolver, _resolveModuleSync } from "../util/resolve.js";
8
+ import { createSyncModuleResolver, resolveModuleSync } from "../util/resolve.js";
9
9
  import { isDeclarationFileExtension } from "./ast-helpers.js";
10
10
  const resolutionCache = new Map();
11
11
  const moduleIfFileExists = (name, containingFile) => {
@@ -23,7 +23,7 @@ const tsResolveModuleName = timerify(ts.resolveModuleName);
23
23
  export function createCustomModuleResolver(compilerOptions, customCompilerExtensions, toSourceFilePath, useCache = true) {
24
24
  const customCompilerExtensionsSet = new Set(customCompilerExtensions);
25
25
  const extensions = [...DEFAULT_EXTENSIONS, ...customCompilerExtensions];
26
- const resolveSync = customCompilerExtensionsSet.size === 0 ? _resolveModuleSync : _createSyncModuleResolver(extensions);
26
+ const resolveSync = customCompilerExtensionsSet.size === 0 ? resolveModuleSync : createSyncModuleResolver(extensions);
27
27
  const virtualDeclarationFiles = new Map();
28
28
  const tsSys = {
29
29
  ...ts.sys,
@@ -1,10 +1,10 @@
1
1
  import { type PerformanceEntry, PerformanceObserver } from 'node:perf_hooks';
2
- import { memoryUsage } from 'node:process';
3
2
  export declare const timerify: <T extends (...params: any[]) => any>(fn: T, name?: string) => T;
4
3
  type MemInfo = {
4
+ label: string;
5
5
  heapUsed: number;
6
6
  heapTotal: number;
7
- freemem: number;
7
+ rss: number;
8
8
  };
9
9
  interface MemoryEntry extends PerformanceEntry {
10
10
  detail: MemInfo;
@@ -21,8 +21,6 @@ declare class Performance {
21
21
  memId?: string;
22
22
  fnObserver?: PerformanceObserver;
23
23
  memObserver?: PerformanceObserver;
24
- memoryUsageStart?: ReturnType<typeof memoryUsage>;
25
- freeMemoryStart?: number;
26
24
  constructor({ isTimerifyFunctions, isMemoryUsageEnabled }: {
27
25
  isTimerifyFunctions?: boolean | undefined;
28
26
  isMemoryUsageEnabled?: boolean | undefined;
@@ -32,7 +30,7 @@ declare class Performance {
32
30
  private flush;
33
31
  private getPerfEntriesByName;
34
32
  getTimerifiedFunctionsTable(): string;
35
- addMemoryMark(index: number): void;
33
+ addMemoryMark(label: string): void;
36
34
  getMemoryUsageTable(): string;
37
35
  getCurrentDurationInMs(): number;
38
36
  getMemHeapUsage(): number;
@@ -1,4 +1,3 @@
1
- import os from 'node:os';
2
1
  import { PerformanceObserver, performance } from 'node:perf_hooks';
3
2
  import { memoryUsage } from 'node:process';
4
3
  import { parseArgs } from 'node:util';
@@ -24,12 +23,15 @@ export const timerify = (fn, name = fn.name) => {
24
23
  return fn;
25
24
  return performance.timerify(Object.defineProperty(fn, 'name', { get: () => name }));
26
25
  };
27
- const getMemInfo = () => Object.assign({ freemem: os.freemem() }, memoryUsage());
26
+ const getMemInfo = (label) => {
27
+ const usage = memoryUsage();
28
+ return { label, heapUsed: usage.heapUsed, heapTotal: usage.heapTotal, rss: usage.rss };
29
+ };
28
30
  const twoFixed = (value) => (typeof value === 'number' ? value.toFixed(2) : value);
29
31
  const inMB = (bytes) => bytes / 1024 / 1024;
30
- const keys = ['heapUsed', 'heapTotal', 'freemem'];
31
- const logHead = () => console.log(keys.map(key => key.padStart(10)).join(' '));
32
- const log = (memInfo) => console.log(keys.map(key => twoFixed(inMB(memInfo[key])).padStart(10)).join(' '));
32
+ const keys = ['heapUsed', 'heapTotal', 'rss'];
33
+ const logHead = () => console.log(['phase', ...keys].map(key => key.padStart(10)).join(' '));
34
+ const log = (memInfo) => console.log([memInfo.label.padStart(10), ...keys.map(key => twoFixed(inMB(memInfo[key])).padStart(10))].join(' '));
33
35
  class Performance {
34
36
  isEnabled;
35
37
  isTimerifyFunctions;
@@ -42,8 +44,6 @@ class Performance {
42
44
  memId;
43
45
  fnObserver;
44
46
  memObserver;
45
- memoryUsageStart;
46
- freeMemoryStart;
47
47
  constructor({ isTimerifyFunctions = false, isMemoryUsageEnabled = false }) {
48
48
  this.isEnabled = isTimerifyFunctions || isMemoryUsageEnabled;
49
49
  this.isTimerifyFunctions = isTimerifyFunctions;
@@ -69,7 +69,7 @@ class Performance {
69
69
  this.memObserver.observe({ type: 'mark' });
70
70
  if (isMemoryRealtime)
71
71
  logHead();
72
- this.addMemoryMark(0);
72
+ this.addMemoryMark('start');
73
73
  }
74
74
  }
75
75
  setMark(name) {
@@ -98,6 +98,7 @@ class Performance {
98
98
  }
99
99
  getTimerifiedFunctionsTable() {
100
100
  const entriesByName = this.getPerfEntriesByName();
101
+ const totalDuration = this.getCurrentDurationInMs();
101
102
  const table = new Table({ header: true });
102
103
  for (const [name, values] of Object.entries(entriesByName)) {
103
104
  const stats = getStats(values);
@@ -108,38 +109,53 @@ class Performance {
108
109
  table.cell('max', stats.max, twoFixed);
109
110
  table.cell('median', stats.median, twoFixed);
110
111
  table.cell('sum', stats.sum, twoFixed);
112
+ table.cell('%', (stats.sum / totalDuration) * 100, v => (typeof v === 'number' ? `${v.toFixed(0)}%` : ''));
111
113
  }
112
114
  table.sort('sum|desc');
113
115
  return table.toString();
114
116
  }
115
- addMemoryMark(index) {
117
+ addMemoryMark(label) {
116
118
  if (!this.isMemoryUsageEnabled)
117
119
  return;
118
- const id = `${this.memId}:${index}`;
119
- const detail = getMemInfo();
120
+ const id = `${this.memId}:${label}`;
121
+ const detail = getMemInfo(label);
120
122
  performance.mark(id, { detail });
121
- if (isMemoryRealtime && detail)
123
+ if (isMemoryRealtime)
122
124
  log(detail);
123
125
  }
124
126
  getMemoryUsageTable() {
125
127
  const table = new Table({ header: true });
126
- let i = 0;
128
+ let prevHeapUsed = 0;
129
+ let peakHeapUsed = 0;
130
+ let peakRss = 0;
127
131
  for (const entry of this.memEntries) {
128
132
  if (!entry.detail)
129
133
  continue;
134
+ const { label, heapUsed, rss } = entry.detail;
135
+ const delta = heapUsed - prevHeapUsed;
136
+ if (heapUsed > peakHeapUsed)
137
+ peakHeapUsed = heapUsed;
138
+ if (rss > peakRss)
139
+ peakRss = rss;
130
140
  table.row();
131
- table.cell('#', String(i++));
132
- table.cell('heapUsed', inMB(entry.detail.heapUsed), twoFixed);
133
- table.cell('heapTotal', inMB(entry.detail.heapTotal), twoFixed);
134
- table.cell('freemem', inMB(entry.detail.freemem), twoFixed);
141
+ table.cell('Phase', label);
142
+ table.cell('heapUsed', inMB(heapUsed), twoFixed);
143
+ table.cell('rss', inMB(rss), twoFixed);
144
+ table.cell('Δheap', prevHeapUsed === 0 ? '' : `${delta > 0 ? '+' : ''}${twoFixed(inMB(delta))}`, String);
145
+ prevHeapUsed = heapUsed;
135
146
  }
147
+ table.row();
148
+ table.cell('Phase', 'peak');
149
+ table.cell('heapUsed', inMB(peakHeapUsed), twoFixed);
150
+ table.cell('rss', inMB(peakRss), twoFixed);
151
+ table.cell('Δheap', '');
136
152
  return table.toString();
137
153
  }
138
154
  getCurrentDurationInMs() {
139
155
  return performance.now() - this.startTime;
140
156
  }
141
157
  getMemHeapUsage() {
142
- return (memoryUsage().heapUsed ?? 0) - (this.memoryUsageStart?.heapUsed ?? 0);
158
+ return memoryUsage().heapUsed;
143
159
  }
144
160
  getCurrentMemUsageInMb() {
145
161
  return twoFixed(inMB(this.getMemHeapUsage()));
@@ -147,6 +163,7 @@ class Performance {
147
163
  async finalize() {
148
164
  if (!this.isEnabled)
149
165
  return;
166
+ this.addMemoryMark('end');
150
167
  await this.flush();
151
168
  }
152
169
  reset() {
@@ -3,7 +3,7 @@ import { debugLog } from "./debug.js";
3
3
  import { fromBinary, isBinary, isConfig, isDeferResolve, isDeferResolveEntry, isDependency, toDebugString, } from "./input.js";
4
4
  import { getPackageNameFromSpecifier } from "./modules.js";
5
5
  import { dirname, isAbsolute, isInNodeModules, isInternal, join } from "./path.js";
6
- import { _resolveModuleSync, _resolveSync } from "./resolve.js";
6
+ import { resolveModuleSync, _resolveSync } from "./resolve.js";
7
7
  const isJoinable = (specifier) => {
8
8
  const char = specifier.charCodeAt(0);
9
9
  return char !== 35 && char !== 126 && char !== 64 && !isAbsolute(specifier);
@@ -84,7 +84,7 @@ export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, extern
84
84
  }
85
85
  const filePath = isJoinable(specifier) ? join(input.dir ?? dirname(containingFilePath), specifier) : specifier;
86
86
  const basePath = input.dir ? join(input.dir, 'file.ts') : containingFilePath;
87
- const resolvedFilePath = _resolveModuleSync(filePath, basePath);
87
+ const resolvedFilePath = resolveModuleSync(filePath, basePath);
88
88
  if (resolvedFilePath && isInternal(resolvedFilePath)) {
89
89
  return isGitIgnored(resolvedFilePath) ? undefined : resolvedFilePath;
90
90
  }
@@ -400,6 +400,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
400
400
  entry?: string | string[] | undefined;
401
401
  project?: string | string[] | undefined;
402
402
  } | undefined;
403
+ oxfmt?: string | boolean | string[] | {
404
+ config?: string | string[] | undefined;
405
+ entry?: string | string[] | undefined;
406
+ project?: string | string[] | undefined;
407
+ } | undefined;
403
408
  oxlint?: string | boolean | string[] | {
404
409
  config?: string | string[] | undefined;
405
410
  entry?: string | string[] | undefined;
@@ -1091,6 +1096,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1091
1096
  entry?: string | string[] | undefined;
1092
1097
  project?: string | string[] | undefined;
1093
1098
  } | undefined;
1099
+ oxfmt?: string | boolean | string[] | {
1100
+ config?: string | string[] | undefined;
1101
+ entry?: string | string[] | undefined;
1102
+ project?: string | string[] | undefined;
1103
+ } | undefined;
1094
1104
  oxlint?: string | boolean | string[] | {
1095
1105
  config?: string | string[] | undefined;
1096
1106
  entry?: string | string[] | undefined;
@@ -11,7 +11,6 @@ import { timerify } from "./Performance.js";
11
11
  import { parseAndConvertGitignorePatterns } from "./parse-and-convert-gitignores.js";
12
12
  import { dirname, join, relative, toPosix } from "./path.js";
13
13
  const walk = promisify(_walk);
14
- const _picomatch = timerify(picomatch);
15
14
  const cachedGitIgnores = new Map();
16
15
  const cachedGlobIgnores = new Map();
17
16
  const isGitRoot = (dir) => isDirectory(dir, '.git') || isFile(dir, '.git');
@@ -51,9 +50,18 @@ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
51
50
  const gitignoreFiles = [];
52
51
  const pmOptions = { ignore: unignores };
53
52
  let deepFilterMatcher;
53
+ let prevUnignoreLength = unignores.length;
54
+ const pendingIgnores = [];
54
55
  const getMatcher = () => {
55
- if (!deepFilterMatcher)
56
- deepFilterMatcher = _picomatch(Array.from(ignores), pmOptions);
56
+ if (!deepFilterMatcher) {
57
+ deepFilterMatcher = picomatch(Array.from(ignores), pmOptions);
58
+ pendingIgnores.length = 0;
59
+ }
60
+ else if (pendingIgnores.length > 0) {
61
+ const prev = deepFilterMatcher;
62
+ const incr = picomatch(pendingIgnores.splice(0), pmOptions);
63
+ deepFilterMatcher = (path) => prev(path) || incr(path);
64
+ }
57
65
  return deepFilterMatcher;
58
66
  };
59
67
  const addFile = (filePath, baseDir) => {
@@ -63,6 +71,7 @@ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
63
71
  const ancestor = base.startsWith('..') ? `${relative(dir, cwd)}/` : undefined;
64
72
  const ignoresForDir = new Set(base === '' ? GLOBAL_IGNORE_PATTERNS : []);
65
73
  const unignoresForDir = new Set();
74
+ const prevIgnoreSize = ignores.size;
66
75
  const patterns = readFileSync(filePath, 'utf8');
67
76
  for (const rule of parseAndConvertGitignorePatterns(patterns, ancestor)) {
68
77
  const [pattern, extraPattern] = rule.patterns;
@@ -112,7 +121,15 @@ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
112
121
  else {
113
122
  cachedGitIgnores.set(cacheDir, { ignores: ignoresForDir, unignores: unignoresForDir });
114
123
  }
115
- deepFilterMatcher = undefined;
124
+ if (unignores.length !== prevUnignoreLength) {
125
+ deepFilterMatcher = undefined;
126
+ prevUnignoreLength = unignores.length;
127
+ }
128
+ else if (ignores.size !== prevIgnoreSize) {
129
+ for (const p of ignoresForDir)
130
+ if (!GLOBAL_IGNORE_PATTERNS.includes(p))
131
+ pendingIgnores.push(p);
132
+ }
116
133
  };
117
134
  for (const filePath of findAncestorGitignoreFiles(cwd))
118
135
  addFile(filePath);
@@ -159,8 +176,8 @@ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
159
176
  const deepFilter = (entry) => (!isRelevantDir || isRelevantDir(toPosix(entry.path))) && !getMatcher()(relative(cwd, entry.path));
160
177
  await walk(cwd, {
161
178
  concurrency: 16,
162
- entryFilter: timerify(entryFilter),
163
- deepFilter: timerify(deepFilter),
179
+ entryFilter,
180
+ deepFilter,
164
181
  });
165
182
  debugLogObject('*', 'Parsed gitignore files', { gitignoreFiles });
166
183
  return { gitignoreFiles, ignores, unignores };
@@ -207,7 +224,15 @@ export async function getGitIgnoredHandler(options, workspaceDirs) {
207
224
  if (options.gitignore === false)
208
225
  return () => false;
209
226
  const { ignores, unignores } = await _parseFindGitignores(options.cwd, workspaceDirs);
210
- const matcher = _picomatch(Array.from(ignores), { ignore: unignores });
211
- const isGitIgnored = (filePath) => matcher(relative(options.cwd, filePath));
212
- return timerify(isGitIgnored);
227
+ const matcher = picomatch(Array.from(ignores), { ignore: unignores });
228
+ const cache = new Map();
229
+ const isGitIgnored = (filePath) => {
230
+ let result = cache.get(filePath);
231
+ if (result === undefined) {
232
+ result = matcher(relative(options.cwd, filePath));
233
+ cache.set(filePath, result);
234
+ }
235
+ return result;
236
+ };
237
+ return isGitIgnored;
213
238
  }
@@ -1,4 +1,3 @@
1
- import { isBuiltin } from 'node:module';
2
1
  import { DT_SCOPE, PROTOCOL_VIRTUAL } from "../constants.js";
3
2
  import { isAbsolute, isInNodeModules, toPosix } from "./path.js";
4
3
  export const getPackageNameFromModuleSpecifier = (moduleSpecifier) => {
@@ -53,7 +52,7 @@ const CHAR_COLON = 58;
53
52
  const CHAR_HASH = 35;
54
53
  const CHAR_QUESTION = 63;
55
54
  export const sanitizeSpecifier = (specifier) => {
56
- if (isBuiltin(specifier) ||
55
+ if (specifier.startsWith('node:') ||
57
56
  isAbsolute(specifier) ||
58
57
  specifier.charCodeAt(0) === CHAR_COLON ||
59
58
  specifier.startsWith(PROTOCOL_VIRTUAL)) {
package/dist/util/path.js CHANGED
@@ -5,7 +5,7 @@ export const dirname = path.posix.dirname;
5
5
  export const extname = path.posix.extname;
6
6
  export const basename = path.posix.basename;
7
7
  export const join = path.posix.join;
8
- export const toPosix = (value) => value.split(path.sep).join(path.posix.sep);
8
+ export const toPosix = isWin ? (value) => value.split(path.sep).join(path.posix.sep) : (value) => value;
9
9
  export const resolve = path.posix.resolve;
10
10
  export const relative = (from, to) => {
11
11
  if (to.startsWith(from)) {
@@ -1,5 +1,4 @@
1
1
  declare const createSyncModuleResolver: (extensions: string[]) => (specifier: string, basePath: string) => string | undefined;
2
- export declare const _resolveModuleSync: (specifier: string, basePath: string) => string | undefined;
3
- export declare const _createSyncModuleResolver: typeof createSyncModuleResolver;
2
+ export declare const resolveModuleSync: (specifier: string, basePath: string) => string | undefined;
3
+ export { createSyncModuleResolver };
4
4
  export declare const _resolveSync: (specifier: string, baseDir: string) => string | undefined;
5
- export {};
@@ -13,6 +13,7 @@ const createSyncModuleResolver = (extensions) => {
13
13
  '.cjs': ['.cjs', '.cts'],
14
14
  },
15
15
  conditionNames: ['require', 'import', 'node', 'default'],
16
+ nodePath: false,
16
17
  });
17
18
  return function resolveSync(specifier, basePath) {
18
19
  try {
@@ -23,13 +24,13 @@ const createSyncModuleResolver = (extensions) => {
23
24
  catch (_error) { }
24
25
  };
25
26
  };
26
- const resolveModuleSync = createSyncModuleResolver([...DEFAULT_EXTENSIONS, '.json', '.jsonc']);
27
- export const _resolveModuleSync = timerify(resolveModuleSync, 'resolveModuleSync');
28
- export const _createSyncModuleResolver = extensions => timerify(createSyncModuleResolver(extensions), 'resolveModuleSync');
27
+ export const resolveModuleSync = createSyncModuleResolver([...DEFAULT_EXTENSIONS, '.json', '.jsonc']);
28
+ export { createSyncModuleResolver };
29
29
  const createSyncResolver = (extensions) => {
30
30
  const resolver = new ResolverFactory({
31
31
  extensions,
32
32
  conditionNames: ['require', 'import', 'node', 'default'],
33
+ nodePath: false,
33
34
  });
34
35
  return function resolveSync(specifier, baseDir) {
35
36
  try {
@@ -30,9 +30,10 @@ export const getSessionHandler = async (options, { analyzedFiles, analyzeSourceF
30
30
  continue;
31
31
  switch (change.type) {
32
32
  case 'added':
33
- added.add(filePath);
34
33
  principal.addProjectPath(filePath);
35
34
  principal.deletedFiles.delete(filePath);
35
+ if (principal.projectPaths.has(filePath))
36
+ added.add(filePath);
36
37
  debugLog(workspace.name, `Watcher: + ${relativePath}`);
37
38
  break;
38
39
  case 'deleted':
@@ -106,8 +107,9 @@ export const getSessionHandler = async (options, { analyzedFiles, analyzeSourceF
106
107
  const workspace = chief.findWorkspaceByFilePath(filePath);
107
108
  if (workspace) {
108
109
  const principal = factory.getPrincipalByPackageName(workspace.pkgName);
109
- if (principal)
110
+ if (principal && (principal.projectPaths.has(filePath) || graph.has(filePath))) {
110
111
  analyzeSourceFile(filePath, principal);
112
+ }
111
113
  }
112
114
  }
113
115
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.86.0";
1
+ export declare const version = "5.87.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.86.0';
1
+ export const version = '5.87.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.86.0",
3
+ "version": "5.87.0",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "keywords": [
6
6
  "analysis",
package/schema.json CHANGED
@@ -628,6 +628,10 @@
628
628
  "title": "oxlint plugin configuration (https://knip.dev/reference/plugins/oxlint)",
629
629
  "$ref": "#/definitions/plugin"
630
630
  },
631
+ "oxfmt": {
632
+ "title": "oxfmt plugin configuration (https://knip.dev/reference/plugins/oxfmt)",
633
+ "$ref": "#/definitions/plugin"
634
+ },
631
635
  "payload": {
632
636
  "title": "payload plugin configuration (https://knip.dev/reference/plugins/payload)",
633
637
  "$ref": "#/definitions/plugin"
@@ -1,8 +0,0 @@
1
- type PluginRef = string | {
2
- name: string;
3
- };
4
- type Config = {
5
- plugins?: PluginRef[];
6
- };
7
- export type OpenApiTsConfig = Config | Config[];
8
- export {};
@@ -1 +0,0 @@
1
- export {};