Weird webpack error with nextjs, libsql and pnpm workspaces
Hello there! š
I have a side project that uses drizzle with turso in a pnpm workspace with the following structure:
The
web
app is a Remix app with Vite, and the db
package is turso + drizzle, using a db file for local development. Everything works flawlessly and the DX is awesome. Loving Drizzle so far ššš
The thing is, I wanted a similar setup but with nextjs instead. Webpack hates it and fails to compile with the error shown in the screenshot š Works fine when moving the db files inside the web
app, but then I loose the monorepo structure and I kinda need it for my next project š
I've uploaded a minimal repro here https://github.com/carloitaben/nextjs-pnpm-monorepo-libsql-webpack-repro
Any ideas? I'm new to monorepos and I'm really curious now š¤ seems like a funny error. Could it be some ESM/CJS compatibility error? Or something in my tsconfig files?
Thanks in advance šGitHub
GitHub - carloitaben/nextjs-pnpm-monorepo-libsql-webpack-repro
Contribute to carloitaben/nextjs-pnpm-monorepo-libsql-webpack-repro development by creating an account on GitHub.
4 Replies
You might wanna take a look at this page
next.config.js Options: transpilePackages | Next.js
Automatically transpile and bundle dependencies from local packages (like monorepos) or from external dependencies (
node_modules
).Yeah, tried that but doesn't work. I've also tried with the
experimental.serverComponentsExternalPackages
config but doesn't work either š
It's so weird. Installing @libsql/client
package in the web
app does the trick but it's not ideal, I really want it to just be a dependency of db
.
Thanks for the help btw šInstall it as a dev dependency while you keep looking. That way there shouldn't be anything in the compiled js
Are you sure you're not importing the db somwhere in the front end?