File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
packages/cloudflare/src/cli/build Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ import { patchDepdDeprecations } from "./patches/plugins/patch-depd-deprecations
2323import { fixRequire } from "./patches/plugins/require.js" ;
2424import { shimRequireHook } from "./patches/plugins/require-hook.js" ;
2525import { setWranglerExternal } from "./patches/plugins/wrangler-external.js" ;
26- import { normalizePath , patchCodeWithValidations } from "./utils/index.js" ;
26+ import { needsExperimentalReact , normalizePath , patchCodeWithValidations } from "./utils/index.js" ;
2727
2828/** The dist directory of the Cloudflare adapter package */
2929const packageDistDir = path . join ( path . dirname ( fileURLToPath ( import . meta. url ) ) , "../.." ) ;
@@ -139,7 +139,8 @@ export async function bundleServer(buildOpts: BuildOptions): Promise<void> {
139139 "process.env.NEXT_RUNTIME" : '"nodejs"' ,
140140 "process.env.NODE_ENV" : '"production"' ,
141141 "process.env.TURBOPACK" : "false" ,
142- // Ideally here we should define the `process.env.__NEXT_EXPERIMENTAL_REACT`, but this would require that function splitting is enabled for the case where both versions are needed (i.e. page and app router routes)
142+ // This define should be safe to use for Next 14.2+
143+ "process.env.__NEXT_EXPERIMENTAL_REACT" : `${ needsExperimentalReact ( nextConfig ) } ` ,
143144 } ,
144145 platform : "node" ,
145146 banner : {
Original file line number Diff line number Diff line change @@ -2,4 +2,5 @@ export * from "./apply-patches.js";
22export * from "./create-config-files.js" ;
33export * from "./ensure-cf-config.js" ;
44export * from "./extract-project-env-vars.js" ;
5+ export * from "./needs-experimental-react.js" ;
56export * from "./normalize-path.js" ;
Original file line number Diff line number Diff line change 1+ import type { NextConfig } from "@opennextjs/aws/types/next-types" ;
2+
3+ // Not sure if this should be upstreamed to aws
4+ // Adding more stuff there make typing incorrect actually, these properties are never undefined as long as it is the right version of next
5+ // Ideally we'd have different `NextConfig` types for different versions of next
6+ interface ExtendedNextConfig extends NextConfig {
7+ experimental : {
8+ ppr ?: boolean ;
9+ taint ?: boolean ;
10+ viewTransition ?: boolean ;
11+ serverActions ?: boolean ;
12+ } ;
13+ }
14+
15+ // Copied from https://github.com/vercel/next.js/blob/4518bc91641a0fd938664b781e12ae7c145f3396/packages/next/src/lib/needs-experimental-react.ts#L3-L6
16+ export function needsExperimentalReact ( nextConfig : ExtendedNextConfig ) {
17+ const { ppr, taint, viewTransition } = nextConfig . experimental || { } ;
18+ return Boolean ( ppr || taint || viewTransition ) ;
19+ }
You can’t perform that action at this time.
0 commit comments