Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions packages/cloudflare/src/cli/build/bundle-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { build, type Plugin } from "esbuild";
import { getOpenNextConfig } from "../../api/config.js";
import { patchVercelOgLibrary } from "./patches/ast/patch-vercel-og-library.js";
import { patchWebpackRuntime } from "./patches/ast/webpack-runtime.js";
import * as patches from "./patches/index.js";
import { inlineDynamicRequires } from "./patches/plugins/dynamic-requires.js";
import { inlineFindDir } from "./patches/plugins/find-dir.js";
import { patchInstrumentation } from "./patches/plugins/instrumentation.js";
Expand All @@ -23,7 +22,7 @@ import { patchDepdDeprecations } from "./patches/plugins/patch-depd-deprecations
import { fixRequire } from "./patches/plugins/require.js";
import { shimRequireHook } from "./patches/plugins/require-hook.js";
import { setWranglerExternal } from "./patches/plugins/wrangler-external.js";
import { needsExperimentalReact, normalizePath, patchCodeWithValidations } from "./utils/index.js";
import { copyPackageCliFiles, needsExperimentalReact, normalizePath } from "./utils/index.js";

/** The dist directory of the Cloudflare adapter package */
const packageDistDir = path.join(path.dirname(fileURLToPath(import.meta.url)), "../..");
Expand All @@ -46,7 +45,7 @@ const optionalDependencies = [
* Bundle the Open Next server.
*/
export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
patches.copyPackageCliFiles(packageDistDir, buildOpts);
copyPackageCliFiles(packageDistDir, buildOpts);

const { appPath, outputDir, monorepoRoot, debug } = buildOpts;
const baseManifestPath = path.join(
Expand Down Expand Up @@ -174,13 +173,11 @@ export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
}

/**
* This function applies patches required for the code to run on workers.
* This function apply updates to the bundled code.
*/
export async function updateWorkerBundledCode(workerOutputFile: string): Promise<void> {
const code = await readFile(workerOutputFile, "utf8");
const patchedCode = await patchCodeWithValidations(code, [
["require", patches.patchRequire, { isOptional: true }],
]);
const patchedCode = code.replace(/__require\d?\(/g, "require(").replace(/__require\d?\./g, "require.");
await writeFile(workerOutputFile, patchedCode);
}

Expand Down
1 change: 0 additions & 1 deletion packages/cloudflare/src/cli/build/patches/index.ts

This file was deleted.

This file was deleted.

This file was deleted.

29 changes: 0 additions & 29 deletions packages/cloudflare/src/cli/build/utils/apply-patches.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from "node:path";

import type { BuildOptions } from "@opennextjs/aws/build/helper.js";

import { getOutputWorkerPath } from "../../bundle-server.js";
import { getOutputWorkerPath } from "../bundle-server.js";

/**
* Copies
Expand Down
2 changes: 1 addition & 1 deletion packages/cloudflare/src/cli/build/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "./apply-patches.js";
export * from "./copy-package-cli-files.js";
export * from "./create-config-files.js";
export * from "./ensure-cf-config.js";
export * from "./extract-project-env-vars.js";
Expand Down