Skip to content

Commit fc7a91a

Browse files
committed
chore: added require.resolve for incremental cache
1 parent de33423 commit fc7a91a

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

packages/runtime/src/helpers/config.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { join, dirname, relative } from 'pathe'
77
import slash from 'slash'
88

99
import { HANDLER_FUNCTION_NAME, IMAGE_FUNCTION_NAME, ODB_FUNCTION_NAME } from '../constants'
10-
import { generateCacheHandler } from '../templates/getCacheHandler'
1110

1211
import type { APILambda, SSRLambda } from './functions'
1312
import type { RoutesManifest } from './types'
@@ -56,8 +55,6 @@ export const getNextConfig = async function getNextConfig({
5655
)
5756
}
5857

59-
await generateCacheHandler(INTERNAL_FUNCTIONS_SRC)
60-
6158
// For more info, see https://nextjs.org/docs/app/api-reference/next-config-js/incrementalCacheHandlerPath
6259
// ./cache-handler.js will be copied to the root or the .next build folder
6360

@@ -67,7 +64,9 @@ export const getNextConfig = async function getNextConfig({
6764
...config,
6865
experimental: {
6966
...config.experimental,
70-
incrementalCacheHandlerPath: join(INTERNAL_FUNCTIONS_SRC, '__incremental-cache', 'incremental-cache.js'),
67+
incrementalCacheHandlerPath: require.resolve(
68+
join(INTERNAL_FUNCTIONS_SRC, '__incremental-cache', 'incremental-cache.js'),
69+
),
7170
},
7271
},
7372
})

packages/runtime/src/helpers/functions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
LAMBDA_WARNING_SIZE,
2323
} from '../constants'
2424
import { getApiHandler } from '../templates/getApiHandler'
25+
import { generateCacheHandler } from '../templates/getCacheHandler'
2526
import { getHandler } from '../templates/getHandler'
2627
import { getResolverForPages, getResolverForSourceFiles } from '../templates/getPageResolver'
2728

@@ -168,6 +169,7 @@ export const generateFunctions = async (
168169

169170
await writeHandler(HANDLER_FUNCTION_NAME, HANDLER_FUNCTION_TITLE, false)
170171
await writeHandler(ODB_FUNCTION_NAME, ODB_FUNCTION_TITLE, true)
172+
await generateCacheHandler(functionsDir)
171173
}
172174

173175
/**

packages/runtime/src/templates/getCacheHandler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ export const generateCacheHandler = async (functionsDir: string): Promise<void>
88
await ensureDir(join(functionsDir, '__incremental-cache'))
99

1010
await writeFile(join(functionsDir, '__incremental-cache', 'incremental-cache.js'), blobCache)
11-
await copyFile(join(__dirname, '..', '..', 'lib', 'helpers', 'blobStorage.js'), join('.netlify', 'blobStorage.js'))
11+
await copyFile(
12+
join(__dirname, '..', '..', 'lib', 'helpers', 'blobStorage.js'),
13+
join(functionsDir, '__incremental-cache', 'blobStorage.js'),
14+
)
1215
}
1316

1417
const getCacheHandler = (): string =>

0 commit comments

Comments
 (0)