DT
Drizzle Teamā€¢12mo ago
carlo

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:
.
ā”œā”€ā”€ apps/
ā”‚ ā””ā”€ā”€ web/
ā”‚ ā””ā”€ā”€ package.json
ā”œā”€ā”€ packages/
ā”‚ ā””ā”€ā”€ db/
ā”‚ ā””ā”€ā”€ package.json
ā”œā”€ā”€ package.json
ā””ā”€ā”€ pnpm-workspaces.yaml
.
ā”œā”€ā”€ apps/
ā”‚ ā””ā”€ā”€ web/
ā”‚ ā””ā”€ā”€ package.json
ā”œā”€ā”€ packages/
ā”‚ ā””ā”€ā”€ db/
ā”‚ ā””ā”€ā”€ package.json
ā”œā”€ā”€ package.json
ā””ā”€ā”€ pnpm-workspaces.yaml
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.
No description
4 Replies
Angelelz
Angelelzā€¢12mo ago
You might wanna take a look at this page
Angelelz
Angelelzā€¢12mo ago
next.config.js Options: transpilePackages | Next.js
Automatically transpile and bundle dependencies from local packages (like monorepos) or from external dependencies (node_modules).
carlo
carloOPā€¢12mo ago
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 šŸ™Œ
Angelelz
Angelelzā€¢12mo ago
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?
Want results from more Discord servers?
Add your server