BuilderIO / builder

Visual Development for React, Vue, Svelte, Qwik, and more
https://builder.io
MIT License
7.49k stars 934 forks source link

NextJS SDK lru-cache error #3422

Closed bmstefanski closed 3 weeks ago

bmstefanski commented 3 months ago

Describe the bug I started using new experimental nextjs SDK since our app doesn't make sense without RSC and we want to use builder. There's sadly no workaround I know that would allow us to use server components & have drag-and-drop custom components. If you know some workaround for now, please let me know! :)

To Reproduce Steps to reproduce the behavior:

  1. Set up the app like the example here https://github.com/BuilderIO/builder/blob/main/packages/sdks/output/nextjs/README.md#examples
  2. Yarn install & yarn dev and the error with lru-cache appears

Expected behavior Should work with RSC

Screenshots

image

Additional context

My next.config.js

  reactStrictMode: true,
  transpilePackages: ["@builder.io/sdk-react-nextjs"],
  experimental: {
    serverComponentsExternalPackages: ["isolated-vm"],
  },
  // removed for brevity

I also tried adding lru-cache to serverComponentsExternalPackages, but that didn't help. I have isolated-vm and lru-cache installed locally.

It also doesn't matter whether I set up any custom components in <Content />. It throws the same error even if it's empty

I tested it on the same versions (next, react, react-dom, sdk) as in the example and also on the newest (0.15.1).

Node.js version: 20.x

Thanks in advance!

samijaber commented 3 months ago

Thanks for filing. Our example repository that lives at https://github.com/BuilderIO/builder/tree/main/examples/next-js-sdk-gen-2-experimental-app-directory is continuously deployed on Vercel to make sure its build works properly.

The latest version is live at https://nextjs-sdk.vercel.app, grabbing the current code from the main branch.

The Vercel server is configured with Node.js 20.x and other versions respect whatever is in package-lock.json and package.json.

The repo should work as-is without any modifications. Have you made any additions or changes to the app? Could you share a fork/reproduction repo that reproduces the build error?

bmstefanski commented 3 months ago

Thank you for quick response, I will build a small reproduction app today and post it here

bmstefanski commented 3 months ago

I downloaded the example and replaced npm with yarn and used Node 20.11.1 (nvm use 20.11.1 ) and now it exists the process of yarn dev whenever I visit any route. When I go back to 18.17.0 it seems to work fine in that example.

Repo: https://github.com/Blazity/builder-nextjs-sdk-repro

samijaber commented 2 months ago

@bmstefanski Thank you for the reproduction. We are able to reproduce the issue, and have identified the root cause(s).

Will share here when a fix is made.

Thank you for your patience 🙏🏽

Rudolf-Dudarev commented 1 month ago

Subscribing for the update. Great communication by builder.io team, thanks for the effort! :)

samijaber commented 3 weeks ago

fix published in 0.16.12 https://github.com/BuilderIO/builder/blob/main/packages/sdks/output/nextjs/CHANGELOG.md#01612