mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +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 mode = query.nuxt_component
|
||||||
const bare = id.replace(/\?.*/, '')
|
const bare = id.replace(/\?.*/, '')
|
||||||
if (mode === 'async') {
|
if (mode === 'async') {
|
||||||
return [
|
return {
|
||||||
'import { defineAsyncComponent } from "vue"',
|
code: [
|
||||||
`export default defineAsyncComponent(() => import(${JSON.stringify(bare)}).then(r => r.default))`
|
'import { defineAsyncComponent } from "vue"',
|
||||||
].join('\n')
|
`export default defineAsyncComponent(() => import(${JSON.stringify(bare)}).then(r => r.default))`
|
||||||
|
].join('\n'),
|
||||||
|
map: null
|
||||||
|
}
|
||||||
} else if (mode === 'client') {
|
} else if (mode === 'client') {
|
||||||
return [
|
return {
|
||||||
`import __component from ${JSON.stringify(bare)}`,
|
code: [
|
||||||
'import { createClientOnly } from "#app/components/client-only"',
|
`import __component from ${JSON.stringify(bare)}`,
|
||||||
'export default createClientOnly(__component)'
|
'import { createClientOnly } from "#app/components/client-only"',
|
||||||
].join('\n')
|
'export default createClientOnly(__component)'
|
||||||
|
].join('\n'),
|
||||||
|
map: null
|
||||||
|
}
|
||||||
} else if (mode === 'client,async') {
|
} else if (mode === 'client,async') {
|
||||||
return [
|
return {
|
||||||
'import { defineAsyncComponent } from "vue"',
|
code: [
|
||||||
'import { createClientOnly } from "#app/components/client-only"',
|
'import { defineAsyncComponent } from "vue"',
|
||||||
`export default defineAsyncComponent(() => import(${JSON.stringify(bare)}).then(r => createClientOnly(r.default)))`
|
'import { createClientOnly } from "#app/components/client-only"',
|
||||||
].join('\n')
|
`export default defineAsyncComponent(() => import(${JSON.stringify(bare)}).then(r => createClientOnly(r.default)))`
|
||||||
|
].join('\n'),
|
||||||
|
map: null
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unknown component mode: ${mode}, this might be an internal bug of Nuxt.`)
|
throw new Error(`Unknown component mode: ${mode}, this might be an internal bug of Nuxt.`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!code.includes('#components')) {
|
if (!code.includes('#components')) { return }
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
componentUnimport.modifyDynamicImports((imports) => {
|
componentUnimport.modifyDynamicImports((imports) => {
|
||||||
imports.length = 0
|
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 })
|
const result = await componentUnimport.injectImports(code, id, { autoImport: false, transformVirtualImports: true })
|
||||||
if (!result) {
|
if (!result) { return }
|
||||||
return null
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
code: result.code,
|
code: result.code,
|
||||||
map: nuxt.options.sourcemap
|
map: nuxt.options.sourcemap.server || nuxt.options.sourcemap.client
|
||||||
? result.s.generateMap({ hires: true })
|
? result.s.generateMap({ hires: true })
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user