Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nextjs): enable Next.js 13.4 support #16819

Merged
merged 1 commit into from
May 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/next/plugins/with-nx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ function withNx(
_nextConfig = {} as WithNxOptions,
context: WithNxContext = getWithNxContext()
): NextConfigFn {
// If this is not set user will see compile errors in Next.js 13.4.
// See: https://github.com/nrwl/nx/issues/16692, https://github.com/vercel/next.js/issues/49169
// TODO(jack): Remove this once Nx is refactored to invoke CLI directly.
forNextVersion('>=13.4.0', () => {
process.env['__NEXT_PRIVATE_PREBUNDLED_REACT'] =
// Not in Next 13.3 or earlier, so need to access config via string
_nextConfig.experimental['serverActions'] ? 'experimental' : 'next';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaysoo If serverActions is not specified on the experimental object, then it will throw an error because of undefined.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I had the same error as @ruslanguns. It should be first checked if experimental object exists in the config, something like _nextConfig.experimental && _nextConfig.experimental['serverActions']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dpnolte just dropped a PR with your suggested fix #16846

});

return async (phase: string) => {
const { PHASE_PRODUCTION_SERVER } = await import('next/constants');
if (phase === PHASE_PRODUCTION_SERVER) {
Expand Down