nit: move shiki highlighter consts to outer scope
This commit is contained in:
parent
aec7a0931f
commit
1de419034d
1 changed files with 5 additions and 3 deletions
|
@ -122,6 +122,10 @@ export interface AstroErrorPayload {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shiki does not support `mjs` or `cjs` aliases by default.
|
||||||
|
// Map these to `.js` during error highlighting.
|
||||||
|
const ALTERNATIVE_JS_EXTS = ['cjs', 'mjs'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a payload for Vite's error overlay
|
* Generate a payload for Vite's error overlay
|
||||||
*/
|
*/
|
||||||
|
@ -151,9 +155,7 @@ export async function getViteErrorPayload(err: ErrorWithMetadata): Promise<Astro
|
||||||
|
|
||||||
const highlighter = await getHighlighter({ theme: 'css-variables' });
|
const highlighter = await getHighlighter({ theme: 'css-variables' });
|
||||||
let highlighterLang = err.loc?.file?.split('.').pop();
|
let highlighterLang = err.loc?.file?.split('.').pop();
|
||||||
if (['cjs', 'mjs'].includes(highlighterLang ?? '')) {
|
if (ALTERNATIVE_JS_EXTS.includes(highlighterLang ?? '')) {
|
||||||
// Shiki does not support `mjs` or `cjs` aliases by default.
|
|
||||||
// Map these to `js` instead.
|
|
||||||
highlighterLang = 'js';
|
highlighterLang = 'js';
|
||||||
}
|
}
|
||||||
const highlightedCode = err.fullCode
|
const highlightedCode = err.fullCode
|
||||||
|
|
Loading…
Reference in a new issue