0
Fork 0
mirror of https://github.com/TanStack/router.git synced 2026-11-16 19:38:07 +00:00

test(start-plugin-core): Vite dev import protection gaps (onViolation, start entry, split routes, non-JS modules, edits, traces)

Dev server tests (tests/importProtection/dev.test.ts):
- onViolation that returns nothing keeps the warning; with behavior
  "error", an onViolation that does not return false does not allow the
  import (denied file and specifier).
- A denied import reached only from the start entry (src/start.ts) is
  mocked and logged.
- A split route component using a denied file, directly or through a module
  only the split module imports, is mocked and logged at each use (Start's
  whole plugin).
- An .mdx module (stand-in compiler plugin) importing a denied file, directly
  or through a module, is mocked and logged at each importer.
- A denied specifier added to an importer by an edit is a mock the edited
  module can import.
- An edit of a CSS module and a JSON module updates without an HMR error.
- A use of a specifier denied by a custom pattern rule in a JSX module is
  located on its source line.
- Full-bundle dev (bundledDev): denied imports are mocked in the client
  bundle and logged (no import-protection test covered bundledDev).
- With maxTraceDepth, the trace ends at the importer, each step naming the
  import of the next.
- Control: a module the client loads after the server rendered is logged.
start-apps.ts: startProtectedDevServer gains an additive `bundledDev` option.

Pins (test.fails, NEW main bugs):
- Dev ignores maxTraceDepth: the module graph trace replaces the cut trace
  (vite/import-protection-plugin/plugin.ts rebuildAndAnnotateTrace).
- Dev: an .mdx (non-JS) module importing a denied specifier fails to load
  with "[vite] The "code" property of ModuleInfo is not supported."
  (resolveExportsForDeniedSpecifier falls back to getModuleInfo().code).
- With server.perEnvironmentStartEndDuringDev, the first request of another
  environment clears every environment's state (buildStart clearEnvState),
  so violations of modules the client loads afterwards are discarded.

Kills: spc:4741, 4763, 4524, 4639, 4579, 4609, 4611, 4174, 4182, 4529,
4530, 4536, 4542, 4510, 4551, 4552, 4553, 4556, 4497, 4494, 4474, 4484,
4037, 4043, 4045, 4047, 4049, 4052, 4054, 4056, 4059, 4070, 4071, 4076,
4077, 4078, 4081, 4085, 4086, 4088, 4089, 4090, 4094, 4098, 4099, 4103,
4107, 4110, 4114, 4115, 4213, 4035, 4036, 4039, 4040, 4042, 4048, 4061,
4063, 4065, 4074, 4075, 4092, 4096, 4100, 4111, 4212, 4214, 4215, 4217,
4221, 4222 (module graph trace and clearEnvState keys by pin flip).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sheraff 2026-10-17 19:44:10 +02:00
commit 0814bc3da2
No known key found for this signature in database
2 changed files with 459 additions and 0 deletions