Remove legacy compiler error handling (#5855)
* refactor: remove legacy compiler handling * docs: add hint to unknown compiler error * feat: add link detection to error overlay * chore: update compiler * chore: update compiler issue link * Update packages/astro/src/core/errors/overlay.ts Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> Co-authored-by: Nate Moore <nate@astro.build> Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
This commit is contained in:
parent
39c1daa641
commit
16dc36a870
6 changed files with 21 additions and 32 deletions
5
.changeset/angry-spoons-flow.md
Normal file
5
.changeset/angry-spoons-flow.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Remove legacy compiler error handling
|
|
@ -99,7 +99,7 @@
|
|||
"test:e2e:match": "playwright test -g"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/compiler": "^0.32.0",
|
||||
"@astrojs/compiler": "^0.33.0",
|
||||
"@astrojs/language-server": "^0.28.3",
|
||||
"@astrojs/markdown-remark": "^2.0.0-beta.2",
|
||||
"@astrojs/telemetry": "^2.0.0-beta.0",
|
||||
|
|
|
@ -17,6 +17,7 @@ export const AstroErrorData = defineErrors({
|
|||
UnknownCompilerError: {
|
||||
title: 'Unknown compiler error.',
|
||||
code: 1000,
|
||||
hint: 'This is almost always a problem with the Astro compiler, not your code. Please open an issue at https://astro.build/issues/compiler.',
|
||||
},
|
||||
// 1xxx and 2xxx codes are reserved for compiler errors and warnings respectively
|
||||
/**
|
||||
|
@ -47,7 +48,7 @@ export const AstroErrorData = defineErrors({
|
|||
* - [Official integrations](https://docs.astro.build/en/guides/integrations-guide/#official-integrations)
|
||||
* - [Astro.clientAddress](https://docs.astro.build/en/reference/api-reference/#astroclientaddress)
|
||||
* @description
|
||||
* The adapter you.'re using unfortunately does not support `Astro.clientAddress`.
|
||||
* The adapter you're using unfortunately does not support `Astro.clientAddress`.
|
||||
*/
|
||||
ClientAddressNotAvailable: {
|
||||
title: '`Astro.clientAddress` is not available in current adapter.',
|
||||
|
|
|
@ -522,6 +522,15 @@ class ErrorOverlay extends HTMLElement {
|
|||
|
||||
const el = this.root.querySelector(selector);
|
||||
|
||||
if (html) {
|
||||
// Automatically detect links
|
||||
text = text.split(' ').map(v => {
|
||||
if (!v.startsWith('https://')) return v;
|
||||
if (v.endsWith('.')) return `<a target="_blank" href="${v.slice(0, -1)}">${v.slice(0, -1)}</a>.`
|
||||
return `<a target="_blank" href="${v}">${v}</a>`
|
||||
}).join(' ');
|
||||
}
|
||||
|
||||
if (el) {
|
||||
if (!html) {
|
||||
el.textContent = text.trim();
|
||||
|
|
|
@ -124,31 +124,5 @@ async function enhanceCompileError({
|
|||
}
|
||||
}
|
||||
|
||||
// improve compiler errors
|
||||
if (err.stack && err.stack.includes('wasm-function')) {
|
||||
const search = new URLSearchParams({
|
||||
labels: 'compiler',
|
||||
title: '🐛 BUG: `@astrojs/compiler` panic',
|
||||
template: '---01-bug-report.yml',
|
||||
'bug-description': `\`@astrojs/compiler\` encountered an unrecoverable error when compiling the following file.
|
||||
|
||||
**${id.replace(fileURLToPath(config.root), '')}**
|
||||
\`\`\`astro
|
||||
${source}
|
||||
\`\`\``,
|
||||
});
|
||||
(err as any).url = `https://github.com/withastro/astro/issues/new?${search.toString()}`;
|
||||
err.message = `Error: Uh oh, the Astro compiler encountered an unrecoverable error!
|
||||
|
||||
Please open
|
||||
a GitHub issue using the link below:
|
||||
${(err as any).url}`;
|
||||
|
||||
if (logging.level !== 'debug') {
|
||||
// TODO: remove stack replacement when compiler throws better errors
|
||||
err.stack = ` at ${id}`;
|
||||
}
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
|
|
@ -385,7 +385,7 @@ importers:
|
|||
|
||||
packages/astro:
|
||||
specifiers:
|
||||
'@astrojs/compiler': ^0.32.0
|
||||
'@astrojs/compiler': ^0.33.0
|
||||
'@astrojs/language-server': ^0.28.3
|
||||
'@astrojs/markdown-remark': ^2.0.0-beta.2
|
||||
'@astrojs/telemetry': ^2.0.0-beta.0
|
||||
|
@ -475,7 +475,7 @@ importers:
|
|||
yargs-parser: ^21.0.1
|
||||
zod: ^3.17.3
|
||||
dependencies:
|
||||
'@astrojs/compiler': 0.32.0
|
||||
'@astrojs/compiler': 0.33.0
|
||||
'@astrojs/language-server': 0.28.3
|
||||
'@astrojs/markdown-remark': link:../markdown/remark
|
||||
'@astrojs/telemetry': link:../telemetry
|
||||
|
@ -3834,8 +3834,8 @@ packages:
|
|||
/@astrojs/compiler/0.31.4:
|
||||
resolution: {integrity: sha512-6bBFeDTtPOn4jZaiD3p0f05MEGQL9pw2Zbfj546oFETNmjJFWO3nzHz6/m+P53calknCvyVzZ5YhoBLIvzn5iw==}
|
||||
|
||||
/@astrojs/compiler/0.32.0:
|
||||
resolution: {integrity: sha512-QL5qMGkfsC1/kDjJF4RRagz8/hACBUb19cHWrQ8AROphS42qXM6JhoO1Og5FohV3p2VfT5CdEJspn4uNsgZvmw==}
|
||||
/@astrojs/compiler/0.33.0:
|
||||
resolution: {integrity: sha512-REr2QpGR8+/ZccMFBcKqg5+cveuGG5C9b80XQn7ZCBkYDUJM+Yb2fC9koiWcK73ODXXDW14Ro+8+c58Q45lqRA==}
|
||||
dev: false
|
||||
|
||||
/@astrojs/language-server/0.28.3:
|
||||
|
|
Loading…
Reference in a new issue