From 01deac78c45b7376d1e3c63dc7a195de52aa9ceb Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 24 Jul 2024 20:20:16 +0000 Subject: [PATCH] 880: Support new compile/generate syntax for next >=14.2.0 (#886) Fix for https://git.vdb.to/cerc-io/stack-orchestrator/issues/880 to support the next compile/generate syntax. Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/886 Co-authored-by: Thomas E Lackey Co-committed-by: Thomas E Lackey --- .../cerc-nextjs-base/scripts/build-app.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/build-app.sh b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/build-app.sh index 4e769224..9842aa0a 100755 --- a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/build-app.sh +++ b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/build-app.sh @@ -107,8 +107,6 @@ if [ ! -f "package.dist" ]; then cp package.json package.dist fi -cat package.dist | jq '.scripts.cerc_compile = "next experimental-compile"' | jq '.scripts.cerc_generate = "next experimental-generate"' > package.json - CUR_NEXT_VERSION="`jq -r '.dependencies.next' package.json`" if [ "$CERC_NEXT_VERSION" != "keep" ] && [ "$CUR_NEXT_VERSION" != "$CERC_NEXT_VERSION" ]; then @@ -121,6 +119,21 @@ time $CERC_BUILD_TOOL install || exit 1 CUR_NEXT_VERSION=`jq -r '.version' node_modules/next/package.json` +# See https://github.com/vercel/next.js/discussions/46544 +semver -p -r ">=14.2.0" "$CUR_NEXT_VERSION" +if [ $? -eq 0 ]; then + # For >= 14.2.0 + CERC_NEXT_COMPILE_COMMAND="next build --experimental-build-mode compile" + CERC_NEXT_GENERATE_COMMAND="next build --experimental-build-mode generate" +else + # For 13.4.2 to 14.1.x + CERC_NEXT_COMPILE_COMMAND="next experimental-compile" + CERC_NEXT_GENERATE_COMMAND="next experimental-generate" +fi + +cat package.json | jq ".scripts.cerc_compile = \"$CERC_NEXT_COMPILE_COMMAND\"" | jq ".scripts.cerc_generate = \"$CERC_NEXT_GENERATE_COMMAND\"" > package.json.$$ +mv package.json.$$ package.json + semver -p -r ">=$CERC_MIN_NEXTVER" $CUR_NEXT_VERSION if [ $? -ne 0 ]; then cat <