On Vercel I am having an issue where sharp is causing type errors in the payload config when using the vercel build caching feature.
Vercel build logs:
pragmatic-papers:build: Failed to compile.
pragmatic-papers:build:
pragmatic-papers:build: ./src/payload.config.ts:84:3
pragmatic-papers:build: Type error: Type 'typeof sharp' is not assignable to type 'SharpDependency'.
pragmatic-papers:build: Types of parameters 'options' and 'input' are incompatible.
pragmatic-papers:build: Type 'string | ArrayBuffer | Buffer | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | ... 7 more ... | undefined' is not assignable to type 'SharpOptions | undefined'.
pragmatic-papers:build: Type 'string' has no properties in common with type 'SharpOptions'.
pragmatic-papers:build:
pragmatic-papers:build: 82 | ],
pragmatic-papers:build: 83 | secret: process.env.PAYLOAD_SECRET,
pragmatic-papers:build: > 84 | sharp,
pragmatic-papers:build: | ^
pragmatic-papers:build: 85 | typescript: {
pragmatic-papers:build: 86 | outputFile: path.resolve(dirname, 'payload-types.ts'),
pragmatic-papers:build: 87 | },
pragmatic-papers:build: Next.js build worker exited with code: 1 and signal: null
pragmatic-papers:build: ELIFECYCLE Command failed with exit code 1.
pragmatic-papers:build: ERROR: command finished with error: command (/vercel/path0/apps/pragmatic-papers) /pnpm10/node_modules/.bin/pnpm run build exited (1)
pragmatic-papers#build: command (/vercel/path0/apps/pragmatic-papers) /pnpm10/node_modules/.bin/pnpm run build exited (1)
For now I disabled vercel build cache with the VERCEL_FORCE_NO_BUILD_CACHE=1 environment variable, but I'd like it if we can use build caching to see if we can trim down the ~3 minute build time.
Trying to upgrade sharp from 0.32.6 to 0.34.2 is now causing the type error in GitHub Actions:
[error]src/payload.config.ts(78,3): error TS2322: Type 'typeof sharp' is not assignable to type 'SharpDependency'.
Types of parameters 'options' and 'input' are incompatible.
Type 'string | ArrayBuffer | Buffer | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | ... 7 more ... | undefined' is not assignable to type 'SharpOptions | undefined'.
Type 'string' has no properties in common with type 'SharpOptions'.
Also, I'm not having any issues locally ofc.
