Files
payload/test/jest.setup.js
Alessio Gravili ebd43c7763 feat: pre-compile ui and richtext-lexical with react compiler (#7688)
This noticeably improves performance in the admin panel, for example
when there are multiple richtext editors on one page (& likely
performance in other areas too, though I mainly tested rich text).

The babel plugin currently only optimizes files with a 'use client'
directive at the top - thus we have to make sure to add use client
wherever possible, even if it's imported by a parent client component.

There's one single component that broke when it was compiled using the
React compiler (it stopped being reactive and failed one of our admin
e2e tests):
150808f608
opting out of it completely fixed that issue

Fixes https://github.com/payloadcms/payload/issues/7366
2024-08-19 17:31:36 -04:00

33 lines
888 B
JavaScript

import fs from 'fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { getDatabaseAdapter } from './getDatabaseAdapter.js'
process.env.PAYLOAD_DISABLE_ADMIN = 'true'
process.env.PAYLOAD_DROP_DATABASE = 'true'
process.env.PAYLOAD_PUBLIC_CLOUD_STORAGE_ADAPTER = 's3'
process.env.NODE_OPTIONS = '--no-deprecation'
process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER = 'true'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
const dbAdapter = process.env.PAYLOAD_DATABASE || 'mongodb'
// Generate databaseAdapter.ts
const databaseAdapter = getDatabaseAdapter(dbAdapter)
// Write to databaseAdapter.ts
fs.writeFileSync(
path.resolve(dirname, 'databaseAdapter.ts'),
`
// DO NOT MODIFY. This file is automatically generated in initDevAndTest.ts
${databaseAdapter}
`,
)
console.log('Wrote', dbAdapter, 'db adapter')