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

next.js build: building contentlayer prior to TSC or adding more clear docs #105

Open
jzxhuang opened this issue Jun 20, 2023 · 5 comments · May be fixed by #106
Open

next.js build: building contentlayer prior to TSC or adding more clear docs #105

jzxhuang opened this issue Jun 20, 2023 · 5 comments · May be fixed by #106

Comments

@jzxhuang
Copy link

jzxhuang commented Jun 20, 2023

When following the official Getting Started example for Next.js, the app fails to build on CI or any environemnt where .contentlayer doesn't exist already.

This appears to be because TSC runs prior to contentlayer, which errors out.

I'm not sure if this can be changed at all (to run a Next plugin prior to the TSC step). That would seem like the ideal solution, but otherwise, would be great to update the documentation & examples to modify the build step

"scripts": {
  "build": "contentlayer && next build"
}

I'm happy to make a PR to help out, just wanted to check if this is indeed an issue that others experience or if I'm really missing something basic

@shaneafsar
Copy link

Just adding a comment that we've had to do the same thing for our site. We also have to use concurrently for running both contentlayer and next in dev mode.

@seancdavis
Copy link
Contributor

@jzxhuang Where would you expect to see this documentation?

Perhaps a mention in the getting started guide and also a note in Known Problems or maybe a separate troubleshooting page?

@seancdavis
Copy link
Contributor

@shaneafsar Can you say more about your development setup?

  • What errors were you running into?
  • How did concurrently fix those errors?
  • Why did you choose concurrently over other options for this type of behavior?

@jzxhuang
Copy link
Author

@jzxhuang Where would you expect to see this documentation?

Perhaps a mention in the getting started guide and also a note in Known Problems or maybe a separate troubleshooting page?

Yeah, I would expect it in the Getting Started guide — probably under "next.js configuration" or a new section like "Building for Production" or something like that. Also adding a note in Known Problems is a great idea!

btw, happy to make a PR for this — I just wanted to first confirm that it's a known issue with any easy solutions, and not just something I'm missing 😅

@schickling schickling transferred this issue from contentlayerdev/contentlayer Jun 28, 2023
@shaneafsar
Copy link

@shaneafsar Can you say more about your development setup?

  • What errors were you running into?
  • How did concurrently fix those errors?
  • Why did you choose concurrently over other options for this type of behavior?

We followed a recommendation from this issue: contentlayerdev/contentlayer#415 (comment)

Some info about our setup:

  • We're using the latest version of NextJS and contentlayer
  • We're using turborepo

It's been awhile, but we ran into the missing .contentlayer folder issue. Once the folder was created, it seemed to work properly and we could go back to using the recommended approach, but people pulling down the repo for the first time would encounter the issue. (There was another dev who had an infinite reload issue, but we hadn't narrowed that down).

We'll try the recommended way in a couple sprints to see if the issue is still happening, and try to provide more detailed reproduction steps from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants