Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions packages/vite-plugin-angular/src/lib/angular-vite-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { createRequire } from 'node:module';
import * as ts from 'typescript';

import * as ngCompiler from '@angular/compiler';
import { globSync } from 'tinyglobby';
import {
defaultClientConditions,
ModuleNode,
Expand All @@ -23,7 +24,6 @@ import {
ResolvedConfig,
ViteDevServer,
} from 'vite';
import { globSync } from 'tinyglobby';
import { buildOptimizerPlugin } from './angular-build-optimizer-plugin.js';
import { jitPlugin } from './angular-jit-plugin.js';
import { createCompilerPlugin } from './compiler-plugin.js';
Expand Down Expand Up @@ -123,7 +123,6 @@ export function angular(options?: PluginOptions): Plugin[] {
};

let resolvedConfig: ResolvedConfig;
let resolvedTsConfigPath: string = '';
// Store config context needed for getTsConfigPath resolution
let tsConfigResolutionContext: {
root: string;
Expand Down Expand Up @@ -181,13 +180,7 @@ export function angular(options?: PluginOptions): Plugin[] {
};

// Do a preliminary resolution for esbuild plugin (before configResolved)
const preliminaryTsConfigPath = getTsConfigPath(
tsConfigResolutionContext.root,
pluginOptions.tsconfigGetter(),
tsConfigResolutionContext.isProd,
isTest,
tsConfigResolutionContext.isLib,
);
const preliminaryTsConfigPath = resolveTsConfigPath();

return {
esbuild: config.esbuild ?? false,
Expand Down Expand Up @@ -226,18 +219,6 @@ export function angular(options?: PluginOptions): Plugin[] {
configResolved(config) {
resolvedConfig = config;

// resolve the tsconfig path after config is fully resolved
if (tsConfigResolutionContext) {
const tsconfigValue = pluginOptions.tsconfigGetter();
resolvedTsConfigPath = getTsConfigPath(
tsConfigResolutionContext.root,
tsconfigValue,
tsConfigResolutionContext.isProd,
isTest,
tsConfigResolutionContext.isLib,
);
}

if (isTest) {
// set test watch mode
// - vite override from vitest-angular
Expand Down Expand Up @@ -672,10 +653,24 @@ export function angular(options?: PluginOptions): Plugin[] {
return resolvedPath;
}

function resolveTsConfigPath() {
const tsconfigValue = pluginOptions.tsconfigGetter();

return getTsConfigPath(
tsConfigResolutionContext!.root,
tsconfigValue,
tsConfigResolutionContext!.isProd,
isTest,
tsConfigResolutionContext!.isLib,
);
}

async function performCompilation(config: ResolvedConfig, ids?: string[]) {
const isProd = config.mode === 'production';
const includeFiles = findIncludes();

const resolvedTsConfigPath = resolveTsConfigPath();

let { options: tsCompilerOptions, rootNames } =
compilerCli.readConfiguration(resolvedTsConfigPath, {
suppressOutputPathCheck: true,
Expand Down