From 42037f33e644d5a2bfba71377697fc7336ecb15b Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Wed, 2 Oct 2024 17:08:36 +0100 Subject: [PATCH 01/23] fix: pass custom statusText in Response (#12105) * fix: pass custom statusText in Response * Add changeset --- .changeset/moody-doors-wink.md | 5 +++++ packages/astro/src/core/app/node.ts | 3 ++- .../astro/src/vite-plugin-astro-server/response.ts | 4 ++-- .../fixtures/ssr-api-route/src/pages/food.json.js | 11 ++++++++--- packages/astro/test/ssr-api-route.test.js | 12 ++++++++++++ 5 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 .changeset/moody-doors-wink.md diff --git a/.changeset/moody-doors-wink.md b/.changeset/moody-doors-wink.md new file mode 100644 index 000000000000..38a7cadf9bd9 --- /dev/null +++ b/.changeset/moody-doors-wink.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Returns custom statusText that has been set in a Response diff --git a/packages/astro/src/core/app/node.ts b/packages/astro/src/core/app/node.ts index f9afa6189d5a..9fa1b645ff22 100644 --- a/packages/astro/src/core/app/node.ts +++ b/packages/astro/src/core/app/node.ts @@ -107,7 +107,8 @@ export class NodeApp extends App { * @param destination NodeJS ServerResponse */ static async writeResponse(source: Response, destination: ServerResponse) { - const { status, headers, body } = source; + const { status, headers, body, statusText } = source; + destination.statusMessage = statusText; destination.writeHead(status, createOutgoingHttpHeaders(headers)); if (!body) return destination.end(); try { diff --git a/packages/astro/src/vite-plugin-astro-server/response.ts b/packages/astro/src/vite-plugin-astro-server/response.ts index 707a26e4091c..bc316d7c21f2 100644 --- a/packages/astro/src/vite-plugin-astro-server/response.ts +++ b/packages/astro/src/vite-plugin-astro-server/response.ts @@ -53,7 +53,7 @@ export function writeHtmlResponse(res: http.ServerResponse, statusCode: number, } export async function writeWebResponse(res: http.ServerResponse, webResponse: Response) { - const { status, headers, body } = webResponse; + const { status, headers, body, statusText } = webResponse; // Attach any set-cookie headers added via Astro.cookies.set() const setCookieHeaders = Array.from(getSetCookiesFromResponse(webResponse)); @@ -67,7 +67,7 @@ export async function writeWebResponse(res: http.ServerResponse, webResponse: Re if (headers.has('set-cookie')) { _headers['set-cookie'] = headers.getSetCookie(); } - + res.statusMessage = statusText; res.writeHead(status, _headers); if (body) { if (Symbol.for('astro.responseBody') in webResponse) { diff --git a/packages/astro/test/fixtures/ssr-api-route/src/pages/food.json.js b/packages/astro/test/fixtures/ssr-api-route/src/pages/food.json.js index 2d6fb6d1b236..e145757b1342 100644 --- a/packages/astro/test/fixtures/ssr-api-route/src/pages/food.json.js +++ b/packages/astro/test/fixtures/ssr-api-route/src/pages/food.json.js @@ -5,14 +5,19 @@ export function GET() { { name: 'lettuce' }, { name: 'broccoli' }, { name: 'pizza' } - ]) + ]), { + status: 200, + statusText: `tasty`, + } ) } export async function POST({ params, request }) { const body = await request.text(); - return new Response(body === `some data` ? `ok` : `not ok`, { - status: 200, + const ok = body === `some data` + return new Response( ok ? `ok` : `not ok`, { + status: ok ? 200 : 400, + statusText: ok ? `ok` : `not ok`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } diff --git a/packages/astro/test/ssr-api-route.test.js b/packages/astro/test/ssr-api-route.test.js index 2e7405326fcc..ecdf458472e7 100644 --- a/packages/astro/test/ssr-api-route.test.js +++ b/packages/astro/test/ssr-api-route.test.js @@ -33,6 +33,7 @@ describe('API routes in SSR', () => { const request = new Request('http://example.com/food.json'); const response = await app.render(request); assert.equal(response.status, 200); + assert.equal(response.statusText, 'tasty'); const body = await response.json(); assert.equal(body.length, 3); }); @@ -78,6 +79,17 @@ describe('API routes in SSR', () => { assert.equal(text, 'ok'); }); + it('Can read custom status text from API routes', async () => { + const response = await fixture.fetch('/food.json', { + method: 'POST', + body: `not some data`, + }); + assert.equal(response.status, 400); + assert.equal(response.statusText, 'not ok'); + const text = await response.text(); + assert.equal(text, 'not ok'); + }); + it('Can be passed binary data from multipart formdata', async () => { const formData = new FormData(); const raw = await fs.promises.readFile( From fbe1bc51d89994c4919c12768908658604513bd3 Mon Sep 17 00:00:00 2001 From: Sondre Aasemoen Date: Thu, 3 Oct 2024 10:01:42 +0200 Subject: [PATCH 02/23] feat(sitemap): add xslURL to enable styling (#11485) * feat(sitemap): add xslURL to enable styling * Add test * Update .changeset/proud-horses-cry.md --------- Co-authored-by: bluwy Co-authored-by: Florian Lefebvre --- .changeset/proud-horses-cry.md | 5 ++++ packages/integrations/sitemap/src/index.ts | 8 ++++--- packages/integrations/sitemap/src/schema.ts | 1 + .../integrations/sitemap/src/write-sitemap.ts | 5 +++- .../test/{filter.test.js => config.test.js} | 24 ++++++++++++++++--- 5 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 .changeset/proud-horses-cry.md rename packages/integrations/sitemap/test/{filter.test.js => config.test.js} (61%) diff --git a/.changeset/proud-horses-cry.md b/.changeset/proud-horses-cry.md new file mode 100644 index 000000000000..8d086b071c59 --- /dev/null +++ b/.changeset/proud-horses-cry.md @@ -0,0 +1,5 @@ +--- +'@astrojs/sitemap': minor +--- + +Adds new `xslURL` option to enable styling of sitemaps diff --git a/packages/integrations/sitemap/src/index.ts b/packages/integrations/sitemap/src/index.ts index 057fc2371d62..4342ed5dba0b 100644 --- a/packages/integrations/sitemap/src/index.ts +++ b/packages/integrations/sitemap/src/index.ts @@ -88,7 +88,7 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { const { filter, customPages, serialize, entryLimit } = opts; - let finalSiteUrl = new URL(config.base, config.site); + const finalSiteUrl = new URL(config.base, config.site); const shouldIgnoreStatus = isStatusCodePage(Object.keys(opts.i18n?.locales ?? {})); let pageUrls = pages .filter((p) => !shouldIgnoreStatus(p.pathname)) @@ -100,7 +100,7 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { return new URL(fullPath, finalSiteUrl).href; }); - let routeUrls = routes.reduce((urls, r) => { + const routeUrls = routes.reduce((urls, r) => { // Only expose pages, not endpoints or redirects if (r.type !== 'page') return urls; @@ -116,7 +116,7 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { if (fullPath.endsWith('/')) fullPath += r.generate(r.pathname).substring(1); else fullPath += r.generate(r.pathname); - let newUrl = new URL(fullPath, finalSiteUrl).href; + const newUrl = new URL(fullPath, finalSiteUrl).href; if (config.trailingSlash === 'never') { urls.push(newUrl); @@ -168,6 +168,7 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { } } const destDir = fileURLToPath(dir); + const xslURL = opts.xslURL ? new URL(opts.xslURL, finalSiteUrl).href : undefined; await writeSitemap( { hostname: finalSiteUrl.href, @@ -175,6 +176,7 @@ const createPlugin = (options?: SitemapOptions): AstroIntegration => { publicBasePath: config.base, sourceData: urlData, limit: entryLimit, + xslURL: xslURL, }, config, ); diff --git a/packages/integrations/sitemap/src/schema.ts b/packages/integrations/sitemap/src/schema.ts index 17ca41b413cc..ba5438452395 100644 --- a/packages/integrations/sitemap/src/schema.ts +++ b/packages/integrations/sitemap/src/schema.ts @@ -9,6 +9,7 @@ export const SitemapOptionsSchema = z filter: z.function().args(z.string()).returns(z.boolean()).optional(), customPages: z.string().url().array().optional(), canonicalURL: z.string().url().optional(), + xslURL: z.string().optional(), i18n: z .object({ diff --git a/packages/integrations/sitemap/src/write-sitemap.ts b/packages/integrations/sitemap/src/write-sitemap.ts index 4c189ee3c990..ef36f1ab2497 100644 --- a/packages/integrations/sitemap/src/write-sitemap.ts +++ b/packages/integrations/sitemap/src/write-sitemap.ts @@ -17,6 +17,7 @@ type WriteSitemapConfig = { destinationDir: string; publicBasePath?: string; limit?: number; + xslURL?: string; }; // adapted from sitemap.js/sitemap-simple @@ -28,6 +29,7 @@ export async function writeSitemap( destinationDir, limit = 50000, publicBasePath = './', + xslURL: xslUrl, }: WriteSitemapConfig, astroConfig: AstroConfig, ) { @@ -38,6 +40,7 @@ export async function writeSitemap( getSitemapStream: (i) => { const sitemapStream = new SitemapStream({ hostname, + xslUrl, }); const path = `./sitemap-${i}.xml`; const writePath = resolve(destinationDir, path); @@ -63,7 +66,7 @@ export async function writeSitemap( }, }); - let src = Readable.from(sourceData); + const src = Readable.from(sourceData); const indexPath = resolve(destinationDir, `./sitemap-index.xml`); return promisify(pipeline)(src, sitemapAndIndexStream, createWriteStream(indexPath)); } diff --git a/packages/integrations/sitemap/test/filter.test.js b/packages/integrations/sitemap/test/config.test.js similarity index 61% rename from packages/integrations/sitemap/test/filter.test.js rename to packages/integrations/sitemap/test/config.test.js index adecb59e6c0e..e4b7c38826e8 100644 --- a/packages/integrations/sitemap/test/filter.test.js +++ b/packages/integrations/sitemap/test/config.test.js @@ -3,7 +3,7 @@ import { before, describe, it } from 'node:test'; import { sitemap } from './fixtures/static/deps.mjs'; import { loadFixture, readXML } from './test-utils.js'; -describe('Filter support', () => { +describe('Config', () => { /** @type {import('./test-utils.js').Fixture} */ let fixture; @@ -14,17 +14,26 @@ describe('Filter support', () => { integrations: [ sitemap({ filter: (page) => page === 'http://example.com/one/', + xslURL: '/sitemap.xsl', }), ], }); await fixture.build(); }); - it('Just one page is added', async () => { + it('filter: Just one page is added', async () => { const data = await readXML(fixture.readFile('/sitemap-0.xml')); const urls = data.urlset.url; assert.equal(urls.length, 1); }); + + it('xslURL: Includes xml-stylsheet', async () => { + const xml = await fixture.readFile('/sitemap-0.xml'); + assert.ok( + xml.includes(''), + xml, + ); + }); }); describe('SSR', () => { @@ -34,16 +43,25 @@ describe('Filter support', () => { integrations: [ sitemap({ filter: (page) => page === 'http://example.com/one/', + xslURL: '/sitemap.xsl', }), ], }); await fixture.build(); }); - it('Just one page is added', async () => { + it('filter: Just one page is added', async () => { const data = await readXML(fixture.readFile('/client/sitemap-0.xml')); const urls = data.urlset.url; assert.equal(urls.length, 1); }); + + it('xslURL: Includes xml-stylsheet', async () => { + const xml = await fixture.readFile('/client/sitemap-0.xml'); + assert.ok( + xml.includes(''), + xml, + ); + }); }); }); From d3a74da19644477ffc81acf2a3efb26ad3335a5e Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Thu, 3 Oct 2024 09:21:11 +0100 Subject: [PATCH 03/23] fix: handle immutable response object (#12106) * fix: handle immutable response object * changeset --- .changeset/poor-doors-listen.md | 5 +++++ packages/astro/src/runtime/server/endpoint.ts | 20 ++++++++++++++----- .../fixtures/ssr-api-route/src/pages/fail.js | 3 +++ packages/astro/test/ssr-api-route.test.js | 20 ++++++++++++------- 4 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 .changeset/poor-doors-listen.md create mode 100644 packages/astro/test/fixtures/ssr-api-route/src/pages/fail.js diff --git a/.changeset/poor-doors-listen.md b/.changeset/poor-doors-listen.md new file mode 100644 index 000000000000..098cf769104b --- /dev/null +++ b/.changeset/poor-doors-listen.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Handles case where an immutable Response object is returned from an endpoint diff --git a/packages/astro/src/runtime/server/endpoint.ts b/packages/astro/src/runtime/server/endpoint.ts index 900d604fd569..473cae180d6f 100644 --- a/packages/astro/src/runtime/server/endpoint.ts +++ b/packages/astro/src/runtime/server/endpoint.ts @@ -50,7 +50,7 @@ export async function renderEndpoint( return new Response(null, { status: 500 }); } - const response = await handler.call(mod, context); + let response = await handler.call(mod, context); if (!response || response instanceof Response === false) { throw new AstroError(EndpointDidNotReturnAResponse); @@ -59,10 +59,20 @@ export async function renderEndpoint( // Endpoints explicitly returning 404 or 500 response status should // NOT be subject to rerouting to 404.astro or 500.astro. if (REROUTABLE_STATUS_CODES.includes(response.status)) { - // Only `Response.redirect` headers are immutable, therefore a `try..catch` is not necessary. - // Note: `Response.redirect` can only be called with HTTP status codes: 301, 302, 303, 307, 308. - // Source: https://developer.mozilla.org/en-US/docs/Web/API/Response/redirect_static#parameters - response.headers.set(REROUTE_DIRECTIVE_HEADER, 'no'); + try { + response.headers.set(REROUTE_DIRECTIVE_HEADER, 'no'); + } catch (err) { + // In some cases the response may have immutable headers + // This is the case if, for example, the user directly returns a `fetch` response + // There's no clean way to check if the headers are immutable, so we just catch the error + // Note that response.clone() still has immutable headers! + if((err as Error).message?.includes('immutable')) { + response = new Response(response.body, response); + response.headers.set(REROUTE_DIRECTIVE_HEADER, 'no'); + } else { + throw err; + } + } } return response; diff --git a/packages/astro/test/fixtures/ssr-api-route/src/pages/fail.js b/packages/astro/test/fixtures/ssr-api-route/src/pages/fail.js new file mode 100644 index 000000000000..f9852dd93794 --- /dev/null +++ b/packages/astro/test/fixtures/ssr-api-route/src/pages/fail.js @@ -0,0 +1,3 @@ +export async function GET({ request }) { + return fetch("https://http.im/status/500", request) +} diff --git a/packages/astro/test/ssr-api-route.test.js b/packages/astro/test/ssr-api-route.test.js index ecdf458472e7..8e9c1bb5efa8 100644 --- a/packages/astro/test/ssr-api-route.test.js +++ b/packages/astro/test/ssr-api-route.test.js @@ -137,23 +137,29 @@ describe('API routes in SSR', () => { assert.equal(count, 2, 'Found two separate set-cookie response headers'); }); + it('can return an immutable response object', async () => { + const response = await fixture.fetch('/fail'); + const text = await response.text(); + assert.equal(response.status, 500); + assert.equal(text, ''); + }); + it('Has valid api context', async () => { const response = await fixture.fetch('/context/any'); assert.equal(response.status, 200); const data = await response.json(); - assert.equal(data.cookiesExist, true); - assert.equal(data.requestExist, true); - assert.equal(data.redirectExist, true); - assert.equal(data.propsExist, true); + assert.ok(data.cookiesExist); + assert.ok(data.requestExist); + assert.ok(data.redirectExist); + assert.ok(data.propsExist); assert.deepEqual(data.params, { param: 'any' }); assert.match(data.generator, /^Astro v/); - assert.equal( + assert.ok( ['http://[::1]:4321/blog/context/any', 'http://127.0.0.1:4321/blog/context/any'].includes( data.url, ), - true, ); - assert.equal(['::1', '127.0.0.1'].includes(data.clientAddress), true); + assert.ok(['::1', '127.0.0.1'].includes(data.clientAddress)); assert.equal(data.site, 'https://mysite.dev/subsite/'); }); }); From fdba5f344fc63802f1d1e7821b0da83d39f666ae Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Thu, 3 Oct 2024 08:21:59 +0000 Subject: [PATCH 04/23] [ci] format --- packages/astro/src/runtime/server/endpoint.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/runtime/server/endpoint.ts b/packages/astro/src/runtime/server/endpoint.ts index 473cae180d6f..a8f9403fe824 100644 --- a/packages/astro/src/runtime/server/endpoint.ts +++ b/packages/astro/src/runtime/server/endpoint.ts @@ -66,7 +66,7 @@ export async function renderEndpoint( // This is the case if, for example, the user directly returns a `fetch` response // There's no clean way to check if the headers are immutable, so we just catch the error // Note that response.clone() still has immutable headers! - if((err as Error).message?.includes('immutable')) { + if ((err as Error).message?.includes('immutable')) { response = new Response(response.body, response); response.headers.set(REROUTE_DIRECTIVE_HEADER, 'no'); } else { From 918953bd09f057131dfe029e810019c0909345cf Mon Sep 17 00:00:00 2001 From: lam eu ler <27113373+lameuler@users.noreply.github.com> Date: Thu, 3 Oct 2024 17:54:01 +0800 Subject: [PATCH 05/23] use shorthash for data url image to prevent ENAMETOOLONG (#12108) * use shorthash for filename of data url images * add changeset * add fixture to test processing of data url images * run format * update changeset * fix test * Update .changeset/dull-worms-own.md --------- Co-authored-by: Emanuele Stoppa --- .changeset/dull-worms-own.md | 5 ++ .../astro/src/assets/utils/transformToPath.ts | 6 ++- packages/astro/test/core-image.test.js | 53 +++++++++++++++++++ .../fixtures/core-image-data-url/package.json | 8 +++ .../core-image-data-url/src/pages/index.astro | 17 ++++++ pnpm-lock.yaml | 6 +++ 6 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 .changeset/dull-worms-own.md create mode 100644 packages/astro/test/fixtures/core-image-data-url/package.json create mode 100644 packages/astro/test/fixtures/core-image-data-url/src/pages/index.astro diff --git a/.changeset/dull-worms-own.md b/.changeset/dull-worms-own.md new file mode 100644 index 000000000000..fb5384d01571 --- /dev/null +++ b/.changeset/dull-worms-own.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes a bug where [data URL images](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data) were not correctly handled. The bug resulted in an `ENAMETOOLONG` error. diff --git a/packages/astro/src/assets/utils/transformToPath.ts b/packages/astro/src/assets/utils/transformToPath.ts index 554761487de9..e11680a12269 100644 --- a/packages/astro/src/assets/utils/transformToPath.ts +++ b/packages/astro/src/assets/utils/transformToPath.ts @@ -8,7 +8,11 @@ import { isESMImportedImage } from './imageKind.js'; export function propsToFilename(filePath: string, transform: ImageTransform, hash: string) { let filename = decodeURIComponent(removeQueryString(filePath)); const ext = extname(filename); - filename = basename(filename, ext); + if (filePath.startsWith('data:')) { + filename = shorthash(filePath); + } else { + filename = basename(filename, ext); + } const prefixDirname = isESMImportedImage(transform.src) ? dirname(filePath) : ''; let outputExt = transform.format ? `.${transform.format}` : ext; diff --git a/packages/astro/test/core-image.test.js b/packages/astro/test/core-image.test.js index 9c62a679ef80..887a3a35de69 100644 --- a/packages/astro/test/core-image.test.js +++ b/packages/astro/test/core-image.test.js @@ -1263,4 +1263,57 @@ describe('astro:image', () => { assert.equal(imgData instanceof Buffer, true); }); }); + + describe('build data url', () => { + before(async () => { + fixture = await loadFixture({ + root: './fixtures/core-image-data-url/', + image: { + remotePatterns: [ + { + protocol: 'data', + }, + ], + }, + }); + + await fixture.build(); + }); + + it('uses short hash for data url filename', async () => { + const html = await fixture.readFile('/index.html'); + const $ = cheerio.load(html); + const src1 = $('#data-url img').attr('src'); + assert.equal(basename(src1).length < 32, true); + const src2 = $('#data-url-no-size img').attr('src'); + assert.equal(basename(src2).length < 32, true); + assert.equal(src1.split('_')[0], src2.split('_')[0]); + }); + + it('adds file extension for data url images', async () => { + const html = await fixture.readFile('/index.html'); + const $ = cheerio.load(html); + const src = $('#data-url img').attr('src'); + assert.equal(src.endsWith('.webp'), true); + }); + + it('writes data url images to dist', async () => { + const html = await fixture.readFile('/index.html'); + const $ = cheerio.load(html); + const src = $('#data-url img').attr('src'); + assert.equal(src.length > 0, true); + const data = await fixture.readFile(src, null); + assert.equal(data instanceof Buffer, true); + }); + + it('infers size of data url images', async () => { + const html = await fixture.readFile('/index.html'); + const $ = cheerio.load(html); + const img = $('#data-url-no-size img'); + const width = img.attr('width'); + const height = img.attr('height'); + assert.equal(width, '256'); + assert.equal(height, '144'); + }); + }); }); diff --git a/packages/astro/test/fixtures/core-image-data-url/package.json b/packages/astro/test/fixtures/core-image-data-url/package.json new file mode 100644 index 000000000000..a402422dbb20 --- /dev/null +++ b/packages/astro/test/fixtures/core-image-data-url/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/core-image-data-url", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} \ No newline at end of file diff --git a/packages/astro/test/fixtures/core-image-data-url/src/pages/index.astro b/packages/astro/test/fixtures/core-image-data-url/src/pages/index.astro new file mode 100644 index 000000000000..5e8d291480f9 --- /dev/null +++ b/packages/astro/test/fixtures/core-image-data-url/src/pages/index.astro @@ -0,0 +1,17 @@ +--- +import { Image } from 'astro:assets'; +const data = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAACQCAQAAABNan0aAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAKqNIzIAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQflBAsNKgIhYT8HAAAAXklEQVR42u3BMQEAAADCoPVPbQlPoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4G8gnwABm4i4EAAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMS0wNC0xMVQxMzo0MjowMiswMDowMNhkaiwAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDQtMTFUMTM6NDI6MDIrMDA6MDCpOdKQAAAAAElFTkSuQmCC" +--- + + + + + +
+ transparent +
+
+ transparent +
+ + \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ffb68676bd0b..08d69a407b11 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2813,6 +2813,12 @@ importers: specifier: workspace:* version: link:../../.. + packages/astro/test/fixtures/core-image-data-url: + dependencies: + astro: + specifier: workspace:* + version: link:../../.. + packages/astro/test/fixtures/core-image-deletion: dependencies: '@astrojs/markdoc': From ea225585fd12d27006434266163512ca66ad572b Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 3 Oct 2024 14:38:23 +0100 Subject: [PATCH 06/23] fix(routing): incorrect assumption when loading the middleware (#12109) --- .changeset/nasty-trains-invite.md | 7 +++++++ packages/astro/src/core/app/types.ts | 2 +- packages/astro/src/core/base-pipeline.ts | 8 +++++++- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .changeset/nasty-trains-invite.md diff --git a/.changeset/nasty-trains-invite.md b/.changeset/nasty-trains-invite.md new file mode 100644 index 000000000000..48f3cb1c84d6 --- /dev/null +++ b/.changeset/nasty-trains-invite.md @@ -0,0 +1,7 @@ +--- +'astro': patch +--- + +Fixes a regression that was introduced by an internal refactor of how the middleware is loaded by the Astro application. The regression was introduced by [#11550](https://github.com/withastro/astro/pull/11550). + +When the edge middleware feature is opted in, Astro removes the middleware function from the SSR manifest, and this wasn't taken into account during the refactor. diff --git a/packages/astro/src/core/app/types.ts b/packages/astro/src/core/app/types.ts index 73ddea268d9a..66035e4d5697 100644 --- a/packages/astro/src/core/app/types.ts +++ b/packages/astro/src/core/app/types.ts @@ -68,7 +68,7 @@ export type SSRManifest = { serverIslandNameMap?: Map; key: Promise; i18n: SSRManifestI18n | undefined; - middleware: () => Promise | AstroMiddlewareInstance; + middleware?: () => Promise | AstroMiddlewareInstance; checkOrigin: boolean; // TODO: remove experimental prefix experimentalEnvGetSecretEnabled: boolean; diff --git a/packages/astro/src/core/base-pipeline.ts b/packages/astro/src/core/base-pipeline.ts index 8a448133ab3d..b1fc5568e0a6 100644 --- a/packages/astro/src/core/base-pipeline.ts +++ b/packages/astro/src/core/base-pipeline.ts @@ -109,7 +109,10 @@ export abstract class Pipeline { async getMiddleware(): Promise { if (this.resolvedMiddleware) { return this.resolvedMiddleware; - } else { + } + // The middleware can be undefined when using edge middleware. + // This is set to undefined by the plugin-ssr.ts + else if (this.middleware) { const middlewareInstance = await this.middleware(); const onRequest = middlewareInstance.onRequest ?? NOOP_MIDDLEWARE_FN; if (this.manifest.checkOrigin) { @@ -118,6 +121,9 @@ export abstract class Pipeline { this.resolvedMiddleware = onRequest; } return this.resolvedMiddleware; + } else { + this.resolvedMiddleware = NOOP_MIDDLEWARE_FN; + return this.resolvedMiddleware } } } From 406a21fe4673cbcaaf123ffc6bae62a2ef12c748 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 3 Oct 2024 13:39:16 +0000 Subject: [PATCH 07/23] [ci] format --- packages/astro/src/core/base-pipeline.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/core/base-pipeline.ts b/packages/astro/src/core/base-pipeline.ts index b1fc5568e0a6..4eeb2f0525b5 100644 --- a/packages/astro/src/core/base-pipeline.ts +++ b/packages/astro/src/core/base-pipeline.ts @@ -111,7 +111,7 @@ export abstract class Pipeline { return this.resolvedMiddleware; } // The middleware can be undefined when using edge middleware. - // This is set to undefined by the plugin-ssr.ts + // This is set to undefined by the plugin-ssr.ts else if (this.middleware) { const middlewareInstance = await this.middleware(); const onRequest = middlewareInstance.onRequest ?? NOOP_MIDDLEWARE_FN; @@ -123,7 +123,7 @@ export abstract class Pipeline { return this.resolvedMiddleware; } else { this.resolvedMiddleware = NOOP_MIDDLEWARE_FN; - return this.resolvedMiddleware + return this.resolvedMiddleware; } } } From 34d79527a4cd88864c4a9128a393c0d2f7d9eda7 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 3 Oct 2024 06:50:19 -0700 Subject: [PATCH 08/23] [ci] release (#12098) Co-authored-by: github-actions[bot] --- .changeset/bright-swans-shout.md | 5 -- .changeset/dull-worms-own.md | 5 -- .changeset/moody-doors-wink.md | 5 -- .changeset/nasty-trains-invite.md | 7 --- .changeset/poor-doors-listen.md | 5 -- .changeset/proud-horses-cry.md | 5 -- .changeset/rich-apes-divide.md | 5 -- examples/basics/package.json | 2 +- examples/blog/package.json | 4 +- examples/component/package.json | 2 +- examples/container-with-vitest/package.json | 2 +- examples/framework-alpine/package.json | 2 +- examples/framework-lit/package.json | 2 +- examples/framework-multiple/package.json | 2 +- examples/framework-preact/package.json | 2 +- examples/framework-react/package.json | 2 +- examples/framework-solid/package.json | 2 +- examples/framework-svelte/package.json | 2 +- examples/framework-vue/package.json | 2 +- examples/hackernews/package.json | 2 +- examples/integration/package.json | 2 +- examples/middleware/package.json | 2 +- examples/minimal/package.json | 2 +- examples/non-html-pages/package.json | 2 +- examples/portfolio/package.json | 2 +- examples/server-islands/package.json | 2 +- examples/ssr/package.json | 2 +- examples/starlog/package.json | 2 +- examples/toolbar-app/package.json | 2 +- examples/view-transitions/package.json | 2 +- examples/with-markdoc/package.json | 2 +- examples/with-markdown-plugins/package.json | 2 +- examples/with-markdown-shiki/package.json | 2 +- examples/with-mdx/package.json | 2 +- examples/with-nanostores/package.json | 2 +- examples/with-tailwindcss/package.json | 2 +- examples/with-vitest/package.json | 2 +- packages/astro/CHANGELOG.md | 18 ++++++ packages/astro/package.json | 2 +- packages/integrations/sitemap/CHANGELOG.md | 6 ++ packages/integrations/sitemap/package.json | 2 +- pnpm-lock.yaml | 62 ++++++++++----------- 42 files changed, 88 insertions(+), 101 deletions(-) delete mode 100644 .changeset/bright-swans-shout.md delete mode 100644 .changeset/dull-worms-own.md delete mode 100644 .changeset/moody-doors-wink.md delete mode 100644 .changeset/nasty-trains-invite.md delete mode 100644 .changeset/poor-doors-listen.md delete mode 100644 .changeset/proud-horses-cry.md delete mode 100644 .changeset/rich-apes-divide.md diff --git a/.changeset/bright-swans-shout.md b/.changeset/bright-swans-shout.md deleted file mode 100644 index 9be80e806d6a..000000000000 --- a/.changeset/bright-swans-shout.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes error where references in content layer schemas sometimes incorrectly report as missing diff --git a/.changeset/dull-worms-own.md b/.changeset/dull-worms-own.md deleted file mode 100644 index fb5384d01571..000000000000 --- a/.changeset/dull-worms-own.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes a bug where [data URL images](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data) were not correctly handled. The bug resulted in an `ENAMETOOLONG` error. diff --git a/.changeset/moody-doors-wink.md b/.changeset/moody-doors-wink.md deleted file mode 100644 index 38a7cadf9bd9..000000000000 --- a/.changeset/moody-doors-wink.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Returns custom statusText that has been set in a Response diff --git a/.changeset/nasty-trains-invite.md b/.changeset/nasty-trains-invite.md deleted file mode 100644 index 48f3cb1c84d6..000000000000 --- a/.changeset/nasty-trains-invite.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'astro': patch ---- - -Fixes a regression that was introduced by an internal refactor of how the middleware is loaded by the Astro application. The regression was introduced by [#11550](https://github.com/withastro/astro/pull/11550). - -When the edge middleware feature is opted in, Astro removes the middleware function from the SSR manifest, and this wasn't taken into account during the refactor. diff --git a/.changeset/poor-doors-listen.md b/.changeset/poor-doors-listen.md deleted file mode 100644 index 098cf769104b..000000000000 --- a/.changeset/poor-doors-listen.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Handles case where an immutable Response object is returned from an endpoint diff --git a/.changeset/proud-horses-cry.md b/.changeset/proud-horses-cry.md deleted file mode 100644 index 8d086b071c59..000000000000 --- a/.changeset/proud-horses-cry.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/sitemap': minor ---- - -Adds new `xslURL` option to enable styling of sitemaps diff --git a/.changeset/rich-apes-divide.md b/.changeset/rich-apes-divide.md deleted file mode 100644 index c0f70e5b9696..000000000000 --- a/.changeset/rich-apes-divide.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Server islands: changes the server island HTML placeholder comment so that it is much less likely to get removed by HTML minifiers. diff --git a/examples/basics/package.json b/examples/basics/package.json index 61491cc9884c..cc794deb39dc 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 82509d804dee..8f20c398ca6e 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^3.1.7", "@astrojs/rss": "^4.0.7", - "@astrojs/sitemap": "^3.1.6", - "astro": "^4.15.10" + "@astrojs/sitemap": "^3.2.0", + "astro": "^4.15.11" } } diff --git a/examples/component/package.json b/examples/component/package.json index 23954920fd68..350d58f40956 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index 470dd7af1a14..7ab82e6fff07 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest run" }, "dependencies": { - "astro": "^4.15.10", + "astro": "^4.15.11", "@astrojs/react": "^3.6.2", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index da225dfe4163..672050c57a51 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -14,6 +14,6 @@ "@astrojs/alpinejs": "^0.4.0", "@types/alpinejs": "^3.13.10", "alpinejs": "^3.14.1", - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 20d76f401af1..e346a30c25fb 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/lit": "^4.3.0", "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^4.15.10", + "astro": "^4.15.11", "lit": "^3.2.0" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 249d4ac6dfbf..06ddcda852a6 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -18,7 +18,7 @@ "@astrojs/vue": "^4.5.1", "@types/react": "^18.3.10", "@types/react-dom": "^18.3.0", - "astro": "^4.15.10", + "astro": "^4.15.11", "preact": "^10.24.1", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index ba60f0564b47..bf08ffed67d9 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.3", "@preact/signals": "^1.3.0", - "astro": "^4.15.10", + "astro": "^4.15.11", "preact": "^10.24.1" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index fd5ab9d07441..7216053ef802 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.6.2", "@types/react": "^18.3.10", "@types/react-dom": "^18.3.0", - "astro": "^4.15.10", + "astro": "^4.15.11", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index edfde49d14be..cb99bbb437b3 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^4.4.2", - "astro": "^4.15.10", + "astro": "^4.15.11", "solid-js": "^1.9.1" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index f198f9c8bc0a..48e01dd8433c 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^5.7.1", - "astro": "^4.15.10", + "astro": "^4.15.11", "svelte": "^4.2.19" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 92632633afd6..9b931b8c2dc1 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^4.5.1", - "astro": "^4.15.10", + "astro": "^4.15.11", "vue": "^3.5.10" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 56e749c7189d..fcb216010a41 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^8.3.4", - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 0b5df70f60fd..4737e512d327 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index 493fc6196ea8..bb0aae85413b 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^8.3.4", - "astro": "^4.15.10", + "astro": "^4.15.11", "html-minifier": "^4.0.0" }, "devDependencies": { diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 038691111677..faa801c00639 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index 88a16c7fe96e..b7c88a476fda 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index adcf51a56da3..c05136f77071 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/server-islands/package.json b/examples/server-islands/package.json index 82f61d9a1821..43199037e65e 100644 --- a/examples/server-islands/package.json +++ b/examples/server-islands/package.json @@ -17,7 +17,7 @@ "@tailwindcss/forms": "^0.5.9", "@types/react": "^18.3.10", "@types/react-dom": "^18.3.0", - "astro": "^4.15.10", + "astro": "^4.15.11", "postcss": "^8.4.47", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 4d2b73ae38f5..05e66e08f204 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^8.3.4", "@astrojs/svelte": "^5.7.1", - "astro": "^4.15.10", + "astro": "^4.15.11", "svelte": "^4.2.19" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index d0e6ba18e2a5..e9030e34517e 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.10", + "astro": "^4.15.11", "sass": "^1.79.4", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index f457deca934f..c53809e72fb0 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -15,6 +15,6 @@ "./app": "./dist/app.js" }, "devDependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index f539e82d7e30..86dc3b9f9b11 100644 --- a/examples/view-transitions/package.json +++ b/examples/view-transitions/package.json @@ -12,6 +12,6 @@ "devDependencies": { "@astrojs/tailwind": "^5.1.1", "@astrojs/node": "^8.3.4", - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index d4377f6d911c..4678c8941a5d 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.11.4", - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index 209cf4576e35..7320e6c00b4a 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/markdown-remark": "^5.2.0", - "astro": "^4.15.10", + "astro": "^4.15.11", "hast-util-select": "^6.0.2", "rehype-autolink-headings": "^7.1.0", "rehype-slug": "^6.0.0", diff --git a/examples/with-markdown-shiki/package.json b/examples/with-markdown-shiki/package.json index fe9856c3bfb0..ddaea577fb8d 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.10" + "astro": "^4.15.11" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index edc755554aaf..8b31c286dd58 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^3.1.7", "@astrojs/preact": "^3.5.3", - "astro": "^4.15.10", + "astro": "^4.15.11", "preact": "^10.24.1" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 455a6027addf..1fbc343ff06b 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.3", "@nanostores/preact": "^0.5.2", - "astro": "^4.15.10", + "astro": "^4.15.11", "nanostores": "^0.11.3", "preact": "^10.24.1" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 085e86ad15a6..390f8c17fd4f 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^3.1.7", "@astrojs/tailwind": "^5.1.1", "@types/canvas-confetti": "^1.6.4", - "astro": "^4.15.10", + "astro": "^4.15.11", "autoprefixer": "^10.4.20", "canvas-confetti": "^1.9.3", "postcss": "^8.4.47", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index 8c0dbc017ff2..dc45fcaea57b 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.15.10", + "astro": "^4.15.11", "vitest": "^2.1.1" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index f8e804be6875..f6e36a0bf73a 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,23 @@ # astro +## 4.15.11 + +### Patch Changes + +- [#12097](https://github.com/withastro/astro/pull/12097) [`11d447f`](https://github.com/withastro/astro/commit/11d447f66b1a0f39489c2600139ebfb565336ce7) Thanks [@ascorbic](https://github.com/ascorbic)! - Fixes error where references in content layer schemas sometimes incorrectly report as missing + +- [#12108](https://github.com/withastro/astro/pull/12108) [`918953b`](https://github.com/withastro/astro/commit/918953bd09f057131dfe029e810019c0909345cf) Thanks [@lameuler](https://github.com/lameuler)! - Fixes a bug where [data URL images](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data) were not correctly handled. The bug resulted in an `ENAMETOOLONG` error. + +- [#12105](https://github.com/withastro/astro/pull/12105) [`42037f3`](https://github.com/withastro/astro/commit/42037f33e644d5a2bfba71377697fc7336ecb15b) Thanks [@ascorbic](https://github.com/ascorbic)! - Returns custom statusText that has been set in a Response + +- [#12109](https://github.com/withastro/astro/pull/12109) [`ea22558`](https://github.com/withastro/astro/commit/ea225585fd12d27006434266163512ca66ad572b) Thanks [@ematipico](https://github.com/ematipico)! - Fixes a regression that was introduced by an internal refactor of how the middleware is loaded by the Astro application. The regression was introduced by [#11550](https://github.com/withastro/astro/pull/11550). + + When the edge middleware feature is opted in, Astro removes the middleware function from the SSR manifest, and this wasn't taken into account during the refactor. + +- [#12106](https://github.com/withastro/astro/pull/12106) [`d3a74da`](https://github.com/withastro/astro/commit/d3a74da19644477ffc81acf2a3efb26ad3335a5e) Thanks [@ascorbic](https://github.com/ascorbic)! - Handles case where an immutable Response object is returned from an endpoint + +- [#12090](https://github.com/withastro/astro/pull/12090) [`d49a537`](https://github.com/withastro/astro/commit/d49a537f2aaccd132154a15f1da4db471272ee90) Thanks [@markjaquith](https://github.com/markjaquith)! - Server islands: changes the server island HTML placeholder comment so that it is much less likely to get removed by HTML minifiers. + ## 4.15.10 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index 7e9647e5893a..c12e8233b448 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.15.10", + "version": "4.15.11", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/packages/integrations/sitemap/CHANGELOG.md b/packages/integrations/sitemap/CHANGELOG.md index c498b97cc677..ceede43c63b5 100644 --- a/packages/integrations/sitemap/CHANGELOG.md +++ b/packages/integrations/sitemap/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/sitemap +## 3.2.0 + +### Minor Changes + +- [#11485](https://github.com/withastro/astro/pull/11485) [`fbe1bc5`](https://github.com/withastro/astro/commit/fbe1bc51d89994c4919c12768908658604513bd3) Thanks [@sondr3](https://github.com/sondr3)! - Adds new `xslURL` option to enable styling of sitemaps + ## 3.1.6 ### Patch Changes diff --git a/packages/integrations/sitemap/package.json b/packages/integrations/sitemap/package.json index b48e974692f9..b16ac77f84f1 100644 --- a/packages/integrations/sitemap/package.json +++ b/packages/integrations/sitemap/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/sitemap", "description": "Generate a sitemap for your Astro site", - "version": "3.1.6", + "version": "3.2.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 08d69a407b11..2ec7374ce90c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -113,7 +113,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro examples/blog: @@ -125,16 +125,16 @@ importers: specifier: ^4.0.7 version: link:../../packages/astro-rss '@astrojs/sitemap': - specifier: ^3.1.6 + specifier: ^3.2.0 version: link:../../packages/integrations/sitemap astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro examples/container-with-vitest: @@ -143,7 +143,7 @@ importers: specifier: ^3.6.2 version: link:../../packages/integrations/react astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -174,7 +174,7 @@ importers: specifier: ^3.14.1 version: 3.14.1 astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro examples/framework-lit: @@ -186,7 +186,7 @@ importers: specifier: ^0.2.1 version: 0.2.1 astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro lit: specifier: ^3.2.0 @@ -216,7 +216,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro preact: specifier: ^10.24.1 @@ -246,7 +246,7 @@ importers: specifier: ^1.3.0 version: 1.3.0(preact@10.24.1) astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro preact: specifier: ^10.24.1 @@ -264,7 +264,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -279,7 +279,7 @@ importers: specifier: ^4.4.2 version: link:../../packages/integrations/solid astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro solid-js: specifier: ^1.9.1 @@ -291,7 +291,7 @@ importers: specifier: ^5.7.1 version: link:../../packages/integrations/svelte astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro svelte: specifier: ^4.2.19 @@ -303,7 +303,7 @@ importers: specifier: ^4.5.1 version: link:../../packages/integrations/vue astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro vue: specifier: ^3.5.10 @@ -315,13 +315,13 @@ importers: specifier: ^8.3.4 version: 8.3.4(astro@packages+astro) astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro examples/middleware: @@ -330,7 +330,7 @@ importers: specifier: ^8.3.4 version: 8.3.4(astro@packages+astro) astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro html-minifier: specifier: ^4.0.0 @@ -343,19 +343,19 @@ importers: examples/minimal: dependencies: astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro examples/non-html-pages: dependencies: astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro examples/server-islands: @@ -382,7 +382,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro postcss: specifier: ^8.4.47 @@ -406,7 +406,7 @@ importers: specifier: ^5.7.1 version: link:../../packages/integrations/svelte astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro svelte: specifier: ^4.2.19 @@ -415,7 +415,7 @@ importers: examples/starlog: dependencies: astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro sass: specifier: ^1.79.4 @@ -427,7 +427,7 @@ importers: examples/toolbar-app: devDependencies: astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro examples/view-transitions: @@ -439,7 +439,7 @@ importers: specifier: ^5.1.1 version: link:../../packages/integrations/tailwind astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro examples/with-markdoc: @@ -448,7 +448,7 @@ importers: specifier: ^0.11.4 version: link:../../packages/integrations/markdoc astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro examples/with-markdown-plugins: @@ -457,7 +457,7 @@ importers: specifier: ^5.2.0 version: link:../../packages/markdown/remark astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro hast-util-select: specifier: ^6.0.2 @@ -478,7 +478,7 @@ importers: examples/with-markdown-shiki: dependencies: astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro examples/with-mdx: @@ -490,7 +490,7 @@ importers: specifier: ^3.5.3 version: link:../../packages/integrations/preact astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro preact: specifier: ^10.24.1 @@ -505,7 +505,7 @@ importers: specifier: ^0.5.2 version: 0.5.2(nanostores@0.11.3)(preact@10.24.1) astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro nanostores: specifier: ^0.11.3 @@ -526,7 +526,7 @@ importers: specifier: ^1.6.4 version: 1.6.4 astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro autoprefixer: specifier: ^10.4.20 @@ -544,7 +544,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^4.15.10 + specifier: ^4.15.11 version: link:../../packages/astro vitest: specifier: ^2.1.1 From f9dd9428c6cd1c9d23488ea4645f186b4a4ad4b2 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 3 Oct 2024 20:52:11 +0200 Subject: [PATCH 09/23] fix(vue): useId() collisions (#12112) --- .changeset/beige-students-compete.md | 5 ++++ packages/integrations/vue/client.js | 1 + packages/integrations/vue/context.js | 24 +++++++++++++++++++ packages/integrations/vue/server.js | 10 +++++++- packages/integrations/vue/test/basics.test.js | 9 +++++++ .../fixtures/basics/src/components/WithId.vue | 9 +++++++ .../fixtures/basics/src/pages/index.astro | 3 +++ 7 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 .changeset/beige-students-compete.md create mode 100644 packages/integrations/vue/context.js create mode 100644 packages/integrations/vue/test/fixtures/basics/src/components/WithId.vue diff --git a/.changeset/beige-students-compete.md b/.changeset/beige-students-compete.md new file mode 100644 index 000000000000..06588695c307 --- /dev/null +++ b/.changeset/beige-students-compete.md @@ -0,0 +1,5 @@ +--- +'@astrojs/vue': patch +--- + +Fixes a case where IDs generated by `useId()` (introduced in Vue 3.5) would not be unique between islands diff --git a/packages/integrations/vue/client.js b/packages/integrations/vue/client.js index 58ee11d5c3d3..b3935752c08c 100644 --- a/packages/integrations/vue/client.js +++ b/packages/integrations/vue/client.js @@ -40,6 +40,7 @@ export default (element) => return content; }, }); + app.config.idPrefix = element.getAttribute('prefix'); await setup(app); app.mount(element, isHydrate); appMap.set(element, appInstance); diff --git a/packages/integrations/vue/context.js b/packages/integrations/vue/context.js new file mode 100644 index 000000000000..80a569ce6c1e --- /dev/null +++ b/packages/integrations/vue/context.js @@ -0,0 +1,24 @@ +const contexts = new WeakMap(); + +const ID_PREFIX = 'v'; + +function getContext(rendererContextResult) { + if (contexts.has(rendererContextResult)) { + return contexts.get(rendererContextResult); + } + const ctx = { + currentIndex: 0, + get id() { + return ID_PREFIX + this.currentIndex.toString(); + }, + }; + contexts.set(rendererContextResult, ctx); + return ctx; +} + +export function incrementId(rendererContextResult) { + const ctx = getContext(rendererContextResult); + const id = ctx.id; + ctx.currentIndex++; + return id; +} diff --git a/packages/integrations/vue/server.js b/packages/integrations/vue/server.js index afdc9e8a2dae..5b7f6cb5056d 100644 --- a/packages/integrations/vue/server.js +++ b/packages/integrations/vue/server.js @@ -2,12 +2,19 @@ import { setup } from 'virtual:@astrojs/vue/app'; import { createSSRApp, h } from 'vue'; import { renderToString } from 'vue/server-renderer'; import StaticHtml from './static-html.js'; +import { incrementId } from './context.js'; function check(Component) { return !!Component['ssrRender'] || !!Component['__ssrInlineRender']; } async function renderToStaticMarkup(Component, inputProps, slotted, metadata) { + let prefix; + if (this && this.result) { + prefix = incrementId(this.result); + } + const attrs = { prefix }; + const slots = {}; const props = { ...inputProps }; delete props.slot; @@ -21,9 +28,10 @@ async function renderToStaticMarkup(Component, inputProps, slotted, metadata) { }); } const app = createSSRApp({ render: () => h(Component, props, slots) }); + app.config.idPrefix = prefix; await setup(app); const html = await renderToString(app); - return { html }; + return { html, attrs }; } export default { diff --git a/packages/integrations/vue/test/basics.test.js b/packages/integrations/vue/test/basics.test.js index 4eb2b987c313..d54ea66b652e 100644 --- a/packages/integrations/vue/test/basics.test.js +++ b/packages/integrations/vue/test/basics.test.js @@ -30,4 +30,13 @@ describe('Basics', () => { assert.notEqual(img, undefined); assert.equal(img.getAttribute('src'), '/light_walrus.avif'); }); + + it('Should generate unique ids when using useId()', async () => { + const data = await fixture.readFile('/index.html'); + const { document } = parseHTML(data); + + const els = document.querySelectorAll('.vue-use-id'); + assert.equal(els.length, 2); + assert.notEqual(els[0].getAttribute('id'), els[1].getAttribute('id')); + }); }); diff --git a/packages/integrations/vue/test/fixtures/basics/src/components/WithId.vue b/packages/integrations/vue/test/fixtures/basics/src/components/WithId.vue new file mode 100644 index 000000000000..2c8667696213 --- /dev/null +++ b/packages/integrations/vue/test/fixtures/basics/src/components/WithId.vue @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/packages/integrations/vue/test/fixtures/basics/src/pages/index.astro b/packages/integrations/vue/test/fixtures/basics/src/pages/index.astro index b2f292d1057c..162b326c8324 100644 --- a/packages/integrations/vue/test/fixtures/basics/src/pages/index.astro +++ b/packages/integrations/vue/test/fixtures/basics/src/pages/index.astro @@ -1,6 +1,7 @@ --- import Bar from '../components/Foo.vue'; import Parent from '../components/Parent.astro'; +import WithId from '../components/WithId.vue'; --- @@ -10,5 +11,7 @@ import Parent from '../components/Parent.astro'; + + From 4dc00cc7c938cb0ddb3e71d38e6c7d060a26d17a Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 3 Oct 2024 18:53:02 +0000 Subject: [PATCH 10/23] [ci] format --- packages/integrations/vue/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/vue/server.js b/packages/integrations/vue/server.js index 5b7f6cb5056d..315909087a74 100644 --- a/packages/integrations/vue/server.js +++ b/packages/integrations/vue/server.js @@ -1,8 +1,8 @@ import { setup } from 'virtual:@astrojs/vue/app'; import { createSSRApp, h } from 'vue'; import { renderToString } from 'vue/server-renderer'; -import StaticHtml from './static-html.js'; import { incrementId } from './context.js'; +import StaticHtml from './static-html.js'; function check(Component) { return !!Component['ssrRender'] || !!Component['__ssrInlineRender']; From a54e520d3c139fa123e7029c5933951b5c7f5a39 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Thu, 3 Oct 2024 19:55:55 +0100 Subject: [PATCH 11/23] fix: throw a useful error if rendering undefined entry (#12113) * fix: throw a useful error if rendering undefined entry * Update .changeset/wise-pumas-fry.md Co-authored-by: Sarah Rainsberger --------- Co-authored-by: Emanuele Stoppa Co-authored-by: Sarah Rainsberger --- .changeset/wise-pumas-fry.md | 5 +++++ packages/astro/src/content/runtime.ts | 6 +++++- packages/astro/src/core/errors/errors-data.ts | 11 +++++++++++ packages/astro/test/content-layer.test.js | 7 +++++++ .../fixtures/content-layer/src/pages/missing.astro | 14 ++++++++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .changeset/wise-pumas-fry.md create mode 100644 packages/astro/test/fixtures/content-layer/src/pages/missing.astro diff --git a/.changeset/wise-pumas-fry.md b/.changeset/wise-pumas-fry.md new file mode 100644 index 000000000000..90452298ca3f --- /dev/null +++ b/.changeset/wise-pumas-fry.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Adds a helpful error when attempting to render an undefined collection entry diff --git a/packages/astro/src/content/runtime.ts b/packages/astro/src/content/runtime.ts index bbe4a2b1f116..98d1c4fcdbde 100644 --- a/packages/astro/src/content/runtime.ts +++ b/packages/astro/src/content/runtime.ts @@ -436,7 +436,11 @@ function updateImageReferencesInData>( export async function renderEntry( entry: DataEntry | { render: () => Promise<{ Content: AstroComponentFactory }> }, ) { - if (entry && 'render' in entry) { + if (!entry) { + throw new AstroError(AstroErrorData.RenderUndefinedEntryError); + } + + if ('render' in entry) { // This is an old content collection entry, so we use its render method return entry.render(); } diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index 5760c5d96726..42e834005539 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -1410,6 +1410,17 @@ export const UnknownContentCollectionError = { title: 'Unknown Content Collection Error.', } satisfies ErrorData; +/** + * @docs + * @description + * Astro tried to render a content collection entry that was undefined. This can happen if you try to render an entry that does not exist. + */ +export const RenderUndefinedEntryError = { + name: 'RenderUndefinedEntryError', + title: 'Attempted to render an undefined content collection entry.', + hint: 'Check if the entry is undefined before passing it to `render()`', +} satisfies ErrorData; + /** * @docs * @description diff --git a/packages/astro/test/content-layer.test.js b/packages/astro/test/content-layer.test.js index 428a4ac3f204..78cde2bff2e8 100644 --- a/packages/astro/test/content-layer.test.js +++ b/packages/astro/test/content-layer.test.js @@ -317,5 +317,12 @@ describe('Content Layer', () => { assert.ok(updated.fileLoader[0].data.temperament.includes('Bouncy')); await fixture.resetAllFiles(); }); + + it('returns an error if we render an undefined entry', async () => { + const res = await fixture.fetch('/missing'); + const text = await res.text(); + assert.equal(res.status, 500); + assert.ok(text.includes('RenderUndefinedEntryError')); + }); }); }); diff --git a/packages/astro/test/fixtures/content-layer/src/pages/missing.astro b/packages/astro/test/fixtures/content-layer/src/pages/missing.astro new file mode 100644 index 000000000000..6fee7db07b4a --- /dev/null +++ b/packages/astro/test/fixtures/content-layer/src/pages/missing.astro @@ -0,0 +1,14 @@ +--- +import { getEntry, render } from "astro:content" +// Skipping the broken page in production so the build doesn't fail +if(import.meta.env.PROD) { + return new Response(null, { status: 404 }) +} + +const entry = await getEntry("spacecraft", "missing") + +const { Content } = await render(entry) + +--- + + From a46839a5c818b7de63c36d0c7e27f1a8f3b773dc Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Thu, 3 Oct 2024 23:29:52 +0200 Subject: [PATCH 12/23] docs: update Vite links to use their new domain (#12117) * docs: update Vite links to use their new domain See https://github.com/withastro/docs/issues/9548 * update other links with the new Vite domain * Create strange-cats-notice.md --------- Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> --- .changeset/strange-cats-notice.md | 5 +++++ packages/astro-rss/README.md | 2 +- packages/astro/CHANGELOG.md | 8 ++++---- packages/astro/client.d.ts | 2 +- packages/astro/src/@types/astro.ts | 2 +- packages/astro/src/core/errors/errors-data.ts | 6 +++--- packages/astro/src/vite-plugin-env/README.md | 2 +- packages/integrations/react/CHANGELOG.md | 4 ++-- packages/integrations/svelte/CHANGELOG.md | 8 ++++---- packages/integrations/vue/CHANGELOG.md | 8 ++++---- 10 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 .changeset/strange-cats-notice.md diff --git a/.changeset/strange-cats-notice.md b/.changeset/strange-cats-notice.md new file mode 100644 index 000000000000..bb17a5aaed9a --- /dev/null +++ b/.changeset/strange-cats-notice.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Updates Vite links to use their new domain diff --git a/packages/astro-rss/README.md b/packages/astro-rss/README.md index c8485b02e3e8..2a5d6a7954f2 100644 --- a/packages/astro-rss/README.md +++ b/packages/astro-rss/README.md @@ -345,7 +345,7 @@ const blog = defineCollection({ ## `pagesGlobToRssItems()` -To create an RSS feed from documents in `src/pages/`, use the `pagesGlobToRssItems()` helper. This accepts an `import.meta.glob` result ([see Vite documentation](https://vitejs.dev/guide/features.html#glob-import)) and outputs an array of valid [`RSSFeedItem`s](#items). +To create an RSS feed from documents in `src/pages/`, use the `pagesGlobToRssItems()` helper. This accepts an `import.meta.glob` result ([see Vite documentation](https://vite.dev/guide/features.html#glob-import)) and outputs an array of valid [`RSSFeedItem`s](#items). This function assumes, but does not verify, you are globbing for items inside `src/pages/`, and all necessary feed properties are present in each document's frontmatter. If you encounter errors, verify each page frontmatter manually. diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index f6e36a0bf73a..8db3a1bb83a5 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -3828,7 +3828,7 @@ To not break existing APIs, aliases for the Toolbar-based names have been created. The previous API names will continue to function but will be deprecated in the future. All documentation has been updated to reflect Toolbar-based names. -- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vitejs.dev/guide/migration.html) for details of the breaking changes from Vite instead. +- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vite.dev/guide/migration.html) for details of the breaking changes from Vite instead. - [#9225](https://github.com/withastro/astro/pull/9225) [`c421a3d17`](https://github.com/withastro/astro/commit/c421a3d17911aeda29b5204f6d568ae87e329eaf) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Removes the opt-in `handleForms` property for ``. Form submissions are now handled by default and this property is no longer necessary. This default behavior can be disabled by setting `data-astro-reload` on relevant `
` elements. @@ -4164,7 +4164,7 @@ The types for middlewares have also been revised. To type a middleware function, you should now use `MiddlewareHandler` instead of `MiddlewareResponseHandler`. If you used `defineMiddleware()` to type the function, no changes are needed. -- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vitejs.dev/guide/migration.html) for details of the breaking changes from Vite instead. +- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vite.dev/guide/migration.html) for details of the breaking changes from Vite instead. - [#9196](https://github.com/withastro/astro/pull/9196) [`37697a2c5`](https://github.com/withastro/astro/commit/37697a2c5511572dc29c0a4ea46f90c2f62be8e6) Thanks [@bluwy](https://github.com/bluwy)! - Removes support for Shiki custom language's `path` property. The language JSON file should be imported and passed to the option instead. @@ -8373,7 +8373,7 @@ ``` -- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vitejs.dev/guide/migration.html) for more information. +- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vite.dev/guide/migration.html) for more information. - [#5724](https://github.com/withastro/astro/pull/5724) [`16c7d0bfd`](https://github.com/withastro/astro/commit/16c7d0bfd49d2b9bfae45385f506bcd642f9444a) Thanks [@bluwy](https://github.com/bluwy)! - Remove outdated Vue info log. Remove `toString` support for `RenderTemplateResult`. @@ -8930,7 +8930,7 @@ - [#5716](https://github.com/withastro/astro/pull/5716) [`dd56c1941`](https://github.com/withastro/astro/commit/dd56c19411b126439b8bc42d681b6fa8c06e8c61) Thanks [@bluwy](https://github.com/bluwy)! - Remove MDX Fragment hack. This was used by `@astrojs/mdx` to access the `Fragment` component, but isn't require anymore since `@astrojs/mdx` v0.12.1. -- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vitejs.dev/guide/migration.html) for more information. +- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vite.dev/guide/migration.html) for more information. - [#5724](https://github.com/withastro/astro/pull/5724) [`16c7d0bfd`](https://github.com/withastro/astro/commit/16c7d0bfd49d2b9bfae45385f506bcd642f9444a) Thanks [@bluwy](https://github.com/bluwy)! - Remove outdated Vue info log. Remove `toString` support for `RenderTemplateResult`. diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts index 4d4b031432af..8e1d64f23dab 100644 --- a/packages/astro/client.d.ts +++ b/packages/astro/client.d.ts @@ -24,7 +24,7 @@ interface ImportMeta { * Astro and Vite expose environment variables through `import.meta.env`. For a complete list of the environment variables available, see the two references below. * * - [Astro reference](https://docs.astro.build/en/guides/environment-variables/#default-environment-variables) - * - [Vite reference](https://vitejs.dev/guide/env-and-mode.html#env-variables) + * - [Vite reference](https://vite.dev/guide/env-and-mode.html#env-variables) */ readonly env: ImportMetaEnv; } diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index e0c85f33c0c6..4cba5610b0c1 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -861,7 +861,7 @@ export interface AstroUserConfig { * * Pass additional configuration options to Vite. Useful when Astro doesn't support some advanced configuration that you may need. * - * View the full `vite` configuration object documentation on [vitejs.dev](https://vitejs.dev/config/). + * View the full `vite` configuration object documentation on [vite.dev](https://vite.dev/config/). * * #### Examples * diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index 42e834005539..89bc9780b1aa 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -888,14 +888,14 @@ export const LocalImageUsedWrongly = { * @see * - [Astro.glob](https://docs.astro.build/en/reference/api-reference/#astroglob) * @description - * `Astro.glob()` can only be used in `.astro` files. You can use [`import.meta.glob()`](https://vitejs.dev/guide/features.html#glob-import) instead to achieve the same result. + * `Astro.glob()` can only be used in `.astro` files. You can use [`import.meta.glob()`](https://vite.dev/guide/features.html#glob-import) instead to achieve the same result. */ export const AstroGlobUsedOutside = { name: 'AstroGlobUsedOutside', title: 'Astro.glob() used outside of an Astro file.', message: (globStr: string) => `\`Astro.glob(${globStr})\` can only be used in \`.astro\` files. \`import.meta.glob(${globStr})\` can be used instead to achieve a similar result.`, - hint: "See Vite's documentation on `import.meta.glob` for more information: https://vitejs.dev/guide/features.html#glob-import", + hint: "See Vite's documentation on `import.meta.glob` for more information: https://vite.dev/guide/features.html#glob-import", } satisfies ErrorData; /** @@ -967,7 +967,7 @@ export const MissingSharp = { /** * @docs * @see - * - [Vite troubleshooting guide](https://vitejs.dev/guide/troubleshooting.html) + * - [Vite troubleshooting guide](https://vite.dev/guide/troubleshooting.html) * @description * Vite encountered an unknown error while rendering your project. We unfortunately do not know what happened (or we would tell you!) * diff --git a/packages/astro/src/vite-plugin-env/README.md b/packages/astro/src/vite-plugin-env/README.md index dbaf4b8bf7cc..305cff024240 100644 --- a/packages/astro/src/vite-plugin-env/README.md +++ b/packages/astro/src/vite-plugin-env/README.md @@ -1,6 +1,6 @@ # vite-plugin-env -Improves Vite's [Env Variables](https://vitejs.dev/guide/env-and-mode.html#env-files) support to include **private** env variables during Server-Side Rendering (SSR) but never in client-side rendering (CSR). +Improves Vite's [Env Variables](https://vite.dev/guide/env-and-mode.html#env-files) support to include **private** env variables during Server-Side Rendering (SSR) but never in client-side rendering (CSR). Private env variables can be accessed through `import.meta.env.SECRET` like Vite. Where the env variable is declared changes how it is replaced when transforming it: diff --git a/packages/integrations/react/CHANGELOG.md b/packages/integrations/react/CHANGELOG.md index e6bedd08f31b..65eb7056cbd8 100644 --- a/packages/integrations/react/CHANGELOG.md +++ b/packages/integrations/react/CHANGELOG.md @@ -288,13 +288,13 @@ ### Patch Changes -- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vitejs.dev/guide/migration.html) for details of the breaking changes from Vite instead. +- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vite.dev/guide/migration.html) for details of the breaking changes from Vite instead. ## 3.0.7-beta.0 ### Patch Changes -- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vitejs.dev/guide/migration.html) for details of the breaking changes from Vite instead. +- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vite.dev/guide/migration.html) for details of the breaking changes from Vite instead. ## 3.0.6 diff --git a/packages/integrations/svelte/CHANGELOG.md b/packages/integrations/svelte/CHANGELOG.md index 88c18163314e..2d6c5b42b2a9 100644 --- a/packages/integrations/svelte/CHANGELOG.md +++ b/packages/integrations/svelte/CHANGELOG.md @@ -127,7 +127,7 @@ ### Major Changes -- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vitejs.dev/guide/migration.html) for details of the breaking changes from Vite instead. +- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vite.dev/guide/migration.html) for details of the breaking changes from Vite instead. - [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Drops support for Svelte 3 as `@sveltejs/vite-plugin-svelte` is updated to `3.0.0` which does not support Svelte 3 @@ -135,7 +135,7 @@ ### Major Changes -- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vitejs.dev/guide/migration.html) for details of the breaking changes from Vite instead. +- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vite.dev/guide/migration.html) for details of the breaking changes from Vite instead. - [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Drops support for Svelte 3 as `@sveltejs/vite-plugin-svelte` is updated to `3.0.0` which does not support Svelte 3 @@ -345,7 +345,7 @@ - [#5782](https://github.com/withastro/astro/pull/5782) [`1f92d64ea`](https://github.com/withastro/astro/commit/1f92d64ea35c03fec43aff64eaf704dc5a9eb30a) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Remove support for Node 14. Minimum supported Node version is now >=16.12.0 -- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vitejs.dev/guide/migration.html) for more information. +- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vite.dev/guide/migration.html) for more information. - [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Simplify Svelte preprocess setup. `