0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-24 22:46:02 -05:00

Merge branch 'main' into renovate/major-react-monorepo

This commit is contained in:
bluwy 2025-01-07 17:39:37 +08:00
commit 2f7cd47383
45 changed files with 126 additions and 124 deletions

View file

@ -1,5 +0,0 @@
---
'astro': patch
---
Fixes sourcemap warning generated by the `astro:server-islands` Vite plugin

View file

@ -1,5 +0,0 @@
---
'astro': patch
---
Fixes a bug that caused pages that return an empty array from getStaticPath to match every path

View file

@ -1,5 +0,0 @@
---
'astro': patch
---
Fixes race condition where dev server would attempt to load collections before the content had loaded

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Allows configuring Astro modules TypeScript compilation with the `vite.esbuild` config

View file

@ -1,5 +0,0 @@
---
'@astrojs/underscore-redirects': patch
---
Fixes the type of `force`

View file

@ -1,5 +0,0 @@
---
'astro': patch
---
Fixes a bug where responses can be returned before session data is saved

View file

@ -1,5 +0,0 @@
---
'astro': patch
---
Some non-index files that were incorrectly being treated as index files are now excluded

View file

@ -1,5 +0,0 @@
---
'astro': patch
---
Adds `render()` to stub content types

View file

@ -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

View file

@ -1,5 +0,0 @@
---
'astro': patch
---
Fixes a bug where session data could be corrupted if it is changed after calling .set()

View file

@ -1,5 +0,0 @@
---
'astro': patch
---
Fixes an issue when crawlers try to index Server Islands thinking that Server Islands are pages

View file

@ -10,6 +10,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^5.1.2"
"astro": "^5.1.3"
}
}

View file

@ -13,6 +13,6 @@
"@astrojs/mdx": "^4.0.3",
"@astrojs/rss": "^4.0.11",
"@astrojs/sitemap": "^3.2.1",
"astro": "^5.1.2"
"astro": "^5.1.3"
}
}

View file

@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^5.1.2"
"astro": "^5.1.3"
},
"peerDependencies": {
"astro": "^4.0.0 || ^5.0.0"

View file

@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/react": "^4.1.2",
"astro": "^5.1.2",
"astro": "^5.1.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"vitest": "^3.0.0-beta.3"

View file

@ -13,6 +13,6 @@
"@astrojs/alpinejs": "^0.4.1",
"@types/alpinejs": "^3.13.10",
"alpinejs": "^3.14.3",
"astro": "^5.1.2"
"astro": "^5.1.3"
}
}

View file

@ -17,7 +17,7 @@
"@astrojs/vue": "^5.0.4",
"@types/react": "^19.0.3",
"@types/react-dom": "^19.0.2",
"astro": "^5.1.2",
"astro": "^5.1.3",
"preact": "^10.24.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",

View file

@ -12,7 +12,7 @@
"dependencies": {
"@astrojs/preact": "^4.0.1",
"@preact/signals": "^2.0.0",
"astro": "^5.1.2",
"astro": "^5.1.3",
"preact": "^10.24.3"
}
}

View file

@ -13,7 +13,7 @@
"@astrojs/react": "^4.1.2",
"@types/react": "^19.0.3",
"@types/react-dom": "^19.0.2",
"astro": "^5.1.2",
"astro": "^5.1.3",
"react": "^19.0.0",
"react-dom": "^19.0.0"
}

View file

@ -11,7 +11,7 @@
},
"dependencies": {
"@astrojs/solid-js": "^5.0.1",
"astro": "^5.1.2",
"astro": "^5.1.3",
"solid-js": "^1.9.3"
}
}

View file

@ -11,7 +11,7 @@
},
"dependencies": {
"@astrojs/svelte": "^7.0.3",
"astro": "^5.1.2",
"astro": "^5.1.3",
"svelte": "^5.1.16"
}
}

View file

