Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/services/bundler/bundler-compiler-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,14 @@ export class BundlerCompilerService
}

private async shouldUsePreserveSymlinksOption(): Promise<boolean> {
// 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;
}

Expand Down
30 changes: 28 additions & 2 deletions test/services/bundler/bundler-compiler-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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", {});
Expand Down Expand Up @@ -64,6 +67,29 @@ describe("BundlerCompilerService", () => {
bundlerCompilerService = testInjector.resolve(BundlerCompilerService);
});

describe("shouldUsePreserveSymlinksOption", () => {
it("should preserve symlinks for npm", async () => {
const result = await (<any>(
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 (<any>(
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 () => {
Expand Down