@@ -16,6 +16,7 @@ import { inlineFindDir } from "./patches/plugins/find-dir.js";
1616import { patchInstrumentation } from "./patches/plugins/instrumentation.js" ;
1717import { inlineLoadManifest } from "./patches/plugins/load-manifest.js" ;
1818import { patchNextServer } from "./patches/plugins/next-server.js" ;
19+ import { patchResolveCache } from "./patches/plugins/open-next.js" ;
1920import { handleOptionalDependencies } from "./patches/plugins/optional-deps.js" ;
2021import { patchPagesRouterContext } from "./patches/plugins/pages-router-context.js" ;
2122import { patchDepdDeprecations } from "./patches/plugins/patch-depd-deprecations.js" ;
@@ -99,6 +100,7 @@ export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
99100 inlineLoadManifest ( updater , buildOpts ) ,
100101 patchNextServer ( updater , buildOpts ) ,
101102 patchDepdDeprecations ( updater ) ,
103+ patchResolveCache ( updater , buildOpts ) ,
102104 // Apply updater updates, must be the last plugin
103105 updater . plugin ,
104106 ] as Plugin [ ] ,
@@ -152,7 +154,7 @@ export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
152154
153155 fs . writeFileSync ( openNextServerBundle + ".meta.json" , JSON . stringify ( result . metafile , null , 2 ) ) ;
154156
155- await updateWorkerBundledCode ( openNextServerBundle , buildOpts ) ;
157+ await updateWorkerBundledCode ( openNextServerBundle ) ;
156158
157159 const isMonorepo = monorepoRoot !== appPath ;
158160 if ( isMonorepo ) {
@@ -170,28 +172,9 @@ export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
170172/**
171173 * This function applies patches required for the code to run on workers.
172174 */
173- export async function updateWorkerBundledCode (
174- workerOutputFile : string ,
175- buildOpts : BuildOptions
176- ) : Promise < void > {
175+ export async function updateWorkerBundledCode ( workerOutputFile : string ) : Promise < void > {
177176 const code = await readFile ( workerOutputFile , "utf8" ) ;
178-
179- const patchedCode = await patchCodeWithValidations ( code , [
180- [ "require" , patches . patchRequire ] ,
181- [ "cacheHandler" , ( code ) => patches . patchCache ( code , buildOpts ) ] ,
182- [ "composableCache" , ( code ) => patches . patchComposableCache ( code , buildOpts ) , { isOptional : true } ] ,
183- [
184- "`require.resolve` call" ,
185- // workers do not support dynamic require nor require.resolve
186- ( code ) => code . replace ( 'require.resolve("./cache.cjs")' , '"unused"' ) ,
187- ] ,
188- [
189- "`require.resolve composable cache` call" ,
190- // workers do not support dynamic require nor require.resolve
191- ( code ) => code . replace ( 'require.resolve("./composable-cache.cjs")' , '"unused"' ) ,
192- ] ,
193- ] ) ;
194-
177+ const patchedCode = await patchCodeWithValidations ( code , [ [ "require" , patches . patchRequire ] ] ) ;
195178 await writeFile ( workerOutputFile , patchedCode ) ;
196179}
197180
0 commit comments