Please provide the environment you discovered this bug in.
@analogjs/vite-plugin-angular: 2.6.0 (also present on main)
@analogjs/vitest-angular: 2.6.0
vite: 8.0.12
vitest: 4.1.5
@angular/core: 21.2.12
- Node: 22.20.0
- Nx monorepo,
useAngularCompilationAPI enabled
Which area/package is the issue in?
vite-plugin-angular
Description
Upgrading from 2.4.0 to 2.6.0 causes some .spec.ts files to fail to transform with a parse error, because the new angularVitestSourcemapPlugin parses TypeScript source as JavaScript.
I think the issue might come from here: lang: 'js'
https://github.com/analogjs/analog/blob/main/packages/vite-plugin-angular/src/lib/angular-vitest-plugin.ts#L113-L120
The regression source seems to be 46c608f (#2333).
Minimal reproduction
A .spec.ts with no Angular decorators (so Angular's compiler skips it) containing any top-level TypeScript-only syntax:
// some.mapper.spec.ts — no Angular decorators, so Angular's compiler skips it
import { mapToLabel } from './some.mapper';
describe('mapToLabel', () => {
const data: [string, string][] = [['a', 'A']]; // ❌ TS type annotation → PARSE_ERROR
it('works', () => {
expect(mapToLabel(data[0][0])).toBe('A');
});
});
Please provide the exception or error you saw
Error: Transform failed with 2 errors:
[PARSE_ERROR] Error: Missing initializer in const declaration
╭─[ some.mapper.spec.ts:5:9 ]
5 │ const data: [string, string][] = [
│ ──┬─
│ ╰──── Help: Add an initializer (e.g. ` = undefined`) here
───╯
[PARSE_ERROR] Error: Expected a semicolon or an implicit semicolon after a statement, but found none
╭─[ some.mapper.spec.ts:5:13 ]
5 │ const data: [string, string][] = [
│ │
│ ╰─ Help: Try inserting a semicolon here
───╯
Plugin: @analogjs/vitest-angular-sourcemap-plugin
File: .../some.mapper.spec.ts
❯ Module.transformWithOxc node_modules/vite/dist/node/chunks/node.js
❯ TransformPluginContext.transform packages/vite-plugin-angular/src/lib/angular-vitest-plugin.ts:114
Please provide the environment you discovered this bug in.
@analogjs/vite-plugin-angular: 2.6.0 (also present onmain)@analogjs/vitest-angular: 2.6.0vite: 8.0.12vitest: 4.1.5@angular/core: 21.2.12useAngularCompilationAPIenabledWhich area/package is the issue in?
vite-plugin-angular
Description
Upgrading from
2.4.0to2.6.0causes some.spec.tsfiles to fail to transform with a parse error, because the newangularVitestSourcemapPluginparses TypeScript source as JavaScript.I think the issue might come from here:
lang: 'js'https://github.com/analogjs/analog/blob/main/packages/vite-plugin-angular/src/lib/angular-vitest-plugin.ts#L113-L120
The regression source seems to be 46c608f (#2333).
Minimal reproduction
A
.spec.tswith no Angular decorators (so Angular's compiler skips it) containing any top-level TypeScript-only syntax:Please provide the exception or error you saw