knip 5.44.2 → 5.44.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.
@@ -205,7 +205,7 @@ export class ConfigurationChief {
205
205
  }
206
206
  getIncludedWorkspaces() {
207
207
  if (this.workspace) {
208
- const dir = resolve(this.workspace);
208
+ const dir = resolve(this.cwd, this.workspace);
209
209
  if (!isDirectory(dir))
210
210
  throw new ConfigurationError('Workspace is not a directory');
211
211
  if (!isFile(join(dir, 'package.json')))
@@ -50,7 +50,7 @@ export declare class ProjectPrincipal {
50
50
  getUsedResolvedFiles(): string[];
51
51
  private getProgramSourceFiles;
52
52
  getUnreferencedFiles(): string[];
53
- analyzeSourceFile(filePath: string, options: Omit<GetImportsAndExportsOptions, 'skipExports'>, isGitIgnored: (filePath: string) => boolean, isPackageNameInternalWorkspace: (packageName: string) => boolean, getPrincipalByFilePath: (filePath: string) => undefined | ProjectPrincipal): FileNode;
53
+ analyzeSourceFile(filePath: string, options: Omit<GetImportsAndExportsOptions, 'skipExports'>, isGitIgnored: (filePath: string) => boolean, isInternalWorkspace: (packageName: string) => boolean, getPrincipalByFilePath: (filePath: string) => undefined | ProjectPrincipal): FileNode;
54
54
  invalidateFile(filePath: string): void;
55
55
  findUnusedMembers(filePath: string, members: ExportMember[]): ExportMember[];
56
56
  hasExternalReferences(filePath: string, exportedItem: Export): boolean;
@@ -143,7 +143,7 @@ export class ProjectPrincipal {
143
143
  const sourceFiles = this.getProgramSourceFiles();
144
144
  return Array.from(this.projectPaths).filter(filePath => !sourceFiles.has(filePath));
145
145
  }
146
- analyzeSourceFile(filePath, options, isGitIgnored, isPackageNameInternalWorkspace, getPrincipalByFilePath) {
146
+ analyzeSourceFile(filePath, options, isGitIgnored, isInternalWorkspace, getPrincipalByFilePath) {
147
147
  const fd = this.cache.getFileDescriptor(filePath);
148
148
  if (!fd.changed && fd.meta?.data)
149
149
  return fd.meta.data;
@@ -160,7 +160,7 @@ export class ProjectPrincipal {
160
160
  const unresolvedImports = new Set();
161
161
  for (const [specifier, specifierFilePath] of specifiers) {
162
162
  const packageName = getPackageNameFromModuleSpecifier(specifier);
163
- if (packageName && isPackageNameInternalWorkspace(packageName)) {
163
+ if (packageName && isInternalWorkspace(packageName)) {
164
164
  external.add(packageName);
165
165
  const principal = getPrincipalByFilePath(specifierFilePath);
166
166
  if (principal && !isGitIgnored(specifierFilePath))
@@ -172,7 +172,7 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
172
172
  const analyzedFiles = new Set();
173
173
  const unreferencedFiles = new Set();
174
174
  const entryPaths = new Set();
175
- const isPackageNameInternalWorkspace = (packageName) => chief.availableWorkspacePkgNames.has(packageName);
175
+ const isInternalWorkspace = (packageName) => chief.availableWorkspacePkgNames.has(packageName);
176
176
  const getPrincipalByFilePath = (filePath) => {
177
177
  const workspace = chief.findWorkspaceByFilePath(filePath);
178
178
  if (workspace)
@@ -191,7 +191,7 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
191
191
  ignoreExportsUsedInFile: chief.config.ignoreExportsUsedInFile,
192
192
  isReportClassMembers,
193
193
  tags,
194
- }, isGitIgnored, isPackageNameInternalWorkspace, getPrincipalByFilePath);
194
+ }, isGitIgnored, isInternalWorkspace, getPrincipalByFilePath);
195
195
  const node = getOrCreateFileNode(graph, filePath);
196
196
  node.imports = imports;
197
197
  node.exports = exports;
@@ -1,8 +1,3 @@
1
- import type { PackageJson } from '../types/package-json.js';
2
- interface Package {
3
- manifest: PackageJson;
4
- dir: string;
5
- }
1
+ import type { WorkspacePackage } from '../types/package-json.js';
6
2
  export type WorkspaceGraph = Record<string, Set<string>>;
7
- export declare function createWorkspaceGraph(cwd: string, wsNames: string[], wsPkgNames: Set<string>, wsPackages: Map<string, Package>): WorkspaceGraph;
8
- export {};
3
+ export declare function createWorkspaceGraph(cwd: string, wsNames: string[], wsPkgNames: Set<string>, wsPackages: Map<string, WorkspacePackage>): WorkspaceGraph;
@@ -2,13 +2,14 @@ import { join } from './path.js';
2
2
  const types = ['peerDependencies', 'devDependencies', 'optionalDependencies', 'dependencies'];
3
3
  export function createWorkspaceGraph(cwd, wsNames, wsPkgNames, wsPackages) {
4
4
  const graph = {};
5
- const getWorkspaceDirs = (pkg, name) => {
5
+ const packages = Array.from(wsPackages.values());
6
+ const getWorkspaceDirs = (pkg) => {
6
7
  const dirs = new Set();
7
8
  for (const type of types) {
8
9
  if (pkg.manifest[type]) {
9
10
  for (const pkgName in pkg.manifest[type]) {
10
11
  if (wsPkgNames.has(pkgName)) {
11
- const wsPackage = wsPackages.get(name);
12
+ const wsPackage = packages.find(pkg => pkg.pkgName === pkgName);
12
13
  if (wsPackage)
13
14
  dirs.add(wsPackage.dir);
14
15
  }
@@ -20,7 +21,7 @@ export function createWorkspaceGraph(cwd, wsNames, wsPkgNames, wsPackages) {
20
21
  for (const name of wsNames) {
21
22
  const pkg = wsPackages.get(name);
22
23
  if (pkg)
23
- graph[join(cwd, name)] = getWorkspaceDirs(pkg, name);
24
+ graph[join(cwd, name)] = getWorkspaceDirs(pkg);
24
25
  }
25
26
  return graph;
26
27
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.44.2";
1
+ export declare const version = "5.44.3";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.44.2';
1
+ export const version = '5.44.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.44.2",
3
+ "version": "5.44.3",
4
4
  "description": "Find and fix unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {