From 949d2f1447e2bfd5348d802649b7ae40b8502f8d Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Fri, 13 Jan 2023 14:36:02 -0600 Subject: [PATCH 1/6] refactor: remove legacy compiler handling --- .changeset/angry-spoons-flow.md | 5 ++++ .../astro/src/vite-plugin-astro/compile.ts | 26 ------------------- 2 files changed, 5 insertions(+), 26 deletions(-) create mode 100644 .changeset/angry-spoons-flow.md diff --git a/.changeset/angry-spoons-flow.md b/.changeset/angry-spoons-flow.md new file mode 100644 index 000000000000..e00f0cce2c32 --- /dev/null +++ b/.changeset/angry-spoons-flow.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Remove legacy compiler error handling diff --git a/packages/astro/src/vite-plugin-astro/compile.ts b/packages/astro/src/vite-plugin-astro/compile.ts index c42ef34b77c2..929dac2ca80a 100644 --- a/packages/astro/src/vite-plugin-astro/compile.ts +++ b/packages/astro/src/vite-plugin-astro/compile.ts @@ -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; } From b1acca9545f11a5d616f83f365fc31df4e42da7c Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Sun, 15 Jan 2023 14:24:18 -0600 Subject: [PATCH 2/6] docs: add hint to unknown compiler error --- packages/astro/src/core/errors/errors-data.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index 957a199583ee..5e5ae3e179ee 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -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.', }, // 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.', From 91bc2495c74d179b12dc9653cfbb957a036a8626 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 17 Jan 2023 08:26:40 -0600 Subject: [PATCH 3/6] feat: add link detection to error overlay --- packages/astro/src/core/errors/overlay.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/astro/src/core/errors/overlay.ts b/packages/astro/src/core/errors/overlay.ts index 7ed3df148411..e08a7e1b2d19 100644 --- a/packages/astro/src/core/errors/overlay.ts +++ b/packages/astro/src/core/errors/overlay.ts @@ -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 `${v.slice(0, -1)}.` + return `${v}` + }).join(' '); + } + if (el) { if (!html) { el.textContent = text.trim(); From 4429b44cef8fb23aaf92f9c5c9d9d57b0e11c19c Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 17 Jan 2023 09:29:48 -0600 Subject: [PATCH 4/6] chore: update compiler --- packages/astro/package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/astro/package.json b/packages/astro/package.json index afcae5bfefd1..9bfa2681c2ea 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -109,7 +109,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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 53f439ebb7d3..96914ea8a86c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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 @@ -3836,8 +3836,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: From 85b9f98804c1093ca60f0a2e218b416156d849b8 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 17 Jan 2023 09:31:28 -0600 Subject: [PATCH 5/6] chore: update compiler issue link --- packages/astro/src/core/errors/errors-data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index 5e5ae3e179ee..0fc56a06d8ea 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -17,7 +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.', + 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 /** From 54ee2e39ccdebf48030efe054e608cc110348283 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Wed, 18 Jan 2023 09:46:14 -0600 Subject: [PATCH 6/6] Update packages/astro/src/core/errors/overlay.ts Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> --- packages/astro/src/core/errors/overlay.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/core/errors/overlay.ts b/packages/astro/src/core/errors/overlay.ts index e08a7e1b2d19..8eb297ea008b 100644 --- a/packages/astro/src/core/errors/overlay.ts +++ b/packages/astro/src/core/errors/overlay.ts @@ -526,8 +526,8 @@ class ErrorOverlay extends HTMLElement { // Automatically detect links text = text.split(' ').map(v => { if (!v.startsWith('https://')) return v; - if (v.endsWith('.')) return `${v.slice(0, -1)}.` - return `${v}` + if (v.endsWith('.')) return `${v.slice(0, -1)}.` + return `${v}` }).join(' '); }