Skip to content

Make typescript an optional peer dependency and load TS/Vue detectives lazily - #164

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

Make typescript an optional peer dependency and load TS/Vue detectives lazily#164
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

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.

@veksa
veksa force-pushed the typescript-optional-peer branch 2 times, most recently from e9884ab to dd31d93 Compare August 14, 2026 08:19
@veksa
veksa force-pushed the typescript-optional-peer branch from dd31d93 to 13d1ad4 Compare August 14, 2026 08:43
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