Hi, I have a turborepo including a Next

Hi, I have a turborepo including a Next project that is deployed on CF pages. Everything works fine, but build caching says 'Skipping build output cache as it's not supported for your project'. Is this due to using turborepo? The source directory to build in is set to the app directory. Or why would the build ouput be skipped?
9 Replies
Dario
Dario•9mo ago
yes it is most definitely an issue with turborepo or more precisely... it's because the Pages build system doesn't (yet) properly support monorepos basically to have the build cache working you have to make sure two things are in place, which I'd imagine they are not in your setup - next needs to be a dependency in your root project's package.json - the Next.js cache directory needs to be .next/cache at the root of your repository
Pepijn
PepijnOP•9mo ago
Hi Dario, thanks for your reply. Will there be any updates made in the near future for this? Adding next to the root may be fine for now, but of course not really what we want to have that package installed in all workspaces when not necessary. Also moving the .next/cache is not something that next has configurable in the build step at the moment I do have the root directory changed, so if Vercel would read from there instead of the root directory, the issue would also be resolved I guess.
Dario
Dario•9mo ago
I don't think so, because the Pages build system would not cache the directory, so even if the Vercel CLI would try to get the cache from the correct location there would be nothing to read there... no? ah, Next.js doesn't allow that uh? 😓
Dario
Dario•9mo ago
Dario
Dario•9mo ago
I'm not really sure 😕 , @Walshy | Deploying do you know? 🙂
Walshy
Walshy•9mo ago
Keep an eye out 🙂
Pepijn
PepijnOP•9mo ago
I tried playing with the YARN_CACHE_FOLDER which I could point to root .next/cache/yarn, howevere this only provided an optimization in bypassing donwloading the dependencies, still it needed linking and also the Next build cache was not cached. Hopefully there will be an update to the build cache!
Dario
Dario•9mo ago
@Pepijn silly idea! 😅 what if you add the next dependency, then add logic to your (CI) build script so that it: - moves a potential Pages build cache to the cache location Next.js expects (i.e. (mv) moves /.next/cache to <YOUR_APP_DIR>/.next/cache) - runs the build command - moves a potential Next.js cache to the cache location Pages expects (i.e. (mv) moves <YOUR_APP_DIR>/.next/cache to /.next/cache) In this way you could be able to trick Pages to cache the Next build output (and mv should be fairly inexpensive)
Pepijn
PepijnOP•9mo ago
Yeah I was experimenting with that, bit clumsy to use mv because it also should merge whenever there is already a directory. I made a test case and will check if it works out. Just using the yarn cache folder shaves about half a minute of my build, moving around with the next cache does not really matter in my build times Yarn linking dependencies could save about 30-40s additionally, but I think then the node_modules shoud be cached
Want results from more Discord servers?
Add your server