11import * as fs from "node:fs/promises" ;
22import logger from "../../logger.js" ;
33import * as buildHelper from "../helper.js" ;
4+ import type { getManifests } from "../copyTracedFiles.js" ;
45
56// Either before or after should be provided, otherwise just use the field directly
67export interface VersionedField < T > {
@@ -21,14 +22,22 @@ export interface VersionedField<T> {
2122}
2223
2324export type PatchCodeFn = ( args : {
24- // The content of the file that needs to be patched
25+ /**
26+ * The code of the file that needs to be patched
27+ */
2528 code : string ;
26- // The final path of the file that needs to be patched
29+ /**
30+ * The final path of the file that needs to be patched
31+ */
2732 filePath : string ;
28- // All js files that will be included in this specific server function
33+ /**
34+ * All files that are traced and will be included in the bundle
35+ */
2936 tracedFiles : string [ ] ;
30- // All next.js manifest that are present at runtime - Key relative to `.next` folder
31- manifests : Record < string , any > ;
37+ /**
38+ * Next.js manifests that are used by Next at runtime
39+ */
40+ manifests : ReturnType < typeof getManifests > ;
3241} ) => Promise < string > ;
3342
3443export interface CodePatcher {
@@ -69,7 +78,7 @@ export function extractVersionedField<T>(
6978export async function applyCodePatches (
7079 buildOptions : buildHelper . BuildOptions ,
7180 tracedFiles : string [ ] ,
72- manifests : Record < string , any > ,
81+ manifests : ReturnType < typeof getManifests > ,
7382 codePatcher : CodePatcher [ ] ,
7483) {
7584 const nextVersion = buildOptions . nextVersion ;
0 commit comments