diff --git a/.changeset/chatty-ways-hunt.md b/.changeset/chatty-ways-hunt.md new file mode 100644 index 000000000000..d6a9584a1354 --- /dev/null +++ b/.changeset/chatty-ways-hunt.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Adds a link to the error reference in the CLI when an error occurs diff --git a/.changeset/olive-moles-tan.md b/.changeset/olive-moles-tan.md new file mode 100644 index 000000000000..9840fd4e3891 --- /dev/null +++ b/.changeset/olive-moles-tan.md @@ -0,0 +1,5 @@ +--- +'@astrojs/deno': patch +--- + +TypeScript users now get better suggestions when configuring the Deno adapter. diff --git a/packages/astro/src/core/errors/dev/utils.ts b/packages/astro/src/core/errors/dev/utils.ts index 69026b6cd07b..837b52fdeb20 100644 --- a/packages/astro/src/core/errors/dev/utils.ts +++ b/packages/astro/src/core/errors/dev/utils.ts @@ -9,6 +9,7 @@ import { normalizePath } from 'vite'; import type { SSRError } from '../../../@types/astro.js'; import { removeLeadingForwardSlashWindows } from '../../path.js'; import { AggregateError, type ErrorWithMetadata } from '../errors.js'; +import { AstroErrorData } from '../index.js'; import { codeFrame } from '../printer.js'; import { normalizeLF } from '../utils.js'; @@ -206,13 +207,29 @@ function cleanErrorStack(stack: string) { .join('\n'); } +export function getDocsForError(err: ErrorWithMetadata): string | undefined { + if (err.name in AstroErrorData) { + return `https://docs.astro.build/en/reference/errors/${getKebabErrorName(err.name)}/`; + } + + return undefined; + + /** + * The docs has kebab-case urls for errors, so we need to convert the error name + * @param errorName + */ + function getKebabErrorName(errorName: string): string { + return errorName.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); + } +} + /** * Render a subset of Markdown to HTML or a CLI output */ export function renderErrorMarkdown(markdown: string, target: 'html' | 'cli') { const linkRegex = /\[(.+)\]\((.+)\)/gm; const boldRegex = /\*\*(.+)\*\*/gm; - const urlRegex = / (\b(https?|ftp):\/\/[-A-Z0-9+&@#\\/%?=~_|!:,.;]*[-A-Z0-9+&@#\\/%=~_|]) /gim; + const urlRegex = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\\/%?=~_|!:,.;]*[-A-Z0-9+&@#\\/%=~_|])/gim; const codeRegex = /`([^`]+)`/gim; if (target === 'html') { diff --git a/packages/astro/src/core/errors/dev/vite.ts b/packages/astro/src/core/errors/dev/vite.ts index 76ada28656c7..11e7cfe7431f 100644 --- a/packages/astro/src/core/errors/dev/vite.ts +++ b/packages/astro/src/core/errors/dev/vite.ts @@ -7,7 +7,7 @@ import { FailedToLoadModuleSSR, InvalidGlob, MdxIntegrationMissingError } from ' import { AstroError, type ErrorWithMetadata } from '../errors.js'; import { createSafeError } from '../utils.js'; import type { SSRLoadedRenderer } from './../../../@types/astro.js'; -import { renderErrorMarkdown } from './utils.js'; +import { getDocsForError, renderErrorMarkdown } from './utils.js'; export function enhanceViteSSRError({ error, @@ -137,10 +137,7 @@ export async function getViteErrorPayload(err: ErrorWithMetadata): Promise | undefined = undefined; diff --git a/packages/integrations/deno/src/types.ts b/packages/integrations/deno/src/types.ts new file mode 100644 index 000000000000..c44d0a842571 --- /dev/null +++ b/packages/integrations/deno/src/types.ts @@ -0,0 +1,11 @@ +export interface Options { + port?: number; + hostname?: string; + start?: boolean; +} + +export interface BuildConfig { + server: URL; + serverEntry: string; + assets: string; +} diff --git a/packages/integrations/react/README.md b/packages/integrations/react/README.md index 98eb252d3da1..00a574c547d3 100644 --- a/packages/integrations/react/README.md +++ b/packages/integrations/react/README.md @@ -113,7 +113,7 @@ import ReactComponent from './ReactComponent'; ``` -If you are using a library that _expects_ more than one child element element to be passed, for example so that it can slot certain elements in different places, you might find this to be a blocker. +If you are using a library that _expects_ more than one child element to be passed, for example so that it can slot certain elements in different places, you might find this to be a blocker. You can set the experimental flag `experimentalReactChildren` to tell Astro to always pass children to React as React vnodes. There is some runtime cost to this, but it can help with compatibility.