mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(nuxt): generate empty sourcemaps for wrappers (#20744)
This commit is contained in:
parent
fd9b179f5a
commit
eb8e9169d6
@ -53,30 +53,37 @@ export function createTransformPlugin (nuxt: Nuxt, getComponents: getComponentsT
|
||||
const mode = query.nuxt_component
|
||||
const bare = id.replace(/\?.*/, '')
|
||||
if (mode === 'async') {
|
||||
return [
|
||||
return {
|
||||
code: [
|
||||
'import { defineAsyncComponent } from "vue"',
|
||||
`export default defineAsyncComponent(() => import(${JSON.stringify(bare)}).then(r => r.default))`
|
||||
].join('\n')
|
||||
].join('\n'),
|
||||
map: null
|
||||
}
|
||||
} else if (mode === 'client') {
|
||||
return [
|
||||
return {
|
||||
code: [
|
||||
`import __component from ${JSON.stringify(bare)}`,
|
||||
'import { createClientOnly } from "#app/components/client-only"',
|
||||
'export default createClientOnly(__component)'
|
||||
].join('\n')
|
||||
].join('\n'),
|
||||
map: null
|
||||
}
|
||||
} else if (mode === 'client,async') {
|
||||
return [
|
||||
return {
|
||||
code: [
|
||||
'import { defineAsyncComponent } from "vue"',
|
||||
'import { createClientOnly } from "#app/components/client-only"',
|
||||
`export default defineAsyncComponent(() => import(${JSON.stringify(bare)}).then(r => createClientOnly(r.default)))`
|
||||
].join('\n')
|
||||
].join('\n'),
|
||||
map: null
|
||||
}
|
||||
} else {
|
||||
throw new Error(`Unknown component mode: ${mode}, this might be an internal bug of Nuxt.`)
|
||||
}
|
||||
}
|
||||
|
||||
if (!code.includes('#components')) {
|
||||
return null
|
||||
}
|
||||
if (!code.includes('#components')) { return }
|
||||
|
||||
componentUnimport.modifyDynamicImports((imports) => {
|
||||
imports.length = 0
|
||||
@ -85,12 +92,11 @@ export function createTransformPlugin (nuxt: Nuxt, getComponents: getComponentsT
|
||||
})
|
||||
|
||||
const result = await componentUnimport.injectImports(code, id, { autoImport: false, transformVirtualImports: true })
|
||||
if (!result) {
|
||||
return null
|
||||
}
|
||||
if (!result) { return }
|
||||
|
||||
return {
|
||||
code: result.code,
|
||||
map: nuxt.options.sourcemap
|
||||
map: nuxt.options.sourcemap.server || nuxt.options.sourcemap.client
|
||||
? result.s.generateMap({ hires: true })
|
||||
: undefined
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user