Skip to content

getPayload tries to deal with email even outside Next.js #10046

@fofoy

Description

@fofoy

Describe the Bug

I reported some time ago about a problem when using getPayload method outside of Next.js generating importMap outside Next.js when it was not needed and it was actually causing problems. This issue was kindly fixed by @r1tsuu but this didn't resolve the other issue I had which is that when I'm invoking getPayload method outside Next.js, it's trying to deal with some email stuff from my payload.config.ts that I'm importing.

Of course this is not needed at all when we just want to consume the Local API and generates errors in the console of the application that's consuming the Local API. Here is a sample log from my app :

Image

In a more general way, it seems like when we use Payload from outside Next.js, it's trying to do way more things that we'd like to, especially when you just want to consume the Local API. (e.g Sentry stuff).

Image

I don't know if something can be done to opt-out some plugins to be used only in Payload for example.

Link to the code that reproduces this issue

https://github.com/fofoy/payload-getPayload-outside-nextjs

Reproduction Steps

1 - Clone repo
2 - Run command pnpm install
3 - Run command docker run -d --name payload-monorepo -p 27017:27017 mongo to spin up a new MongoDB instance
4 - Run command pnpm run dev to start the apps in the monorepo
5 - Go to the next application URL, it should be http://localhost:3001
6 - Check out next#dev task and you should see following logs about email adapter not being provided

Image

and also Sentry logs

Image

Which area(s) are affected? (Select all that apply)

area: core, email-nodemailer, plugin: sentry

Environment Info

Binaries:
  Node: 20.12.2
  npm: 10.5.0
  Yarn: 1.22.19
  pnpm: 9.6.0
Relevant Packages:
  payload: 3.6.0
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Tue Nov 5 00:21:55 UTC 2024
  Available memory (MB): 11967
  Available CPU cores: 8

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions