0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-06 22:10:10 -05:00

[ci] format

This commit is contained in:
Arsh 2024-01-25 19:39:17 +00:00 committed by astrobot-houston
parent dc75180aa6
commit 00e6adb033
7 changed files with 19 additions and 15 deletions

View file

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

View file

@ -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,
};
}

View file

@ -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');
}
},

View file

@ -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);`,
];

View file

@ -53,7 +53,7 @@ export function vitePluginMiddleware({ settings }: { settings: AstroSettings }):
preserveSignature: 'strict',
fileName: 'middleware.mjs',
id,
})
});
}
const preMiddleware = createMiddlewareImports(settings.middlewares.pre, 'pre');

View file

@ -141,7 +141,7 @@ export function createDevelopmentManifest(settings: AstroSettings): SSRManifest
componentMetadata: new Map(),
i18n: i18nManifest,
middleware(_, next) {
return next()
}
return next();
},
};
}

View file

@ -277,7 +277,7 @@ export async function handleRoute({
pathname,
request,
route,
middleware
middleware,
};
mod = options.preload;