@ -11,7 +11,7 @@
},
"dependencies": {
"@astrojs/vue": "^5.0.4",
"astro": "^5.1.2",
"astro": "^5.1.3",
"vue": "^3.5.12"
}
}

View file

@ -11,6 +11,6 @@
},
"dependencies": {
"@astrojs/node": "^9.0.0",
"astro": "^5.1.2"
"astro": "^5.1.3"
}
}

View file

@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^5.1.2"
"astro": "^5.1.3"
},
"peerDependencies": {
"astro": "^4.0.0"

View file

@ -10,6 +10,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^5.1.2"
"astro": "^5.1.3"
}
}

View file

@ -10,6 +10,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^5.1.2"
"astro": "^5.1.3"
}
}

View file

@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/node": "^9.0.0",
"@astrojs/svelte": "^7.0.3",
"astro": "^5.1.2",
"astro": "^5.1.3",
"svelte": "^5.1.16"
}
}

View file

@ -9,7 +9,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^5.1.2",
"astro": "^5.1.3",
"sass": "^1.80.6",
"sharp": "^0.33.3"
}

View file

@ -16,6 +16,6 @@
},
"devDependencies": {
"@types/node": "^18.17.8",
"astro": "^5.1.2"
"astro": "^5.1.3"
}
}

View file

@ -11,6 +11,6 @@
},
"dependencies": {
"@astrojs/markdoc": "^0.12.4",
"astro": "^5.1.2"
"astro": "^5.1.3"
}
}

View file

@ -12,7 +12,7 @@
"dependencies": {
"@astrojs/mdx": "^4.0.3",
"@astrojs/preact": "^4.0.1",
"astro": "^5.1.2",
"astro": "^5.1.3",
"preact": "^10.24.3"
}
}

View file

@ -12,7 +12,7 @@
"dependencies": {
"@astrojs/preact": "^4.0.1",
"@nanostores/preact": "^0.5.2",
"astro": "^5.1.2",
"astro": "^5.1.3",
"nanostores": "^0.11.3",
"preact": "^10.24.3"
}

View file

@ -13,7 +13,7 @@
"@astrojs/mdx": "^4.0.3",
"@astrojs/tailwind": "^5.1.4",
"@types/canvas-confetti": "^1.6.4",
"astro": "^5.1.2",
"astro": "^5.1.3",
"autoprefixer": "^10.4.20",
"canvas-confetti": "^1.9.3",
"postcss": "^8.4.49",

View file

@ -11,7 +11,7 @@
"test": "vitest"
},
"dependencies": {
"astro": "^5.1.2",
"astro": "^5.1.3",
"vitest": "^3.0.0-beta.3"
}
}

View file

