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