fix(vite): normalise entry id for typeCheck plugin (#24114)

This commit is contained in:
Mehdi Lahlou 2023-11-03 23:35:13 +01:00 committed by GitHub
parent 9ef94d6afb
commit 38b6d88cfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -135,7 +135,7 @@ export async function buildClient (ctx: ViteBuildContext) {
}
// Add type checking client panel
if (ctx.nuxt.options.typescript.typeCheck && ctx.nuxt.options.dev) {
if (ctx.nuxt.options.typescript.typeCheck === true && ctx.nuxt.options.dev) {
clientConfig.plugins!.push(typeCheckPlugin({ sourcemap: !!ctx.nuxt.options.sourcemap.client }))
}

View File

@ -1,6 +1,8 @@
import MagicString from 'magic-string'
import type { Plugin } from 'vite'
const QUERY_RE = /\?.+$/
export function typeCheckPlugin (options: { sourcemap?: boolean } = {}): Plugin {
let entry: string
return {
@ -12,7 +14,7 @@ export function typeCheckPlugin (options: { sourcemap?: boolean } = {}): Plugin
}
},
transform (code, id) {
if (id !== entry) { return }
if (id.replace(QUERY_RE, '') !== entry) { return }
const s = new MagicString(code)