mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-18 06:31:27 +00:00
fix(vite): normalise entry id for typeCheck
plugin (#24114)
This commit is contained in:
parent
9ef94d6afb
commit
38b6d88cfa
@ -135,7 +135,7 @@ export async function buildClient (ctx: ViteBuildContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add type checking client panel
|
// 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 }))
|
clientConfig.plugins!.push(typeCheckPlugin({ sourcemap: !!ctx.nuxt.options.sourcemap.client }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import MagicString from 'magic-string'
|
import MagicString from 'magic-string'
|
||||||
import type { Plugin } from 'vite'
|
import type { Plugin } from 'vite'
|
||||||
|
|
||||||
|
const QUERY_RE = /\?.+$/
|
||||||
|
|
||||||
export function typeCheckPlugin (options: { sourcemap?: boolean } = {}): Plugin {
|
export function typeCheckPlugin (options: { sourcemap?: boolean } = {}): Plugin {
|
||||||
let entry: string
|
let entry: string
|
||||||
return {
|
return {
|
||||||
@ -12,7 +14,7 @@ export function typeCheckPlugin (options: { sourcemap?: boolean } = {}): Plugin
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
transform (code, id) {
|
transform (code, id) {
|
||||||
if (id !== entry) { return }
|
if (id.replace(QUERY_RE, '') !== entry) { return }
|
||||||
|
|
||||||
const s = new MagicString(code)
|
const s = new MagicString(code)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user