From 4c47c446197deedbfae2a3a7689e7004e1ab8fd4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 09:29:19 +0100 Subject: [PATCH 1/4] fix(deps): update dependency @oslojs/encoding to v1 (#12058) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- packages/astro/package.json | 2 +- pnpm-lock.yaml | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/astro/package.json b/packages/astro/package.json index abbed3e10754..6ae16580cf07 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -129,7 +129,7 @@ "@babel/core": "^7.25.2", "@babel/plugin-transform-react-jsx": "^7.25.2", "@babel/types": "^7.25.6", - "@oslojs/encoding": "^0.4.1", + "@oslojs/encoding": "^1.0.0", "@rollup/pluginutils": "^5.1.0", "@types/babel__core": "^7.20.5", "@types/cookie": "^0.6.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fb9e2516a117..fbaf30af79a0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -574,8 +574,8 @@ importers: specifier: ^7.25.6 version: 7.25.6 '@oslojs/encoding': - specifier: ^0.4.1 - version: 0.4.1 + specifier: ^1.0.0 + version: 1.0.0 '@rollup/pluginutils': specifier: ^5.1.0 version: 5.1.0(rollup@4.21.2) @@ -6806,8 +6806,8 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} - '@oslojs/encoding@0.4.1': - resolution: {integrity: sha512-hkjo6MuIK/kQR5CrGNdAPZhS01ZCXuWDRJ187zh6qqF2+yMHZpD9fAYpX8q2bOO6Ryhl3XpCT6kUX76N8hhm4Q==} + '@oslojs/encoding@1.0.0': + resolution: {integrity: sha512-dyIB0SdZgMm5BhGwdSp8rMxEFIopLKxDG1vxIBaiogyom6ZqH2aXPb6DEC2WzOOWKdPSq1cxdNeRx2wAn1Z+ZQ==} '@parse5/tools@0.3.0': resolution: {integrity: sha512-zxRyTHkqb7WQMV8kTNBKWb1BeOFUKXBXTBWuxg9H9hfvQB3IwP6Iw2U75Ia5eyRxPNltmY7E8YAlz6zWwUnjKg==} @@ -8861,10 +8861,12 @@ packages: libsql@0.3.19: resolution: {integrity: sha512-Aj5cQ5uk/6fHdmeW0TiXK42FqUlwx7ytmMLPSaUQPin5HKKKuUPD62MAbN4OEweGBBI7q1BekoEN4gPUEL6MZA==} + cpu: [x64, arm64, wasm32] os: [darwin, linux, win32] libsql@0.4.1: resolution: {integrity: sha512-qZlR9Yu1zMBeLChzkE/cKfoKV3Esp9cn9Vx5Zirn4AVhDWPcjYhKwbtJcMuHehgk3mH+fJr9qW+3vesBWbQpBg==} + cpu: [x64, arm64, wasm32] os: [darwin, linux, win32] lilconfig@2.1.0: @@ -12375,7 +12377,7 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.17.1 - '@oslojs/encoding@0.4.1': {} + '@oslojs/encoding@1.0.0': {} '@parse5/tools@0.3.0': dependencies: From 25a104b4513619e3b2a852975c32f6b77334f6ba Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 23 Sep 2024 16:39:06 +0100 Subject: [PATCH 2/4] refactor: dynamically import middleware (#11550) * refactor: dynamically import middleware * update tests * chore: fix code merge * address linting * remove changeset * feedback * feedback * fix test failing * add suggestion * change order of resolution to cache the middleware before inserting a route * address comment --- packages/astro/src/container/index.ts | 15 ++++++----- packages/astro/src/container/pipeline.ts | 2 +- packages/astro/src/core/app/common.ts | 5 ++-- packages/astro/src/core/app/index.ts | 16 +++--------- packages/astro/src/core/app/types.ts | 4 +-- packages/astro/src/core/base-pipeline.ts | 25 ++++++++++++++++++- packages/astro/src/core/build/generate.ts | 13 ++++++++-- packages/astro/src/core/build/pipeline.ts | 6 ++++- .../src/core/build/plugins/plugin-ssr.ts | 3 +-- .../src/core/middleware/noop-middleware.ts | 3 +++ packages/astro/src/core/render-context.ts | 9 ++++--- .../src/vite-plugin-astro-server/plugin.ts | 7 ++++-- .../src/vite-plugin-astro-server/route.ts | 4 +-- packages/astro/test/units/render/head.test.js | 6 ++--- packages/astro/test/units/render/jsx.test.js | 6 ++--- packages/astro/test/units/test-utils.js | 4 +++ 16 files changed, 86 insertions(+), 42 deletions(-) create mode 100644 packages/astro/src/core/middleware/noop-middleware.ts diff --git a/packages/astro/src/container/index.ts b/packages/astro/src/container/index.ts index fef82df2a382..9aa4e2d2f2d9 100644 --- a/packages/astro/src/container/index.ts +++ b/packages/astro/src/container/index.ts @@ -2,6 +2,7 @@ import './polyfill.js'; import { posix } from 'node:path'; import type { AstroConfig, + AstroMiddlewareInstance, AstroUserConfig, ComponentInstance, ContainerImportRendererFn, @@ -21,6 +22,7 @@ import { validateConfig } from '../core/config/validate.js'; import { createKey } from '../core/encryption.js'; import { Logger } from '../core/logger/core.js'; import { nodeLogDestination } from '../core/logger/node.js'; +import { NOOP_MIDDLEWARE_FN } from '../core/middleware/noop-middleware.js'; import { removeLeadingForwardSlash } from '../core/path.js'; import { RenderContext } from '../core/render-context.js'; import { getParts, validateSegment } from '../core/routing/manifest/create.js'; @@ -109,9 +111,11 @@ function createManifest( renderers?: SSRLoadedRenderer[], middleware?: MiddlewareHandler, ): SSRManifest { - const defaultMiddleware: MiddlewareHandler = (_, next) => { - return next(); - }; + function middlewareInstance(): AstroMiddlewareInstance { + return { + onRequest: middleware ?? NOOP_MIDDLEWARE_FN, + }; + } return { hrefRoot: import.meta.url, @@ -130,7 +134,7 @@ function createManifest( inlinedScripts: manifest?.inlinedScripts ?? new Map(), i18n: manifest?.i18n, checkOrigin: false, - middleware: manifest?.middleware ?? middleware ?? defaultMiddleware, + middleware: manifest?.middleware ?? middlewareInstance, experimentalEnvGetSecretEnabled: false, key: createKey(), }; @@ -476,11 +480,10 @@ export class experimental_AstroContainer { params: options.params, type: routeType, }); - const renderContext = RenderContext.create({ + const renderContext = await RenderContext.create({ pipeline: this.#pipeline, routeData, status: 200, - middleware: this.#pipeline.middleware, request, pathname: url.pathname, locals: options?.locals ?? {}, diff --git a/packages/astro/src/container/pipeline.ts b/packages/astro/src/container/pipeline.ts index 6a2af65ce384..0412da4df8a1 100644 --- a/packages/astro/src/container/pipeline.ts +++ b/packages/astro/src/container/pipeline.ts @@ -88,7 +88,7 @@ export class ContainerPipeline extends Pipeline { return Promise.resolve(componentInstance); }, renderers: this.manifest.renderers, - onRequest: this.manifest.middleware, + onRequest: this.resolvedMiddleware, }); } diff --git a/packages/astro/src/core/app/common.ts b/packages/astro/src/core/app/common.ts index 7cfe1c5dd741..3d951267caeb 100644 --- a/packages/astro/src/core/app/common.ts +++ b/packages/astro/src/core/app/common.ts @@ -1,6 +1,7 @@ import { decodeKey } from '../encryption.js'; import { deserializeRouteData } from '../routing/manifest/serialization.js'; import type { RouteInfo, SSRManifest, SerializedSSRManifest } from './types.js'; +import { NOOP_MIDDLEWARE_FN } from '../middleware/noop-middleware.js'; export function deserializeManifest(serializedManifest: SerializedSSRManifest): SSRManifest { const routes: RouteInfo[] = []; @@ -23,8 +24,8 @@ export function deserializeManifest(serializedManifest: SerializedSSRManifest): return { // in case user middleware exists, this no-op middleware will be reassigned (see plugin-ssr.ts) - middleware(_, next) { - return next(); + middleware() { + return { onRequest: NOOP_MIDDLEWARE_FN }; }, ...serializedManifest, assets, diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index 8041dda3c6f7..97f11c82682c 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -11,7 +11,6 @@ import { getSetCookiesFromResponse } from '../cookies/index.js'; import { AstroError, AstroErrorData } from '../errors/index.js'; import { consoleLogDestination } from '../logger/console.js'; import { AstroIntegrationLogger, Logger } from '../logger/core.js'; -import { sequence } from '../middleware/index.js'; import { appendForwardSlash, joinPaths, @@ -22,8 +21,8 @@ import { RenderContext } from '../render-context.js'; import { createAssetLink } from '../render/ssr-element.js'; import { createDefaultRoutes, injectDefaultRoutes } from '../routing/default.js'; import { matchRoute } from '../routing/match.js'; -import { createOriginCheckMiddleware } from './middlewares.js'; import { AppPipeline } from './pipeline.js'; +import { NOOP_MIDDLEWARE_FN } from '../middleware/noop-middleware.js'; export { deserializeManifest } from './common.js'; @@ -111,13 +110,6 @@ export class App { * @private */ #createPipeline(manifestData: ManifestData, streaming = false) { - if (this.#manifest.checkOrigin) { - this.#manifest.middleware = sequence( - createOriginCheckMiddleware(), - this.#manifest.middleware, - ); - } - return AppPipeline.create(manifestData, { logger: this.#logger, manifest: this.#manifest, @@ -323,7 +315,7 @@ export class App { // Load route module. We also catch its error here if it fails on initialization const mod = await this.#pipeline.getModuleForRoute(routeData); - const renderContext = RenderContext.create({ + const renderContext = await RenderContext.create({ pipeline: this.#pipeline, locals, pathname, @@ -428,10 +420,10 @@ export class App { } const mod = await this.#pipeline.getModuleForRoute(errorRouteData); try { - const renderContext = RenderContext.create({ + const renderContext = await RenderContext.create({ locals, pipeline: this.#pipeline, - middleware: skipMiddleware ? (_, next) => next() : undefined, + middleware: skipMiddleware ? NOOP_MIDDLEWARE_FN : undefined, pathname: this.#getPathnameFromRequest(request), request, routeData: errorRouteData, diff --git a/packages/astro/src/core/app/types.ts b/packages/astro/src/core/app/types.ts index 6a00ec0a7993..b268c010bc64 100644 --- a/packages/astro/src/core/app/types.ts +++ b/packages/astro/src/core/app/types.ts @@ -1,12 +1,12 @@ import type { ComponentInstance, Locales, - MiddlewareHandler, RouteData, SSRComponentMetadata, SSRLoadedRenderer, SSRResult, SerializedRouteData, + AstroMiddlewareInstance, } from '../../@types/astro.js'; import type { RoutingStrategies } from '../../i18n/utils.js'; import type { SinglePageBuiltModule } from '../build/types.js'; @@ -68,7 +68,7 @@ export type SSRManifest = { serverIslandNameMap?: Map; key: Promise; i18n: SSRManifestI18n | undefined; - middleware: MiddlewareHandler; + 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 6742a8425597..7f6a4096bceb 100644 --- a/packages/astro/src/core/base-pipeline.ts +++ b/packages/astro/src/core/base-pipeline.ts @@ -15,6 +15,9 @@ import { AstroErrorData } from './errors/index.js'; import type { Logger } from './logger/core.js'; import { RouteCache } from './render/route-cache.js'; import { createDefaultRoutes } from './routing/default.js'; +import {NOOP_MIDDLEWARE_FN} from "./middleware/noop-middleware.js"; +import {sequence} from "./middleware/index.js"; +import {createOriginCheckMiddleware} from "./app/middlewares.js"; /** * The `Pipeline` represents the static parts of rendering that do not change between requests. @@ -24,7 +27,8 @@ import { createDefaultRoutes } from './routing/default.js'; */ export abstract class Pipeline { readonly internalMiddleware: MiddlewareHandler[]; - + resolvedMiddleware: MiddlewareHandler | undefined = undefined; + constructor( readonly logger: Logger, readonly manifest: SSRManifest, @@ -97,6 +101,25 @@ export abstract class Pipeline { * @param routeData */ abstract getComponentByRoute(routeData: RouteData): Promise; + + /** + * Resolves the middleware from the manifest, and returns the `onRequest` function. If `onRequest` isn't there, + * it returns a no-op function + */ + async getMiddleware(): Promise { + if (this.resolvedMiddleware) { + return this.resolvedMiddleware; + } else { + const middlewareInstance = await this.middleware(); + const onRequest = middlewareInstance.onRequest ?? NOOP_MIDDLEWARE_FN; + if (this.manifest.checkOrigin) { + this.resolvedMiddleware = sequence(createOriginCheckMiddleware(), onRequest); + } else { + this.resolvedMiddleware = onRequest; + } + return this.resolvedMiddleware; + } + } } // eslint-disable-next-line @typescript-eslint/no-empty-object-type diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index b24fb17c416c..7cd2aa91e367 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -443,7 +443,12 @@ async function generatePath( logger, staticLike: true, }); - const renderContext = RenderContext.create({ pipeline, pathname, request, routeData: route }); + const renderContext = await RenderContext.create({ + pipeline, + pathname, + request, + routeData: route, + }); let body: string | Uint8Array; let response: Response; @@ -552,7 +557,11 @@ function createBuildManifest( componentMetadata: internals.componentMetadata, i18n: i18nManifest, buildFormat: settings.config.build.format, - middleware, + middleware() { + return { + onRequest: middleware, + }; + }, checkOrigin: settings.config.security?.checkOrigin ?? false, key, experimentalEnvGetSecretEnabled: false, diff --git a/packages/astro/src/core/build/pipeline.ts b/packages/astro/src/core/build/pipeline.ts index 760c353d1da1..a009e6130f57 100644 --- a/packages/astro/src/core/build/pipeline.ts +++ b/packages/astro/src/core/build/pipeline.ts @@ -138,7 +138,11 @@ export class BuildPipeline extends Pipeline { const renderers = await import(renderersEntryUrl.toString()); const middleware = await import(new URL('middleware.mjs', baseDirectory).toString()) - .then((mod) => mod.onRequest) + .then((mod) => { + return function () { + return { onRequest: mod.onRequest }; + }; + }) // middleware.mjs is not emitted if there is no user middleware // in which case the import fails with ERR_MODULE_NOT_FOUND, and we fall back to a no-op middleware .catch(() => manifest.middleware); diff --git a/packages/astro/src/core/build/plugins/plugin-ssr.ts b/packages/astro/src/core/build/plugins/plugin-ssr.ts index e9eda1dc90c2..883cdee38831 100644 --- a/packages/astro/src/core/build/plugins/plugin-ssr.ts +++ b/packages/astro/src/core/build/plugins/plugin-ssr.ts @@ -291,12 +291,11 @@ function generateSSRCode(settings: AstroSettings, adapter: AstroAdapter, middlew const contents = [ settings.config.experimental.serverIslands ? '' : `const serverIslandMap = new Map()`, - edgeMiddleware ? `const middleware = (_, next) => next()` : '', `const _manifest = Object.assign(defaultManifest, {`, ` ${pageMap},`, ` serverIslandMap,`, ` renderers,`, - ` middleware`, + ` middleware: ${edgeMiddleware ? 'undefined' : `() => import("${middlewareId}")`}`, `});`, `const _args = ${adapter.args ? JSON.stringify(adapter.args, null, 4) : 'undefined'};`, adapter.exports diff --git a/packages/astro/src/core/middleware/noop-middleware.ts b/packages/astro/src/core/middleware/noop-middleware.ts new file mode 100644 index 000000000000..bf5f10d89054 --- /dev/null +++ b/packages/astro/src/core/middleware/noop-middleware.ts @@ -0,0 +1,3 @@ +import type { MiddlewareHandler } from '../../@types/astro.js'; + +export const NOOP_MIDDLEWARE_FN: MiddlewareHandler = (_, next) => next(); diff --git a/packages/astro/src/core/render-context.ts b/packages/astro/src/core/render-context.ts index 9d813e19a381..1658f6c23593 100644 --- a/packages/astro/src/core/render-context.ts +++ b/packages/astro/src/core/render-context.ts @@ -67,7 +67,7 @@ export class RenderContext { */ counter = 0; - static create({ + static async create({ locals = {}, middleware, pathname, @@ -77,11 +77,14 @@ export class RenderContext { status = 200, props, }: Pick & - Partial>): RenderContext { + Partial< + Pick + >): Promise { + const pipelineMiddleware = await pipeline.getMiddleware(); return new RenderContext( pipeline, locals, - sequence(...pipeline.internalMiddleware, middleware ?? pipeline.middleware), + sequence(...pipeline.internalMiddleware, middleware ?? pipelineMiddleware), pathname, request, routeData, diff --git a/packages/astro/src/vite-plugin-astro-server/plugin.ts b/packages/astro/src/vite-plugin-astro-server/plugin.ts index 19ceed811727..073bb8f6d68e 100644 --- a/packages/astro/src/vite-plugin-astro-server/plugin.ts +++ b/packages/astro/src/vite-plugin-astro-server/plugin.ts @@ -19,6 +19,7 @@ import { recordServerError } from './error.js'; import { DevPipeline } from './pipeline.js'; import { handleRequest } from './request.js'; import { setRouteError } from './server-state.js'; +import { NOOP_MIDDLEWARE_FN } from "../core/middleware/noop-middleware.js"; export interface AstroPluginOptions { settings: AstroSettings; @@ -152,8 +153,10 @@ export function createDevelopmentManifest(settings: AstroSettings): SSRManifest checkOrigin: settings.config.security?.checkOrigin ?? false, experimentalEnvGetSecretEnabled: false, key: createKey(), - middleware(_, next) { - return next(); + middleware() { + return { + onRequest: NOOP_MIDDLEWARE_FN + }; }, }; } diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts index d6084dbdda22..30a6eda0190e 100644 --- a/packages/astro/src/vite-plugin-astro-server/route.ts +++ b/packages/astro/src/vite-plugin-astro-server/route.ts @@ -198,7 +198,7 @@ export async function handleRoute({ matchedRoute.route.prerender && matchedRoute.route.component === DEFAULT_404_COMPONENT; - renderContext = RenderContext.create({ + renderContext = await RenderContext.create({ locals, pipeline, pathname, @@ -235,7 +235,7 @@ export async function handleRoute({ req({ url: pathname, method: incomingRequest.method, - statusCode: isRewrite ? response.status : status ?? response.status, + statusCode: isRewrite ? response.status : (status ?? response.status), isRewrite, reqTime: timeEnd - timeStart, }), diff --git a/packages/astro/test/units/render/head.test.js b/packages/astro/test/units/render/head.test.js index 0eb4c77153d4..4c4a9eb77f9e 100644 --- a/packages/astro/test/units/render/head.test.js +++ b/packages/astro/test/units/render/head.test.js @@ -103,7 +103,7 @@ describe('core/render', () => { component: 'src/pages/index.astro', params: {}, }; - const renderContext = RenderContext.create({ pipeline, request, routeData }); + const renderContext = await RenderContext.create({ pipeline, request, routeData }); const response = await renderContext.render(PageModule); const html = await response.text(); @@ -184,7 +184,7 @@ describe('core/render', () => { component: 'src/pages/index.astro', params: {}, }; - const renderContext = RenderContext.create({ pipeline, request, routeData }); + const renderContext = await RenderContext.create({ pipeline, request, routeData }); const response = await renderContext.render(PageModule); const html = await response.text(); @@ -232,7 +232,7 @@ describe('core/render', () => { component: 'src/pages/index.astro', params: {}, }; - const renderContext = RenderContext.create({ pipeline, request, routeData }); + const renderContext = await RenderContext.create({ pipeline, request, routeData }); const response = await renderContext.render(PageModule); const html = await response.text(); diff --git a/packages/astro/test/units/render/jsx.test.js b/packages/astro/test/units/render/jsx.test.js index ba03a6f55d22..a42b819cea78 100644 --- a/packages/astro/test/units/render/jsx.test.js +++ b/packages/astro/test/units/render/jsx.test.js @@ -50,7 +50,7 @@ describe('core/render', () => { component: 'src/pages/index.mdx', params: {}, }; - const renderContext = RenderContext.create({ pipeline, request, routeData }); + const renderContext = await RenderContext.create({ pipeline, request, routeData }); const response = await renderContext.render(mod); assert.equal(response.status, 200); @@ -97,7 +97,7 @@ describe('core/render', () => { component: 'src/pages/index.mdx', params: {}, }; - const renderContext = RenderContext.create({ pipeline, request, routeData }); + const renderContext = await RenderContext.create({ pipeline, request, routeData }); const response = await renderContext.render(mod); assert.equal(response.status, 200); @@ -128,7 +128,7 @@ describe('core/render', () => { component: 'src/pages/index.mdx', params: {}, }; - const renderContext = RenderContext.create({ pipeline, request, routeData }); + const renderContext = await RenderContext.create({ pipeline, request, routeData }); const response = await renderContext.render(mod); try { diff --git a/packages/astro/test/units/test-utils.js b/packages/astro/test/units/test-utils.js index bab850b68530..ce84b7feaac7 100644 --- a/packages/astro/test/units/test-utils.js +++ b/packages/astro/test/units/test-utils.js @@ -13,6 +13,7 @@ import { nodeLogDestination } from '../../dist/core/logger/node.js'; import { Pipeline } from '../../dist/core/render/index.js'; import { RouteCache } from '../../dist/core/render/route-cache.js'; import { unixify } from './correct-path.js'; +import {NOOP_MIDDLEWARE_FN} from "../../dist/core/middleware/noop-middleware.js"; /** @type {import('../../src/core/logger/core').Logger} */ export const defaultLogger = new Logger({ @@ -207,6 +208,9 @@ export function createBasicPipeline(options = {}) { ); pipeline.headElements = () => ({ scripts: new Set(), styles: new Set(), links: new Set() }); pipeline.componentMetadata = () => new Map(); + pipeline.getMiddleware = () => { + return NOOP_MIDDLEWARE_FN; + } return pipeline; } From 72dc2313ec8a570cd935deadeeb0ab9fd39d5c3b Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 23 Sep 2024 15:42:36 +0000 Subject: [PATCH 3/4] [ci] format --- packages/astro/src/core/app/common.ts | 2 +- packages/astro/src/core/app/index.ts | 2 +- packages/astro/src/core/app/types.ts | 2 +- packages/astro/src/core/base-pipeline.ts | 8 ++++---- packages/astro/src/vite-plugin-astro-server/plugin.ts | 4 ++-- packages/astro/src/vite-plugin-astro-server/route.ts | 2 +- packages/astro/test/units/test-utils.js | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/astro/src/core/app/common.ts b/packages/astro/src/core/app/common.ts index 3d951267caeb..2a5922bca100 100644 --- a/packages/astro/src/core/app/common.ts +++ b/packages/astro/src/core/app/common.ts @@ -1,7 +1,7 @@ import { decodeKey } from '../encryption.js'; +import { NOOP_MIDDLEWARE_FN } from '../middleware/noop-middleware.js'; import { deserializeRouteData } from '../routing/manifest/serialization.js'; import type { RouteInfo, SSRManifest, SerializedSSRManifest } from './types.js'; -import { NOOP_MIDDLEWARE_FN } from '../middleware/noop-middleware.js'; export function deserializeManifest(serializedManifest: SerializedSSRManifest): SSRManifest { const routes: RouteInfo[] = []; diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index 97f11c82682c..69dd18a06ee1 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -11,6 +11,7 @@ import { getSetCookiesFromResponse } from '../cookies/index.js'; import { AstroError, AstroErrorData } from '../errors/index.js'; import { consoleLogDestination } from '../logger/console.js'; import { AstroIntegrationLogger, Logger } from '../logger/core.js'; +import { NOOP_MIDDLEWARE_FN } from '../middleware/noop-middleware.js'; import { appendForwardSlash, joinPaths, @@ -22,7 +23,6 @@ import { createAssetLink } from '../render/ssr-element.js'; import { createDefaultRoutes, injectDefaultRoutes } from '../routing/default.js'; import { matchRoute } from '../routing/match.js'; import { AppPipeline } from './pipeline.js'; -import { NOOP_MIDDLEWARE_FN } from '../middleware/noop-middleware.js'; export { deserializeManifest } from './common.js'; diff --git a/packages/astro/src/core/app/types.ts b/packages/astro/src/core/app/types.ts index b268c010bc64..73ddea268d9a 100644 --- a/packages/astro/src/core/app/types.ts +++ b/packages/astro/src/core/app/types.ts @@ -1,4 +1,5 @@ import type { + AstroMiddlewareInstance, ComponentInstance, Locales, RouteData, @@ -6,7 +7,6 @@ import type { SSRLoadedRenderer, SSRResult, SerializedRouteData, - AstroMiddlewareInstance, } from '../../@types/astro.js'; import type { RoutingStrategies } from '../../i18n/utils.js'; import type { SinglePageBuiltModule } from '../build/types.js'; diff --git a/packages/astro/src/core/base-pipeline.ts b/packages/astro/src/core/base-pipeline.ts index 7f6a4096bceb..8a448133ab3d 100644 --- a/packages/astro/src/core/base-pipeline.ts +++ b/packages/astro/src/core/base-pipeline.ts @@ -10,14 +10,14 @@ import type { } from '../@types/astro.js'; import { setGetEnv } from '../env/runtime.js'; import { createI18nMiddleware } from '../i18n/middleware.js'; +import { createOriginCheckMiddleware } from './app/middlewares.js'; import { AstroError } from './errors/errors.js'; import { AstroErrorData } from './errors/index.js'; import type { Logger } from './logger/core.js'; +import { sequence } from './middleware/index.js'; +import { NOOP_MIDDLEWARE_FN } from './middleware/noop-middleware.js'; import { RouteCache } from './render/route-cache.js'; import { createDefaultRoutes } from './routing/default.js'; -import {NOOP_MIDDLEWARE_FN} from "./middleware/noop-middleware.js"; -import {sequence} from "./middleware/index.js"; -import {createOriginCheckMiddleware} from "./app/middlewares.js"; /** * The `Pipeline` represents the static parts of rendering that do not change between requests. @@ -28,7 +28,7 @@ import {createOriginCheckMiddleware} from "./app/middlewares.js"; export abstract class Pipeline { readonly internalMiddleware: MiddlewareHandler[]; resolvedMiddleware: MiddlewareHandler | undefined = undefined; - + constructor( readonly logger: Logger, readonly manifest: SSRManifest, diff --git a/packages/astro/src/vite-plugin-astro-server/plugin.ts b/packages/astro/src/vite-plugin-astro-server/plugin.ts index 073bb8f6d68e..3b75a3843e0d 100644 --- a/packages/astro/src/vite-plugin-astro-server/plugin.ts +++ b/packages/astro/src/vite-plugin-astro-server/plugin.ts @@ -9,6 +9,7 @@ import { getViteErrorPayload } from '../core/errors/dev/index.js'; import { AstroError, AstroErrorData } from '../core/errors/index.js'; import { patchOverlay } from '../core/errors/overlay.js'; import type { Logger } from '../core/logger/core.js'; +import { NOOP_MIDDLEWARE_FN } from '../core/middleware/noop-middleware.js'; import { createViteLoader } from '../core/module-loader/index.js'; import { injectDefaultRoutes } from '../core/routing/default.js'; import { createRouteManifest } from '../core/routing/index.js'; @@ -19,7 +20,6 @@ import { recordServerError } from './error.js'; import { DevPipeline } from './pipeline.js'; import { handleRequest } from './request.js'; import { setRouteError } from './server-state.js'; -import { NOOP_MIDDLEWARE_FN } from "../core/middleware/noop-middleware.js"; export interface AstroPluginOptions { settings: AstroSettings; @@ -155,7 +155,7 @@ export function createDevelopmentManifest(settings: AstroSettings): SSRManifest key: createKey(), middleware() { return { - onRequest: NOOP_MIDDLEWARE_FN + onRequest: NOOP_MIDDLEWARE_FN, }; }, }; diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts index 30a6eda0190e..58113891e8b0 100644 --- a/packages/astro/src/vite-plugin-astro-server/route.ts +++ b/packages/astro/src/vite-plugin-astro-server/route.ts @@ -235,7 +235,7 @@ export async function handleRoute({ req({ url: pathname, method: incomingRequest.method, - statusCode: isRewrite ? response.status : (status ?? response.status), + statusCode: isRewrite ? response.status : status ?? response.status, isRewrite, reqTime: timeEnd - timeStart, }), diff --git a/packages/astro/test/units/test-utils.js b/packages/astro/test/units/test-utils.js index ce84b7feaac7..fea8e967ea7d 100644 --- a/packages/astro/test/units/test-utils.js +++ b/packages/astro/test/units/test-utils.js @@ -10,10 +10,10 @@ import { createBaseSettings } from '../../dist/core/config/settings.js'; import { createContainer } from '../../dist/core/dev/container.js'; import { Logger } from '../../dist/core/logger/core.js'; import { nodeLogDestination } from '../../dist/core/logger/node.js'; +import { NOOP_MIDDLEWARE_FN } from '../../dist/core/middleware/noop-middleware.js'; import { Pipeline } from '../../dist/core/render/index.js'; import { RouteCache } from '../../dist/core/render/route-cache.js'; import { unixify } from './correct-path.js'; -import {NOOP_MIDDLEWARE_FN} from "../../dist/core/middleware/noop-middleware.js"; /** @type {import('../../src/core/logger/core').Logger} */ export const defaultLogger = new Logger({ @@ -210,7 +210,7 @@ export function createBasicPipeline(options = {}) { pipeline.componentMetadata = () => new Map(); pipeline.getMiddleware = () => { return NOOP_MIDDLEWARE_FN; - } + }; return pipeline; } From 7814a6cad15f06931f963580176d9b38aa7819f2 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Mon, 23 Sep 2024 10:26:46 -0700 Subject: [PATCH 4/4] [ci] release (#12037) Co-authored-by: github-actions[bot] --- .changeset/clever-vans-flash.md | 5 -- .changeset/fast-queens-try.md | 5 -- .changeset/sixty-oranges-walk.md | 7 --- 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/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 | 12 ++++ packages/astro/package.json | 2 +- pnpm-lock.yaml | 62 ++++++++++----------- 36 files changed, 73 insertions(+), 80 deletions(-) delete mode 100644 .changeset/clever-vans-flash.md delete mode 100644 .changeset/fast-queens-try.md delete mode 100644 .changeset/sixty-oranges-walk.md diff --git a/.changeset/clever-vans-flash.md b/.changeset/clever-vans-flash.md deleted file mode 100644 index 3f616316a7e5..000000000000 --- a/.changeset/clever-vans-flash.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes an issue where the middleware wasn't called when a project uses `404.astro`. diff --git a/.changeset/fast-queens-try.md b/.changeset/fast-queens-try.md deleted file mode 100644 index b062639c1f91..000000000000 --- a/.changeset/fast-queens-try.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes a problem in the Container API, where a polyfill wasn't correctly applied. This caused an issue in some environments where `crypto` isn't supported. diff --git a/.changeset/sixty-oranges-walk.md b/.changeset/sixty-oranges-walk.md deleted file mode 100644 index ef3e14a7eb98..000000000000 --- a/.changeset/sixty-oranges-walk.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'astro': patch ---- - -Resolves image paths in content layer with initial slash as project-relative - -When using the `image()` schema helper, previously paths with an initial slash were treated as public URLs. This was to match the behavior of markdown images. However this is a change from before, where paths with an initial slash were treated as project-relative. This change restores the previous behavior, so that paths with an initial slash are treated as project-relative. diff --git a/examples/basics/package.json b/examples/basics/package.json index 62607e6fd305..1c081e458c54 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.8" + "astro": "^4.15.9" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 95c14b9a553e..09e7acb3a60e 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -14,6 +14,6 @@ "@astrojs/mdx": "^3.1.7", "@astrojs/rss": "^4.0.7", "@astrojs/sitemap": "^3.1.6", - "astro": "^4.15.8" + "astro": "^4.15.9" } } diff --git a/examples/component/package.json b/examples/component/package.json index aae8588cbb65..37f8fedb71d0 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.15.8" + "astro": "^4.15.9" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index 4a6dd7e93b9e..23cde212c4c5 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.8", + "astro": "^4.15.9", "@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 36a20513adf4..92257fedcb15 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.8" + "astro": "^4.15.9" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index e92285c4cdc0..131a7c463f74 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.8", + "astro": "^4.15.9", "lit": "^3.2.0" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 3e9b6998deb5..4494adb42924 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.5", "@types/react-dom": "^18.3.0", - "astro": "^4.15.8", + "astro": "^4.15.9", "preact": "^10.23.2", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index faf1e7650ded..ac84a3f35091 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.8", + "astro": "^4.15.9", "preact": "^10.23.2" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index 0574a99ecab3..911bbfa08bf8 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.5", "@types/react-dom": "^18.3.0", - "astro": "^4.15.8", + "astro": "^4.15.9", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 6fbd5f5a5081..11358a0d8365 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.8", + "astro": "^4.15.9", "solid-js": "^1.8.22" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index 3cebc3061dc4..36e9f8566b44 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.8", + "astro": "^4.15.9", "svelte": "^4.2.19" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 5cfcc67c209d..f0161cd3113a 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.8", + "astro": "^4.15.9", "vue": "^3.5.3" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index e020e6b9f04d..c0476d6ed847 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^8.3.3", - "astro": "^4.15.8" + "astro": "^4.15.9" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 0fd8a6f834b2..e91d3568aae1 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.15.8" + "astro": "^4.15.9" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index 46db3e980700..8217aa5cd8b6 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^8.3.3", - "astro": "^4.15.8", + "astro": "^4.15.9", "html-minifier": "^4.0.0" }, "devDependencies": { diff --git a/examples/minimal/package.json b/examples/minimal/package.json index be4496e51e8d..75179c0e84ed 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.8" + "astro": "^4.15.9" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index 556672c67a74..84a9b84257be 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.8" + "astro": "^4.15.9" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index 8519069a5d62..413c8599b9c2 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.8" + "astro": "^4.15.9" } } diff --git a/examples/server-islands/package.json b/examples/server-islands/package.json index 42fc61672e9d..df1ba68c57a6 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.5", "@types/react-dom": "^18.3.0", - "astro": "^4.15.8", + "astro": "^4.15.9", "postcss": "^8.4.45", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 29b3804860b4..48b3b8121454 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^8.3.3", "@astrojs/svelte": "^5.7.1", - "astro": "^4.15.8", + "astro": "^4.15.9", "svelte": "^4.2.19" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index 4161e3239ed8..7a74a1a7565b 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.8", + "astro": "^4.15.9", "sass": "^1.78.0", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index 664fc9d5a1d4..9fb44ce2b99c 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.8" + "astro": "^4.15.9" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index cb127fd20e3c..3613a603b068 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.3", - "astro": "^4.15.8" + "astro": "^4.15.9" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index c7707c6cd749..cf3ee54ffaea 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.8" + "astro": "^4.15.9" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index e2fcd19c4049..1a6ce6bec4b6 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.8", + "astro": "^4.15.9", "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 661ab6255edc..a072a8c76430 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.8" + "astro": "^4.15.9" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index beb675d39f14..6b94971ed21a 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.8", + "astro": "^4.15.9", "preact": "^10.23.2" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 4c5ae953c88f..eb19406b42f7 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.8", + "astro": "^4.15.9", "nanostores": "^0.11.3", "preact": "^10.23.2" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 8259affaea22..2e2773ac7814 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.8", + "astro": "^4.15.9", "autoprefixer": "^10.4.20", "canvas-confetti": "^1.9.3", "postcss": "^8.4.45", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index b243f89fe435..fcd99480acb2 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.15.8", + "astro": "^4.15.9", "vitest": "^2.0.5" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 325b63ae1d0c..d176e09d1278 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,17 @@ # astro +## 4.15.9 + +### Patch Changes + +- [#12034](https://github.com/withastro/astro/pull/12034) [`5b3ddfa`](https://github.com/withastro/astro/commit/5b3ddfadcb2d09b6cbd9cd42641f30ca565d0f58) Thanks [@ematipico](https://github.com/ematipico)! - Fixes an issue where the middleware wasn't called when a project uses `404.astro`. + +- [#12042](https://github.com/withastro/astro/pull/12042) [`243ecb6`](https://github.com/withastro/astro/commit/243ecb6d6146dc483b4726d0e76142fb25e56243) Thanks [@ematipico](https://github.com/ematipico)! - Fixes a problem in the Container API, where a polyfill wasn't correctly applied. This caused an issue in some environments where `crypto` isn't supported. + +- [#12038](https://github.com/withastro/astro/pull/12038) [`26ea5e8`](https://github.com/withastro/astro/commit/26ea5e814ab8c973e683fff62389fda28c180940) Thanks [@ascorbic](https://github.com/ascorbic)! - Resolves image paths in content layer with initial slash as project-relative + + When using the `image()` schema helper, previously paths with an initial slash were treated as public URLs. This was to match the behavior of markdown images. However this is a change from before, where paths with an initial slash were treated as project-relative. This change restores the previous behavior, so that paths with an initial slash are treated as project-relative. + ## 4.15.8 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index 6ae16580cf07..01e5a7935ca2 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.15.8", + "version": "4.15.9", "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 fbaf30af79a0..91a66c983db0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -113,7 +113,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^4.15.8 + specifier: ^4.15.9 version: link:../../packages/astro examples/blog: @@ -128,13 +128,13 @@ importers: specifier: ^3.1.6 version: link:../../packages/integrations/sitemap astro: - specifier: ^4.15.8 + specifier: ^4.15.9 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^4.15.8 + specifier: ^4.15.9 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.8 + specifier: ^4.15.9 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.8 + specifier: ^4.15.9 version: link:../../packages/astro examples/framework-lit: @@ -186,7 +186,7 @@ importers: specifier: ^0.2.1 version: 0.2.1 astro: - specifier: ^4.15.8 + specifier: ^4.15.9 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.8 + specifier: ^4.15.9 version: link:../../packages/astro preact: specifier: ^10.23.2 @@ -246,7 +246,7 @@ importers: specifier: ^1.3.0 version: 1.3.0(preact@10.23.2) astro: - specifier: ^4.15.8 + specifier: ^4.15.9 version: link:../../packages/astro preact: specifier: ^10.23.2 @@ -264,7 +264,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.15.8 + specifier: ^4.15.9 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.8 + specifier: ^4.15.9 version: link:../../packages/astro solid-js: specifier: ^1.8.22 @@ -291,7 +291,7 @@ importers: specifier: ^5.7.1 version: link:../../packages/integrations/svelte astro: - specifier: ^4.15.8 + specifier: ^4.15.9 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.8 + specifier: ^4.15.9 version: link:../../packages/astro vue: specifier: ^3.5.3 @@ -315,13 +315,13 @@ importers: specifier: ^8.3.3 version: 8.3.3(astro@packages+astro) astro: - specifier: ^4.15.8 + specifier: ^4.15.9 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^4.15.8 + specifier: ^4.15.9 version: link:../../packages/astro examples/middleware: @@ -330,7 +330,7 @@ importers: specifier: ^8.3.3 version: 8.3.3(astro@packages+astro) astro: - specifier: ^4.15.8 + specifier: ^4.15.9 version: link:../../packages/astro html-minifier: specifier: ^4.0.0 @@ -343,19 +343,19 @@ importers: examples/minimal: dependencies: astro: - specifier: ^4.15.8 + specifier: ^4.15.9 version: link:../../packages/astro examples/non-html-pages: dependencies: astro: - specifier: ^4.15.8 + specifier: ^4.15.9 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^4.15.8 + specifier: ^4.15.9 version: link:../../packages/astro examples/server-islands: @@ -382,7 +382,7 @@ importers: specifier: ^18.3.0 version: 18.3.0 astro: - specifier: ^4.15.8 + specifier: ^4.15.9 version: link:../../packages/astro postcss: specifier: ^8.4.45 @@ -406,7 +406,7 @@ importers: specifier: ^5.7.1 version: link:../../packages/integrations/svelte astro: - specifier: ^4.15.8 + specifier: ^4.15.9 version: link:../../packages/astro svelte: specifier: ^4.2.19 @@ -415,7 +415,7 @@ importers: examples/starlog: dependencies: astro: - specifier: ^4.15.8 + specifier: ^4.15.9 version: link:../../packages/astro sass: specifier: ^1.78.0 @@ -427,7 +427,7 @@ importers: examples/toolbar-app: devDependencies: astro: - specifier: ^4.15.8 + specifier: ^4.15.9 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.8 + specifier: ^4.15.9 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.8 + specifier: ^4.15.9 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.8 + specifier: ^4.15.9 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.8 + specifier: ^4.15.9 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.8 + specifier: ^4.15.9 version: link:../../packages/astro preact: specifier: ^10.23.2 @@ -505,7 +505,7 @@ importers: specifier: ^0.5.2 version: 0.5.2(nanostores@0.11.3)(preact@10.23.2) astro: - specifier: ^4.15.8 + specifier: ^4.15.9 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.8 + specifier: ^4.15.9 version: link:../../packages/astro autoprefixer: specifier: ^10.4.20 @@ -544,7 +544,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^4.15.8 + specifier: ^4.15.9 version: link:../../packages/astro vitest: specifier: ^2.0.5 @@ -8861,12 +8861,10 @@ packages: libsql@0.3.19: resolution: {integrity: sha512-Aj5cQ5uk/6fHdmeW0TiXK42FqUlwx7ytmMLPSaUQPin5HKKKuUPD62MAbN4OEweGBBI7q1BekoEN4gPUEL6MZA==} - cpu: [x64, arm64, wasm32] os: [darwin, linux, win32] libsql@0.4.1: resolution: {integrity: sha512-qZlR9Yu1zMBeLChzkE/cKfoKV3Esp9cn9Vx5Zirn4AVhDWPcjYhKwbtJcMuHehgk3mH+fJr9qW+3vesBWbQpBg==} - cpu: [x64, arm64, wasm32] os: [darwin, linux, win32] lilconfig@2.1.0: