Skip to content

Commit a6e98f0

Browse files
Brooooooklynclaude
andauthored
feat: add useDefineForClassFields playground fixture and pass tsconfig to Rolldown (#82)
* feat: add useDefineForClassFields playground fixture and pass tsconfig to Rolldown - Add tsconfig.base.json with useDefineForClassFields: false (non-standard name to test extends chain resolution) - Add CasesComponent fixture with inject(), private fields (#view), and field cross-references - Pass tsconfig to Rolldown via resolvedConfig.build.rolldownOptions.tsconfig - Wire CasesComponent into playground routes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: pass tsconfig via config hook instead of mutating resolvedConfig Move rolldownOptions.tsconfig from configResolved mutation to the config hook's return value, so Vite properly deep-merges it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: only set rolldownOptions.tsconfig when tsconfig is provided Avoid passing undefined tsconfig which could override Rolldown's auto-discovery default. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 65d09f9 commit a6e98f0

File tree

7 files changed

+347
-179
lines changed

7 files changed

+347
-179
lines changed

napi/angular-compiler/vite-plugin/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,13 @@ export function angular(options: PluginOptions = {}): Plugin[] {
196196
include: ['rxjs/operators', 'rxjs'],
197197
exclude: ['@angular/platform-server'],
198198
},
199-
// Note: We dynamically unwatch template/style files when discovered during transform
200-
// using server.watcher.unwatch(). This is more precise than static glob patterns.
199+
...(options.tsconfig && {
200+
build: {
201+
rolldownOptions: {
202+
tsconfig: options.tsconfig,
203+
},
204+
},
205+
}),
201206
}
202207
},
203208
configResolved(config) {
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import { Routes } from '@angular/router'
22

3-
export const routes: Routes = []
3+
import { CasesComponent } from './cases.component'
4+
5+
export const routes: Routes = [{ path: 'cases', component: CasesComponent }]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Component, Injectable, inject, signal } from '@angular/core'
2+
import { Observable, of, delay } from 'rxjs'
3+
4+
@Injectable({ providedIn: 'root' })
5+
export class CifaPanelService {
6+
onClose: Observable<boolean> = of(true)
7+
}
8+
9+
@Component({
10+
selector: 'app-cases',
11+
template: '<div>Cases: {{ view() }}</div>',
12+
standalone: true,
13+
})
14+
export class CasesComponent {
15+
// Field using inject()
16+
private cifaPanelService = inject(CifaPanelService)
17+
18+
// Field referencing the inject() field above - CRASHES with native class fields
19+
// because cifaPanelService may not be initialized yet
20+
private casesDrawerCloseChangeEvent$ = this.cifaPanelService.onClose.pipe(delay(0))
21+
22+
// Private field with signal
23+
#view = signal<string>('home')
24+
view = this.#view.asReadonly()
25+
26+
constructor() {
27+
this.casesDrawerCloseChangeEvent$.subscribe()
28+
console.log('CasesComponent view:', this.#view())
29+
}
30+
}

napi/playground/tsconfig.base.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true,
4+
"noImplicitOverride": true,
5+
"noPropertyAccessFromIndexSignature": true,
6+
"noImplicitReturns": true,
7+
"noFallthroughCasesInSwitch": true,
8+
"skipLibCheck": true,
9+
"isolatedModules": true,
10+
"experimentalDecorators": true,
11+
"importHelpers": true,
12+
"target": "ES2022",
13+
"useDefineForClassFields": false,
14+
"module": "preserve",
15+
"moduleResolution": "bundler"
16+
},
17+
"angularCompilerOptions": {
18+
"enableI18nLegacyMessageIdFormat": false,
19+
"strictInjectionParameters": true,
20+
"strictInputAccessModifiers": true,
21+
"strictTemplates": true
22+
}
23+
}

napi/playground/tsconfig.json

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,5 @@
11
{
2-
"compilerOptions": {
3-
"strict": true,
4-
"noImplicitOverride": true,
5-
"noPropertyAccessFromIndexSignature": true,
6-
"noImplicitReturns": true,
7-
"noFallthroughCasesInSwitch": true,
8-
"skipLibCheck": true,
9-
"isolatedModules": true,
10-
"experimentalDecorators": true,
11-
"importHelpers": true,
12-
"target": "ES2022",
13-
"module": "preserve",
14-
"moduleResolution": "bundler"
15-
},
16-
"angularCompilerOptions": {
17-
"enableI18nLegacyMessageIdFormat": false,
18-
"strictInjectionParameters": true,
19-
"strictInputAccessModifiers": true,
20-
"strictTemplates": true
21-
},
2+
"extends": "./tsconfig.base.json",
223
"references": [
234
{
245
"path": "../angular-compiler"

0 commit comments

Comments
 (0)