-
Notifications
You must be signed in to change notification settings - Fork 201
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
Turborepo support (Currently INIT_CWD
workaround required)
#104
Comments
Hi @0xdhrv. Thanks for opening this issue and providing a repro. I've just given it a try and can confirm the problem you're running into. This is currently happening due to a limitation in Turborepo itself (see vercel/turborepo#485). However, until this is resolved you can workaround the problem by simply adding // apps/starter/package.json
"scripts": {
// ...
"build": "INIT_CWD=$PWD next build",
// ...
}, Related: |
I'm having the same issue with lerna. The |
Yeah, same here but with Yarn workspaces... discovered the contentlayer/packages/@contentlayer/core/src/cwd.ts Lines 9 to 13 in 20ce905
|
Some background / motivation on this subject: Contentlayer is trying to aiming to work as smoothly "out of the box" as possible. One aspect of this is the auto-discovery functionality in regards to the Contentlayer config file and where to generate the Most users of Contentlayer are working in a single-project repository where the Contentlayer config and generated folder are "living" in the root of the repo. However, in more complex setups (e.g. in a mono-repo) your website project (using Contentlayer) might live in a sub directory. Depending on how you're interacting (e.g. via Turbo, Yarn, ...) with your tools (e.g. Next.js, Contentlayer etc) In these more complex cases Contentlayer needs to know which subdirectory you're targeting. The most commonly used "solution"/convention for this in the JS ecosystem is for mono-repo tools to set the Unfortunately it seems that some tools (e.g. Turbo, Lerna) currently don't support this pattern. Alternative approach: @jrolfs @pomber would you rather prefer explicitly providing a Contentlayer config path when you're calling the Contentlayer CLI or e.g. provide it in your |
INIT_CWD
workaround required)
@schickling I think ultimately it makes sense to be available in both places, right? That said, I think I would prefer a CLI argument as I have a build step on CI that invokes I could probably take a stab at this, although admittedly there's a bit of a learning curve with this codebase on account of Effect-TS (and its lack of documentation 😜). Here's a bunch of detail around my specific case, just so you have it when considering all the idiosyncrasies of package managers 😅 I am using Yarn 1's ExampleConfiguration lives @
{
"name": "my-monorepo",
"scripts": {
"start:site": "yarn workspace @foo/site run start",
"build:site": "yarn workspace @foo/site run build"
}
}
{
"name": "@foo/site",
"scripts": {
"start": "next dev",
"build:site": "contentlayer build"
}
} From yarn start:site and yarn build:site ...both fail to find the configuration because However — if I invoke I'm hoping to get onto Yarn 2+ soon in this project, and I'm curious if it has different behavior for Finally, I just want to say nice work so far on contentlayer. I really like the approach y'all are taking and I'm so glad I found it :) |
Did you try running |
In my use case, the contentlayer next.js app is in an I have it there for three reasons:
So ideally for me, the build should run the same way if you run it as part of a monorepo or standalone, without adding any extra configuration inside the examples folder. |
Huh, I guess I missed that CLI flag as I was originally looking for the Next.js case... unfortunately it seems to have issues as well (and from playing around it seems like the path provided is relative to Maybe I'm missing something or oversimplifying things but I'm pretty sure most tools just use |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This should be addressed with the |
I am getting this error at build step. I am using next13 and turborepo. However the build is successful when i run build from the specific app's json file. Eg. build from root does not work, but cd apps/starter build does work Edit: I just noticed that my contentlayer config can not be located even in dev mode. I get this message on running the app in dev mode. This means it is looking for my file in the root of my repo. And unfortunately i cannot use INIT_CWD because I get this error INIT_CWD' is not recognized as an internal or external command |
I removed this line from my next.config and my turbo repo setup now works for me. const { withContentlayer } = require('next-contentlayer') I am using tsup to build my package, but the error was still appearing in my turbo build. is there any reason I would need withContentLayer in a mono repo? when I build my markdown package I am getting refreshed content on my nextjs app and everything looks ok. |
When using contentlayer inside turbo repo, the config gives an error for importing
contentlayer/source-files
This is the same repository for reproduction of the same: https://github.com/0xdhrv/turborepo-with-contentlayer
And, inside
apps/starter
The text was updated successfully, but these errors were encountered: