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
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Jack Hsu 2024-05-22 17:58:59 -04:00 committed by GitHub
parent dc5f91beee
commit 58a28e5ddf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -11,6 +11,7 @@ import {
ExecutorContext, ExecutorContext,
getOutputsForTargetAndConfiguration, getOutputsForTargetAndConfiguration,
joinPathFragments, joinPathFragments,
logger,
ProjectFileMap, ProjectFileMap,
ProjectGraph, ProjectGraph,
ProjectGraphExternalNode, ProjectGraphExternalNode,
@ -103,6 +104,11 @@ export function updatePackageJson(
if (options.generateLockfile) { if (options.generateLockfile) {
const packageManager = detectPackageManager(context.root); const packageManager = detectPackageManager(context.root);
if (packageManager === 'bun') {
logger.warn(
`Bun lockfile generation is unsupported. Remove "generateLockfile" option or set it to false.`
);
} else {
const lockFile = createLockFile( const lockFile = createLockFile(
packageJson, packageJson,
context.projectGraph, context.projectGraph,
@ -117,6 +123,7 @@ export function updatePackageJson(
); );
} }
} }
}
function isNpmNode( function isNpmNode(
node: ProjectGraphProjectNode | ProjectGraphExternalNode, node: ProjectGraphProjectNode | ProjectGraphExternalNode,