knip 6.2.0 → 6.3.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.
@@ -527,6 +527,11 @@ export declare class ConfigurationChief {
527
527
  entry?: string | string[] | undefined;
528
528
  project?: string | string[] | undefined;
529
529
  } | undefined;
530
+ rolldown?: string | boolean | string[] | {
531
+ config?: string | string[] | undefined;
532
+ entry?: string | string[] | undefined;
533
+ project?: string | string[] | undefined;
534
+ } | undefined;
530
535
  rollup?: string | boolean | string[] | {
531
536
  config?: string | string[] | undefined;
532
537
  entry?: string | string[] | undefined;
@@ -880,6 +885,7 @@ export declare class ConfigurationChief {
880
885
  "release-it"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
881
886
  remark?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
882
887
  remix?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
888
+ rolldown?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
883
889
  rollup?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
884
890
  rsbuild?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
885
891
  rslib?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
@@ -187,12 +187,12 @@ export class DependencyDeputy {
187
187
  const referencedDependencies = this.referencedDependencies.get(workspace);
188
188
  const hasTypesIncluded = this.getHasTypesIncluded(workspace);
189
189
  const peeker = new PackagePeeker(manifestStr);
190
- const peerDepCount = {};
191
- const isReferencedDependency = (dependency, isPeerDep) => {
190
+ const isReferencedDependency = (dependency, visited = new Set()) => {
192
191
  if (referencedDependencies?.has(dependency))
193
192
  return true;
194
- if (isPeerDep && peerDepCount[dependency])
193
+ if (visited.has(dependency))
195
194
  return false;
195
+ visited.add(dependency);
196
196
  const [scope, typedDependency] = dependency.split('/');
197
197
  if (scope === DT_SCOPE) {
198
198
  const typedPackageName = getPackageFromDefinitelyTyped(typedDependency);
@@ -205,21 +205,15 @@ export class DependencyDeputy {
205
205
  ...this.getHostDependenciesFor(workspace, typedPackageName),
206
206
  ];
207
207
  if (hostDependencies.length)
208
- return !!hostDependencies.find(host => isReferencedDependency(host.name, true));
208
+ return !!hostDependencies.find(host => isReferencedDependency(host.name, visited));
209
209
  if (!referencedDependencies?.has(dependency))
210
210
  return false;
211
211
  return referencedDependencies.has(typedPackageName);
212
212
  }
213
213
  const hostDependencies = this.getHostDependenciesFor(workspace, dependency);
214
- for (const { name } of hostDependencies) {
215
- if (!peerDepCount[name])
216
- peerDepCount[name] = 1;
217
- else
218
- peerDepCount[name]++;
219
- }
220
- return hostDependencies.some(hostDependency => (isPeerDep === false || !hostDependency.isPeerOptional) && isReferencedDependency(hostDependency.name, true));
214
+ return hostDependencies.some(hostDependency => isReferencedDependency(hostDependency.name, visited));
221
215
  };
222
- const isNotReferencedDependency = (dependency) => !isReferencedDependency(dependency, false);
216
+ const isNotReferencedDependency = (dependency) => !isReferencedDependency(dependency);
223
217
  for (const symbol of this.getProductionDependencies(workspace).filter(isNotReferencedDependency)) {
224
218
  const position = peeker.getLocation('dependencies', symbol);
225
219
  dependencyIssues.push({ type: 'dependencies', workspace, filePath, symbol, fixes: [], ...position });
@@ -475,6 +475,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
475
475
  entry?: string | string[] | undefined;
476
476
  project?: string | string[] | undefined;
477
477
  } | undefined;
478
+ rolldown?: string | boolean | string[] | {
479
+ config?: string | string[] | undefined;
480
+ entry?: string | string[] | undefined;
481
+ project?: string | string[] | undefined;
482
+ } | undefined;
478
483
  rollup?: string | boolean | string[] | {
479
484
  config?: string | string[] | undefined;
480
485
  entry?: string | string[] | undefined;
@@ -1186,6 +1191,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
1186
1191
  entry?: string | string[] | undefined;
1187
1192
  project?: string | string[] | undefined;
1188
1193
  } | undefined;
1194
+ rolldown?: string | boolean | string[] | {
1195
+ config?: string | string[] | undefined;
1196
+ entry?: string | string[] | undefined;
1197
+ project?: string | string[] | undefined;
1198
+ } | undefined;
1189
1199
  rollup?: string | boolean | string[] | {
1190
1200
  config?: string | string[] | undefined;
1191
1201
  entry?: string | string[] | undefined;
@@ -175,11 +175,8 @@ export async function build({ chief, collector, counselor, deputy, principal, is
175
175
  const ws = (input.containingFilePath && chief.findWorkspaceByFilePath(input.containingFilePath)) || workspace;
176
176
  const resolvedFilePath = handleInput(input, ws);
177
177
  if (resolvedFilePath) {
178
- if (isDeferResolveProductionEntry(input)) {
179
- addPattern(productionPatternsSkipExports, input, resolvedFilePath);
180
- }
181
- else if (isDeferResolveEntry(input)) {
182
- if (!options.isProduction || !input.optional)
178
+ if (isDeferResolveEntry(input) && options.isProduction && !isDeferResolveProductionEntry(input)) {
179
+ if (!input.optional)
183
180
  addPattern(entryPatternsSkipExports, input, resolvedFilePath);
184
181
  }
185
182
  else {
@@ -98,6 +98,7 @@ export declare const Plugins: {
98
98
  'release-it': import("../types/config.ts").Plugin;
99
99
  remark: import("../types/config.ts").Plugin;
100
100
  remix: import("../types/config.ts").Plugin;
101
+ rolldown: import("../types/config.ts").Plugin;
101
102
  rollup: import("../types/config.ts").Plugin;
102
103
  rsbuild: import("../types/config.ts").Plugin;
103
104
  rslib: import("../types/config.ts").Plugin;
@@ -92,6 +92,7 @@ import { default as relay } from "./relay/index.js";
92
92
  import { default as releaseIt } from "./release-it/index.js";
93
93
  import { default as remark } from "./remark/index.js";
94
94
  import { default as remix } from "./remix/index.js";
95
+ import { default as rolldown } from "./rolldown/index.js";
95
96
  import { default as rollup } from "./rollup/index.js";
96
97
  import { default as rsbuild } from "./rsbuild/index.js";
97
98
  import { default as rslib } from "./rslib/index.js";
@@ -235,6 +236,7 @@ export const Plugins = {
235
236
  'release-it': releaseIt,
236
237
  remark,
237
238
  remix,
239
+ rolldown,
238
240
  rollup,
239
241
  rsbuild,
240
242
  rslib,
@@ -26,7 +26,7 @@ const resolveConfig = async (localConfig, options) => {
26
26
  routeConfig = await load(routesPathJs);
27
27
  }
28
28
  const mapRoute = (route) => {
29
- return [join(appDir, route.file), ...(route.children ? route.children.flatMap(mapRoute) : [])];
29
+ return [toAbsolute(route.file, appDir), ...(route.children ? route.children.flatMap(mapRoute) : [])];
30
30
  };
31
31
  const routes = routeConfig
32
32
  .flatMap(mapRoute)
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,19 @@
1
+ import { toProductionEntry } from "../../util/input.js";
2
+ import { hasDependency } from "../../util/plugin.js";
3
+ import { getInputFromAST } from "./resolveFromAST.js";
4
+ const title = 'Rolldown';
5
+ const enablers = ['rolldown'];
6
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
+ const config = ['rolldown.config.{js,cjs,mjs,ts,cts,mts}'];
8
+ const resolveFromAST = program => {
9
+ const inputs = getInputFromAST(program);
10
+ return [...inputs].map(id => toProductionEntry(id));
11
+ };
12
+ const plugin = {
13
+ title,
14
+ enablers,
15
+ isEnabled,
16
+ config,
17
+ resolveFromAST,
18
+ };
19
+ export default plugin;
@@ -0,0 +1,2 @@
1
+ import type { Program } from 'oxc-parser';
2
+ export declare const getInputFromAST: (program: Program) => Set<string>;
@@ -0,0 +1,4 @@
1
+ import { collectPropertyValues } from "../../typescript/ast-helpers.js";
2
+ export const getInputFromAST = (program) => {
3
+ return collectPropertyValues(program, 'input');
4
+ };
@@ -1,19 +1,26 @@
1
+ import { toProductionEntry } from "../../util/input.js";
1
2
  import { hasDependency } from "../../util/plugin.js";
3
+ import { getInputFromAST } from "./resolveFromAST.js";
2
4
  const title = 'Rollup';
3
5
  const enablers = ['rollup'];
4
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
- const entry = ['rollup.config.{js,cjs,mjs,ts}'];
7
+ const config = ['rollup.config.{js,cjs,mjs,ts}'];
6
8
  const args = {
7
9
  alias: { plugin: ['p'] },
8
10
  args: (args) => args.map(arg => (arg.startsWith('--watch.onEnd') ? `--_exec${arg.slice(13)}` : arg)),
9
11
  fromArgs: ['_exec'],
10
12
  resolve: ['plugin', 'configPlugin'],
11
13
  };
14
+ const resolveFromAST = program => {
15
+ const inputs = getInputFromAST(program);
16
+ return [...inputs].map(id => toProductionEntry(id));
17
+ };
12
18
  const plugin = {
13
19
  title,
14
20
  enablers,
15
21
  isEnabled,
16
- entry,
22
+ config,
17
23
  args,
24
+ resolveFromAST,
18
25
  };
19
26
  export default plugin;
@@ -0,0 +1,2 @@
1
+ import type { Program } from 'oxc-parser';
2
+ export declare const getInputFromAST: (program: Program) => Set<string>;
@@ -0,0 +1,4 @@
1
+ import { collectPropertyValues } from "../../typescript/ast-helpers.js";
2
+ export const getInputFromAST = (program) => {
3
+ return collectPropertyValues(program, 'input');
4
+ };
@@ -472,6 +472,11 @@ export declare const workspaceConfigurationSchema: z.ZodMiniObject<{
472
472
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
473
473
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
474
474
  }, z.core.$strip>]>>;
475
+ rolldown: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
476
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
477
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
478
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
479
+ }, z.core.$strip>]>>;
475
480
  rollup: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
476
481
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
477
482
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1194,6 +1199,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1194
1199
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1195
1200
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1196
1201
  }, z.core.$strip>]>>;
1202
+ rolldown: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1203
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1204
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1205
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1206
+ }, z.core.$strip>]>>;
1197
1207
  rollup: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1198
1208
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1199
1209
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1905,6 +1915,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1905
1915
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1906
1916
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1907
1917
  }, z.core.$strip>]>>;
1918
+ rolldown: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1919
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1920
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1921
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1922
+ }, z.core.$strip>]>>;
1908
1923
  rollup: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1909
1924
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1910
1925
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -476,6 +476,11 @@ export declare const pluginsSchema: z.ZodMiniObject<{
476
476
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
477
477
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
478
478
  }, z.core.$strip>]>;
