Skip to content

Commit 9877ee9

Browse files
committed
fix: bun does not require symlink
1 parent 4d46547 commit 9877ee9

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

lib/services/bundler/bundler-compiler-service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,14 @@ export class BundlerCompilerService
480480
}
481481

482482
private async shouldUsePreserveSymlinksOption(): Promise<boolean> {
483-
// pnpm does not require symlink (https://github.com/nodejs/node-eps/issues/46#issuecomment-277373566)
483+
// pnpm and Bun's isolated linker do not require symlink (https://github.com/nodejs/node-eps/issues/46#issuecomment-277373566)
484484
// and it also does not work in some cases.
485485
// Check https://github.com/NativeScript/nativescript-cli/issues/5259 for more information
486486
const currentPackageManager =
487487
await this.$packageManager.getPackageManagerName();
488-
const res = currentPackageManager !== PackageManagers.pnpm;
488+
const res =
489+
currentPackageManager !== PackageManagers.pnpm &&
490+
currentPackageManager !== PackageManagers.bun;
489491
return res;
490492
}
491493

test/services/bundler/bundler-compiler-service.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { IInjector } from "../../../lib/common/definitions/yok";
88
import {
99
BUNDLER_COMPILATION_COMPLETE,
1010
CONFIG_FILE_NAME_DISPLAY,
11+
PackageManagers,
1112
} from "../../../lib/constants";
1213

1314
const iOSPlatformName = "ios";
@@ -23,10 +24,12 @@ function getAllEmittedFiles(hash: string) {
2324
];
2425
}
2526

26-
function createTestInjector(): IInjector {
27+
function createTestInjector(
28+
packageManager: PackageManagers = PackageManagers.npm,
29+
): IInjector {
2730
const testInjector = new Yok();
2831
testInjector.register("packageManager", {
29-
getPackageManagerName: async () => "npm",
32+
getPackageManagerName: async () => packageManager,
3033
});
3134
testInjector.register("bundlerCompilerService", BundlerCompilerService);
3235
testInjector.register("childProcess", {});
@@ -64,6 +67,29 @@ describe("BundlerCompilerService", () => {
6467
bundlerCompilerService = testInjector.resolve(BundlerCompilerService);
6568
});
6669

70+
describe("shouldUsePreserveSymlinksOption", () => {
71+
it("should preserve symlinks for npm", async () => {
72+
const result = await (<any>(
73+
bundlerCompilerService
74+
)).shouldUsePreserveSymlinksOption();
75+
76+
assert.isTrue(result);
77+
});
78+
79+
for (const packageManager of [PackageManagers.pnpm, PackageManagers.bun]) {
80+
it(`should not preserve symlinks for ${packageManager}`, async () => {
81+
testInjector = createTestInjector(packageManager);
82+
bundlerCompilerService = testInjector.resolve(BundlerCompilerService);
83+
84+
const result = await (<any>(
85+
bundlerCompilerService
86+
)).shouldUsePreserveSymlinksOption();
87+
88+
assert.isFalse(result);
89+
});
90+
}
91+
});
92+
6793
describe("getUpdatedEmittedFiles", () => {
6894
// backwards compatibility with old versions of nativescript-dev-webpack
6995
it("should return only hot updates when nextHash is not provided", async () => {

0 commit comments

Comments
 (0)