Skip to content

Commit

Permalink
Add basic support for Bun package manager (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
harveylee authored Aug 4, 2024
1 parent c332456 commit b9f544e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ integrated, check out [mono-ts](https://github.com/0x80/mono-ts)
- Preserve packages file structure, without code bundling
- Should work with any package manager, and tested with NPM, PNPM, and Yarn
(both classic and modern)
- There is partial support for Bun - the process will detect the Bun package manager but will not output a Bun lockfile for the isolated package; instead it will fall back to generating an NPM lockfile.
- Zero-config for the vast majority of use-cases
- Isolates dependencies recursively. If package A depends on internal package B
which depends on internal package C, all of them will be included
Expand Down
12 changes: 12 additions & 0 deletions src/lib/lockfile/process-lockfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ export async function processLockfile({
});
break;
}
case "bun": {
log.warn(
`Ouput lockfiles for Bun are not yet supported. Using NPM for output`
);
await generateNpmLockfile({
workspaceRootDir,
isolateDir,
});

usedFallbackToNpm = true;
break;
}
default:
log.warn(`Unexpected package manager ${name}. Using NPM for output`);
await generateNpmLockfile({
Expand Down
9 changes: 8 additions & 1 deletion src/lib/package-manager/names.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
export const supportedPackageManagerNames = ["pnpm", "yarn", "npm"] as const;
export const supportedPackageManagerNames = [
"pnpm",
"yarn",
"npm",
"bun",
] as const;

export type PackageManagerName = (typeof supportedPackageManagerNames)[number];

Expand All @@ -11,6 +16,8 @@ export type PackageManager = {

export function getLockfileFileName(name: PackageManagerName) {
switch (name) {
case "bun":
return "bun.lockb";
case "pnpm":
return "pnpm-lock.yaml";
case "yarn":
Expand Down
1 change: 1 addition & 0 deletions src/lib/registry/helpers/find-packages-globs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function findPackagesGlobs(workspaceRootDir: string) {
log.debug("Detected pnpm packages globs:", inspectValue(globs));
return globs;
}
case "bun":
case "yarn":
case "npm": {
const workspaceRootManifestPath = path.join(
Expand Down

0 comments on commit b9f544e

Please sign in to comment.