@@ -14,6 +14,7 @@ import { createRequire } from 'node:module';
1414import * as ts from 'typescript' ;
1515
1616import * as ngCompiler from '@angular/compiler' ;
17+ import { globSync } from 'tinyglobby' ;
1718import {
1819 defaultClientConditions ,
1920 ModuleNode ,
@@ -23,7 +24,6 @@ import {
2324 ResolvedConfig ,
2425 ViteDevServer ,
2526} from 'vite' ;
26- import { globSync } from 'tinyglobby' ;
2727import { buildOptimizerPlugin } from './angular-build-optimizer-plugin.js' ;
2828import { jitPlugin } from './angular-jit-plugin.js' ;
2929import { createCompilerPlugin } from './compiler-plugin.js' ;
@@ -123,7 +123,6 @@ export function angular(options?: PluginOptions): Plugin[] {
123123 } ;
124124
125125 let resolvedConfig : ResolvedConfig ;
126- let resolvedTsConfigPath : string = '' ;
127126 // Store config context needed for getTsConfigPath resolution
128127 let tsConfigResolutionContext : {
129128 root : string ;
@@ -181,13 +180,7 @@ export function angular(options?: PluginOptions): Plugin[] {
181180 } ;
182181
183182 // Do a preliminary resolution for esbuild plugin (before configResolved)
184- const preliminaryTsConfigPath = getTsConfigPath (
185- tsConfigResolutionContext . root ,
186- pluginOptions . tsconfigGetter ( ) ,
187- tsConfigResolutionContext . isProd ,
188- isTest ,
189- tsConfigResolutionContext . isLib ,
190- ) ;
183+ const preliminaryTsConfigPath = resolveTsConfigPath ( ) ;
191184
192185 return {
193186 esbuild : config . esbuild ?? false ,
@@ -226,18 +219,6 @@ export function angular(options?: PluginOptions): Plugin[] {
226219 configResolved ( config ) {
227220 resolvedConfig = config ;
228221
229- // resolve the tsconfig path after config is fully resolved
230- if ( tsConfigResolutionContext ) {
231- const tsconfigValue = pluginOptions . tsconfigGetter ( ) ;
232- resolvedTsConfigPath = getTsConfigPath (
233- tsConfigResolutionContext . root ,
234- tsconfigValue ,
235- tsConfigResolutionContext . isProd ,
236- isTest ,
237- tsConfigResolutionContext . isLib ,
238- ) ;
239- }
240-
241222 if ( isTest ) {
242223 // set test watch mode
243224 // - vite override from vitest-angular
@@ -672,10 +653,24 @@ export function angular(options?: PluginOptions): Plugin[] {
672653 return resolvedPath ;
673654 }
674655
656+ function resolveTsConfigPath ( ) {
657+ const tsconfigValue = pluginOptions . tsconfigGetter ( ) ;
658+
659+ return getTsConfigPath (
660+ tsConfigResolutionContext ! . root ,
661+ tsconfigValue ,
662+ tsConfigResolutionContext ! . isProd ,
663+ isTest ,
664+ tsConfigResolutionContext ! . isLib ,
665+ ) ;
666+ }
667+
675668 async function performCompilation ( config : ResolvedConfig , ids ?: string [ ] ) {
676669 const isProd = config . mode === 'production' ;
677670 const includeFiles = findIncludes ( ) ;
678671
672+ const resolvedTsConfigPath = resolveTsConfigPath ( ) ;
673+
679674 let { options : tsCompilerOptions , rootNames } =
680675 compilerCli . readConfiguration ( resolvedTsConfigPath , {
681676 suppressOutputPathCheck : true ,
0 commit comments