From a3d30a602aaa1755197c73f0b51cace61f9088b3 Mon Sep 17 00:00:00 2001 From: Timon Jurschitsch <103483059+DerTimonius@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:47:37 +0200 Subject: [PATCH 1/7] fix: improve error for inferSize and Image component (#11823) * fix: improve error for inferSize and Image component * add changeset * move isRemovePath check --------- Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> --- .changeset/lazy-flowers-destroy.md | 5 +++++ packages/astro/src/assets/internal.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/lazy-flowers-destroy.md diff --git a/.changeset/lazy-flowers-destroy.md b/.changeset/lazy-flowers-destroy.md new file mode 100644 index 0000000000..b08525b184 --- /dev/null +++ b/.changeset/lazy-flowers-destroy.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +fix: improve error message when inferSize is used in local images with the Image component diff --git a/packages/astro/src/assets/internal.ts b/packages/astro/src/assets/internal.ts index 4cc85799c1..58cd41f432 100644 --- a/packages/astro/src/assets/internal.ts +++ b/packages/astro/src/assets/internal.ts @@ -1,3 +1,4 @@ +import { isRemotePath } from '@astrojs/internal-helpers/path'; import type { AstroConfig } from '../@types/astro.js'; import { AstroError, AstroErrorData } from '../core/errors/index.js'; import { DEFAULT_HASH_PROPS } from './consts.js'; @@ -65,7 +66,11 @@ export async function getImage( }; // Infer size for remote images if inferSize is true - if (options.inferSize && isRemoteImage(resolvedOptions.src)) { + if ( + options.inferSize && + isRemoteImage(resolvedOptions.src) && + isRemotePath(resolvedOptions.src) + ) { const result = await inferRemoteSize(resolvedOptions.src); // Directly probe the image URL resolvedOptions.width ??= result.width; resolvedOptions.height ??= result.height; From 2b6daa5840c18729c41f6cd8b4571b88d0cba119 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Wed, 16 Oct 2024 14:07:59 +0100 Subject: [PATCH 2/7] fix(container): emit components as partials (#12239) Co-authored-by: Sarah Rainsberger --- .changeset/soft-rabbits-draw.md | 22 +++++++++++++++++++ packages/astro/src/container/index.ts | 9 ++++++++ packages/astro/src/core/render-context.ts | 7 ++++-- packages/astro/test/container.test.js | 12 ++++++++++ .../src/pages/react-as-page.ts | 12 ++++++++++ 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 .changeset/soft-rabbits-draw.md create mode 100644 packages/astro/test/fixtures/container-custom-renderers/src/pages/react-as-page.ts diff --git a/.changeset/soft-rabbits-draw.md b/.changeset/soft-rabbits-draw.md new file mode 100644 index 0000000000..87094d3e16 --- /dev/null +++ b/.changeset/soft-rabbits-draw.md @@ -0,0 +1,22 @@ +--- +"astro": patch +--- + +**BREAKING CHANGE to the experimental Container API only** + +Changes the default page rendering behavior of Astro components in containers, and adds a new option `partial: false` to render full Astro pages as before. + +Previously, the Container API was rendering all Astro components as if they were full Astro pages containing `` by default. This was not intended, and now by default, all components will render as [page partials](https://docs.astro.build/en/basics/astro-pages/#page-partials): only the contents of the components without a page shell. + +To render the component as a full-fledged Astro page, pass a new option called `partial: false` to `renderToString()` and `renderToResponse()`: + +```js +import { experimental_AstroContainer as AstroContainer } from 'astro/container'; +import Card from "../src/components/Card.astro"; + +const container = AstroContainer.create(); + +await container.renderToString(Card); // the string will not contain `` +await container.renderToString(Card, { partial: false }); // the string will contain `` +``` + diff --git a/packages/astro/src/container/index.ts b/packages/astro/src/container/index.ts index 9aa4e2d2f2..374f0252ca 100644 --- a/packages/astro/src/container/index.ts +++ b/packages/astro/src/container/index.ts @@ -89,6 +89,14 @@ export type ContainerRenderOptions = { * ``` */ props?: Props; + + /** + * When `false`, it forces to render the component as it was a full-fledged page. + * + * By default, the container API render components as [partials](https://docs.astro.build/en/basics/astro-pages/#page-partials). + * + */ + partial?: boolean; }; export type AddServerRenderer = @@ -487,6 +495,7 @@ export class experimental_AstroContainer { request, pathname: url.pathname, locals: options?.locals ?? {}, + partial: options?.partial ?? true, }); if (options.params) { renderContext.params = options.params; diff --git a/packages/astro/src/core/render-context.ts b/packages/astro/src/core/render-context.ts index 952c9c03b2..02a0b46f6d 100644 --- a/packages/astro/src/core/render-context.ts +++ b/packages/astro/src/core/render-context.ts @@ -56,6 +56,7 @@ export class RenderContext { public params = getParams(routeData, pathname), protected url = new URL(request.url), public props: Props = {}, + public partial: undefined | boolean = undefined, ) {} /** @@ -76,9 +77,10 @@ export class RenderContext { routeData, status = 200, props, + partial = undefined, }: Pick & Partial< - Pick + Pick >): Promise { const pipelineMiddleware = await pipeline.getMiddleware(); return new RenderContext( @@ -93,6 +95,7 @@ export class RenderContext { undefined, undefined, props, + partial, ); } @@ -319,7 +322,7 @@ export class RenderContext { const componentMetadata = (await pipeline.componentMetadata(routeData)) ?? manifest.componentMetadata; const headers = new Headers({ 'Content-Type': 'text/html' }); - const partial = Boolean(mod.partial); + const partial = typeof this.partial === 'boolean' ? this.partial : Boolean(mod.partial); const response = { status, statusText: 'OK', diff --git a/packages/astro/test/container.test.js b/packages/astro/test/container.test.js index 7d8b61d9c6..13138ef951 100644 --- a/packages/astro/test/container.test.js +++ b/packages/astro/test/container.test.js @@ -252,6 +252,16 @@ describe('Container with renderers', () => { const html = await response.text(); assert.match(html, /I am a react button/); + assert.doesNotMatch(html, //); + }); + + it('the endpoint should return the HTML of the React component, with DOCTYPE when rendered when partial is off', async () => { + const request = new Request('https://example.com/react-as-page'); + const response = await app.render(request); + const html = await response.text(); + + assert.match(html, /I am a react button/); + assert.match(html, //); }); it('the endpoint should return the HTML of the Vue component', async () => { @@ -260,6 +270,7 @@ describe('Container with renderers', () => { const html = await response.text(); assert.match(html, /I am a vue button/); + assert.doesNotMatch(html, //); }); it('Should render a component with directives', async () => { @@ -269,5 +280,6 @@ describe('Container with renderers', () => { assert.match(html, /Button not rendered/); assert.match(html, /I am a react button/); + assert.doesNotMatch(html, //); }); }); diff --git a/packages/astro/test/fixtures/container-custom-renderers/src/pages/react-as-page.ts b/packages/astro/test/fixtures/container-custom-renderers/src/pages/react-as-page.ts new file mode 100644 index 0000000000..5ddddadac3 --- /dev/null +++ b/packages/astro/test/fixtures/container-custom-renderers/src/pages/react-as-page.ts @@ -0,0 +1,12 @@ +import type {APIRoute} from "astro"; +import { experimental_AstroContainer } from "astro/container"; +import renderer from '@astrojs/react/server.js'; +import Component from "../components/button.jsx" + +export const GET: APIRoute = async (ctx) => { + const container = await experimental_AstroContainer.create(); + container.addServerRenderer({ renderer }); + return await container.renderToResponse(Component, { + partial: false + }); +} From 7bcae4e3eea9aecc3480881088e334a77ae5c3e3 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Wed, 16 Oct 2024 21:14:51 +0800 Subject: [PATCH 3/7] Setup CI for next branch (#12242) --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc214ba413..8a494b3179 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: push: branches: - main + - next merge_group: pull_request: paths-ignore: @@ -208,6 +209,11 @@ jobs: with: repository: withastro/docs path: smoke/docs + # For a commit event on the `next` branch (`ref_name`), use the `5.0.0-beta` branch. + # For a pull_request event merging into the `next` branch (`base_ref`), use the `5.0.0-beta` branch. + # NOTE: For a pull_request event, the `ref_name` is something like `/merge` than the branch name. + # NOTE: Perhaps docs repo should use a consistent `next` branch in the future. + ref: ${{ (github.ref_name == 'next' || github.base_ref == 'next') && '5.0.0-beta' || 'main' }} - name: Install dependencies run: pnpm install --no-frozen-lockfile From 8b1a641be9de4baa9ae48dd0d045915fbbeffa8c Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Wed, 16 Oct 2024 15:51:03 +0200 Subject: [PATCH 4/7] fix: do not override process.env (#12227) Co-authored-by: Bjorn Lu --- .changeset/real-actors-jog.md | 5 +++++ packages/astro/src/env/runtime-constants.ts | 1 + packages/astro/src/env/runtime.ts | 6 +++++- packages/astro/src/env/vite-plugin-env.ts | 13 ++----------- 4 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 .changeset/real-actors-jog.md create mode 100644 packages/astro/src/env/runtime-constants.ts diff --git a/.changeset/real-actors-jog.md b/.changeset/real-actors-jog.md new file mode 100644 index 0000000000..d2a77195fd --- /dev/null +++ b/.changeset/real-actors-jog.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes a case where environment variables would not be refreshed when using `astro:env` diff --git a/packages/astro/src/env/runtime-constants.ts b/packages/astro/src/env/runtime-constants.ts new file mode 100644 index 0000000000..27b5d72113 --- /dev/null +++ b/packages/astro/src/env/runtime-constants.ts @@ -0,0 +1 @@ +export const ENV_SYMBOL = Symbol.for('astro:env/dev'); diff --git a/packages/astro/src/env/runtime.ts b/packages/astro/src/env/runtime.ts index a2017b617f..3d3b3c7750 100644 --- a/packages/astro/src/env/runtime.ts +++ b/packages/astro/src/env/runtime.ts @@ -1,4 +1,5 @@ import { AstroError, AstroErrorData } from '../core/errors/index.js'; +import { ENV_SYMBOL } from './runtime-constants.js'; import { invalidVariablesToError } from './errors.js'; import type { ValidationResultInvalid } from './validators.js'; export { validateEnvVariable, getEnvFieldType } from './validators.js'; @@ -6,7 +7,10 @@ export { validateEnvVariable, getEnvFieldType } from './validators.js'; export type GetEnv = (key: string) => string | undefined; type OnSetGetEnv = (reset: boolean) => void; -let _getEnv: GetEnv = (key) => process.env[key]; +let _getEnv: GetEnv = (key) => { + const env = (globalThis as any)[ENV_SYMBOL] ?? {}; + return env[key]; +}; export function setGetEnv(fn: GetEnv, reset = false) { _getEnv = fn; diff --git a/packages/astro/src/env/vite-plugin-env.ts b/packages/astro/src/env/vite-plugin-env.ts index 9ae24a90ba..d8165f48ca 100644 --- a/packages/astro/src/env/vite-plugin-env.ts +++ b/packages/astro/src/env/vite-plugin-env.ts @@ -11,12 +11,7 @@ import { import { type InvalidVariable, invalidVariablesToError } from './errors.js'; import type { EnvSchema } from './schema.js'; import { getEnvFieldType, validateEnvVariable } from './validators.js'; - -// TODO: reminders for when astro:env comes out of experimental -// Types should always be generated (like in types/content.d.ts). That means the client module will be empty -// and server will only contain getSecret for unknown variables. Then, specifying a schema should only add -// variables as needed. For secret variables, it will only require specifying SecretValues and it should get -// merged with the static types/content.d.ts +import { ENV_SYMBOL } from './runtime-constants.js'; interface AstroEnvVirtualModPluginParams { settings: AstroSettings; @@ -47,11 +42,7 @@ export function astroEnv({ fileURLToPath(settings.config.root), '', ); - for (const [key, value] of Object.entries(loadedEnv)) { - if (value !== undefined) { - process.env[key] = value; - } - } + (globalThis as any)[ENV_SYMBOL] = loadedEnv; const validatedVariables = validatePublicVariables({ schema, From 0bbf2fb526b21a8d89ab87aa0e37d83e0724474f Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Wed, 16 Oct 2024 13:53:31 +0000 Subject: [PATCH 5/7] [ci] format --- packages/astro/src/env/runtime.ts | 2 +- packages/astro/src/env/vite-plugin-env.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/env/runtime.ts b/packages/astro/src/env/runtime.ts index 3d3b3c7750..50684f63ef 100644 --- a/packages/astro/src/env/runtime.ts +++ b/packages/astro/src/env/runtime.ts @@ -1,6 +1,6 @@ import { AstroError, AstroErrorData } from '../core/errors/index.js'; -import { ENV_SYMBOL } from './runtime-constants.js'; import { invalidVariablesToError } from './errors.js'; +import { ENV_SYMBOL } from './runtime-constants.js'; import type { ValidationResultInvalid } from './validators.js'; export { validateEnvVariable, getEnvFieldType } from './validators.js'; diff --git a/packages/astro/src/env/vite-plugin-env.ts b/packages/astro/src/env/vite-plugin-env.ts index d8165f48ca..a672addccd 100644 --- a/packages/astro/src/env/vite-plugin-env.ts +++ b/packages/astro/src/env/vite-plugin-env.ts @@ -9,9 +9,9 @@ import { VIRTUAL_MODULES_IDS_VALUES, } from './constants.js'; import { type InvalidVariable, invalidVariablesToError } from './errors.js'; +import { ENV_SYMBOL } from './runtime-constants.js'; import type { EnvSchema } from './schema.js'; import { getEnvFieldType, validateEnvVariable } from './validators.js'; -import { ENV_SYMBOL } from './runtime-constants.js'; interface AstroEnvVirtualModPluginParams { settings: AstroSettings; From c5cd5be36a81af2040461359ae5fd8d5028d00a8 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Thu, 17 Oct 2024 15:59:50 +0800 Subject: [PATCH 6/7] Fix test:vite-ci script (#12246) --- package.json | 6 +----- packages/astro/package.json | 2 +- patches/fs-fixture@2.4.0.patch | 24 ------------------------ pnpm-lock.yaml | 15 +++++---------- 4 files changed, 7 insertions(+), 40 deletions(-) delete mode 100644 patches/fs-fixture@2.4.0.patch diff --git a/package.json b/package.json index 683384edf3..06a4c5188c 100644 --- a/package.json +++ b/package.json @@ -25,12 +25,11 @@ "test:match": "cd packages/astro && pnpm run test:match", "test:unit": "cd packages/astro && pnpm run test:unit", "test:types": "cd packages/astro && pnpm run test:types", - "test:unit:match": "cd packages/astro && pnpm run test:unit:match", "test:smoke": "pnpm test:smoke:example && pnpm test:smoke:docs", "test:smoke:example": "turbo run build --concurrency=100% --filter=\"@example/*\"", "test:smoke:docs": "turbo run build --filter=docs", "test:check-examples": "node ./scripts/smoke/check.js", - "test:vite-ci": "cd packages/astro && pnpm run test:node", + "test:vite-ci": "cd packages/astro && pnpm run test:unit && pnpm run test:integration", "test:e2e": "cd packages/astro && pnpm playwright install chromium firefox && pnpm run test:e2e", "test:e2e:match": "cd packages/astro && pnpm playwright install chromium firefox && pnpm run test:e2e:match", "test:e2e:hosts": "turbo run test:hosted", @@ -87,9 +86,6 @@ "allowAny": [ "astro" ] - }, - "patchedDependencies": { - "fs-fixture@2.4.0": "patches/fs-fixture@2.4.0.patch" } } } diff --git a/packages/astro/package.json b/packages/astro/package.json index 7f6e52a304..0cf43e4753 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -211,7 +211,7 @@ "eol": "^0.10.0", "execa": "^8.0.1", "expect-type": "^1.1.0", - "fs-fixture": "^2.4.0", + "fs-fixture": "^2.5.0", "mdast-util-mdx": "^3.0.0", "mdast-util-mdx-jsx": "^3.1.3", "node-mocks-http": "^1.16.1", diff --git a/patches/fs-fixture@2.4.0.patch b/patches/fs-fixture@2.4.0.patch deleted file mode 100644 index 1ec3a3c4db..0000000000 --- a/patches/fs-fixture@2.4.0.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/dist/index.d.mts b/dist/index.d.mts -index be5b88e034211892ba079c3c5c5c6f5d5f767cd4..55dcc0e99c66719d5fa68d4713b02c1919deae19 100644 ---- a/dist/index.d.mts -+++ b/dist/index.d.mts -@@ -61,6 +61,10 @@ type Api = ApiBase & { - type FileTree = { - [path: string]: string | FileTree | ((api: Api) => string | Symlink); - }; --declare const createFixture: (source?: string | FileTree) => Promise; -+type CreateFixtureOptions = { -+ // An absolute path to a different directory than `os.tmpdir()` -+ tempDir?: string -+} -+declare const createFixture: (source?: string | FileTree, opts?: CreateFixtureOptions) => Promise; - --export { type FileTree, FsFixture, createFixture }; -+export { type FileTree, FsFixture, CreateFixtureOptions, createFixture }; -diff --git a/dist/index.mjs b/dist/index.mjs -index cd6cab3beebf3f38fe4f1e2a9c58aff2b87258f7..ad24d852a357fd582f9e83ac20cb73bfbcb9bfc0 100755 ---- a/dist/index.mjs -+++ b/dist/index.mjs -@@ -1 +1 @@ --import s from"fs/promises";import o from"path";import y from"fs";import m from"os";typeof Symbol.asyncDispose!="symbol"&&Object.defineProperty(Symbol,"asyncDispose",{configurable:!1,enumerable:!1,writable:!1,value:Symbol.for("asyncDispose")});class w{path;constructor(t){this.path=t}getPath(...t){return o.join(this.path,...t)}exists(t=""){return s.access(this.getPath(t)).then(()=>!0,()=>!1)}rm(t=""){return s.rm(this.getPath(t),{recursive:!0,force:!0})}writeFile(t,r){return s.writeFile(this.getPath(t),r)}writeJson(t,r){return this.writeFile(t,JSON.stringify(r,null,2))}readFile(t,r){return s.readFile(this.getPath(t),r)}async[Symbol.asyncDispose](){await this.rm()}}const g=y.realpathSync(m.tmpdir()),b=`fs-fixture-${Date.now()}`;let l=0;const P=()=>(l+=1,l);class h{target;type;path;constructor(t,r){this.target=t,this.type=r}}const u=(i,t,r)=>{const e=[];for(const n in i){if(!Object.hasOwn(i,n))continue;const c=o.join(t,n);let a=i[n];if(typeof a=="function"){const f=Object.assign(Object.create(r),{filePath:c}),p=a(f);if(p instanceof h){p.path=c,e.push(p);continue}else a=p}typeof a=="string"?e.push({path:c,content:a}):e.push(...u(a,c,r))}return e},d=async i=>{const t=o.join(g,`${b}-${P()}/`);if(await s.mkdir(t,{recursive:!0}),i){if(typeof i=="string")await s.cp(i,t,{recursive:!0});else if(typeof i=="object"){const r={fixturePath:t,getPath:(...e)=>o.join(t,...e),symlink:(e,n)=>new h(e,n)};await Promise.all(u(i,t,r).map(async e=>{await s.mkdir(o.dirname(e.path),{recursive:!0}),e instanceof h?await s.symlink(e.target,e.path,e.type):await s.writeFile(e.path,e.content)}))}}return new w(t)};export{d as createFixture}; -+import s from"fs/promises";import o from"path";import y from"fs";import m from"os";typeof Symbol.asyncDispose!="symbol"&&Object.defineProperty(Symbol,"asyncDispose",{configurable:!1,enumerable:!1,writable:!1,value:Symbol.for("asyncDispose")});class w{path;constructor(t){this.path=t}getPath(...t){return o.join(this.path,...t)}exists(t=""){return s.access(this.getPath(t)).then(()=>!0,()=>!1)}rm(t=""){return s.rm(this.getPath(t),{recursive:!0,force:!0})}writeFile(t,r){return s.writeFile(this.getPath(t),r)}writeJson(t,r){return this.writeFile(t,JSON.stringify(r,null,2))}readFile(t,r){return s.readFile(this.getPath(t),r)}async[Symbol.asyncDispose](){await this.rm()}}const g=y.realpathSync(m.tmpdir()),b=`fs-fixture-${Date.now()}`;let l=0;const P=()=>(l+=1,l);class h{target;type;path;constructor(t,r){this.target=t,this.type=r}}const u=(i,t,r)=>{const e=[];for(const n in i){if(!Object.hasOwn(i,n))continue;const c=o.join(t,n);let a=i[n];if(typeof a=="function"){const f=Object.assign(Object.create(r),{filePath:c}),p=a(f);if(p instanceof h){p.path=c,e.push(p);continue}else a=p}typeof a=="string"?e.push({path:c,content:a}):e.push(...u(a,c,r))}return e},d=async (i, opts)=>{const t=o.join(opts?.tempDir ?? g,`${b}-${P()}/`);if(await s.mkdir(t,{recursive:!0}),i){if(typeof i=="string")await s.cp(i,t,{recursive:!0});else if(typeof i=="object"){const r={fixturePath:t,getPath:(...e)=>o.join(t,...e),symlink:(e,n)=>new h(e,n)};await Promise.all(u(i,t,r).map(async e=>{await s.mkdir(o.dirname(e.path),{recursive:!0}),e instanceof h?await s.symlink(e.target,e.path,e.type):await s.writeFile(e.path,e.content)}))}}return new w(t)};export{d as createFixture}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c9fab03a83..7006b7f97e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,11 +4,6 @@ settings: autoInstallPeers: false excludeLinksFromLockfile: false -patchedDependencies: - fs-fixture@2.4.0: - hash: hvkuaks2ic76pdflr3iifgi4ku - path: patches/fs-fixture@2.4.0.patch - importers: .: @@ -709,8 +704,8 @@ importers: specifier: ^1.1.0 version: 1.1.0 fs-fixture: - specifier: ^2.4.0 - version: 2.4.0(patch_hash=hvkuaks2ic76pdflr3iifgi4ku) + specifier: ^2.5.0 + version: 2.5.0 mdast-util-mdx: specifier: ^3.0.0 version: 3.0.0 @@ -8264,8 +8259,8 @@ packages: resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==} engines: {node: '>=6 <7 || >=8'} - fs-fixture@2.4.0: - resolution: {integrity: sha512-aFoTWGj288IEOdXBeesdcbdMvRtExbqpOp1SCjE3nRdlT7vBBCD6bf76C9FCq8/6pIPSo56P7+HeT9zT/n8rMA==} + fs-fixture@2.5.0: + resolution: {integrity: sha512-AzCSCaChZORdNcSa9w9IBnGWhDP2Bv/lOso0P9mAl5nJw2s7pjSEoDaHtzZ9VGIHQlSXR2fuTPO7ln1dM4HTNQ==} engines: {node: '>=18.0.0'} fsevents@2.3.2: @@ -13791,7 +13786,7 @@ snapshots: jsonfile: 4.0.0 universalify: 0.1.2 - fs-fixture@2.4.0(patch_hash=hvkuaks2ic76pdflr3iifgi4ku): {} + fs-fixture@2.5.0: {} fsevents@2.3.2: optional: true From d6f17044d3873df77cfbc73230cb3194b5a7d82a Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 17 Oct 2024 05:58:23 -0700 Subject: [PATCH 7/7] [ci] release (#12240) Co-authored-by: github-actions[bot] --- .changeset/lazy-flowers-destroy.md | 5 --- .changeset/real-actors-jog.md | 5 --- .changeset/soft-rabbits-draw.md | 22 ---------- examples/basics/package.json | 2 +- examples/blog/package.json | 2 +- 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/minimal/package.json | 2 +- examples/portfolio/package.json | 2 +- examples/ssr/package.json | 2 +- examples/starlog/package.json | 2 +- examples/toolbar-app/package.json | 2 +- examples/with-markdoc/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 | 26 +++++++++++ packages/astro/package.json | 2 +- pnpm-lock.yaml | 48 ++++++++++----------- 30 files changed, 75 insertions(+), 81 deletions(-) delete mode 100644 .changeset/lazy-flowers-destroy.md delete mode 100644 .changeset/real-actors-jog.md delete mode 100644 .changeset/soft-rabbits-draw.md diff --git a/.changeset/lazy-flowers-destroy.md b/.changeset/lazy-flowers-destroy.md deleted file mode 100644 index b08525b184..0000000000 --- a/.changeset/lazy-flowers-destroy.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -fix: improve error message when inferSize is used in local images with the Image component diff --git a/.changeset/real-actors-jog.md b/.changeset/real-actors-jog.md deleted file mode 100644 index d2a77195fd..0000000000 --- a/.changeset/real-actors-jog.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes a case where environment variables would not be refreshed when using `astro:env` diff --git a/.changeset/soft-rabbits-draw.md b/.changeset/soft-rabbits-draw.md deleted file mode 100644 index 87094d3e16..0000000000 --- a/.changeset/soft-rabbits-draw.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -"astro": patch ---- - -**BREAKING CHANGE to the experimental Container API only** - -Changes the default page rendering behavior of Astro components in containers, and adds a new option `partial: false` to render full Astro pages as before. - -Previously, the Container API was rendering all Astro components as if they were full Astro pages containing `` by default. This was not intended, and now by default, all components will render as [page partials](https://docs.astro.build/en/basics/astro-pages/#page-partials): only the contents of the components without a page shell. - -To render the component as a full-fledged Astro page, pass a new option called `partial: false` to `renderToString()` and `renderToResponse()`: - -```js -import { experimental_AstroContainer as AstroContainer } from 'astro/container'; -import Card from "../src/components/Card.astro"; - -const container = AstroContainer.create(); - -await container.renderToString(Card); // the string will not contain `` -await container.renderToString(Card, { partial: false }); // the string will contain `` -``` - diff --git a/examples/basics/package.json b/examples/basics/package.json index 27e4b451c5..557cbd2918 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.16.5" + "astro": "^4.16.6" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 1af4f65f4c..fab0190636 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -14,6 +14,6 @@ "@astrojs/mdx": "^3.1.8", "@astrojs/rss": "^4.0.9", "@astrojs/sitemap": "^3.2.1", - "astro": "^4.16.5" + "astro": "^4.16.6" } } diff --git a/examples/component/package.json b/examples/component/package.json index f46ebb32d1..311e2405cc 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.16.5" + "astro": "^4.16.6" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index 576b7c85a4..28892b8977 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.16.5", + "astro": "^4.16.6", "@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 3d280064a6..d63293ef0d 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.16.5" + "astro": "^4.16.6" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 8262577f7f..4022300149 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.16.5", + "astro": "^4.16.6", "lit": "^3.2.1" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 9f9f47a998..51ed2e11d6 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -18,7 +18,7 @@ "@astrojs/vue": "^4.5.2", "@types/react": "^18.3.11", "@types/react-dom": "^18.3.1", - "astro": "^4.16.5", + "astro": "^4.16.6", "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 6f427e5be2..c4dfaf2281 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.16.5", + "astro": "^4.16.6", "preact": "^10.24.3" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index ce1d63c1a3..bd21c833d8 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.11", "@types/react-dom": "^18.3.1", - "astro": "^4.16.5", + "astro": "^4.16.6", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 6256b97bde..8f8d928196 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.16.5", + "astro": "^4.16.6", "solid-js": "^1.9.2" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index b55624cd7e..f022017713 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^5.7.2", - "astro": "^4.16.5", + "astro": "^4.16.6", "svelte": "^4.2.19" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index b341eb34d9..6784452849 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^4.5.2", - "astro": "^4.16.5", + "astro": "^4.16.6", "vue": "^3.5.12" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 18a9ab6a32..d76b0fd293 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^8.3.4", - "astro": "^4.16.5" + "astro": "^4.16.6" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 0438e26b81..5fe6276be3 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.16.5" + "astro": "^4.16.6" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/minimal/package.json b/examples/minimal/package.json index edaad3564d..af4a6912d4 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.16.5" + "astro": "^4.16.6" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index 23dff6f519..0f7a0a8003 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.16.5" + "astro": "^4.16.6" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 95ae9ee64b..2bdd5f5288 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.2", - "astro": "^4.16.5", + "astro": "^4.16.6", "svelte": "^4.2.19" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index 8b729b3eae..0012d118d3 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.16.5", + "astro": "^4.16.6", "sass": "^1.79.5", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index e6c015250e..83c2d478ab 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -15,6 +15,6 @@ "./app": "./dist/app.js" }, "devDependencies": { - "astro": "^4.16.5" + "astro": "^4.16.6" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 6a76dc5657..69487f7566 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.11.5", - "astro": "^4.16.5" + "astro": "^4.16.6" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index da711b495b..d21c7e6368 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^3.1.8", "@astrojs/preact": "^3.5.3", - "astro": "^4.16.5", + "astro": "^4.16.6", "preact": "^10.24.3" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 21864a386f..d4a4d453a5 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.16.5", + "astro": "^4.16.6", "nanostores": "^0.11.3", "preact": "^10.24.3" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 04ab56e7a1..7c522d2ced 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^3.1.8", "@astrojs/tailwind": "^5.1.2", "@types/canvas-confetti": "^1.6.4", - "astro": "^4.16.5", + "astro": "^4.16.6", "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 38d5e4b73c..b400103f26 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.16.5", + "astro": "^4.16.6", "vitest": "^2.1.3" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 4246713f16..1dd875b78f 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,31 @@ # astro +## 4.16.6 + +### Patch Changes + +- [#11823](https://github.com/withastro/astro/pull/11823) [`a3d30a6`](https://github.com/withastro/astro/commit/a3d30a602aaa1755197c73f0b51cace61f9088b3) Thanks [@DerTimonius](https://github.com/DerTimonius)! - fix: improve error message when inferSize is used in local images with the Image component + +- [#12227](https://github.com/withastro/astro/pull/12227) [`8b1a641`](https://github.com/withastro/astro/commit/8b1a641be9de4baa9ae48dd0d045915fbbeffa8c) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Fixes a case where environment variables would not be refreshed when using `astro:env` + +- [#12239](https://github.com/withastro/astro/pull/12239) [`2b6daa5`](https://github.com/withastro/astro/commit/2b6daa5840c18729c41f6cd8b4571b88d0cba119) Thanks [@ematipico](https://github.com/ematipico)! - **BREAKING CHANGE to the experimental Container API only** + + Changes the default page rendering behavior of Astro components in containers, and adds a new option `partial: false` to render full Astro pages as before. + + Previously, the Container API was rendering all Astro components as if they were full Astro pages containing `` by default. This was not intended, and now by default, all components will render as [page partials](https://docs.astro.build/en/basics/astro-pages/#page-partials): only the contents of the components without a page shell. + + To render the component as a full-fledged Astro page, pass a new option called `partial: false` to `renderToString()` and `renderToResponse()`: + + ```js + import { experimental_AstroContainer as AstroContainer } from 'astro/container'; + import Card from '../src/components/Card.astro'; + + const container = AstroContainer.create(); + + await container.renderToString(Card); // the string will not contain `` + await container.renderToString(Card, { partial: false }); // the string will contain `` + ``` + ## 4.16.5 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index 0cf43e4753..2b0e377d1f 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.16.5", + "version": "4.16.6", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7006b7f97e..e1b860f08e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -113,7 +113,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro examples/blog: @@ -128,13 +128,13 @@ importers: specifier: ^3.2.1 version: link:../../packages/integrations/sitemap astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^4.16.5 + specifier: ^4.16.6 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.16.5 + specifier: ^4.16.6 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.16.5 + specifier: ^4.16.6 version: link:../../packages/astro examples/framework-lit: @@ -186,7 +186,7 @@ importers: specifier: ^0.2.1 version: 0.2.1 astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro lit: specifier: ^3.2.1 @@ -216,7 +216,7 @@ importers: specifier: ^18.3.1 version: 18.3.1 astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro preact: specifier: ^10.24.3 @@ -246,7 +246,7 @@ importers: specifier: ^1.3.0 version: 1.3.0(preact@10.24.3) astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro preact: specifier: ^10.24.3 @@ -264,7 +264,7 @@ importers: specifier: ^18.3.1 version: 18.3.1 astro: - specifier: ^4.16.5 + specifier: ^4.16.6 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.16.5 + specifier: ^4.16.6 version: link:../../packages/astro solid-js: specifier: ^1.9.2 @@ -291,7 +291,7 @@ importers: specifier: ^5.7.2 version: link:../../packages/integrations/svelte astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro svelte: specifier: ^4.2.19 @@ -303,7 +303,7 @@ importers: specifier: ^4.5.2 version: link:../../packages/integrations/vue astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro vue: specifier: ^3.5.12 @@ -315,25 +315,25 @@ importers: specifier: ^8.3.4 version: 8.3.4(astro@packages+astro) astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro examples/minimal: dependencies: astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro examples/ssr: @@ -345,7 +345,7 @@ importers: specifier: ^5.7.2 version: link:../../packages/integrations/svelte astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro svelte: specifier: ^4.2.19 @@ -354,7 +354,7 @@ importers: examples/starlog: dependencies: astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro sass: specifier: ^1.79.5 @@ -366,7 +366,7 @@ importers: examples/toolbar-app: devDependencies: astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro examples/with-markdoc: @@ -375,7 +375,7 @@ importers: specifier: ^0.11.5 version: link:../../packages/integrations/markdoc astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro examples/with-mdx: @@ -387,7 +387,7 @@ importers: specifier: ^3.5.3 version: link:../../packages/integrations/preact astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro preact: specifier: ^10.24.3 @@ -402,7 +402,7 @@ importers: specifier: ^0.5.2 version: 0.5.2(nanostores@0.11.3)(preact@10.24.3) astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro nanostores: specifier: ^0.11.3 @@ -423,7 +423,7 @@ importers: specifier: ^1.6.4 version: 1.6.4 astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro autoprefixer: specifier: ^10.4.20 @@ -441,7 +441,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^4.16.5 + specifier: ^4.16.6 version: link:../../packages/astro vitest: specifier: ^2.1.3