Skip to content

fix(vite-plugin-angular): parse skipped .ts files as TypeScript in vitest sourcemap plugin#2367

Merged
brandonroberts merged 1 commit into
betafrom
fix/2364-vitest-oxc-parse-ts
Jun 8, 2026
Merged

fix(vite-plugin-angular): parse skipped .ts files as TypeScript in vitest sourcemap plugin#2367
brandonroberts merged 1 commit into
betafrom
fix/2364-vitest-oxc-parse-ts

Conversation

@brandonroberts

Copy link
Copy Markdown
Member

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 when useAngularCompilationAPI is 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 declaration on rolldown-vite. Surfaced as a regression upgrading 2.4.0 → 2.6.0.

Affected scope

  • Primary scope: vite-plugin-angular
  • Secondary scopes: vitest-angular (regression test)

Recommended merge strategy for maintainer [optional]

  • Squash merge
  • Rebase merge
  • Other

What is the new behavior?

angularVitestSourcemapPlugin now derives the OXC lang from the file extension ('tsx' for .tsx, otherwise 'ts'), matching the esbuild fallback's loader: 'ts'. Skipped .ts/.tsx files 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:check
  • pnpm build
  • Manual verification — reproduced the exact PARSE_ERROR with lang: 'js' and confirmed clean transform with lang: 'ts' via vite.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?

  • Yes
  • No

Other information

Root cause traced to packages/vite-plugin-angular/src/lib/angular-vitest-plugin.ts:114. The lang: 'js' predates #2333, but #2333's getInMap early-return is what routes still-TypeScript (Angular-skipped) files through this branch, exposing the wrong lang.

🤖 Generated with Claude Code

…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>
@netlify

netlify Bot commented Jun 8, 2026

Copy link
Copy Markdown

Deploy Preview for analog-docs ready!

Name Link
🔨 Latest commit 5b42dbc
🔍 Latest deploy log https://app.netlify.com/projects/analog-docs/deploys/6a27115db9bf1800087813b8
😎 Deploy Preview https://deploy-preview-2367--analog-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jun 8, 2026

Copy link
Copy Markdown

Deploy Preview for analog-blog ready!

Name Link
🔨 Latest commit 5b42dbc
🔍 Latest deploy log https://app.netlify.com/projects/analog-blog/deploys/6a27115d85b0f20008fbbb5f
😎 Deploy Preview https://deploy-preview-2367--analog-blog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jun 8, 2026

Copy link
Copy Markdown

Deploy Preview for analog-app ready!

Name Link
🔨 Latest commit 5b42dbc
🔍 Latest deploy log https://app.netlify.com/projects/analog-app/deploys/6a27115d5cefb40009055d0a
😎 Deploy Preview https://deploy-preview-2367--analog-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 63c83c9b-4f52-42cb-be89-6203feb36dbd

📥 Commits

Reviewing files that changed from the base of the PR and between 1847c34 and 5b42dbc.

📒 Files selected for processing (2)
  • packages/vite-plugin-angular/src/lib/angular-vitest-plugin.ts
  • tests/vitest-angular/src/sourcemap/no-decorator-ts-syntax.spec.ts

📝 Walkthrough

Walkthrough

This 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 (.tsx or .ts) instead of hardcoding lang: 'js', which caused TypeScript-only syntax to fail parsing. A new regression test validates that decorator-free TypeScript files with type annotations transform correctly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title follows Conventional Commit style with supported scope (vite-plugin-angular), clear action (fix), and accurately summarizes the main change (parse skipped .ts files as TypeScript in vitest sourcemap plugin).
Description check ✅ Passed Description is comprehensive and directly related to the changeset, documenting the regression, root cause, fix, and test plan.
Linked Issues check ✅ Passed PR fully addresses #2364: fixes the lang: 'js' forcing issue [#2364], derives OXC lang from file extension matching expected behavior, adds regression test with TS-only syntax [vitest-angular], and includes manual verification of the fix.
Out of Scope Changes check ✅ Passed All changes are in scope: vite-plugin-angular source fix (angular-vitest-plugin.ts) and vitest-angular regression test are directly aligned with #2364 objectives.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added scope:vite-plugin-angular Changes in @analogjs/vite-plugin-angular scope:vitest-angular Changes in @analogjs/vitest-angular labels Jun 8, 2026
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

This PR touches multiple package scopes: vite-plugin-angular, vitest-angular.

Please confirm the changes are closely related. Squash merge is highly preferred. If you recommend a non-squash merge, add a brief note explaining why the commit boundaries matter and why this PR should bypass focused changes per package.

@brandonroberts brandonroberts merged commit ba284a8 into beta Jun 8, 2026
24 checks passed
@brandonroberts brandonroberts deleted the fix/2364-vitest-oxc-parse-ts branch June 8, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:vite-plugin-angular Changes in @analogjs/vite-plugin-angular scope:vitest-angular Changes in @analogjs/vitest-angular

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(vite-plugin-angular): vitest sourcemap plugin parses TypeScript as JavaScript

1 participant