Skip to content

Commit

Permalink
Try harder to resolve package name
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Sep 23, 2024
1 parent e2bdb95 commit 1e64b6c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/knip/src/typescript/get-imports-and-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ const getImportsAndExports = (
if (module.isExternalLibraryImport) {
if (skipTypeOnly && isTypeOnly) return;

const sanitizedSpecifier = isInNodeModules(specifier)
? getPackageNameFromFilePath(specifier)
: sanitizeSpecifier(specifier);
const sanitizedSpecifier = sanitizeSpecifier(
isInNodeModules(specifier) || isInNodeModules(filePath) ? getPackageNameFromFilePath(specifier) : specifier
);

if (!isStartsLikePackageName(sanitizedSpecifier)) {
// Import maps and other exceptions, examples from tests: #dep, #internals/used, $app/stores
Expand Down

0 comments on commit 1e64b6c

Please sign in to comment.