mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 15:42:09 +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 {
|
||||||
|
code: [
|
||||||
'import { defineAsyncComponent } from "vue"',
|
'import { defineAsyncComponent } from "vue"',
|
||||||
`export default defineAsyncComponent(() => import(${JSON.stringify(bare)}).then(r => r.default))`
|
`export default defineAsyncComponent(() => import(${JSON.stringify(bare)}).then(r => r.default))`
|
||||||
].join('\n')
|
].join('\n'),
|
||||||
|
map: null
|
||||||
|
}
|
||||||
} else if (mode === 'client') {
|
} else if (mode === 'client') {
|
||||||
return [
|
return {
|
||||||
|
code: [
|
||||||
`import __component from ${JSON.stringify(bare)}`,
|
`import __component from ${JSON.stringify(bare)}`,
|
||||||
'import { createClientOnly } from "#app/components/client-only"',
|
'import { createClientOnly } from "#app/components/client-only"',
|
||||||
'export default createClientOnly(__component)'
|
'export default createClientOnly(__component)'
|
||||||
].join('\n')
|
].join('\n'),
|
||||||
|
map: null
|
||||||
|
}
|
||||||
} else if (mode === 'client,async') {
|
} else if (mode === 'client,async') {
|
||||||
return [
|
return {
|
||||||
|
code: [
|
||||||
'import { defineAsyncComponent } from "vue"',
|
'import { defineAsyncComponent } from "vue"',
|
||||||
'import { createClientOnly } from "#app/components/client-only"',
|
'import { createClientOnly } from "#app/components/client-only"',
|
||||||
`export default defineAsyncComponent(() => import(${JSON.stringify(bare)}).then(r => createClientOnly(r.default)))`
|
`export default defineAsyncComponent(() => import(${JSON.stringify(bare)}).then(r => createClientOnly(r.default)))`
|
||||||
].join('\n')
|
].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