@ -1,5 +1,29 @@
# astro
## 5.1.3
### Patch Changes
- [#12877](https://github.com/withastro/astro/pull/12877) [`73a0788`](https://github.com/withastro/astro/commit/73a078835eb92a05c3f681ee025c93d6db85b907) Thanks [@bluwy](https://github.com/bluwy)! - Fixes sourcemap warning generated by the `astro:server-islands` Vite plugin
- [#12906](https://github.com/withastro/astro/pull/12906) [`2d89492`](https://github.com/withastro/astro/commit/2d89492d73142ed5c7cea9448d841a9892e66598) Thanks [@ascorbic](https://github.com/ascorbic)! - Fixes a bug that caused pages that return an empty array from getStaticPath to match every path
- [`011fa0f`](https://github.com/withastro/astro/commit/011fa0f00ce457cb6b582d36b6b5b17aa89f0a70) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Fixes a case where `astro:content` types would be erased when restarting the dev server
- [#12907](https://github.com/withastro/astro/pull/12907) [`dbf1275`](https://github.com/withastro/astro/commit/dbf1275987d4d9724eab471f1600fba9a50aefb8) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Fixes a regression around the server islands route, which was not passed to the adapters `astro:build:done` hook
- [#12818](https://github.com/withastro/astro/pull/12818) [`579bd93`](https://github.com/withastro/astro/commit/579bd93794b787485479aa3b16554409a0504ed2) Thanks [@ascorbic](https://github.com/ascorbic)! - Fixes race condition where dev server would attempt to load collections before the content had loaded
- [#12883](https://github.com/withastro/astro/pull/12883) [`fbac92f`](https://github.com/withastro/astro/commit/fbac92f8bdbb5ee1312726b2a535a81271b3f7d6) Thanks [@kaytwo](https://github.com/kaytwo)! - Fixes a bug where responses can be returned before session data is saved
- [#12815](https://github.com/withastro/astro/pull/12815) [`3acc654`](https://github.com/withastro/astro/commit/3acc65444c27d87b6f2d61bdfa7df0e0db4e2686) Thanks [@ericswpark](https://github.com/ericswpark)! - Some non-index files that were incorrectly being treated as index files are now excluded
- [#12884](https://github.com/withastro/astro/pull/12884) [`d7e97a7`](https://github.com/withastro/astro/commit/d7e97a775dda7a851bfc10b06161f9a1d3631ed3) Thanks [@ascorbic](https://github.com/ascorbic)! - Adds `render()` to stub content types
- [#12883](https://github.com/withastro/astro/pull/12883) [`fbac92f`](https://github.com/withastro/astro/commit/fbac92f8bdbb5ee1312726b2a535a81271b3f7d6) Thanks [@kaytwo](https://github.com/kaytwo)! - Fixes a bug where session data could be corrupted if it is changed after calling .set()
- [#12827](https://github.com/withastro/astro/pull/12827) [`7b5dc6f`](https://github.com/withastro/astro/commit/7b5dc6f0f1fbb825f52cd587aa1f7d21d731b3de) Thanks [@sinskiy](https://github.com/sinskiy)! - Fixes an issue when crawlers try to index Server Islands thinking that Server Islands are pages
## 5.1.2
### Patch Changes

View file

@ -1,6 +1,6 @@
{
"name": "astro",
"version": "5.1.2",
"version": "5.1.3",
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
"type": "module",
"author": "withastro",

View file

@ -23,6 +23,7 @@ import type { Logger } from '../logger/core.js';
import { levels, timerMessage } from '../logger/core.js';
import { apply as applyPolyfill } from '../polyfill.js';
import { createRouteManifest } from '../routing/index.js';
import { getServerIslandRouteData } from '../server-islands/endpoint.js';
import { clearContentLayerCache } from '../sync/index.js';
import { ensureProcessNodeEnv } from '../util.js';
import { collectPagesData } from './page-data.js';
@ -232,7 +233,8 @@ class AstroBuilder {
pages: pageNames,
routes: Object.values(allPages)
.flat()
.map((pageData) => pageData.route),
.map((pageData) => pageData.route)
.concat(hasServerIslands ? getServerIslandRouteData(this.settings.config) : []),
logging: this.logger,
});

View file

@ -150,17 +150,15 @@ export async function syncInternal({
settings.timer.end('Sync content layer');
} else {
const paths = getContentPaths(settings.config, fs);
// Content is synced after writeFiles. That means references are not created
// To work around it, we create a stub so the reference is created and content
// sync will override the empty file
if (
paths.config.exists ||
// Legacy collections don't require a config file
(settings.config.legacy?.collections && fs.existsSync(paths.contentDir))
) {
// We only create the reference, without a stub to avoid overriding the
// already generated types
settings.injectedTypes.push({
filename: CONTENT_TYPES_FILE,
content: '',
});
}
}
@ -182,7 +180,9 @@ function writeInjectedTypes(settings: AstroSettings, fs: typeof fsMod) {
for (const { filename, content } of settings.injectedTypes) {
const filepath = fileURLToPath(new URL(filename, settings.dotAstroDir));
fs.mkdirSync(dirname(filepath), { recursive: true });
fs.writeFileSync(filepath, content, 'utf-8');
if (content) {
fs.writeFileSync(filepath, content, 'utf-8');
}
references.push(normalizePath(relative(fileURLToPath(settings.dotAstroDir), filepath)));
}

View file

@ -64,7 +64,8 @@ export interface AstroSettings {
latestAstroVersion: string | undefined;
serverIslandMap: NonNullable<SSRManifest['serverIslandMap']>;
serverIslandNameMap: NonNullable<SSRManifest['serverIslandNameMap']>;
injectedTypes: Array<InjectedType>;
// This makes content optional. Internal only so it's not optional on InjectedType
injectedTypes: Array<Omit<InjectedType, 'content'> & Partial<Pick<InjectedType, 'content'>>>;
/**
* Determine if the build output should be a static, dist folder or a adapter-based server output
* undefined when unknown

View file

@ -37,8 +37,8 @@ export async function compileAstro({
// Compile all TypeScript to JavaScript.
// Also, catches invalid JS/TS in the compiled output before returning.
esbuildResult = await transformWithEsbuild(transformResult.code, compileProps.filename, {
...compileProps.viteConfig.esbuild,
loader: 'ts',
target: 'esnext',
sourcemap: 'external',
tsconfigRaw: {
compilerOptions: {

View file

@ -5,13 +5,12 @@ import { init, parse } from 'es-module-lexer';
import { resolveConfig } from 'vite';
import { compileAstro } from '../../../dist/vite-plugin-astro/compile.js';
const viteConfig = await resolveConfig({ configFile: false }, 'serve');
/**
* @param {string} source
* @param {string} id
*/
async function compile(source, id) {
async function compile(source, id, inlineConfig = {}) {
const viteConfig = await resolveConfig({ configFile: false, ...inlineConfig }, 'serve');
return await compileAstro({
compileProps: {
astroConfig: { root: pathToFileURL('/'), base: '/', experimental: {} },
@ -69,4 +68,23 @@ const name = 'world
assert.equal(names.includes('file'), true);
assert.equal(names.includes('url'), true);
});
describe('when the code contains syntax that is transformed by esbuild', () => {
let code = `\
---
using x = {}
---`;
it('should not transform the syntax by default', async () => {
const result = await compile(code, '/src/components/index.astro');
assert.equal(result.code.includes('using x = {}'), true);
});
it('should transform the syntax by esbuild.target', async () => {
const result = await compile(code, '/src/components/index.astro', {
esbuild: { target: 'es2018' },
});
assert.equal(result.code.includes('using x = {}'), false);
});
});
});

View file

@ -1,29 +1,15 @@
import type { NamedSSRLoadedRendererValue } from 'astro';
import { AstroError } from 'astro/errors';
import { AstroJSX, jsx } from 'astro/jsx-runtime';
import { jsx } from 'astro/jsx-runtime';
import { renderJSX } from 'astro/runtime/server/index.js';
const slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
// NOTE: In practice, MDX components are always tagged with `__astro_tag_component__`, so the right renderer
// is used directly, and this check is not often used to return true.
export async function check(
Component: any,
props: any,
{ default: children = null, ...slotted } = {},
) {
if (typeof Component !== 'function') return false;
const slots: Record<string, any> = {};
for (const [key, value] of Object.entries(slotted)) {
const name = slotName(key);
slots[name] = value;
}
try {
const result = await Component({ ...props, ...slots, children });
return result[AstroJSX];
} catch (e) {
throwEnhancedErrorIfMdxComponent(e as Error, Component);
}
// MDX components are tagged with `__astro_tag_component__` in `vite-plugin-mdx-postprocess.ts`
// and tagged componenets can directly tell Astro which renderer to use in build-time, rather
// than checking the components in runtime. So this function is made a no-op as any untagged
// component wouldn't have belonged to MDX.
export async function check() {
return false;
}

View file

@ -1,5 +1,11 @@
# @astrojs/underscore-redirects
## 0.5.1
### Patch Changes
- [#12904](https://github.com/withastro/astro/pull/12904) [`7fdbd43`](https://github.com/withastro/astro/commit/7fdbd4384dea186b9bbc2c6b130e8aba2a2c1e89) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Fixes the type of `force`
## 0.5.0
### Minor Changes

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/underscore-redirects",
"description": "Utilities to generate _redirects files in Astro projects",
"version": "0.5.0",
"version": "0.5.1",
"type": "module",
"author": "withastro",
"license": "MIT",

46
pnpm-lock.yaml generated
View file

@ -142,7 +142,7 @@ importers:
examples/basics:
dependencies:
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
examples/blog:
@ -157,13 +157,13 @@ importers:
specifier: ^3.2.1
version: link:../../packages/integrations/sitemap
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
examples/component:
devDependencies:
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
examples/container-with-vitest:
@ -172,7 +172,7 @@ importers:
specifier: ^4.1.2
version: link:../../packages/integrations/react
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
react:
specifier: ^19.0.0
@ -203,7 +203,7 @@ importers:
specifier: ^3.14.3
version: 3.14.3
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
examples/framework-multiple:
@ -230,7 +230,7 @@ importers:
specifier: ^19.0.2
version: 19.0.2(@types/react@19.0.3)
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
preact:
specifier: ^10.24.3
@ -260,7 +260,7 @@ importers:
specifier: ^2.0.0
version: 2.0.0(preact@10.25.1)
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
preact:
specifier: ^10.24.3
@ -278,7 +278,7 @@ importers:
specifier: ^19.0.2
version: 19.0.2(@types/react@19.0.3)
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
react:
specifier: ^19.0.0
@ -293,7 +293,7 @@ importers:
specifier: ^5.0.1
version: link:../../packages/integrations/solid
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
solid-js:
specifier: ^1.9.3
@ -305,7 +305,7 @@ importers:
specifier: ^7.0.3
version: link:../../packages/integrations/svelte
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
svelte:
specifier: ^5.1.16
@ -317,7 +317,7 @@ importers:
specifier: ^5.0.4
version: link:../../packages/integrations/vue
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
vue:
specifier: ^3.5.12
@ -329,25 +329,25 @@ importers:
specifier: ^9.0.0
version: 9.0.0(astro@packages+astro)
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
examples/integration:
devDependencies:
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
examples/minimal:
dependencies:
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
examples/portfolio:
dependencies:
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
examples/ssr:
@ -359,7 +359,7 @@ importers:
specifier: ^7.0.3
version: link:../../packages/integrations/svelte
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
svelte:
specifier: ^5.1.16
@ -368,7 +368,7 @@ importers:
examples/starlog:
dependencies:
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
sass:
specifier: ^1.80.6
@ -383,7 +383,7 @@ importers:
specifier: ^18.17.8
version: 18.19.50
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
examples/with-markdoc:
@ -392,7 +392,7 @@ importers:
specifier: ^0.12.4
version: link:../../packages/integrations/markdoc
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
examples/with-mdx:
@ -404,7 +404,7 @@ importers:
specifier: ^4.0.1
version: link:../../packages/integrations/preact
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
preact:
specifier: ^10.24.3
@ -419,7 +419,7 @@ importers:
specifier: ^0.5.2
version: 0.5.2(nanostores@0.11.3)(preact@10.25.1)
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
nanostores:
specifier: ^0.11.3
@ -440,7 +440,7 @@ importers:
specifier: ^1.6.4
version: 1.6.4
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
autoprefixer:
specifier: ^10.4.20
@ -458,7 +458,7 @@ importers:
examples/with-vitest:
dependencies:
astro:
specifier: ^5.1.2
specifier: ^5.1.3
version: link:../../packages/astro
vitest:
specifier: ^3.0.0-beta.3