diff --git a/packages/astro/src/core/app/common.ts b/packages/astro/src/core/app/common.ts index c1b445b526..188a8b599b 100644 --- a/packages/astro/src/core/app/common.ts +++ b/packages/astro/src/core/app/common.ts @@ -19,7 +19,9 @@ 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(_, next) { + return next(); + }, ...serializedManifest, assets, componentMetadata, diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index 747f8554e6..966d7ad841 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -150,7 +150,9 @@ export async function generatePages(opts: StaticBuildOptions, internals: BuildIn try { // 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 - middleware = await import(new URL('middleware.mjs', baseDirectory).toString()).then(mod => mod.onRequest); + middleware = await import(new URL('middleware.mjs', baseDirectory).toString()).then( + (mod) => mod.onRequest + ); } catch {} manifest = createBuildManifest( opts.settings, @@ -666,6 +668,6 @@ function createBuildManifest( componentMetadata: internals.componentMetadata, i18n: i18nManifest, buildFormat: settings.config.build.format, - middleware + middleware, }; } diff --git a/packages/astro/src/core/build/plugins/plugin-manifest.ts b/packages/astro/src/core/build/plugins/plugin-manifest.ts index 292a9c962c..d57eb76f32 100644 --- a/packages/astro/src/core/build/plugins/plugin-manifest.ts +++ b/packages/astro/src/core/build/plugins/plugin-manifest.ts @@ -44,15 +44,13 @@ function vitePluginManifest(options: StaticBuildOptions, internals: BuildInterna if (id === RESOLVED_SSR_MANIFEST_VIRTUAL_MODULE_ID) { const imports = [ `import { deserializeManifest as _deserializeManifest } from 'astro/app'`, - `import { _privateSetManifestDontUseThis } from 'astro:ssr-manifest'` + `import { _privateSetManifestDontUseThis } from 'astro:ssr-manifest'`, ]; const contents = [ `const manifest = _deserializeManifest('${manifestReplace}');`, - `_privateSetManifestDontUseThis(manifest);` - ]; - const exports = [ - `export { manifest }` + `_privateSetManifestDontUseThis(manifest);`, ]; + const exports = [`export { manifest }`]; return [...imports, ...contents, ...exports].join('\n'); } }, diff --git a/packages/astro/src/core/build/plugins/plugin-ssr.ts b/packages/astro/src/core/build/plugins/plugin-ssr.ts index 81485d18ce..79bfd1ece4 100644 --- a/packages/astro/src/core/build/plugins/plugin-ssr.ts +++ b/packages/astro/src/core/build/plugins/plugin-ssr.ts @@ -253,14 +253,16 @@ function generateSSRCode(adapter: AstroAdapter, middlewareId: string) { ` middleware`, `});`, `const _args = ${adapter.args ? JSON.stringify(adapter.args, null, 4) : 'undefined'};`, - adapter.exports ? `const _exports = serverEntrypointModule.createExports(_manifest, _args);` : '', - ...adapter.exports?.map((name) => { + adapter.exports + ? `const _exports = serverEntrypointModule.createExports(_manifest, _args);` + : '', + ...(adapter.exports?.map((name) => { if (name === 'default') { return `export default _exports.default;`; } else { return `export const ${name} = _exports['${name}'];`; } - }) ?? [], + }) ?? []), `serverEntrypointModule.start?.(_manifest, _args);`, ]; diff --git a/packages/astro/src/core/middleware/vite-plugin.ts b/packages/astro/src/core/middleware/vite-plugin.ts index 38f66783f8..64c039db72 100644 --- a/packages/astro/src/core/middleware/vite-plugin.ts +++ b/packages/astro/src/core/middleware/vite-plugin.ts @@ -53,7 +53,7 @@ export function vitePluginMiddleware({ settings }: { settings: AstroSettings }): preserveSignature: 'strict', fileName: 'middleware.mjs', id, - }) + }); } const preMiddleware = createMiddlewareImports(settings.middlewares.pre, 'pre'); diff --git a/packages/astro/src/vite-plugin-astro-server/plugin.ts b/packages/astro/src/vite-plugin-astro-server/plugin.ts index 714ca3aac1..f1162b7bc9 100644 --- a/packages/astro/src/vite-plugin-astro-server/plugin.ts +++ b/packages/astro/src/vite-plugin-astro-server/plugin.ts @@ -141,7 +141,7 @@ export function createDevelopmentManifest(settings: AstroSettings): SSRManifest componentMetadata: new Map(), i18n: i18nManifest, middleware(_, next) { - return next() - } + return next(); + }, }; } diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts index f79234a9dc..b4b1811243 100644 --- a/packages/astro/src/vite-plugin-astro-server/route.ts +++ b/packages/astro/src/vite-plugin-astro-server/route.ts @@ -277,7 +277,7 @@ export async function handleRoute({ pathname, request, route, - middleware + middleware, }; mod = options.preload;