Skip to content

Commit

Permalink
Merge branch 'main' into feature/preact-signals
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-lefebvre authored Jan 8, 2025
2 parents 4cf0030 + 3caa337 commit 3292802
Show file tree
Hide file tree
Showing 1,314 changed files with 27,478 additions and 31,111 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-peas-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes a bug where Astro attempted to decode a request URL multiple times, resulting in an unexpected behaviour when decoding the character `%`
5 changes: 5 additions & 0 deletions .changeset/curvy-readers-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Improves the config error for invalid combinations of `context` and `access` properties under `env.schema`
5 changes: 5 additions & 0 deletions .changeset/green-buses-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Ensures image styles are not imported unless experimental responsive images are enabled
5 changes: 5 additions & 0 deletions .changeset/heavy-yaks-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/underscore-redirects': minor
---

Updates how the output is determined in `createRedirectsFromAstroRoutes`. Since `v0.5.0`, the output would use the `buildOutput` property and `config.output` as a fallback. It no longer uses this fallback.
5 changes: 5 additions & 0 deletions .changeset/old-clouds-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/mdx': patch
---

Fixes a bug that caused Image component to be imported on MDX pages that did not include images
5 changes: 5 additions & 0 deletions .changeset/pink-years-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Processes markdown with empty body as remark and rehype plugins may add additional content or frontmatter
5 changes: 5 additions & 0 deletions .changeset/rich-terms-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes a bug where the logged output path does not match the actual output path when using `build.format: 'preserve'`
5 changes: 5 additions & 0 deletions .changeset/seven-feet-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Allows configuring Astro modules TypeScript compilation with the `vite.esbuild` config
5 changes: 5 additions & 0 deletions .changeset/strong-cobras-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/mdx': patch
---

Makes internal `check()` function a no-op to allow faster component renders and prevent React 19 component warnings
40 changes: 40 additions & 0 deletions .changeset/tiny-plums-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
'@astrojs/underscore-redirects': minor
---

Updates the input requirements of `createRedirectsFromAstroRoutes`:

- `routeToDynamicTargetMap` keys are `IntegrationResolvedRoute` instead of `IntegrationRouteData` (obtained from the `astro:routes:resolved` hook)
- There's a new `assets` property, that can be obtained from the `astro:build:done` hook

```js
function myIntegration() {
let routes
let buildOutput
let config

return {
name: "my-integration",
hooks: {
"astro:routes:resolved": (params) => {
routes = params.routes
},
"astro:config:done": (params) => {
buildOutput = params.buildOutput
config = params.config
},
"astro:build:done": (params) => {
const redirects = createRedirectsFromAstroRoutes({
config,
buildOutput,
routeToDynamicTargetMap: new Map(
routes.map(route => [route, ''])
),
dir: params.dir,
assets: params.assets
})
}
}
}
}
```
5 changes: 0 additions & 5 deletions .changeset/tough-snakes-reflect.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/twelve-moose-cough.md

This file was deleted.

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/---01-bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ body:
id: bug-reproduction
attributes:
label: Link to Minimal Reproducible Example
description: 'Use [astro.new](https://astro.new) to create a minimal reproduction of the problem. **A minimal reproduction is required** so that others can help debug your issue. If a report is vague (e.g. just a generic error message) and has no reproduction, it may be auto-closed. Not sure how to create a minimal example? [Read our guide](https://docs.astro.build/en/guides/troubleshooting/#creating-minimal-reproductions)'
description: 'Use [StackBlitz](https://astro.new/repro) to create a minimal reproduction of the problem. **A minimal reproduction is required** so that others can help debug your issue. If a report is vague (e.g. just a generic error message) and has no reproduction, it may be auto-closed. Not sure how to create a minimal example? [Read our guide](https://docs.astro.build/en/guides/troubleshooting/#creating-minimal-reproductions)'
placeholder: 'https://stackblitz.com/abcd1234'
validations:
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@
- packages/integrations/vue/**

'docs pr':
- packages/astro/src/@types/astro.ts
- packages/astro/src/types/public/**
- packages/astro/src/core/errors/errors-data.ts
1 change: 1 addition & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@biomejs/biome",
"@types/node",
"@preact/preset-vite", // v2.8.3 starts to use Vite's esbuild for perf, but this conflicts with the react plugin
"astro-embed", // TODO: investigate upgrade (zod import issues with atproto)
"drizzle-orm", // TODO: investigate upgrade (has type issues)
"sharp",

Expand Down
74 changes: 37 additions & 37 deletions .github/scripts/announce.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { globby as glob } from 'globby';
import { fileURLToPath } from 'node:url';
import { readFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { globby as glob } from 'globby';
import { setOutput } from './utils.mjs';

const { GITHUB_REF = 'main' } = process.env;
const baseUrl = new URL(`https://github.com/withastro/astro/blob/${GITHUB_REF}/`);

const emojis = ['🎉', '🥳', '🚀', '🧑‍🚀', '🎊', '🏆', '✅', '🤩', '🤖', '🙌'];
const emojis = ['🎉', '🥳', '🚀', '🧑', '🎊', '🏆', '✅', '🤩', '🤖', '🙌'];
const descriptors = [
'new releases',
'hot and fresh updates',
Expand All @@ -18,34 +18,34 @@ const descriptors = [
'updates',
];
const verbs = [
"just went out!",
"just launched!",
"now available!",
"in the wild!",
"now live!",
"hit the registry!",
"to share!",
"for you!",
"for y’all! 🤠",
"comin’ your way!",
"comin’ atcha!",
"comin’ in hot!",
"freshly minted on the blockchain! (jk)",
"[is] out (now with 100% more reticulated splines!)",
"(as seen on TV!)",
"just dropped!",
"– artisanally hand-crafted just for you.",
"– oh happy day!",
"– enjoy!",
"now out. Be the first on your block to download!",
"made with love 💕",
"[is] out! Our best [version] yet!",
"[is] here. DOWNLOAD! DOWNLOAD! DOWNLOAD!",
"... HUZZAH!",
"[has] landed!",
"landed! The internet just got a little more fun.",
"– from our family to yours.",
"– go forth and build!"
'just went out!',
'just launched!',
'now available!',
'in the wild!',
'now live!',
'hit the registry!',
'to share!',
'for you!',
'for y’all! 🤠',
'comin’ your way!',
'comin’ atcha!',
'comin’ in hot!',
'freshly minted on the blockchain! (jk)',
'[is] out (now with 100% more reticulated splines!)',
'(as seen on TV!)',
'just dropped!',
'– artisanally hand-crafted just for you.',
'– oh happy day!',
'– enjoy!',
'now out. Be the first on your block to download!',
'made with love 💕',
'[is] out! Our best [version] yet!',
'[is] here. DOWNLOAD! DOWNLOAD! DOWNLOAD!',
'... HUZZAH!',
'[has] landed!',
'landed! The internet just got a little more fun.',
'– from our family to yours.',
'– go forth and build!',
];
const extraVerbs = [
'new',
Expand All @@ -72,7 +72,7 @@ const plurals = new Map([

function pluralize(text) {
return text.replace(/(\[([^\]]+)\])/gm, (_, _full, match) =>
plurals.has(match) ? plurals.get(match) : `${match}s`
plurals.has(match) ? plurals.get(match) : `${match}s`,
);
}

Expand All @@ -91,7 +91,7 @@ async function generatePackageMap() {
const pkgFile = fileURLToPath(new URL(pkg, packageRoot));
const content = await readFile(pkgFile).then((res) => JSON.parse(res.toString()));
packageMap.set(content.name, `./packages/${pkg.replace('/package.json', '')}`);
})
}),
);
}

Expand All @@ -110,7 +110,7 @@ async function generateMessage() {
version,
url: new URL(`${p}/CHANGELOG.md#${version.replace(/\./g, '')}`, baseUrl).toString(),
};
})
}),
);

const emoji = item(emojis);
Expand All @@ -122,7 +122,7 @@ async function generateMessage() {
if (packages.length === 1) {
const { name, version, url } = packages[0];
message += `${emoji} \`${name}@${version}\` ${singularlize(
verb
verb,
)}\nRead the [release notes →](<${url}>)\n`;
} else {
message += `${emoji} Some ${descriptor} ${pluralize(verb)}\n\n`;
Expand All @@ -141,7 +141,7 @@ async function generateMessage() {
message += `\nAlso ${item(extraVerbs)}:`;

const remainingPackages = packages.filter((p) => p.name !== name);
for (const { name, version, url } of remainingPackages) {
for (const { name, version, _url } of remainingPackages) {
message += `\n• \`${name}@${version}\``;
}

Expand All @@ -159,7 +159,7 @@ async function generateMessage() {

async function run() {
const content = await generateMessage();
console.log(content);
console.info(content);
setOutput('DISCORD_MESSAGE', content);
}

Expand Down
54 changes: 35 additions & 19 deletions .github/scripts/bundle-size.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { build } from 'esbuild';
import { existsSync } from 'node:fs';
import { build } from 'esbuild';

const CLIENT_RUNTIME_PATH = 'packages/astro/src/runtime/client/';

function formatBytes(bytes, decimals = 2) {
if (bytes === 0) return '0 B';
if (bytes === 0) return '0 B';

const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];

const i = Math.floor(Math.log(bytes) / Math.log(k));
const i = Math.floor(Math.log(bytes) / Math.log(k));

return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}

export default async function checkBundleSize({ github, context }) {
Expand All @@ -24,7 +24,7 @@ export default async function checkBundleSize({ github, context }) {
pull_number: PR_NUM,
});
const clientRuntimeFiles = files.filter((file) => {
return file.filename.startsWith(CLIENT_RUNTIME_PATH) && file.status !== 'removed'
return file.filename.startsWith(CLIENT_RUNTIME_PATH) && file.status !== 'removed';
});
if (clientRuntimeFiles.length === 0) return;

Expand All @@ -35,17 +35,24 @@ export default async function checkBundleSize({ github, context }) {
const output = await bundle(clientRuntimeFiles);

for (let [filename, { oldSize, newSize, sourceFile }] of Object.entries(output)) {
filename = ['idle', 'load', 'media', 'only', 'visible'].includes(filename) ? `client:${filename}` : filename;
const prefix = (newSize - oldSize) === 0 ? '' : (newSize - oldSize) > 0 ? '+ ' : '- ';
filename = ['idle', 'load', 'media', 'only', 'visible'].includes(filename)
? `client:${filename}`
: filename;
const prefix = newSize - oldSize === 0 ? '' : newSize - oldSize > 0 ? '+ ' : '- ';
const change = `${prefix}${formatBytes(newSize - oldSize)}`;
table.push(`| [\`${filename}\`](https://github.com/${context.repo.owner}/${context.repo.repo}/tree/${context.payload.pull_request.head.ref}/${sourceFile}) | ${formatBytes(oldSize)} | ${formatBytes(newSize)} | ${change} |`);
table.push(
`| [\`${filename}\`](https://github.com/${context.repo.owner}/${context.repo.repo}/tree/${context.payload.pull_request.head.ref}/${sourceFile}) | ${formatBytes(oldSize)} | ${formatBytes(newSize)} | ${change} |`,
);
}

const { data: comments } = await github.rest.issues.listComments({
...context.repo,
issue_number: PR_NUM
})
const comment = comments.find(comment => comment.user.login === 'github-actions[bot]' && comment.body.includes('Bundle Size Check'));
issue_number: PR_NUM,
});
const comment = comments.find(
(comment) =>
comment.user.login === 'github-actions[bot]' && comment.body.includes('Bundle Size Check'),
);
const method = comment ? 'updateComment' : 'createComment';
const payload = comment ? { comment_id: comment.id } : { issue_number: PR_NUM };
await github.rest.issues[method]({
Expand All @@ -60,27 +67,36 @@ ${table.join('\n')}`,
}

async function bundle(files) {

const { metafile } = await build({
entryPoints: [...files.map(({ filename }) => filename), ...files.map(({ filename }) => `main/${filename}`).filter(f => existsSync(f))],
entryPoints: [
...files.map(({ filename }) => filename),
...files.map(({ filename }) => `main/${filename}`).filter((f) => existsSync(f)),
],
bundle: true,
minify: true,
sourcemap: false,
target: ['es2018'],
outdir: 'out',
external: ['astro:*', 'aria-query', 'axobject-query'],
metafile: true,
})
});

return Object.entries(metafile.outputs).reduce((acc, [filename, info]) => {
filename = filename.slice('out/'.length);
if (filename.startsWith('main/')) {
filename = filename.slice('main/'.length).replace(CLIENT_RUNTIME_PATH, '').replace('.js', '');
const oldSize = info.bytes;
return Object.assign(acc, { [filename]: Object.assign(acc[filename] ?? { oldSize: 0, newSize: 0 }, { oldSize }) });
return Object.assign(acc, {
[filename]: Object.assign(acc[filename] ?? { oldSize: 0, newSize: 0 }, { oldSize }),
});
}
filename = filename.replace(CLIENT_RUNTIME_PATH, '').replace('.js', '');
const newSize = info.bytes;
return Object.assign(acc, { [filename]: Object.assign(acc[filename] ?? { oldSize: 0, newSize: 0 }, { newSize, sourceFile: Object.keys(info.inputs).find(src => src.endsWith('.ts')) }) });
return Object.assign(acc, {
[filename]: Object.assign(acc[filename] ?? { oldSize: 0, newSize: 0 }, {
newSize,
sourceFile: Object.keys(info.inputs).find((src) => src.endsWith('.ts')),
}),
});
}, {});
}
Loading

0 comments on commit 3292802

Please sign in to comment.