nx: next: The @nrwl/next:build executor is incompatible with Next 13.2
Current Behavior
When using @nrwl/next@latest with next@13.2.0, the @nrwl/next:build executor doesn’t respect the executor options.
The .next folder is built inline (e.g. apps/X/.next) rather than in the configured ouputPath (e.g. dist/apps/X/.next).
This issue is due to an internal breaking change in version 13.2.0 of Next that removed the custom conf option of the next/dist/build function: https://github.com/vercel/next.js/pull/45455
Expected Behavior
The .next build output should be located in the outputPath folder, e.g. dist/apps/X/.next.
GitHub Repo
https://github.com/jasongerbes/nx-examples/tree/next-13.2.0
Steps to Reproduce
- Create a Nx workspace with
@nrwl/next - Add a Next application
test-next-app - Upgrade
nextto13.2.0 - Run
nx build test-next-app
Nx Report
> NX Report complete - copy this into the issue template
Node : 16.18.0
OS : darwin arm64
yarn : 1.22.19
nx : 15.7.2
@nrwl/jest : 15.7.2
@nrwl/linter : 15.7.2
@nrwl/workspace : 15.7.2
@nrwl/angular : 15.7.2
@nrwl/cli : 15.7.2
@nrwl/cypress : 15.7.2
@nrwl/devkit : 15.7.2
@nrwl/eslint-plugin-nx : 15.7.2
@nrwl/js : 15.7.2
@nrwl/next : 15.7.2
@nrwl/react : 15.7.2
@nrwl/rollup : 15.7.2
@nrwl/tao : 15.7.2
@nrwl/web : 15.7.2
@nrwl/webpack : 15.7.2
@nrwl/nx-cloud : 15.0.3
typescript : 4.8.4
---------------------------------------
Community plugins:
@ngrx/component-store : 15.0.0
@ngrx/effects : 15.0.0
@ngrx/entity : 15.0.0
@ngrx/router-store : 15.0.0
@ngrx/store : 15.0.0
@ngrx/store-devtools : 15.0.0
Failure Logs
No response
Additional Information
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 36
- Comments: 32 (7 by maintainers)
Reading the “tracking” of this issue. It seems like, "hey, you are using undocumented and unsupported features from the dist folder. "
This likely means that the fix needs to come from Nrwl, not NextJS.
This issue is a showstopper, to put it kindly.
Is Nrwl aware that importing a component from a lib breaks when using Next.js 13.2+?
They are not commenting here, but it seems Nrwl is aware of the issue: https://github.com/nrwl/nx/pull/15650
Temporary workaround, tested in
next@13.2.3, if you don’t use NX NextJS features, like:in your next.config.js:
Worth noting that in our case we also have:
NextJS Issue tracking this problem (impacting other folk too): vercel/next.js#46374
I am still seeing some loader issues on the latest that are not related to importing across projects. I seem to get a related issue when I upgrade
nxornextto latest (nx@15.8.7&next@13.2.4). I will also look for another issue to tie this to but I see the same thing @Kolahzary saw at the top of the thread:Also happened to us for updating to 13.2.1
stacktrace:
I was testing out Turborepo, and Next run fine. That’s going to be pretty obvious.
Really, this is just because that monorepo tool is layered on top of the package manager’s workspace features. Well, Nx supports that as well.
So, while it is a bit different, it does seem that you could just set up your app and UI components libs as NPM/PNPM/Yarn workspaces. Parts of the solution, like Tailwind, can end up more manual maybe.
Where there are relative paths for processing. But, this is largely what the Nx tailwind Plugin does anyway and might still work fine.
@gilmillasseau Are you dropping out
withNxcompletely then?Ah, hey @rmachado-studocu! Nice to bump into you over the internets 🙃
So, the reason NX has to pass the config to the build function is for the features I mentioned in this comment: https://github.com/nrwl/nx/issues/15214#issuecomment-1451536766
If you don’t use those features, all you have to do is specify the
distDiron next.config.js, which is something else that@nrwl/next:builddoes, but not to hard to replicate manually.Thanks @ianldgs , I tested but got some weird behaviours, I rather downgraded NextJS to v13.1.1 which works smoothly with Next 15.8.1
@ruslanguns the workaround made it work for our project. But we don’t use any of the features NX provides for NextJS.