diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index 14950b2f9..7a360b01e 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -82,7 +82,7 @@ class AstroBuilder { client: new URL('./client/', this.config.dist), server: new URL('./server/', this.config.dist), serverEntry: 'entry.mjs', - staticMode: undefined + staticMode: undefined, }; await runHookBuildStart({ config: this.config, buildConfig }); @@ -173,7 +173,7 @@ class AstroBuilder { // You're done! Time to clean up. await viteServer.close(); - await runHookBuildDone({ config: this.config, pages: pageNames, routes: Object.values(allPages).map(pd => pd.route) }); + await runHookBuildDone({ config: this.config, pages: pageNames, routes: Object.values(allPages).map((pd) => pd.route) }); if (logging.level && levels[logging.level] <= levels['info']) { const buildMode = this.config.buildOptions.experimentalSsr ? 'ssr' : 'static'; diff --git a/packages/astro/src/core/logger.ts b/packages/astro/src/core/logger.ts index 75a1e36fe..f1bce5d6f 100644 --- a/packages/astro/src/core/logger.ts +++ b/packages/astro/src/core/logger.ts @@ -218,7 +218,12 @@ export function timerMessage(message: string, startTime: number = performance.no * A warning that SSR is experimental. Remove when we can. */ export function warnIfUsingExperimentalSSR(opts: LogOptions, config: AstroConfig) { - if(isBuildingToSSR(config)) { - warn(opts, 'warning', bold(`Warning:`), ` SSR support is still experimental and subject to API changes. If using in production pin your dependencies to prevent accidental breakage.`); + if (isBuildingToSSR(config)) { + warn( + opts, + 'warning', + bold(`Warning:`), + ` SSR support is still experimental and subject to API changes. If using in production pin your dependencies to prevent accidental breakage.` + ); } } diff --git a/packages/astro/src/integrations/index.ts b/packages/astro/src/integrations/index.ts index 15ab427ea..b04caeaf1 100644 --- a/packages/astro/src/integrations/index.ts +++ b/packages/astro/src/integrations/index.ts @@ -91,7 +91,7 @@ export async function runHookBuildStart({ config, buildConfig }: { config: Astro } } -export async function runHookBuildDone({ config, pages, routes }: { config: AstroConfig; pages: string[], routes: RouteData[] }) { +export async function runHookBuildDone({ config, pages, routes }: { config: AstroConfig; pages: string[]; routes: RouteData[] }) { for (const integration of config.integrations) { if (integration.hooks['astro:build:done']) { await integration.hooks['astro:build:done']({ pages: pages.map((p) => ({ pathname: p })), dir: config.dist, routes }); diff --git a/packages/integrations/netlify/src/index.ts b/packages/integrations/netlify/src/index.ts index 4ddacfaf2..5d54f7db6 100644 --- a/packages/integrations/netlify/src/index.ts +++ b/packages/integrations/netlify/src/index.ts @@ -6,7 +6,7 @@ export function getAdapter(site: string | undefined): AstroAdapter { name: '@astrojs/netlify', serverEntrypoint: '@astrojs/netlify/netlify-functions.js', exports: ['handler'], - args: { site } + args: { site }, }; } @@ -21,7 +21,7 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat name: '@astrojs/netlify', hooks: { 'astro:config:setup': ({ config }) => { - if(dist) { + if (dist) { config.dist = dist; } else { config.dist = new URL('./netlify/', config.projectRoot); @@ -31,7 +31,7 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat setAdapter(getAdapter(config.buildOptions.site)); _config = config; }, - 'astro:build:start': async({ buildConfig }) => { + 'astro:build:start': async ({ buildConfig }) => { entryFile = buildConfig.serverEntry.replace(/\.m?js/, ''); buildConfig.client = _config.dist; buildConfig.server = new URL('./functions/', _config.dist); @@ -41,24 +41,21 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat // Create the redirects file that is used for routing. let _redirects = ''; - for(const route of routes) { - if(route.pathname) { + for (const route of routes) { + if (route.pathname) { _redirects += ` -${route.pathname} /.netlify/functions/${entryFile} 200` +${route.pathname} /.netlify/functions/${entryFile} 200`; } } - if(fs.existsSync(_redirects)) { + if (fs.existsSync(_redirects)) { await fs.promises.appendFile(_redirectsURL, _redirects, 'utf-8'); } else { await fs.promises.writeFile(_redirectsURL, _redirects, 'utf-8'); } - } + }, }, }; } -export { - netlifyFunctions, - netlifyFunctions as default -}; +export { netlifyFunctions, netlifyFunctions as default }; diff --git a/packages/integrations/netlify/src/integration-functions.ts b/packages/integrations/netlify/src/integration-functions.ts index 540fcdee2..5b687cda4 100644 --- a/packages/integrations/netlify/src/integration-functions.ts +++ b/packages/integrations/netlify/src/integration-functions.ts @@ -1,3 +1 @@ -export { - netlifyFunctions as default -} from './index.js'; +export { netlifyFunctions as default } from './index.js'; diff --git a/packages/integrations/netlify/src/netlify-functions.ts b/packages/integrations/netlify/src/netlify-functions.ts index cf6c871a9..cb95f1f3f 100644 --- a/packages/integrations/netlify/src/netlify-functions.ts +++ b/packages/integrations/netlify/src/netlify-functions.ts @@ -1,5 +1,5 @@ import { SSRManifest } from 'astro'; -import type { Handler } from "@netlify/functions"; +import type { Handler } from '@netlify/functions'; import { App } from 'astro/app'; import { polyfill } from '@astrojs/webapi'; @@ -19,13 +19,13 @@ export const createExports = (manifest: SSRManifest, args: Args) => { const headers = new Headers(event.headers as any); const request = new Request(new URL(event.path, site).toString(), { method: event.httpMethod, - headers + headers, }); - if(!app.match(request)) { + if (!app.match(request)) { return { statusCode: 404, - body: 'Not found' + body: 'Not found', }; } @@ -35,9 +35,9 @@ export const createExports = (manifest: SSRManifest, args: Args) => { return { statusCode: 200, headers: Object.fromEntries(response.headers.entries()), - body + body, }; - } + }; return { handler }; };