Skip to content

Make typescript an optional peer dependency - #224

Open
veksa wants to merge 1 commit into
dependents:mainfrom
veksa:typescript-optional-peer
Open

Make typescript an optional peer dependency#224
veksa wants to merge 1 commit into
dependents:mainfrom
veksa:typescript-optional-peer

Conversation

@veksa

@veksa veksa commented Aug 13, 2026

Copy link
Copy Markdown

dependency-tree pins typescript in dependencies, which breaks dedup: anyone whose TypeScript falls outside ^6.0.3 gets an extra copy of the compiler nested inside node_modules/dependency-tree. On a project with typescript@5.9.3 that's 114 MB → 91 MB.

typescript is only needed here to pre-parse a tsConfig given as a path, and it is already required lazily, so the peer is marked optional. The require goes through a loadTypeScript() helper that reports a missing peer dependency, or one that no longer carries the config-parsing API, instead of failing on an undefined property. That matters for typescript@7, which is already the latest tag and is a rewrite without readJsonConfigFile or parseJsonSourceFileConfigFileContent. No version is inspected anywhere; the range in package.json matches what detective-typescript and detective-vue2 already declare.

One related fix in index.js: getDependencies() swallows everything precinct throws and returns an empty list, which is right for a file that fails to parse but wrong for a missing peer dependency — that silently produced an empty tree instead of an error. Errors tagged ERR_TYPESCRIPT_UNAVAILABLE are now rethrown. Unrelated parse failures behave exactly as before, and there's a test pinning that down.

@veksa
veksa force-pushed the typescript-optional-peer branch from c672b23 to 63cb128 Compare August 14, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant