From 58a28e5ddf9e17619d75bfc11a537b62ae76abc6 Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Wed, 22 May 2024 17:58:59 -0400 Subject: [PATCH] fix(js): print warning when --generateLockfile is used with Bun rather than erroring out (#25158) Currently if you pass `--generateLockfile` and use Bun, it'll error out because the lockfile content is returned as `null`. There is no API to prune `bun.lockb` files so it's better to skip it with a warning to the user. We can discuss generating `yarn.lock` file instead as a follow-up. ## Current Behavior ## Expected Behavior ## Related Issue(s) Fixes # --- .../utils/package-json/update-package-json.ts | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/packages/js/src/utils/package-json/update-package-json.ts b/packages/js/src/utils/package-json/update-package-json.ts index b97b0c69a2..0dbdf64615 100644 --- a/packages/js/src/utils/package-json/update-package-json.ts +++ b/packages/js/src/utils/package-json/update-package-json.ts @@ -11,6 +11,7 @@ import { ExecutorContext, getOutputsForTargetAndConfiguration, joinPathFragments, + logger, ProjectFileMap, ProjectGraph, ProjectGraphExternalNode, @@ -103,18 +104,24 @@ export function updatePackageJson( if (options.generateLockfile) { const packageManager = detectPackageManager(context.root); - const lockFile = createLockFile( - packageJson, - context.projectGraph, - packageManager - ); - writeFileSync( - `${options.outputPath}/${getLockFileName(packageManager)}`, - lockFile, - { - encoding: 'utf-8', - } - ); + if (packageManager === 'bun') { + logger.warn( + `Bun lockfile generation is unsupported. Remove "generateLockfile" option or set it to false.` + ); + } else { + const lockFile = createLockFile( + packageJson, + context.projectGraph, + packageManager + ); + writeFileSync( + `${options.outputPath}/${getLockFileName(packageManager)}`, + lockFile, + { + encoding: 'utf-8', + } + ); + } } }