fix: loader support for server-only (#6383)

## Description

Allows `server-only` to work within the Payload loader.

Fixes https://github.com/payloadcms/payload-3.0-demo/issues/218
This commit is contained in:
James Mikrut
2024-05-17 09:07:18 -04:00
committed by GitHub
parent e4185259b4
commit 5083525189
6 changed files with 24 additions and 4 deletions

View File

@@ -11,6 +11,11 @@ describe('Loader', () => {
expect(code).toStrictEqual(0)
})
it('should import server-only without breaking', async () => {
const code = await startChildProcess('./server-only-test.ts')
expect(code).toStrictEqual(0)
})
it('should import configs that rely on custom components', async () => {
const code = await startChildProcess('../admin/config.ts')
expect(code).toStrictEqual(0)

View File

@@ -0,0 +1,3 @@
import 'server-only'
console.log('woo')

View File

@@ -48,6 +48,7 @@
"execa": "5.1.1",
"http-status": "1.6.2",
"payload": "workspace:*",
"server-only": "^0.0.1",
"tempy": "^1.0.1",
"ts-essentials": "7.0.3",
"typescript": "5.4.5",