chore: upgrade to pnpm v9, regenerate lockfile (#7369)

- regenerates the lockfile
- upgrades pnpm from v8 to v9.7.0 minimum
- ensures playwright does not import payload config. Even after our
importmap revamp that made the payload config server-only / node-safe, I
was getting these `Error: Invariant: AsyncLocalStorage accessed in
runtime where it is not available` errors in combination with pnpm v9
and lockfile regeneration.
This does not happen with pnpm v8, however I'm still blaming playwright
for this, as this does not happen in dev and we've had this specific
error with playwright in the past when we were importing the payload
config. Perhaps it's related to both playwright and the future Next.js
process importing the same config file, and not related to the config
file containing client-side React code.
Making sure playwright doesn't import the config fixed it (it was
importing it through the import map generation). The import map
generation is now run in a separate process, and playwright simply waits
for it
- One positive thing: this pr fixes a bunch of typescript errors with
react-select components. We got those errors because react-select types
are not compatible with react 19. lockfile regeneration fixed that (not
related to pnpm v9) - probably because we were installing mismatching
react versions (I saw both `fb9a90fa48-20240614` and `06d0b89e-20240801`
in our lockfile). I have thus removed the caret for react and react-dom
in our package.json - now it's consistent
This commit is contained in:
Alessio Gravili
2024-08-14 08:57:04 -04:00
committed by GitHub
parent fca4ee995e
commit 96e7c95ebc
23 changed files with 11263 additions and 8716 deletions

View File

@@ -7,7 +7,7 @@ import { fileURLToPath, parse } from 'url'
import type { GeneratedTypes } from './sdk/types.js'
import { runInit } from '../runInit.js'
import { runInitSeparateProcess } from '../runInitSeparateProcess.js'
import { createTestHooks } from '../testHooks.js'
import { getNextJSRootDir } from './getNextJSRootDir.js'
import { PayloadTestSDK } from './sdk/index.js'
@@ -32,7 +32,7 @@ export async function initPayloadE2ENoConfig<T extends GeneratedTypes<T>>({
}: Args): Promise<Result<T>> {
const testSuiteName = path.basename(dirname)
await runInit(testSuiteName, true)
await runInitSeparateProcess(testSuiteName, true)
const { beforeTest } = await createTestHooks(testSuiteName)
await beforeTest()
@@ -86,6 +86,7 @@ export async function initPayloadE2ENoConfig<T extends GeneratedTypes<T>>({
// which seeds test data twice + other bad things.
// We initialize Payload above so we can have access to it in the tests
void app.prepare().then(() => {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
createServer(async (req, res) => {
const parsedUrl = parse(req.url, true)
await handle(req, res, parsedUrl)

View File

@@ -14,7 +14,7 @@ export async function initPayloadInt(
testSuiteNameOverride?: string,
): Promise<{ config: SanitizedConfig; payload: Payload; restClient: NextRESTClient }> {
const testSuiteName = testSuiteNameOverride ?? path.basename(dirname)
await runInit(testSuiteName, false, false, true)
await runInit(testSuiteName, false, true)
console.log('importing config', path.resolve(dirname, 'config.ts'))
const { default: config } = await import(path.resolve(dirname, 'config.ts'))
console.log('starting payload')

View File

@@ -22,7 +22,7 @@
"tsconfig.json": "node scripts/reset-tsconfig.js"
},
"devDependencies": {
"@aws-sdk/client-s3": "^3.525.0",
"@aws-sdk/client-s3": "^3.614.0",
"@lexical/headless": "0.17.0",
"@lexical/markdown": "0.17.0",
"@payloadcms/db-mongodb": "workspace:*",

View File

@@ -1,70 +1,9 @@
import child_process from 'node:child_process'
import path from 'path'
import { fileURLToPath } from 'url'
import { initDevAndTest } from './initDevAndTest.js'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export async function runInit(
testSuiteArg: string,
writeDBAdapter: boolean,
separateProcess: boolean = false,
skipGenImportMap: boolean = false,
): Promise<void> {
if (!separateProcess) {
await initDevAndTest(testSuiteArg, String(writeDBAdapter), String(skipGenImportMap))
return
}
let done = false
// Now use node & swc-node/register to execute initDevAndTest and wait until it console logs "Done". use child_process
// 1. execute
// 2. wait until console.log("Done")
const child = child_process.spawn(
'node',
[
'--no-deprecation',
'--import',
'@swc-node/register/esm-register',
'test/initDevAndTest.ts',
testSuiteArg,
writeDBAdapter ? 'true' : 'false',
skipGenImportMap ? 'true' : 'false',
],
{
stdio: 'pipe',
cwd: path.resolve(dirname, '..'),
},
)
child.stdout.on('data', (data) => {
console.log('initDevAndTest data', data.toString())
if (data.toString().includes('Done')) {
child.kill()
done = true
}
})
// on error
child.stderr.on('data', (data) => {
console.error('initDevAndTest error', data.toString())
})
child.on('close', (code) => {
console.log(`Child process closed with code ${code}`)
})
// wait for done to be true
await new Promise((resolve) => {
const interval = setInterval(() => {
if (done) {
clearInterval(interval)
resolve(undefined)
}
}, 100)
})
await initDevAndTest(testSuiteArg, String(writeDBAdapter), String(skipGenImportMap))
}

View File

@@ -0,0 +1,62 @@
import child_process from 'node:child_process'
import path from 'path'
import { fileURLToPath } from 'url'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export async function runInitSeparateProcess(
testSuiteArg: string,
writeDBAdapter: boolean,
skipGenImportMap: boolean = false,
): Promise<void> {
let done = false
// Now use node & swc-node/register to execute initDevAndTest and wait until it console logs "Done". use child_process
// 1. execute
// 2. wait until console.log("Done")
const child = child_process.spawn(
'node',
[
'--no-deprecation',
'--import',
'@swc-node/register/esm-register',
'test/initDevAndTest.ts',
'true',
testSuiteArg,
writeDBAdapter ? 'true' : 'false',
skipGenImportMap ? 'true' : 'false',
],
{
stdio: 'pipe',
cwd: path.resolve(dirname, '..'),
},
)
child.stdout.on('data', (data) => {
console.log('initDevAndTest data', data.toString())
if (data.toString().includes('Done')) {
child.kill()
done = true
}
})
// on error
child.stderr.on('data', (data) => {
console.error('initDevAndTest error', data.toString())
})
child.on('close', (code) => {
console.log(`Child process closed with code ${code}`)
})
// wait for done to be true
await new Promise((resolve) => {
const interval = setInterval(() => {
if (done) {
clearInterval(interval)
resolve(undefined)
}
}, 100)
})
}