summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/integrations/netlify/CHANGELOG.md52
-rw-r--r--packages/integrations/netlify/package.json8
-rw-r--r--packages/integrations/netlify/src/index.ts50
-rw-r--r--packages/integrations/netlify/src/polyfill.ts3
-rw-r--r--packages/integrations/netlify/src/ssr-function.ts13
-rw-r--r--packages/integrations/netlify/test/functions/fixtures/redirects/astro.config.mjs4
-rw-r--r--packages/integrations/netlify/test/hosted/hosted-astro-project/package.json2
7 files changed, 86 insertions, 46 deletions
diff --git a/packages/integrations/netlify/CHANGELOG.md b/packages/integrations/netlify/CHANGELOG.md
index a332f0b31..5220ff786 100644
--- a/packages/integrations/netlify/CHANGELOG.md
+++ b/packages/integrations/netlify/CHANGELOG.md
@@ -1,5 +1,57 @@
# @astrojs/netlify
+## 6.0.0-beta.0
+
+### Major Changes
+
+- [#367](https://github.com/withastro/adapters/pull/367) [`e02b54a`](https://github.com/withastro/adapters/commit/e02b54ad864ea25cb972f6196496b5aee36a47a3) Thanks [@alexanderniebuhr](https://github.com/alexanderniebuhr)! - 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
+
+- [#367](https://github.com/withastro/adapters/pull/367) [`e02b54a`](https://github.com/withastro/adapters/commit/e02b54ad864ea25cb972f6196496b5aee36a47a3) Thanks [@alexanderniebuhr](https://github.com/alexanderniebuhr)! - 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,
+ }),
+ });
+ ```
+
+- [#375](https://github.com/withastro/adapters/pull/375) [`e7881f7`](https://github.com/withastro/adapters/commit/e7881f7928c6ca62d43c763033f9ed065a907f3b) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Updates internal code to works with Astro 5 changes to hybrid rendering. No changes are necessary to your project, apart from using Astro 5
+
+- [#397](https://github.com/withastro/adapters/pull/397) [`776a266`](https://github.com/withastro/adapters/commit/776a26670cf483e37ec0e6eba27a0bde09db0146) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Welcome to the Astro 5 beta! This release has no changes from the latest alpha of this package, but it does bring us one step closer to the final, stable release.
+
+ Starting from this release, no breaking changes will be introduced unless absolutely necessary.
+
+ To learn how to upgrade, check out the [Astro v5.0 upgrade guide in our beta docs site](https://5-0-0-beta.docs.astro.build/en/guides/upgrade-to/v5/).
+
+- [#392](https://github.com/withastro/adapters/pull/392) [`3a49eb7`](https://github.com/withastro/adapters/commit/3a49eb7802c44212ccfab06034b7dc5f2b060e94) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Updates internal code for Astro 5 changes. No changes is required to your project, apart from using Astro 5
+
+### Minor Changes
+
+- [#385](https://github.com/withastro/adapters/pull/385) [`bb725b7`](https://github.com/withastro/adapters/commit/bb725b7a430a01a3cd197e3e84381be4fa0c945c) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Cleans up `astro:env` support
+
## 5.5.4
### Patch Changes
diff --git a/packages/integrations/netlify/package.json b/packages/integrations/netlify/package.json
index fda283249..ffdb68d94 100644
--- a/packages/integrations/netlify/package.json
+++ b/packages/integrations/netlify/package.json
@@ -1,7 +1,7 @@
{
"name": "@astrojs/netlify",
"description": "Deploy your site to Netlify",
- "version": "5.5.4",
+ "version": "6.0.0-beta.0",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
@@ -32,21 +32,21 @@
},
"dependencies": {
"@astrojs/internal-helpers": "0.4.1",
- "@astrojs/underscore-redirects": "^0.3.4",
+ "@astrojs/underscore-redirects": "^0.4.0-alpha.0",
"@netlify/functions": "^2.8.0",
"@vercel/nft": "^0.27.5",
"esbuild": "^0.21.5",
"vite": "^5.4.10"
},
"peerDependencies": {
- "astro": "^4.2.0"
+ "astro": "^5.0.0-alpha.8"
},
"devDependencies": {
"@astrojs/test-utils": "workspace:*",
"@netlify/edge-functions": "^2.11.0",
"@netlify/edge-handler-types": "^0.34.1",
"@types/node": "^20.17.4",
- "astro": "^4.16.8",
+ "astro": "^5.0.0-alpha.8",
"astro-scripts": "workspace:*",
"cheerio": "1.0.0",
"execa": "^8.0.1",
diff --git a/packages/integrations/netlify/src/index.ts b/packages/integrations/netlify/src/index.ts
index 8ce19d51e..a64bfb59c 100644
--- a/packages/integrations/netlify/src/index.ts
+++ b/packages/integrations/netlify/src/index.ts
@@ -5,7 +5,13 @@ import { fileURLToPath } from 'node:url';
import { emptyDir } from '@astrojs/internal-helpers/fs';
import { createRedirectsFromAstroRoutes } from '@astrojs/underscore-redirects';
import type { Context } from '@netlify/functions';
-import type { AstroConfig, AstroIntegration, AstroIntegrationLogger, RouteData } from 'astro';
+import type {
+ AstroConfig,
+ AstroIntegration,
+ AstroIntegrationLogger,
+ HookParameters,
+ IntegrationRouteData,
+} from 'astro';
import { build } from 'esbuild';
import { copyDependenciesToFunction } from './lib/nft.js';
import type { Args } from './ssr-function.js';
@@ -20,7 +26,7 @@ export interface NetlifyLocals {
};
}
-const isStaticRedirect = (route: RouteData) =>
+const isStaticRedirect = (route: IntegrationRouteData) =>
route.type === 'redirect' && (route.redirect || route.redirectRoute);
type RemotePattern = AstroConfig['image']['remotePatterns'][number];
@@ -135,16 +141,6 @@ async function writeNetlifyFrameworkConfig(config: AstroConfig, logger: AstroInt
);
}
-// TODO: remove once we don't use a TLA anymore
-async function shouldExternalizeAstroEnvSetup() {
- try {
- await import('astro/env/setup');
- return false;
- } catch {
- return true;
- }
-}
-
export interface NetlifyIntegrationConfig {
/**
* If enabled, On-Demand-Rendered pages are cached for up to a year.
@@ -201,6 +197,8 @@ export default function netlifyIntegration(
// Secret used to verify that the caller is the astro-generated edge middleware and not a third-party
const middlewareSecret = randomUUID();
+ let finalBuildOutput: HookParameters<'astro:config:done'>['buildOutput'];
+
const TRACE_CACHE = {};
const ssrBuildDir = () => new URL('./.netlify/build/', rootDir);
@@ -214,8 +212,8 @@ export default function netlifyIntegration(
emptyDir(ssrBuildDir()),
]);
- async function writeRedirects(routes: RouteData[], dir: URL) {
- const fallback = _config.output === 'static' ? '/.netlify/static' : '/.netlify/functions/ssr';
+ async function writeRedirects(routes: IntegrationRouteData[], dir: URL) {
+ const fallback = finalBuildOutput === 'static' ? '/.netlify/static' : '/.netlify/functions/ssr';
const redirects = createRedirectsFromAstroRoutes({
config: _config,
dir,
@@ -289,7 +287,7 @@ export default function netlifyIntegration(
import { createContext, trySerializeLocals } from 'astro/middleware';
export default async (request, context) => {
- const ctx = createContext({
+ const ctx = createContext({
request,
params: {}
});
@@ -319,7 +317,7 @@ export default function netlifyIntegration(
request.headers.set("x-astro-middleware-secret", "${middlewareSecret}");
return context.next();
};
-
+
return onRequest(ctx, next);
}
@@ -452,11 +450,6 @@ export default function netlifyIntegration(
ignored: [fileURLToPath(new URL('./.netlify/**', rootDir))],
},
},
- ...((await shouldExternalizeAstroEnvSetup())
- ? {
- ssr: { external: ['astro/env/setup'] },
- }
- : {}),
},
image: {
service: {
@@ -465,10 +458,12 @@ export default function netlifyIntegration(
},
});
},
- 'astro:config:done': async ({ config, setAdapter, logger }) => {
+ 'astro:config:done': async ({ config, setAdapter, logger, buildOutput }) => {
rootDir = config.root;
_config = config;
+ finalBuildOutput = buildOutput;
+
await writeNetlifyFrameworkConfig(config, logger);
const edgeMiddleware = integrationConfig?.edgeMiddleware ?? false;
@@ -478,7 +473,6 @@ export default function netlifyIntegration(
serverEntrypoint: '@astrojs/netlify/ssr-function.js',
exports: ['default'],
adapterFeatures: {
- functionPerRoute: false,
edgeMiddleware,
},
args: { middlewareSecret } satisfies Args,
@@ -486,13 +480,7 @@ export default function netlifyIntegration(
hybridOutput: 'stable',
staticOutput: 'stable',
serverOutput: 'stable',
- assets: {
- // keeping this as experimental at least until Netlify Image CDN is out of beta
- supportKind: 'experimental',
- // still using Netlify Image CDN instead
- isSharpCompatible: true,
- isSquooshCompatible: true,
- },
+ sharpImageService: 'stable',
envGetSecret: 'experimental',
},
});
@@ -504,7 +492,7 @@ export default function netlifyIntegration(
await writeRedirects(routes, dir);
logger.info('Emitted _redirects');
- if (_config.output !== 'static') {
+ if (finalBuildOutput !== 'static') {
let notFoundContent = undefined;
try {
notFoundContent = await readFile(new URL('./404.html', dir), 'utf8');
diff --git a/packages/integrations/netlify/src/polyfill.ts b/packages/integrations/netlify/src/polyfill.ts
new file mode 100644
index 000000000..dc00f45d7
--- /dev/null
+++ b/packages/integrations/netlify/src/polyfill.ts
@@ -0,0 +1,3 @@
+import { applyPolyfills } from 'astro/app/node';
+
+applyPolyfills();
diff --git a/packages/integrations/netlify/src/ssr-function.ts b/packages/integrations/netlify/src/ssr-function.ts
index 22925ddaa..5ea2e97f1 100644
--- a/packages/integrations/netlify/src/ssr-function.ts
+++ b/packages/integrations/netlify/src/ssr-function.ts
@@ -1,15 +1,12 @@
+// Keep at the top
+import './polyfill.js';
+
import type { Context } from '@netlify/functions';
import type { SSRManifest } from 'astro';
import { App } from 'astro/app';
-import { applyPolyfills } from 'astro/app/node';
-
-applyPolyfills();
+import { setGetEnv } from 'astro/env/setup';
-// Won't throw if the virtual module is not available because it's not supported in
-// the users's astro version or if astro:env is not enabled in the project
-await import('astro/env/setup')
- .then((mod) => mod.setGetEnv((key) => process.env[key]))
- .catch(() => {});
+setGetEnv((key) => process.env[key]);
export interface Args {
middlewareSecret: string;
diff --git a/packages/integrations/netlify/test/functions/fixtures/redirects/astro.config.mjs b/packages/integrations/netlify/test/functions/fixtures/redirects/astro.config.mjs
index 1773ad73e..55613bd91 100644
--- a/packages/integrations/netlify/test/functions/fixtures/redirects/astro.config.mjs
+++ b/packages/integrations/netlify/test/functions/fixtures/redirects/astro.config.mjs
@@ -2,10 +2,10 @@ import netlify from '@astrojs/netlify';
import { defineConfig } from 'astro/config';
export default defineConfig({
- output: 'hybrid',
+ output: 'static',
adapter: netlify(),
site: `http://example.com`,
redirects: {
'/other': '/',
},
-}); \ No newline at end of file
+});
diff --git a/packages/integrations/netlify/test/hosted/hosted-astro-project/package.json b/packages/integrations/netlify/test/hosted/hosted-astro-project/package.json
index 4a0c8e266..a13a65ca1 100644
--- a/packages/integrations/netlify/test/hosted/hosted-astro-project/package.json
+++ b/packages/integrations/netlify/test/hosted/hosted-astro-project/package.json
@@ -7,6 +7,6 @@
},
"dependencies": {
"@astrojs/netlify": "workspace:*",
- "astro": "^4.16.8"
+ "astro": "^5.0.0-alpha.8"
}
}