Skip to content

Commit

Permalink
only use the Vercel config hack for versions that don't support bun (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
james-elicx authored Sep 18, 2023
1 parent 6d849e1 commit b585099
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/lazy-toys-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cloudflare/next-on-pages': patch
---

Avoid using the Vercel custom config hack for Bun package manager support when a version of the Vercel CLI that supports Bun is used.
2 changes: 1 addition & 1 deletion packages/next-on-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"zodcli": "^0.0.4"
},
"peerDependencies": {
"vercel": "^30.0.0 || ^31.0.0 || ^32.0.0",
"vercel": ">=30.0.0",
"wrangler": "^3.0.0"
},
"devDependencies": {
Expand Down
22 changes: 15 additions & 7 deletions packages/next-on-pages/src/buildApplication/buildVercelOutput.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { writeFile, mkdir, rm, rmdir } from 'fs/promises';
import { spawn, type ChildProcessWithoutNullStreams } from 'child_process';
import { join, resolve } from 'path';
import { cliLog } from '../cli';
import { cliLog, cliWarn } from '../cli';
import { readJsonFile, validateDir, validateFile } from '../utils';
import type { PackageManager } from './packageManagerUtils';
import {
Expand Down Expand Up @@ -34,13 +34,21 @@ export async function buildVercelOutput(): Promise<void> {
await generateProjectJsonFileIfNeeded();

let tempVercelConfig: TempVercelConfigInfo | undefined;
// When using the Bun package manager, we need to ensure the Vercel CLI has a config file that
// tells it to use Bun, since Vercel doesn't support auto-detecting Bun yet.

if (pm === 'bun') {
tempVercelConfig = await createTempVercelConfig({
buildCommand: 'bun run build',
installCommand: 'bun install',
});
// Vercel introduced proper Bun support in 32.2.1 and 32.2.4 (for monorepos), therefore we should
// ensure the Vercel CLI has a config file telling it to use Bun for older versions. This is done
// to prevent a breaking change for users who are using an older version of the Vercel CLI.
const vercelVersion = await getPackageVersion('vercel', pm);
if (vercelVersion && vercelVersion < '32.2.4') {
cliWarn(
'Vercel CLI version is < 32.2.4, creating temporary config for Bun support...',
);
tempVercelConfig = await createTempVercelConfig({
buildCommand: 'bun run build',
installCommand: 'bun install',
});
}
}

cliLog('Project is ready');
Expand Down

0 comments on commit b585099

Please sign in to comment.