Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

Commit d25dafe

Browse files
danielroeSébastien Chopin
andauthored
fix(vite): add type-checker to client build for ssr: false (#7930)
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
1 parent 6d3dc3b commit d25dafe

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

packages/vite/src/server.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { resolveTSConfig } from 'pkg-types'
21
import { resolve } from 'pathe'
32
import * as vite from 'vite'
43
import vuePlugin from '@vitejs/plugin-vue'
@@ -142,16 +141,6 @@ export async function buildServer (ctx: ViteBuildContext) {
142141
})
143142
}
144143

145-
// Add type-checking
146-
if (ctx.nuxt.options.typescript.typeCheck === true || (ctx.nuxt.options.typescript.typeCheck === 'build' && !ctx.nuxt.options.dev)) {
147-
const checker = await import('vite-plugin-checker').then(r => r.default)
148-
serverConfig.plugins!.push(checker({
149-
vueTsc: {
150-
tsconfigPath: await resolveTSConfig(ctx.nuxt.options.rootDir)
151-
}
152-
}))
153-
}
154-
155144
await ctx.nuxt.callHook('vite:extendConfig', serverConfig, { isClient: false, isServer: true })
156145

157146
const onBuild = () => ctx.nuxt.callHook('build:resources', wpfs)

packages/vite/src/vite.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import * as vite from 'vite'
22
import { join, resolve } from 'pathe'
33
import type { Nuxt } from '@nuxt/schema'
44
import type { InlineConfig, SSROptions } from 'vite'
5-
import { logger, isIgnored, resolvePath } from '@nuxt/kit'
5+
import { logger, isIgnored, resolvePath, addVitePlugin } from '@nuxt/kit'
66
import type { Options } from '@vitejs/plugin-vue'
77
import replace from '@rollup/plugin-replace'
88
import { sanitizeFilePath } from 'mlly'
99
import { withoutLeadingSlash } from 'ufo'
1010
import { filename } from 'pathe/utils'
11+
import { resolveTSConfig } from 'pkg-types'
1112
import { buildClient } from './client'
1213
import { buildServer } from './server'
1314
import virtual from './plugins/virtual'
@@ -102,6 +103,16 @@ export async function bundle (nuxt: Nuxt) {
102103

103104
await nuxt.callHook('vite:extend', ctx)
104105

106+
// Add type-checking
107+
if (ctx.nuxt.options.typescript.typeCheck === true || (ctx.nuxt.options.typescript.typeCheck === 'build' && !ctx.nuxt.options.dev)) {
108+
const checker = await import('vite-plugin-checker').then(r => r.default)
109+
addVitePlugin(checker({
110+
vueTsc: {
111+
tsconfigPath: await resolveTSConfig(ctx.nuxt.options.rootDir)
112+
}
113+
}), { client: !nuxt.options.ssr, server: nuxt.options.ssr })
114+
}
115+
105116
nuxt.hook('vite:serverCreated', (server: vite.ViteDevServer, env) => {
106117
// Invalidate virtual modules when templates are re-generated
107118
ctx.nuxt.hook('app:templatesGenerated', () => {

0 commit comments

Comments
 (0)