Skip to content

Commit 6ac789a

Browse files
authored
fix: use the correct runtime (i.e. webpack or turbopack) (#1079)
1 parent 249f738 commit 6ac789a

9 files changed

Lines changed: 27 additions & 9 deletions

File tree

.changeset/shy-brooms-trade.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
fix: use the correct runtime (i.e. webpack or turbopack)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { configurePlaywright } from "../../common/config-e2e";
22

3-
export default configurePlaywright("playground16");
3+
export default configurePlaywright("playground16", { useTurbopack: false });
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { configurePlaywright } from "../../common/config-e2e";
2+
3+
export default configurePlaywright("playground16", { useTurbopack: true });
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import config from "./open-next.config.js";
2+
3+
export default {
4+
...config,
5+
// Override the build command to use Turbopack
6+
buildCommand: "next build --turbopack",
7+
};

examples/playground16/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"preview": "pnpm build:worker && pnpm preview:worker",
1313
"e2e": "playwright test -c e2e/playwright.config.ts",
1414
"e2e:dev": "playwright test -c e2e/playwright.dev.config.ts",
15+
"build:worker-turbopack": "pnpm build:worker --openNextConfigPath open-next.turbopack.config.ts",
16+
"e2e-turbopack": "playwright test -c e2e/playwright.turbopack.config.ts",
1517
"cf-typegen": "wrangler types --env-interface CloudflareEnv"
1618
},
1719
"dependencies": {

packages/cloudflare/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"dependencies": {
5555
"@ast-grep/napi": "0.40.0",
5656
"@dotenvx/dotenvx": "catalog:",
57-
"@opennextjs/aws": "3.9.10",
57+
"@opennextjs/aws": "3.9.11",
5858
"cloudflare": "^4.4.1",
5959
"enquirer": "^2.4.1",
6060
"glob": "catalog:",

packages/cloudflare/src/cli/build/bundle-server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import path from "node:path";
44
import { fileURLToPath } from "node:url";
55

66
import { type BuildOptions, getPackagePath } from "@opennextjs/aws/build/helper.js";
7+
import * as buildHelper from "@opennextjs/aws/build/helper.js";
78
import { ContentUpdater } from "@opennextjs/aws/plugins/content-updater.js";
89
import { build, type Plugin } from "esbuild";
910

@@ -55,7 +56,7 @@ export async function bundleServer(buildOpts: BuildOptions, projectOpts: Project
5556
const serverFiles = path.join(dotNextPath, "required-server-files.json");
5657
const nextConfig = JSON.parse(fs.readFileSync(serverFiles, "utf-8")).config;
5758

58-
const useTurbopack = fs.existsSync(path.join(dotNextPath, "server/chunks/[turbopack]_runtime.js"));
59+
const useTurbopack = buildHelper.getBundlerRuntime(buildOpts) === "turbopack";
5960

6061
console.log(`\x1b[35m⚙️ Bundling the OpenNext server...\n\x1b[0m`);
6162

packages/cloudflare/src/cli/build/open-next/createServerBundle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ async function generateBundle(
205205
awsPatches.patchUnstableCacheForISR,
206206
awsPatches.patchUseCacheForISR,
207207
awsPatches.patchNextServer,
208-
awsPatches.patchEnvVars,
208+
awsPatches.getEnvVarsPatch(options),
209209
awsPatches.patchBackgroundRevalidation,
210210
awsPatches.patchNodeEnvironment,
211211
// Cloudflare specific patches

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)