Make typescript an optional peer dependency and load TS/Vue detectives lazily - #164
Open
veksa wants to merge 1 commit into
Open
Make typescript an optional peer dependency and load TS/Vue detectives lazily#164veksa wants to merge 1 commit into
typescript an optional peer dependency and load TS/Vue detectives lazily#164veksa wants to merge 1 commit into
Conversation
veksa
force-pushed
the
typescript-optional-peer
branch
2 times, most recently
from
August 14, 2026 08:19
e9884ab to
dd31d93
Compare
veksa
force-pushed
the
typescript-optional-peer
branch
from
August 14, 2026 08:43
dd31d93 to
13d1ad4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
precinct never imports typescript itself — it's there only to satisfy detective-typescript and detective-vue2, which both declare it as a peer (^5.4.4 || ^6.0.2). Pinning it in dependencies breaks dedup: anything outside ^6.0.3 gets a second copy of the compiler under node_modules/precinct. On a project with typescript@5.9.3 that's 63 MB → 40 MB. So it's an optional peer now.
The TS and Vue detectives load on demand — they pull in the TypeScript and Vue SFC compilers, which nobody parsing plain JS needs. require(ESM) keeps precinct() synchronous. Import: 420 ms / 113 MB → 104 ms / 57 MB.
If typescript is missing or unusable, the detective's load failure is rewritten into a readable error (ERR_TYPESCRIPT_UNAVAILABLE, original kept as cause) instead of dying inside @typescript-eslint — typescript@7 is a rewrite with no createCompilerHost / resolveModuleName / ModuleKind, and today it surfaces as "Cannot read properties of undefined (reading 'Cjs')". The range quoted in the message is read from peerDependencies.
Breaking: analyzing .ts/.tsx/.vue means installing typescript yourself.