From 962b41b319820fb68c9fe691b0856815b37790bd Mon Sep 17 00:00:00 2001 From: Jaden VanEckhout Date: Tue, 12 Nov 2024 09:44:37 -0600 Subject: [PATCH] feat: add support for open-next v3 --- .gitmodules | 2 +- API.md | 6 +++--- examples/app-router/src/app-router-stack.ts | 1 - examples/app-router/src/overrides-stack.ts | 2 +- open-next | 2 +- src/Nextjs.ts | 4 ++-- src/NextjsBuild.ts | 3 +-- src/constants.ts | 2 +- 8 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.gitmodules b/.gitmodules index c1155c95..5e350c46 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "open-next"] path = open-next - url = https://github.com/sst/open-next.git + url = https://github.com/opennextjs/opennextjs-aws.git diff --git a/API.md b/API.md index 55102e50..9f2a8970 100644 --- a/API.md +++ b/API.md @@ -3849,7 +3849,7 @@ const nextjsProps: NextjsProps = { ... } | --- | --- | --- | | nextjsPath | string | Relative path to the directory where the NextJS project is located. | | basePath | string | Optional value to prefix the Next.js site under a /prefix path on CloudFront. Usually used when you deploy multiple Next.js sites on same domain using /sub-path. | -| buildCommand | string | Optional value used to install NextJS node dependencies. | +| buildCommand | string | Optional build command override value. | | buildPath | string | The directory to execute `npm run build` from. | | distribution | aws-cdk-lib.aws_cloudfront.Distribution | Optional CloudFront Distribution created outside of this construct that will be used to add Next.js behaviors and origins onto. Useful with `basePath`. | | domainProps | NextjsDomainProps | Props to configure {@link NextjsDomain}. | @@ -3907,9 +3907,9 @@ public readonly buildCommand: string; ``` - *Type:* string -- *Default:* 'npx --yes open-next@^2 build' +- *Default:* 'npx -Optional value used to install NextJS node dependencies. +Optional build command override value. --- diff --git a/examples/app-router/src/app-router-stack.ts b/examples/app-router/src/app-router-stack.ts index 73b7c166..73f6d0d5 100644 --- a/examples/app-router/src/app-router-stack.ts +++ b/examples/app-router/src/app-router-stack.ts @@ -11,7 +11,6 @@ export class AppRouterStack extends Stack { const nextjs = new Nextjs(this, 'nextjs', { nextjsPath: '../../open-next/examples/app-router', - buildCommand: 'npx open-next@^2 build', // skipBuild: true, }); diff --git a/examples/app-router/src/overrides-stack.ts b/examples/app-router/src/overrides-stack.ts index 8c6dbae4..5444b9c3 100644 --- a/examples/app-router/src/overrides-stack.ts +++ b/examples/app-router/src/overrides-stack.ts @@ -15,7 +15,7 @@ export class OverridesStack extends Stack { const nextjs = new Nextjs(this, 'nextjs', { nextjsPath: '../../open-next/examples/app-router', - buildCommand: 'npx open-next@^2 build', + buildCommand: 'npx @opennextjs/aws@^3 build', // skipBuild: true, overrides: { nextjs: { diff --git a/open-next b/open-next index 39905022..08874fbe 160000 --- a/open-next +++ b/open-next @@ -1 +1 @@ -Subproject commit 399050226f44360876ef63771dbf29bd0645d816 +Subproject commit 08874fbe1e4ebd055d0372e74291ee82cd811b0e diff --git a/src/Nextjs.ts b/src/Nextjs.ts index e818c32e..0ab9e193 100644 --- a/src/Nextjs.ts +++ b/src/Nextjs.ts @@ -45,8 +45,8 @@ export interface NextjsProps { */ readonly basePath?: string; /** - * Optional value used to install NextJS node dependencies. - * @default 'npx --yes open-next@^2 build' + * Optional build command override value. + * @default 'npx @opennextjs/aws@^3 build' */ readonly buildCommand?: string; /** diff --git a/src/NextjsBuild.ts b/src/NextjsBuild.ts index 7f56ffaa..e828db28 100644 --- a/src/NextjsBuild.ts +++ b/src/NextjsBuild.ts @@ -146,8 +146,7 @@ export class NextjsBuild extends Construct { private build() { const buildPath = this.props.buildPath ?? this.props.nextjsPath; - const defaultBuildCommand = `npx open-next@^2 build ${this.props.streaming ? '--streaming' : ''}`; - const buildCommand = this.props.buildCommand ?? defaultBuildCommand; + const buildCommand = this.props.buildCommand ?? `npx @opennextjs/aws@^3 build`; // run build if (!this.props.quiet) { console.debug(`Running "${buildCommand}" in`, buildPath); diff --git a/src/constants.ts b/src/constants.ts index 312f683d..fb263ed6 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -5,4 +5,4 @@ export const NEXTJS_CACHE_DIR = 'cache'; export const NEXTJS_BUILD_REVALIDATE_FN_DIR = 'revalidation-function'; export const NEXTJS_BUILD_DYNAMODB_PROVIDER_FN_DIR = 'dynamodb-provider'; export const NEXTJS_BUILD_IMAGE_FN_DIR = 'image-optimization-function'; -export const NEXTJS_BUILD_SERVER_FN_DIR = 'server-function'; +export const NEXTJS_BUILD_SERVER_FN_DIR = 'server-functions/default';