@@ -200,15 +200,28 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
200200 try {
201201 const prerenderManifest = await this . getPrerenderManifest ( this . options . serverDistDir )
202202 if ( typeof cacheControl !== 'undefined' ) {
203- // instead of `revalidate` property, we might get `cacheControls` ( https://github.com/vercel/next.js/pull/76207 )
204- // then we need to keep track of revalidate values via SharedCacheControls
205- const { SharedCacheControls } = await import (
206- // @ts -expect-error supporting multiple next version, this module is not resolvable with currently used dev dependency
207- // eslint-disable-next-line import/no-unresolved, n/no-missing-import
208- 'next/dist/server/lib/incremental-cache/shared-cache-controls.js'
209- )
210- const sharedCacheControls = new SharedCacheControls ( prerenderManifest )
211- sharedCacheControls . set ( key , cacheControl )
203+ try {
204+ // instead of `revalidate` property, we might get `cacheControls` ( https://github.com/vercel/next.js/pull/76207 )
205+ // then we need to keep track of revalidate values via SharedCacheControls
206+
207+ // https://github.com/vercel/next.js/pull/80588 renamed shared-cache-controls module
208+ const { SharedCacheControls } = await import (
209+ // @ts -expect-error supporting multiple next version, this module is not resolvable with currently used dev dependency
210+ // eslint-disable-next-line import/no-unresolved, n/no-missing-import
211+ 'next/dist/server/lib/incremental-cache/shared-cache-controls.external.js'
212+ )
213+ const sharedCacheControls = new SharedCacheControls ( prerenderManifest )
214+ sharedCacheControls . set ( key , cacheControl )
215+ } catch {
216+ // attempting to use shared-cache-controls before https://github.com/vercel/next.js/pull/80588 was merged
217+ const { SharedCacheControls } = await import (
218+ // @ts -expect-error supporting multiple next version, this module is not resolvable with currently used dev dependency
219+ // eslint-disable-next-line import/no-unresolved, n/no-missing-import
220+ 'next/dist/server/lib/incremental-cache/shared-cache-controls.js'
221+ )
222+ const sharedCacheControls = new SharedCacheControls ( prerenderManifest )
223+ sharedCacheControls . set ( key , cacheControl )
224+ }
212225 } else if ( typeof revalidate === 'number' || revalidate === false ) {
213226 // if we don't get cacheControls, but we still get revalidate, it should mean we are before
214227 // https://github.com/vercel/next.js/pull/76207
0 commit comments