diff --git a/.changeset/bundler-runtime-build-output-path.md b/.changeset/bundler-runtime-build-output-path.md new file mode 100644 index 000000000..9d99bac0d --- /dev/null +++ b/.changeset/bundler-runtime-build-output-path.md @@ -0,0 +1,14 @@ +--- +"@opennextjs/aws": patch +--- + +Fix `getBundlerRuntime` ignoring `buildOutputPath` + +`getBundlerRuntime` looked for the Next.js server output under `appPath`, which +is always the project root and does not follow the `buildOutputPath` config. +Every other consumer of the Next.js build output (`getBuildId`, +`copyEnvFile`, `createServerBundle`, …) resolves it from `appBuildOutputPath`. + +As a result, setting `buildOutputPath` to anything other than `.` failed the +build with `Unable to determine Next.js runtime (webpack or turbopack)` as soon +as the project root no longer contained a stale `.next` directory. diff --git a/packages/open-next/src/build/helper.ts b/packages/open-next/src/build/helper.ts index a049901e2..60300f251 100644 --- a/packages/open-next/src/build/helper.ts +++ b/packages/open-next/src/build/helper.ts @@ -511,7 +511,10 @@ export function getPackagePath(options: BuildOptions) { export function getBundlerRuntime( options: BuildOptions, ): "webpack" | "turbopack" { - const dotNextServerPath = path.join(options.appPath, ".next/server"); + const dotNextServerPath = path.join( + options.appBuildOutputPath, + ".next/server", + ); if (fs.existsSync(path.join(dotNextServerPath, "webpack-runtime.js"))) { return "webpack"; }