diff --git a/packages/vite/src/executors/build/build.impl.ts b/packages/vite/src/executors/build/build.impl.ts index c6dd26fa44ba2f..b37adec63ae44d 100644 --- a/packages/vite/src/executors/build/build.impl.ts +++ b/packages/vite/src/executors/build/build.impl.ts @@ -26,6 +26,7 @@ import { loadViteDynamicImport, validateTypes, } from '../../utils/executor-utils'; +import { type Plugin } from 'vite'; export async function* viteBuildExecutor( options: Record & ViteBuildExecutorOptions, @@ -82,8 +83,13 @@ export async function* viteBuildExecutor( if (!options.skipTypeCheck) { await validateTypes({ workspaceRoot: context.root, - projectRoot: projectRoot, tsconfig: options.tsConfig ?? getProjectTsConfigPath(projectRoot), + isVueProject: Boolean( + resolved.config.plugins?.find( + (plugin: Plugin) => + typeof plugin === 'object' && plugin?.name === 'vite:vue' + ) + ), }); } diff --git a/packages/vite/src/utils/executor-utils.ts b/packages/vite/src/utils/executor-utils.ts index f92d0a555f2c4d..f59e2a0a38d54d 100644 --- a/packages/vite/src/utils/executor-utils.ts +++ b/packages/vite/src/utils/executor-utils.ts @@ -1,29 +1,41 @@ -import { printDiagnostics, runTypeCheck } from '@nx/js'; -import { join } from 'path'; import { ViteBuildExecutorOptions } from '../executors/build/schema'; -import { ExecutorContext } from '@nx/devkit'; +import { ExecutorContext, getPackageManagerCommand } from '@nx/devkit'; import { ViteDevServerExecutorOptions } from '../executors/dev-server/schema'; import { calculateProjectBuildableDependencies, createTmpTsConfig, } from '@nx/js/src/utils/buildable-libs-utils'; import { getProjectTsConfigPath } from './options-utils'; +import { execSync } from 'node:child_process'; +import { printDiagnostics, runTypeCheck } from '@nx/js'; +import { join } from 'path'; export async function validateTypes(opts: { workspaceRoot: string; - projectRoot: string; tsconfig: string; + isVueProject?: boolean; }): Promise { - const result = await runTypeCheck({ - workspaceRoot: opts.workspaceRoot, - tsConfigPath: join(opts.workspaceRoot, opts.tsconfig), - mode: 'noEmit', - }); + if (!opts.isVueProject) { + const result = await runTypeCheck({ + workspaceRoot: opts.workspaceRoot, + tsConfigPath: join(opts.workspaceRoot, opts.tsconfig), + mode: 'noEmit', + }); - await printDiagnostics(result.errors, result.warnings); + await printDiagnostics(result.errors, result.warnings); - if (result.errors.length > 0) { - throw new Error('Found type errors. See above.'); + if (result.errors.length > 0) { + throw new Error('Found type errors. See above.'); + } + } else { + const pm = getPackageManagerCommand(); + const cp = execSync( + `${pm.exec} vue-tsc --noEmit -p ${opts.tsconfig} --composite false`, + { + cwd: opts.workspaceRoot, + stdio: 'inherit', + } + ); } } diff --git a/packages/vue/src/utils/versions.ts b/packages/vue/src/utils/versions.ts index df3ad4d5f69e16..5a87e728fd87a9 100644 --- a/packages/vue/src/utils/versions.ts +++ b/packages/vue/src/utils/versions.ts @@ -2,7 +2,7 @@ export const nxVersion = require('../../package.json').version; // vue core export const vueVersion = '^3.3.4'; -export const vueTscVersion = '^1.8.8'; +export const vueTscVersion = '^2.0.0'; export const vueRouterVersion = '^4.2.4'; // test deps