@@ -10,7 +10,6 @@ import { build, type Plugin } from "esbuild";
1010import { getOpenNextConfig } from "../../api/config.js" ;
1111import { patchVercelOgLibrary } from "./patches/ast/patch-vercel-og-library.js" ;
1212import { patchWebpackRuntime } from "./patches/ast/webpack-runtime.js" ;
13- import * as patches from "./patches/index.js" ;
1413import { inlineDynamicRequires } from "./patches/plugins/dynamic-requires.js" ;
1514import { inlineFindDir } from "./patches/plugins/find-dir.js" ;
1615import { patchInstrumentation } from "./patches/plugins/instrumentation.js" ;
@@ -23,7 +22,7 @@ import { patchDepdDeprecations } from "./patches/plugins/patch-depd-deprecations
2322import { fixRequire } from "./patches/plugins/require.js" ;
2423import { shimRequireHook } from "./patches/plugins/require-hook.js" ;
2524import { setWranglerExternal } from "./patches/plugins/wrangler-external.js" ;
26- import { needsExperimentalReact , normalizePath , patchCodeWithValidations } from "./utils/index.js" ;
25+ import { copyPackageCliFiles , needsExperimentalReact , normalizePath } from "./utils/index.js" ;
2726
2827/** The dist directory of the Cloudflare adapter package */
2928const packageDistDir = path . join ( path . dirname ( fileURLToPath ( import . meta. url ) ) , "../.." ) ;
@@ -46,7 +45,7 @@ const optionalDependencies = [
4645 * Bundle the Open Next server.
4746 */
4847export async function bundleServer ( buildOpts : BuildOptions ) : Promise < void > {
49- patches . copyPackageCliFiles ( packageDistDir , buildOpts ) ;
48+ copyPackageCliFiles ( packageDistDir , buildOpts ) ;
5049
5150 const { appPath, outputDir, monorepoRoot, debug } = buildOpts ;
5251 const baseManifestPath = path . join (
@@ -174,13 +173,11 @@ export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
174173}
175174
176175/**
177- * This function applies patches required for the code to run on workers .
176+ * This function apply updates to the bundled code .
178177 */
179178export async function updateWorkerBundledCode ( workerOutputFile : string ) : Promise < void > {
180179 const code = await readFile ( workerOutputFile , "utf8" ) ;
181- const patchedCode = await patchCodeWithValidations ( code , [
182- [ "require" , patches . patchRequire , { isOptional : true } ] ,
183- ] ) ;
180+ const patchedCode = code . replace ( / _ _ r e q u i r e \d ? \( / g, "require(" ) . replace ( / _ _ r e q u i r e \d ? \. / g, "require." ) ;
184181 await writeFile ( workerOutputFile , patchedCode ) ;
185182}
186183
0 commit comments