diff --git a/.release-please-manifest.json b/.release-please-manifest.json index e73b5a9290..972254441a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "5.11.3" + ".": "5.11.4" } diff --git a/CHANGELOG.md b/CHANGELOG.md index b65b1c1822..932dca76cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [5.11.4](https://github.com/opennextjs/opennextjs-netlify/compare/v5.11.3...v5.11.4) (2025-06-24) + + +### Bug Fixes + +* handle shared-cache-controls rename ([#2974](https://github.com/opennextjs/opennextjs-netlify/issues/2974)) ([a4a03e1](https://github.com/opennextjs/opennextjs-netlify/commit/a4a03e179e019cc307ca63ef0e06d0e1d58a69e9)) + ## [5.11.3](https://github.com/opennextjs/opennextjs-netlify/compare/v5.11.2...v5.11.3) (2025-06-17) diff --git a/package-lock.json b/package-lock.json index f606e7ed82..26db10cfaf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@netlify/plugin-nextjs", - "version": "5.11.3", + "version": "5.11.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@netlify/plugin-nextjs", - "version": "5.11.3", + "version": "5.11.4", "license": "MIT", "devDependencies": { "@fastly/http-compute-js": "1.1.5", diff --git a/package.json b/package.json index 08b759ef93..5deb31bdb4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@netlify/plugin-nextjs", - "version": "5.11.3", + "version": "5.11.4", "description": "Run Next.js seamlessly on Netlify", "main": "./dist/index.js", "type": "module", diff --git a/src/run/handlers/cache.cts b/src/run/handlers/cache.cts index bfb86555ba..bfd7815635 100644 --- a/src/run/handlers/cache.cts +++ b/src/run/handlers/cache.cts @@ -200,15 +200,28 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions { try { const prerenderManifest = await this.getPrerenderManifest(this.options.serverDistDir) if (typeof cacheControl !== 'undefined') { - // instead of `revalidate` property, we might get `cacheControls` ( https://github.com/vercel/next.js/pull/76207 ) - // then we need to keep track of revalidate values via SharedCacheControls - const { SharedCacheControls } = await import( - // @ts-expect-error supporting multiple next version, this module is not resolvable with currently used dev dependency - // eslint-disable-next-line import/no-unresolved, n/no-missing-import - 'next/dist/server/lib/incremental-cache/shared-cache-controls.js' - ) - const sharedCacheControls = new SharedCacheControls(prerenderManifest) - sharedCacheControls.set(key, cacheControl) + try { + // instead of `revalidate` property, we might get `cacheControls` ( https://github.com/vercel/next.js/pull/76207 ) + // then we need to keep track of revalidate values via SharedCacheControls + + // https://github.com/vercel/next.js/pull/80588 renamed shared-cache-controls module + const { SharedCacheControls } = await import( + // @ts-expect-error supporting multiple next version, this module is not resolvable with currently used dev dependency + // eslint-disable-next-line import/no-unresolved, n/no-missing-import + 'next/dist/server/lib/incremental-cache/shared-cache-controls.external.js' + ) + const sharedCacheControls = new SharedCacheControls(prerenderManifest) + sharedCacheControls.set(key, cacheControl) + } catch { + // attempting to use shared-cache-controls before https://github.com/vercel/next.js/pull/80588 was merged + const { SharedCacheControls } = await import( + // @ts-expect-error supporting multiple next version, this module is not resolvable with currently used dev dependency + // eslint-disable-next-line import/no-unresolved, n/no-missing-import + 'next/dist/server/lib/incremental-cache/shared-cache-controls.js' + ) + const sharedCacheControls = new SharedCacheControls(prerenderManifest) + sharedCacheControls.set(key, cacheControl) + } } else if (typeof revalidate === 'number' || revalidate === false) { // if we don't get cacheControls, but we still get revalidate, it should mean we are before // https://github.com/vercel/next.js/pull/76207 diff --git a/tests/fixtures/page-router-base-path-i18n/pages/fallback-true/[slug].js b/tests/fixtures/page-router-base-path-i18n/pages/fallback-true/[slug].js index 5e85c57657..7f241bce57 100644 --- a/tests/fixtures/page-router-base-path-i18n/pages/fallback-true/[slug].js +++ b/tests/fixtures/page-router-base-path-i18n/pages/fallback-true/[slug].js @@ -27,7 +27,8 @@ export async function getStaticProps({ params }) { } } -export const getStaticPaths = () => { +/** @type {import('next').GetStaticPaths} */ +export const getStaticPaths = ({ locales }) => { return { paths: [ { @@ -35,7 +36,7 @@ export const getStaticPaths = () => { slug: 'prerendered', }, }, - ], + ].flatMap((pathDescription) => locales.map((locale) => ({ ...pathDescription, locale }))), fallback: true, } }