prismicio / slice-machine

A series of tools for developing and deploying website sections with Prismic
https://prismic.io/docs
Apache License 2.0
286 stars 52 forks source link

Slice index file without dynamic ssr false break NextJS 14.0.2+ prod build #1292

Closed webda2l closed 6 months ago

webda2l commented 7 months ago

See https://github.com/vercel/next.js/issues/58576#issuecomment-1936062020 and so, I think the { ssr: false } should be use during slices/index.ts generation. Tried a lots of others things... and it's definitly the root cause.

Versions

angeloashmore commented 7 months ago

Hi @webda2l, this isn't an issue that happens to every Next.js 14 + Prismic website, thus I am not sure we should make { ssr: false } the default.

Could you provide details on your setup and what you think could be causing it? A reproduction project would be best so we can investigate it further.

In the meantime, you could also try disabling lazy loading via next/dynamic by modifying your slicemachine.config.json file like this:

// slicemachine.config.json

{
  "adapter": {
    "name": "@slicemachine/adapter-next",
    "options": {
      "lazyLoadSlices": false
    }
  }
}
webda2l commented 6 months ago

Yes it's certainly a particular case. (NextJS14 still using page router & webpack/babel). After rm .next directory, the build failed on a random page and always the slice-simulator.tsx that follow standard.

Feel free to close the issue, even close it still help if someone find it.

Because it's not directly related to Prismic, I hope a fix on NextJs side, but if doesn't come, maybe add a new adapter.option to enable { ssr: false } or reuse the lazyLoadSlices option to this goal instead its current as improvement?

xrutayisire commented 6 months ago

Thank you. Yes we will close this issue and see if we need to add an option in the future.