wasp icon indicating copy to clipboard operation
wasp copied to clipboard

Frontend doesn't render when there's an empty Prisma schema

Open cprecioso opened this issue 6 months ago • 2 comments

Describe the bug

Write-up: https://www.notion.so/wasp-lang/Error-writeup-Browser-error-on-blank-project-20018a74854c80249e83ec893c7d6d91?pvs=4

wasp/core/serialization is calling @prisma/client as part of its logic. When the Prisma schema doesn't have any models, @prisma/client is an empty placeholder in the CJS format instead of ESM, which trips up Vite.

OTOH, it seems like this workaround is not needed anymore: https://github.com/wasp-lang/wasp/blob/014f661a27f829bddf2290f7cdf1cd7c38f3387c/waspc/data/Generator/templates/react-app/vite.config.ts#L44-L54

To Reproduce

  1. wasp new
  2. wasp start
  3. Browser is blank

Expected behavior

The template page shows up

Screenshots

Image

Possible solutions

  • Do not import @prisma/client from wasp/core/serialization if there aren't any Prisma models
  • Wrap that import in a try..catch
  • Create a Vite plugin that correctly resolves whether Prisma is being a CJS or ESM file
  • Update Prisma
  • Something else (?)

cprecioso avatar May 27 '25 09:05 cprecioso