fix: Windows build — decouple tsc from optional transformers dep#274
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThree files replace inline ChangesAvoid tsc compile-time resolution of
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage ReportScope: files changed in this PR. Enforced threshold: 90% per metric (per file via
File Coverage — 1 file changed
Generated for commit 3017504. |
Problem
The Windows smoke CI job has been red since
cdc4ed83moved@huggingface/transformerstooptionalDependencies. On Windows the optional native package doesn't install, andnpm installfires thepreparehook (husky && npm run build) →tsc, which fails:Root cause: the typecheck hard-depends on an optional, on-demand package.
type TransformersModule = typeof import("@huggingface/transformers")and literalimport("@huggingface/transformers")calls forcetscto resolve the module at compile time, even though it's only installed byhivemind embeddings installand is absent on some platforms.Fix (at the source, not the CI)
nomic.ts: replacetypeof import(...)with a localinterface TransformersModuledescribing only what the wrapper uses (env,pipeline). The runtime bare-specifier import uses a non-literalstringspecifier sotsctreats it as a dynamicanyimport and doesn't resolve the package.import(...)calls;vi.mock("@huggingface/transformers", ...)still intercepts them at runtime by resolved module id.No runtime behavior change — the daemon still resolves and loads the real package via the canonical shared-deps path and bare fallback exactly as before.
Verification (real, local)
Reproduced the Windows condition on Linux by removing
node_modules/@huggingface/transformers:tsc --noEmit→ the TS2307 errors above.tsc --noEmit→ passes with the package absent.embeddings-nomic.test.ts→ 24/24 pass (mock interception via the dynamic import still works). Fullnpm run buildgreen.Summary by CodeRabbit
Refactor
Tests