fix(nuxt): generate hi-res sourcemaps (#20280)

This commit is contained in:
Daniel Roe 2023-04-14 18:21:08 +01:00 committed by GitHub
parent f366ab4eb8
commit d0c8e7fb4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 21 additions and 21 deletions

View File

@ -44,7 +44,7 @@ export const clientFallbackAutoIdPlugin = createUnplugin((options: LoaderOptions
return {
code: s.toString(),
map: options.sourcemap
? s.generateMap({ source: id, includeContent: true })
? s.generateMap({ hires: true })
: undefined
}
}

View File

@ -33,7 +33,7 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
}
return isVueTemplate(id)
},
transform (code, id) {
transform (code) {
const components = options.getComponents()
let num = 0
@ -92,7 +92,7 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
return {
code: s.toString(),
map: options.sourcemap
? s.generateMap({ source: id, includeContent: true })
? s.generateMap({ hires: true })
: undefined
}
}

View File

@ -29,7 +29,7 @@ export const TreeShakeTemplatePlugin = createUnplugin((options: TreeShakeTemplat
const { pathname } = parseURL(decodeURIComponent(pathToFileURL(id).href))
return pathname.endsWith('.vue')
},
transform (code, id) {
transform (code) {
const components = options.getComponents()
if (!regexpMap.has(components)) {
@ -106,7 +106,7 @@ export const TreeShakeTemplatePlugin = createUnplugin((options: TreeShakeTemplat
return {
code: s.toString(),
map: options.sourcemap
? s.generateMap({ source: id, includeContent: true })
? s.generateMap({ hires: true })
: undefined
}
}
@ -192,7 +192,7 @@ function removeImportDeclaration (ast: Program, importName: string, magicString:
* ImportDeclarations and VariableDeclarations are ignored
* return the name of the component if is not called
*/
function isComponentNotCalledInSetup (codeAst: Node, name: string): string|void {
function isComponentNotCalledInSetup (codeAst: Node, name: string): string | void {
if (name) {
let found = false
walk(codeAst, {

View File

@ -23,7 +23,7 @@ export const DevOnlyPlugin = createUnplugin((options: DevOnlyPluginOptions) => {
return true
}
},
transform (code, id) {
transform (code) {
if (!code.match(DEVONLY_COMP_RE)) { return }
const s = new MagicString(code)
@ -36,7 +36,7 @@ export const DevOnlyPlugin = createUnplugin((options: DevOnlyPluginOptions) => {
return {
code: s.toString(),
map: options.sourcemap
? s.generateMap({ source: id, includeContent: true })
? s.generateMap({ hires: true })
: undefined
}
}

View File

@ -60,7 +60,7 @@ export const LayerAliasingPlugin = createUnplugin((options: LayerAliasingOptions
if (s.hasChanged()) {
return {
code: s.toString(),
map: options.sourcemap ? s.generateMap({ source: id, includeContent: true }) : undefined
map: options.sourcemap ? s.generateMap({ hires: true }) : undefined
}
}
}

View File

@ -35,7 +35,7 @@ export const TreeShakeComposablesPlugin = createUnplugin((options: TreeShakeComp
return true
}
},
transform (code, id) {
transform (code) {
if (!code.match(COMPOSABLE_RE)) { return }
const s = new MagicString(code)
@ -48,7 +48,7 @@ export const TreeShakeComposablesPlugin = createUnplugin((options: TreeShakeComp
return {
code: s.toString(),
map: options.sourcemap
? s.generateMap({ source: id, includeContent: true })
? s.generateMap({ hires: true })
: undefined
}
}

View File

@ -34,7 +34,7 @@ export const UnctxTransformPlugin = createUnplugin((options: UnctxTransformPlugi
return true
}
},
transform (code, id) {
transform (code) {
// TODO: needed for webpack - update transform in unctx/unplugin?
if (code.startsWith(TRANSFORM_MARKER) || !transformer.shouldTransform(code)) { return }
const result = transformer.transform(code)
@ -42,7 +42,7 @@ export const UnctxTransformPlugin = createUnplugin((options: UnctxTransformPlugi
return {
code: TRANSFORM_MARKER + result.code,
map: options.sourcemap
? result.magicString.generateMap({ source: id, includeContent: true })
? result.magicString.generateMap({ hires: true })
: undefined
}
}

View File

@ -49,7 +49,7 @@ export const TransformPlugin = createUnplugin(({ ctx, options, sourcemap }: { ct
return {
code: s.toString(),
map: sourcemap
? s.generateMap({ source: id, includeContent: true })
? s.generateMap({ hires: true })
: undefined
}
}

View File

@ -58,7 +58,7 @@ export const PageMetaPlugin = createUnplugin((options: PageMetaPluginOptions) =>
return {
code: s.toString(),
map: options.sourcemap
? s.generateMap({ source: id, includeContent: true })
? s.generateMap({ hires: true })
: undefined
}
}

View File

@ -21,7 +21,7 @@ export const __vitePreload = (...args) => ___vitePreload(...args).catch(err => {
return {
code: s.toString(),
map: options.sourcemap
? s.generateMap({ source: id, includeContent: true })
? s.generateMap({ hires: true })
: undefined
}
}

View File

@ -86,7 +86,7 @@ export const composableKeysPlugin = createUnplugin((options: ComposableKeysOptio
return {
code: s.toString(),
map: options.sourcemap
? s.generateMap({ source: id, includeContent: true })
? s.generateMap({ hires: true })
: undefined
}
}

View File

@ -34,7 +34,7 @@ export function runtimePathsPlugin (options: RuntimePathsOptions): Plugin {
return {
code: s.toString(),
map: options.sourcemap
? s.generateMap({ source: id, includeContent: true })
? s.generateMap({ hires: true })
: undefined
}
}

View File

@ -29,7 +29,7 @@ export const pureAnnotationsPlugin = createUnplugin((options: PureAnnotationsOpt
return true
}
},
transform (code, id) {
transform (code) {
if (!FUNCTION_RE_SINGLE.test(code)) { return }
const s = new MagicString(code)
@ -43,7 +43,7 @@ export const pureAnnotationsPlugin = createUnplugin((options: PureAnnotationsOpt
return {
code: s.toString(),
map: options.sourcemap
? s.generateMap({ source: id, includeContent: true })
? s.generateMap({ hires: true })
: undefined
}
}

View File

@ -25,7 +25,7 @@ export const DynamicBasePlugin = createUnplugin((options: DynamicBasePluginOptio
return {
code: s.toString(),
map: options.sourcemap
? s.generateMap({ source: id, includeContent: true })
? s.generateMap({ hires: true })
: undefined
}
}