fix: compile templates whose id carries an unknown query - #299
Conversation
`stripViteQueries` only stripped `cache`, `v` and `t`, so any other query left the id failing `isMarkoFile` and the template was handed to the rest of the pipeline uncompiled — `@vitest/coverage-istanbul` re-requests uncovered files with its own marker and the raw Marko source reached babel. Split identity from the compile gate: `cleanUrl` for "what file is this", `hasOpaqueQuery` for the vite queries that change what the module is, which `load`/`transform` now bail on so `?raw` and `?url` keep working.
🦋 Changeset detectedLatest commit: 09aef2d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
WalkthroughAdds query utilities that separate transparent URL markers from opaque payload-changing queries. Updates Marko plugin resolution, side-effect tracking, loading, and transformation to normalize transparent query IDs while deferring opaque queries to Vite. Adds unit and Vite integration tests covering unknown marker, cache-busting, 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Comment |
Vite's dev cjs interop consts are hoisted in a nondeterministic order, so asserting the whole transform result matched the un-queried request failed on windows while passing on linux.
stripViteQueriesstripped an allowlist of three params (cache,v,t), so any other query left the id failingisMarkoFileand the template flowed throughload/transformuncompiled.@vitest/coverage-istanbulre-requests uncovered files asfoo.marko?cache=…&vitest-uncovered-coverage=true, so raw Marko source reached its babel instrumenter andvitest run --coveragedied with aSyntaxErroron any.markofile no test imported.Splits the two things that function conflated:
cleanUrlanswers "what file is this" (and no longer emits the malformed?&…ids the old strip left behind),hasOpaqueQueryanswers "may Marko compile it" for the vite queries that change what the module is.loadandtransformbail on the latter, which is what keeps?rawand?urlworking — they previously worked only as a side effect of the id failing the.markocheck.Note this inverts a denylist into an allowlist: an unknown content-changing query from a third-party plugin would now be compiled rather than skipped. That looks like the right default (cache-busters and markers vastly outnumber them, and vite's set is stable), but it's a judgement call worth a second opinion.
Verified against a real vitest 4.1.10 +
@vitest/coverage-istanbulproject with an un-imported.marko: crashes before, passes after with the file reporting real coverage numbers. Covered here by unit cases on the id helpers plus dev-server tests that a marker-queried request transforms identically to the plain one while?raw/?urlstill return source text and url.