479
+ rolldown: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
480
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
481
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
482
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
483
+ }, z.core.$strip>]>;
479
484
  rollup: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
480
485
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
481
486
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -104,6 +104,7 @@ export const pluginsSchema = z.object({
104
104
  'release-it': pluginSchema,
105
105
  remark: pluginSchema,
106
106
  remix: pluginSchema,
107
+ rolldown: pluginSchema,
107
108
  rollup: pluginSchema,
108
109
  rsbuild: pluginSchema,
109
110
  rslib: 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' | 'oxfmt' | 'oxlint' | 'parcel' | 'payload' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'qwik' | 'raycast' | 'react-cosmos' | 'react-native' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'sanity' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'stencil' | '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", "raycast", "react-cosmos", "react-native", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "sanity", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "stencil", "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' | 'raycast' | 'react-cosmos' | 'react-native' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rolldown' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'sanity' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'stencil' | '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", "raycast", "react-cosmos", "react-native", "react-router", "relay", "release-it", "remark", "remix", "rolldown", "rollup", "rsbuild", "rslib", "rspack", "rstest", "sanity", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "stencil", "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"];
@@ -93,6 +93,7 @@ export const pluginNames = [
93
93
  'release-it',
94
94
  'remark',
95
95
  'remix',
96
+ 'rolldown',
96
97
  'rollup',
97
98
  'rsbuild',
98
99
  'rslib',
@@ -32,21 +32,13 @@ export function handleCallExpression(node, s) {
32
32
  s.addImport(specifier, undefined, undefined, undefined, node.arguments[0].start, IMPORT_FLAGS.ENTRY);
33
33
  return;
34
34
  }
35
- if (node.callee.type === 'MemberExpression' &&
36
- node.callee.object.type === 'Identifier' &&
37
- node.callee.object.name === 'module' &&
38
- !node.callee.computed &&
39
- node.callee.property.name === 'register' &&
40
- node.arguments.length >= 1 &&
41
- isStringLiteral(node.arguments[0])) {
42
- const specifier = getStringValue(node.arguments[0]);
43
- if (specifier)
44
- s.addImport(specifier, undefined, undefined, undefined, node.arguments[0].start, IMPORT_FLAGS.ENTRY);
45
- return;
46
- }
47
35
  if (s.hasNodeModuleImport &&
48
- node.callee.type === 'Identifier' &&
49
- node.callee.name === 'register' &&
36
+ ((node.callee.type === 'MemberExpression' &&
37
+ node.callee.object.type === 'Identifier' &&
38
+ node.callee.object.name === 'module' &&
39
+ !node.callee.computed &&
40
+ node.callee.property.name === 'register') ||
41
+ (node.callee.type === 'Identifier' && node.callee.name === 'register')) &&
50
42
  node.arguments.length >= 1 &&
51
43
  isStringLiteral(node.arguments[0])) {
52
44
  const specifier = getStringValue(node.arguments[0]);
@@ -104,7 +96,7 @@ export function handleCallExpression(node, s) {
104
96
  }
105
97
  else if (arg.type === 'ObjectExpression') {
106
98
  for (const prop of arg.properties ?? []) {
107
- if (prop.type === 'Property' && prop.shorthand && prop.value?.type === 'Identifier')
99
+ if (prop.type === 'Property' && !prop.computed && prop.value?.type === 'Identifier')
108
100
  markRefIfNs(prop.value.name);
109
101
  if (prop.type === 'SpreadElement' && prop.argument?.type === 'Identifier')
110
102
  markRefIfNs(prop.argument.name);
@@ -160,18 +160,22 @@ export function handleVariableDeclarator(node, s) {
160
160
  }
161
161
  }
162
162
  }
163
- if (prop.type === 'Property' && prop.shorthand && prop.value?.type === 'Identifier') {
164
- const _import = s.localImportMap.get(prop.value.name);
163
+ if (prop.type === 'Property' &&
164
+ !prop.computed &&
165
+ prop.value?.type === 'Identifier' &&
166
+ prop.key?.type === 'Identifier') {
167
+ const nsName = prop.value.name;
168
+ const _import = s.localImportMap.get(nsName);
165
169
  if (_import?.isNamespace) {
166
170
  const internalImport = s.internal.get(_import.filePath);
167
171
  if (internalImport)
168
- internalImport.refs.add(prop.value.name);
169
- let set = s.shorthandNsContainers.get(aliasName);
170
- if (!set) {
171
- set = new Set();
172
- s.shorthandNsContainers.set(aliasName, set);
172
+ internalImport.refs.add(nsName);
173
+ let map = s.nsContainers.get(aliasName);
174
+ if (!map) {
175
+ map = new Map();
176
+ s.nsContainers.set(aliasName, map);
173
177
  }
174
- set.add(prop.value.name);
178
+ map.set(prop.key.name, nsName);
175
179
  }
176
180
  }
177
181
  }
@@ -130,8 +130,9 @@ export function handleMemberExpression(node, s) {
130
130
  node.object.object.type === 'Identifier' &&
131
131
  node.object.property.type === 'Identifier') {
132
132
  const containerName = node.object.object.name;
133
- const nsName = node.object.property.name;
134
- if (s.shorthandNsContainers.get(containerName)?.has(nsName)) {
133
+ const propKey = node.object.property.name;
134
+ const nsName = s.nsContainers.get(containerName)?.get(propKey);
135
+ if (nsName) {
135
136
  const _import = s.localImportMap.get(nsName);
136
137
  if (_import) {
137
138
  const internalImport = s.internal.get(_import.filePath);
@@ -143,7 +144,7 @@ export function handleMemberExpression(node, s) {
143
144
  memberName = getStringValue(node.property);
144
145
  if (memberName) {
145
146
  s.addNsMemberRefs(internalImport, nsName, memberName);
146
- s.accessedShorthandNs.add(`${containerName}.${nsName}`);
147
+ s.accessedNsContainers.add(`${containerName}.${propKey}`);
147
148
  }
148
149
  }
149
150
  }
@@ -46,8 +46,8 @@ export interface WalkState extends WalkContext {
46
46
  handledImportExpressions: Set<number>;
47
47
  bareExprRefs: Set<string>;
48
48
  accessedAliases: Set<string>;
49
- shorthandNsContainers: Map<string, Set<string>>;
50
- accessedShorthandNs: Set<string>;
49
+ nsContainers: Map<string, Map<string, string>>;
50
+ accessedNsContainers: Set<string>;
51
51
  chainedMemberExprs: WeakSet<object>;
52
52
  currentVarDeclStart: number;
53
53
  nsRanges: [number, number][];
@@ -641,8 +641,8 @@ export function walkAST(program, sourceText, filePath, ctx) {
641
641
  handledImportExpressions: new Set(),
642
642
  bareExprRefs: new Set(),
643
643
  accessedAliases: new Set(),
644
- shorthandNsContainers: new Map(),
645
- accessedShorthandNs: new Set(),
644
+ nsContainers: new Map(),
645
+ accessedNsContainers: new Set(),
646
646
  chainedMemberExprs: new WeakSet(),
647
647
  currentVarDeclStart: -1,
648
648
  nsRanges: [],
@@ -682,9 +682,9 @@ export function walkAST(program, sourceText, filePath, ctx) {
682
682
  }
683
683
  }
684
684
  }
685
- for (const [containerName, nsSet] of state.shorthandNsContainers) {
686
- for (const nsName of nsSet) {
687
- if (!state.accessedShorthandNs.has(`${containerName}.${nsName}`)) {
685
+ for (const [containerName, propMap] of state.nsContainers) {
686
+ for (const [propKey, nsName] of propMap) {
687
+ if (!state.accessedNsContainers.has(`${containerName}.${propKey}`)) {
688
688
  const _import = state.localImportMap.get(nsName);
689
689
  if (_import) {
690
690
  const internalImport = state.internal.get(_import.filePath);
@@ -512,6 +512,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
512
512
  entry?: string | string[] | undefined;
513
513
  project?: string | string[] | undefined;
514
514
  } | undefined;
515
+ rolldown?: string | boolean | string[] | {
516
+ config?: string | string[] | undefined;
517
+ entry?: string | string[] | undefined;
518
+ project?: string | string[] | undefined;
519
+ } | undefined;
515
520
  rollup?: string | boolean | string[] | {
516
521
  config?: string | string[] | undefined;
517
522
  entry?: string | string[] | undefined;
@@ -1223,6 +1228,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1223
1228
  entry?: string | string[] | undefined;
1224
1229
  project?: string | string[] | undefined;
1225
1230
  } | undefined;
1231
+ rolldown?: string | boolean | string[] | {
1232
+ config?: string | string[] | undefined;
1233
+ entry?: string | string[] | undefined;
1234
+ project?: string | string[] | undefined;
1235
+ } | undefined;
1226
1236
  rollup?: string | boolean | string[] | {
1227
1237
  config?: string | string[] | undefined;
1228
1238
  entry?: string | string[] | undefined;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "6.2.0";
1
+ export declare const version = "6.3.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '6.2.0';
1
+ export const version = '6.3.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "6.2.0",
3
+ "version": "6.3.1",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "keywords": [
6
6
  "analysis",
@@ -118,13 +118,13 @@
118
118
  "test": "node scripts/run-test.ts",
119
119
  "test:node": "tsx --test test/*.test.ts test/**/*.test.ts",
120
120
  "test:bun": "bun test test/*.test.ts test/**/*.test.ts",
121
- "test:smoke": "glob-bin -c \"tsx --test\" \"test/*.test.ts\" && glob-bin -c \"tsx --test\" \"test/{plugins,util}/*.test.ts\"",
121
+ "test:smoke": "glob-bin -c \"tsx --test\" \"test/*.test.ts\" && glob-bin -c \"tsx --test\" \"test/plugins/*.test.ts\" && glob-bin -c \"tsx --test\" \"test/util/*.test.ts\"",
122
122
  "test:bun:smoke": "bun test test/*.test.ts test/{plugins,util}/*.test.ts",
123
123
  "watch": "npm link && tsc --watch",
124
124
  "prebuild": "pnpm run generate-plugin-defs && node rmdir.js dist",
125
125
  "build": "tsc",
126
126
  "qa": "pnpm lint && pnpm build && pnpm knip && pnpm knip:production && pnpm run test",
127
- "release": "release-it",
127
+ "release": "NODE_OPTIONS=--no-deprecation release-it",
128
128
  "create-plugin": "node ./scripts/create-new-plugin.ts",
129
129
  "postcreate-plugin": "pnpm run build && (oxfmt schema.json schema-jsonc.json src/schema/plugins.ts || true)",
130
130
  "generate-plugin-defs": "node ./scripts/generate-plugin-defs.js && (oxfmt src/plugins/index.ts src/types/PluginNames.ts src/schema/plugins.ts || true)"
package/schema.json CHANGED
@@ -616,22 +616,22 @@
616
616
  "title": "nyc plugin configuration (https://knip.dev/reference/plugins/nyc)",
617
617
  "$ref": "#/definitions/plugin"
618
618
  },
619
- "openapi-ts": {
620
- "title": "openapi-ts plugin configuration (https://knip.dev/reference/plugins/openapi-ts)",
621
- "$ref": "#/definitions/plugin"
622
- },
623
619
  "oclif": {
624
620
  "title": "oclif plugin configuration (https://knip.dev/reference/plugins/oclif)",
625
621
  "$ref": "#/definitions/plugin"
626
622
  },
627
- "oxlint": {
628
- "title": "oxlint plugin configuration (https://knip.dev/reference/plugins/oxlint)",
623
+ "openapi-ts": {
624
+ "title": "openapi-ts plugin configuration (https://knip.dev/reference/plugins/openapi-ts)",
629
625
  "$ref": "#/definitions/plugin"
630
626
  },
631
627
  "oxfmt": {
632
628
  "title": "oxfmt plugin configuration (https://knip.dev/reference/plugins/oxfmt)",
633
629
  "$ref": "#/definitions/plugin"
634
630
  },
631
+ "oxlint": {
632
+ "title": "oxlint plugin configuration (https://knip.dev/reference/plugins/oxlint)",
633
+ "$ref": "#/definitions/plugin"
634
+ },
635
635
  "payload": {
636
636
  "title": "payload plugin configuration (https://knip.dev/reference/plugins/payload)",
637
637
  "$ref": "#/definitions/plugin"
@@ -704,6 +704,10 @@
704
704
  "title": "Remix plugin configuration (https://knip.dev/reference/plugins/remix)",
705
705
  "$ref": "#/definitions/plugin"
706
706
  },
707
+ "rolldown": {
708
+ "title": "rolldown plugin configuration (https://knip.dev/reference/plugins/rolldown)",
709
+ "$ref": "#/definitions/plugin"
710
+ },
707
711
  "rollup": {
708
712
  "title": "Rollup plugin configuration (https://knip.dev/reference/plugins/rollup)",
709
713
  "$ref": "#/definitions/plugin"