feat: add instrumentation-client support#679
Conversation
commit: |
|
/bigbonk review |
There was a problem hiding this comment.
Review: instrumentation-client support
Well-structured PR — the architecture is clean: separate state module to avoid circular imports, virtual module aliasing to swap in the user's file or an empty fallback, and the dev-only timing plugin. Test coverage is solid across App Router, Pages Router, and src/ directory layouts, with E2E tests ported from Next.js.
A few things to address:
Issues
-
empty-module.tsproduces{}, notnull— Theinstrumentation-client.tsbridge castsinstrumentationClientHooks as ClientInstrumentationHooks | null, butimport * as x from "empty-module"yields{}, nevernull. Functionally harmless (optional chaining handles it), but the type cast is misleading. Consider checking for an empty namespace instead. -
onRouterTransitionStartmissing for Pages Router Link navigations — Inlink.tsx, the hook only fires inside the App Router branch (__VINEXT_RSC_NAVIGATE__). Pages Router Link clicks go through theRouter.push/Router.replacepath without callingonRouterTransitionStart. This may be intentional (Next.js'sonRouterTransitionStartis likely App Router-only), but if so, worth a comment. -
Duplicate
optimizeDeps.entriescomputation for Pages Router + Cloudflare — Theelse if (hasCloudflarePlugin)branch setsenvironments.client.optimizeDeps.entries, then theif (!hasAppDir)block below also setsviteConfig.optimizeDeps.entrieswith identical values. The top-leveloptimizeDepshas no effect when environment-level config is present for that environment, so this is a no-op duplication. Consider extracting the entries computation or guarding the fallback block. -
Fixture
vite.config.tsimports changed from"vinext"to source paths — Bothapp-basicandpages-basicnow import from"../../../packages/vinext/src/index.js"instead of"vinext". This diverges from how the other existing fixtures work and adds the need fortscin the Playwright server commands. Was this intentional, or a debugging artifact? If needed for the new files to be picked up, it should be documented.
Nits
-
The
onRouterTransitionStarthelper function is duplicated identically inlink.tsx:126-131andnavigation.ts:516-521. Consider extracting it intoinstrumentation-client-state.tsas a convenience wrapper. -
The
app-with-srcPlaywright project doesn't have atestMatchproperty, so it uses the defaulttestDirmatching. This is fine sincetestDiris set to./tests/e2e/app-with-src, but noting it differs from the pattern used by other projects.
|
Review posted successfully. Here's a summary of the feedback: Key issues flagged:
Nits: Duplicated |
|
resolved |
|
/bigbonk review |
There was a problem hiding this comment.
Review: instrumentation-client support
Clean architecture — the state module split avoids circular imports, normalizeClientInstrumentationHooks properly filters for the actual export rather than relying on type casts, and the virtual module aliasing via private-next-instrumentation-client is a solid pattern. The notifyAppRouterTransitionStart helper centralizes the hook invocation well, and the call sites in link.tsx, navigation.ts, and app-browser-entry.ts cover push, replace, and traverse without double-firing.
Test coverage is strong: unit tests for file discovery, integration tests for optimizeDeps.entries, E2E tests for timing guarantees, navigation hooks, HMR reload, and src/ directory layout. All ported from Next.js with proper attribution.
One issue to address and a few nits below.
|
Review submitted. Here's a summary of the feedback: Overall: Well-structured PR. The architecture is clean — separate state module to avoid circular imports, Comments posted:
|
|
resolved |
|
/bigbonk review |
There was a problem hiding this comment.
Review: instrumentation-client support
Clean PR overall. The architecture is well-structured — the state module split avoids circular imports, normalizeClientInstrumentationHooks correctly filters for actual function exports (addressing the earlier empty-module → {} concern), and the virtual module aliasing via private-next-instrumentation-client is solid. Test coverage is strong across App Router, Pages Router, and src/ directory layouts, with proper Next.js test suite attribution.
Two issues and two nits below.
|
Review submitted. Here's a summary of the feedback I posted: Issues:
Nits:
|
|
resolved |
No description provided.