Because the Admin Panel browser bundle includes your Payload Config file, files using server-only modules need to be excluded.
It's common for your config to rely on server only modules to perform logic in access control functions, hooks, and other contexts.
Any file that imports a server-only module such as fs, stripe, authorizenet, nodemailer, etc. cannot be included in the browser bundle.
Say we have a collection called Subscriptions that has a beforeChange hook that creates a Stripe subscription whenever a Subscription document is created in Payload.
The above code is NOT production-ready and should not be referenced to create Stripe
subscriptions. Although creating a beforeChange hook is a completely valid spot to do things like
create subscriptions, the code above is incomplete and insecure, meant for explanation purposes
only.
As-is, this collection will prevent your Admin panel from bundling or loading correctly, because Stripe relies on some Node-only packages.
You need to make sure that you use aliases to tell your bundler to import "safe" files vs. attempting to import any server-side code that you need to get rid of. Depending on your bundler (Webpack, Vite, etc.) the steps involved may be slightly different.
The basic idea is to create a file that exports an empty object, and then alias import paths of any files that import server-only modules to that empty object file.
This way when your bundler goes to import a file that contains server-only modules, it will instead import the empty object file, which will not break the browser bundle.