Skip to content

[BUG] Fix JSONC parsing for TS configs and wildcard package export resolution #3317

Description

@rudrakshtank

Bug Description

The dependency checker script contains two major flaws causing false positives for valid imports:

Strict JSON Parsing for Configs: It uses standard JSON.parse to read tsconfig.json and jsconfig.json. Since TypeScript configuration files commonly contain comments and trailing commas (JSONC), JSON.parse crashes. This causes the script to silently fail internal alias resolution, subsequently flagging valid local alias imports (e.g., @/components/Button) as missing third-party dependencies.

Incomplete Subpath Exports Resolution: The isValidPackageSubpath function does not correctly handle advanced wildcard exports (e.g., "./utils/*") or root conditional exports (e.g., "exports": { "import": "...", "require": "..." }). This causes valid deep imports from modern third-party modules to be incorrectly marked as invalid/missing.

Steps to Reproduce

Create a tsconfig.json with standard comments (often auto-generated by Next.js) and custom path aliases.

Import a local file using a path alias (e.g., import Utils from "@/utils/helpers").

Run the script; observe it incorrectly flags @/utils/helpers as a missing dependency because it failed to load the tsconfig aliases.

Install a modern package with specific wildcard exports (like "exports": { "./features/": "./dist/features/.js" }) or root conditions.

Import from it (import { x } from 'pkg/features/auth').

Run the script; observe it incorrectly flags the valid subpath as missing.

Affected Area

Other

Screenshots

No response

Browser & OS

No response

Environment

None

Additional Context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggssoc:assignedGSSoC: Issue assigned to a contributorneeds-triageNeeds maintainer triage

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions