diff --git a/lib/services/bundler/bundler-compiler-service.ts b/lib/services/bundler/bundler-compiler-service.ts index ea4a3751ed..0a4bd8800e 100644 --- a/lib/services/bundler/bundler-compiler-service.ts +++ b/lib/services/bundler/bundler-compiler-service.ts @@ -480,12 +480,14 @@ export class BundlerCompilerService } private async shouldUsePreserveSymlinksOption(): Promise { - // pnpm does not require symlink (https://github.com/nodejs/node-eps/issues/46#issuecomment-277373566) + // pnpm and Bun's isolated linker do not require symlink (https://github.com/nodejs/node-eps/issues/46#issuecomment-277373566) // and it also does not work in some cases. // Check https://github.com/NativeScript/nativescript-cli/issues/5259 for more information const currentPackageManager = await this.$packageManager.getPackageManagerName(); - const res = currentPackageManager !== PackageManagers.pnpm; + const res = + currentPackageManager !== PackageManagers.pnpm && + currentPackageManager !== PackageManagers.bun; return res; } diff --git a/test/services/bundler/bundler-compiler-service.ts b/test/services/bundler/bundler-compiler-service.ts index a33e60aa59..eaebd03f58 100644 --- a/test/services/bundler/bundler-compiler-service.ts +++ b/test/services/bundler/bundler-compiler-service.ts @@ -8,6 +8,7 @@ import { IInjector } from "../../../lib/common/definitions/yok"; import { BUNDLER_COMPILATION_COMPLETE, CONFIG_FILE_NAME_DISPLAY, + PackageManagers, } from "../../../lib/constants"; const iOSPlatformName = "ios"; @@ -23,10 +24,12 @@ function getAllEmittedFiles(hash: string) { ]; } -function createTestInjector(): IInjector { +function createTestInjector( + packageManager: PackageManagers = PackageManagers.npm, +): IInjector { const testInjector = new Yok(); testInjector.register("packageManager", { - getPackageManagerName: async () => "npm", + getPackageManagerName: async () => packageManager, }); testInjector.register("bundlerCompilerService", BundlerCompilerService); testInjector.register("childProcess", {}); @@ -64,6 +67,29 @@ describe("BundlerCompilerService", () => { bundlerCompilerService = testInjector.resolve(BundlerCompilerService); }); + describe("shouldUsePreserveSymlinksOption", () => { + it("should preserve symlinks for npm", async () => { + const result = await (( + bundlerCompilerService + )).shouldUsePreserveSymlinksOption(); + + assert.isTrue(result); + }); + + for (const packageManager of [PackageManagers.pnpm, PackageManagers.bun]) { + it(`should not preserve symlinks for ${packageManager}`, async () => { + testInjector = createTestInjector(packageManager); + bundlerCompilerService = testInjector.resolve(BundlerCompilerService); + + const result = await (( + bundlerCompilerService + )).shouldUsePreserveSymlinksOption(); + + assert.isFalse(result); + }); + } + }); + describe("getUpdatedEmittedFiles", () => { // backwards compatibility with old versions of nativescript-dev-webpack it("should return only hot updates when nextHash is not provided", async () => {