Skip to content

Commit

Permalink
fix: getPayload generate import map only when used in Payload Admin…
Browse files Browse the repository at this point in the history
… Panel (#9371)

After the change with removing `getPayloadHMR`, we do generate import
map even outside of Next.js, which leads to errors when using in a
project without it:

![image](https://github.com/user-attachments/assets/e8dc2af6-566b-443c-a6d8-8b02e719bd30)
  • Loading branch information
r1tsuu authored Dec 4, 2024
1 parent fa39b37 commit d8f7034
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/payload/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -807,15 +807,14 @@ export const getPayload = async (
// will reach `if (cached.reload instanceof Promise) {` which then waits for the first reload to finish.
cached.reload = new Promise((res) => (resolve = res))
const config = await options.config
await reload(config, cached.payload)
await reload(config, cached.payload, !options.importMap)

resolve()
}

if (cached.reload instanceof Promise) {
await cached.reload
}

if (options?.importMap) {
cached.payload.importMap = options.importMap
}
Expand All @@ -839,6 +838,7 @@ export const getPayload = async (
) {
try {
const port = process.env.PORT || '3000'

cached.ws = new WebSocket(
`ws://localhost:${port}${process.env.NEXT_BASE_PATH ?? ''}/_next/webpack-hmr`,
)
Expand Down

0 comments on commit d8f7034

Please sign in to comment.