You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lazy relative require of source modules fails under vitest #2217
Under vitest, a lazy createRequire(import.meta.url)("./x.js") in CLI source loads its target outside Vite's module graph, through Node's native loader. Native resolution can't map the target's own .js imports to .ts files, so the load fails. The CLI tests hide this today because test/preload.ts sets SENTRY_CLI_NO_TELEMETRY=1, and the main case, db/index.ts requiring ../telemetry.js, only runs with telemetry on.
Why: the require-js-to-ts plugin in packages/cli/vitest.config.ts rewrites only the top-level require("./x.js") to an absolute .ts path. Node then loads that file natively (type stripping and require(esm)), and its static .js imports go through Node's resolver, not Vite's.
Consequence (inference): even when the load succeeds, the required module is a different instance from the one the test imported through Vite. Spies such as vi.spyOn(Sentry, "startSpan") would not see its calls.
Other lazy relative requires of source modules in packages/cli/src:db/resilient.ts → ./index.js, and formatters/json.ts → ../../generated/field-list-grammar.js (a generated .js leaf).
Activity
linear-code commentedon Nov 12, 2026
MCP-1219
fix(cli): Load lazy relative requires through Vite's module graph in …