fix(vite-plugin-angular): parse skipped .ts files as TypeScript in vitest sourcemap plugin#2367
Conversation
…test sourcemap plugin The vitest sourcemap plugin's OXC transform path forced `lang: 'js'`, which parses TypeScript source as JavaScript. Files Angular's compilation skips (e.g. decorator-free specs when `useAngularCompilationAPI` is on) reach this pass as raw TypeScript, so any top-level TS-only syntax (type annotations, generics, `as`) failed with a PARSE_ERROR on rolldown-vite. Derive `lang` from the file extension (`'tsx'`/`'ts'`) to match the esbuild fallback's `loader: 'ts'`. Adds a decorator-free regression spec with TS-only syntax to the sourcemap test project. Closes #2364 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
✅ Deploy Preview for analog-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for analog-blog ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for analog-app ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR fixes a regression in the vitest sourcemap plugin introduced in version 2.6.0. The plugin now selects the OXC language mode based on the target file's extension ( Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
|
This PR touches multiple package scopes: Please confirm the changes are closely related. |
PR Checklist
Closes #2364
The vitest sourcemap plugin's OXC transform path forced
lang: 'js', so it parsed TypeScript source as JavaScript. Files that Angular's compilation skips (e.g. decorator-free specs whenuseAngularCompilationAPIis on) reach this post-processing pass as raw TypeScript. Any top-level TS-only syntax — type annotations, generics,as— then failed with[PARSE_ERROR] Missing initializer in const declarationon rolldown-vite. Surfaced as a regression upgrading 2.4.0 → 2.6.0.Affected scope
Recommended merge strategy for maintainer [optional]
What is the new behavior?
angularVitestSourcemapPluginnow derives the OXClangfrom the file extension ('tsx'for.tsx, otherwise'ts'), matching the esbuild fallback'sloader: 'ts'. Skipped.ts/.tsxfiles are correctly parsed as TypeScript, so TS-only syntax no longer triggers a parse error.Test plan
pnpm test(sourcemap project —nx build vite-plugin-angular+vitest run --project sourcemap, both specs pass on rolldown-vite where the OXC path is active)nx format:checkpnpm buildPARSE_ERRORwithlang: 'js'and confirmed clean transform withlang: 'ts'viavite.transformWithOxc; added a decorator-free regression spec with top-level TS-only syntax that fails to transform under the old behavior.Does this PR introduce a breaking change?
Other information
Root cause traced to
packages/vite-plugin-angular/src/lib/angular-vitest-plugin.ts:114. Thelang: 'js'predates #2333, but #2333'sgetInMapearly-return is what routes still-TypeScript (Angular-skipped) files through this branch, exposing the wronglang.🤖 Generated with Claude Code