Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
lilnasy authored and astrobot-houston committed Jan 25, 2024
1 parent dc75180 commit 00e6adb
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
4 changes: 3 additions & 1 deletion packages/astro/src/core/app/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -666,6 +668,6 @@ function createBuildManifest(
componentMetadata: internals.componentMetadata,
i18n: i18nManifest,
buildFormat: settings.config.build.format,
middleware
middleware,
};
}
8 changes: 3 additions & 5 deletions packages/astro/src/core/build/plugins/plugin-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
},
Expand Down
8 changes: 5 additions & 3 deletions packages/astro/src/core/build/plugins/plugin-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);`,
];

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/middleware/vite-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function vitePluginMiddleware({ settings }: { settings: AstroSettings }):
preserveSignature: 'strict',
fileName: 'middleware.mjs',
id,
})
});
}

const preMiddleware = createMiddlewareImports(settings.middlewares.pre, 'pre');
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/vite-plugin-astro-server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export function createDevelopmentManifest(settings: AstroSettings): SSRManifest
componentMetadata: new Map(),
i18n: i18nManifest,
middleware(_, next) {
return next()
}
return next();
},
};
}
2 changes: 1 addition & 1 deletion packages/astro/src/vite-plugin-astro-server/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export async function handleRoute({
pathname,
request,
route,
middleware
middleware,
};

mod = options.preload;
Expand Down

0 comments on commit 00e6adb

Please sign in to comment.