@@ -10,7 +10,6 @@ import { build, type Plugin } from "esbuild";
10
10
import { getOpenNextConfig } from "../../api/config.js" ;
11
11
import { patchVercelOgLibrary } from "./patches/ast/patch-vercel-og-library.js" ;
12
12
import { patchWebpackRuntime } from "./patches/ast/webpack-runtime.js" ;
13
- import * as patches from "./patches/index.js" ;
14
13
import { inlineDynamicRequires } from "./patches/plugins/dynamic-requires.js" ;
15
14
import { inlineFindDir } from "./patches/plugins/find-dir.js" ;
16
15
import { patchInstrumentation } from "./patches/plugins/instrumentation.js" ;
@@ -23,7 +22,7 @@ import { patchDepdDeprecations } from "./patches/plugins/patch-depd-deprecations
23
22
import { fixRequire } from "./patches/plugins/require.js" ;
24
23
import { shimRequireHook } from "./patches/plugins/require-hook.js" ;
25
24
import { 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" ;
27
26
28
27
/** The dist directory of the Cloudflare adapter package */
29
28
const packageDistDir = path . join ( path . dirname ( fileURLToPath ( import . meta. url ) ) , "../.." ) ;
@@ -46,7 +45,7 @@ const optionalDependencies = [
46
45
* Bundle the Open Next server.
47
46
*/
48
47
export async function bundleServer ( buildOpts : BuildOptions ) : Promise < void > {
49
- patches . copyPackageCliFiles ( packageDistDir , buildOpts ) ;
48
+ copyPackageCliFiles ( packageDistDir , buildOpts ) ;
50
49
51
50
const { appPath, outputDir, monorepoRoot, debug } = buildOpts ;
52
51
const baseManifestPath = path . join (
@@ -174,13 +173,11 @@ export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
174
173
}
175
174
176
175
/**
177
- * This function applies patches required for the code to run on workers .
176
+ * This function apply updates to the bundled code .
178
177
*/
179
178
export async function updateWorkerBundledCode ( workerOutputFile : string ) : Promise < void > {
180
179
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." ) ;
184
181
await writeFile ( workerOutputFile , patchedCode ) ;
185
182
}
186
183
0 commit comments