Skip to content

Commit

Permalink
chore: fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderniebuhr committed Aug 29, 2024
1 parent ed930dd commit e02b54a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 17 deletions.
21 changes: 21 additions & 0 deletions .changeset/blue-owls-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@astrojs/cloudflare': major
'@astrojs/netlify': major
---

Removed support for the Squoosh image service. As the underlying library `libsquoosh` is no longer maintained, and the image service sees very little usage we have decided to remove it from Astro.

Our recommendation is to use the base Sharp image service, which is more powerful, faster, and more actively maintained.

```diff
- import { squooshImageService } from "astro/config";
import { defineConfig } from "astro/config";

export default defineConfig({
- image: {
- service: squooshImageService()
- }
});
```

If you are using this service, and cannot migrate to the base Sharp image service, a third-party extraction of the previous service is available here: https://github.com/Princesseuh/astro-image-service-squoosh
21 changes: 21 additions & 0 deletions .changeset/early-berries-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@astrojs/cloudflare': major
'@astrojs/netlify': major
---

Deprecates the `functionPerRoute` option

This option is now deprecated, and will be removed entirely in Astro v5.0. We suggest removing this option from your configuration as soon as you are able to:

```diff
import { defineConfig } from 'astro/config';
import vercel from '@astrojs/vercel/serverless';

export default defineConfig({
// ...
output: 'server',
adapter: vercel({
- functionPerRoute: true,
}),
});
```
2 changes: 0 additions & 2 deletions packages/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ export default function createIntegration(args?: Options): AstroIntegration {
serverEntrypoint: '@astrojs/cloudflare/entrypoints/server.js',
exports: ['default'],
adapterFeatures: {
functionPerRoute: false,
edgeMiddleware: false,
},
supportedAstroFeatures: {
Expand All @@ -166,7 +165,6 @@ export default function createIntegration(args?: Options): AstroIntegration {
assets: {
supportKind: 'stable',
isSharpCompatible: false,
isSquooshCompatible: false,
},
envGetSecret: 'experimental',
},
Expand Down
28 changes: 13 additions & 15 deletions packages/netlify/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ async function writeNetlifyFrameworkConfig(config: AstroConfig, logger: AstroInt
const headers = config.build.assetsPrefix
? undefined
: [
{
for: `${config.base}${config.base.endsWith('/') ? '' : '/'}${config.build.assets}/*`,
values: {
'Cache-Control': 'public, max-age=31536000, immutable',
},
{
for: `${config.base}${config.base.endsWith('/') ? '' : '/'}${config.build.assets}/*`,
values: {
'Cache-Control': 'public, max-age=31536000, immutable',
},
];
},
];

// See https://docs.netlify.com/image-cdn/create-integration/
const deployConfigDir = new URL('.netlify/v1/', config.root);
Expand Down Expand Up @@ -259,9 +259,9 @@ export default function netlifyIntegration(
`
import createSSRHandler from './${handler}';
export default createSSRHandler(${JSON.stringify({
cacheOnDemandPages: Boolean(integrationConfig?.cacheOnDemandPages),
notFoundContent,
})});
cacheOnDemandPages: Boolean(integrationConfig?.cacheOnDemandPages),
notFoundContent,
})});
export const config = {
includedFiles: ['**/*'],
name: 'Astro SSR',
Expand Down Expand Up @@ -343,7 +343,7 @@ export default function netlifyIntegration(
if (typeof req.headers[header] === 'string') {
try {
return JSON.parse(Buffer.from(req.headers[header] as string, 'base64').toString('utf8'));
} catch {}
} catch { }
}
};

Expand Down Expand Up @@ -429,8 +429,8 @@ export default function netlifyIntegration(
},
...((await shouldExternalizeAstroEnvSetup())
? {
ssr: { external: ['astro/env/setup'] },
}
ssr: { external: ['astro/env/setup'] },
}
: {}),
},
image: {
Expand All @@ -453,7 +453,6 @@ export default function netlifyIntegration(
serverEntrypoint: '@astrojs/netlify/ssr-function.js',
exports: ['default'],
adapterFeatures: {
functionPerRoute: false,
edgeMiddleware,
},
args: { middlewareSecret } satisfies Args,
Expand All @@ -466,7 +465,6 @@ export default function netlifyIntegration(
supportKind: 'experimental',
// still using Netlify Image CDN instead
isSharpCompatible: true,
isSquooshCompatible: true,
},
envGetSecret: 'experimental',
},
Expand All @@ -483,7 +481,7 @@ export default function netlifyIntegration(
let notFoundContent = undefined;
try {
notFoundContent = await readFile(new URL('./404.html', dir), 'utf8');
} catch {}
} catch { }
await writeSSRFunction({ notFoundContent, logger });
logger.info('Generated SSR Function');
}
Expand Down

0 comments on commit e02b54a

Please sign in to comment.