From fe6af65b09ce75cc66aff9c54905ed0e1aac2db1 Mon Sep 17 00:00:00 2001 From: Miroslav Jonas Date: Wed, 26 Jul 2023 15:48:29 +0200 Subject: [PATCH] fix(js): ensure compile swc uses current package manager --- packages/js/src/utils/swc/compile-swc.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/js/src/utils/swc/compile-swc.ts b/packages/js/src/utils/swc/compile-swc.ts index 30dbab9edb689d..cf3322ebf0d440 100644 --- a/packages/js/src/utils/swc/compile-swc.ts +++ b/packages/js/src/utils/swc/compile-swc.ts @@ -1,4 +1,9 @@ -import { cacheDir, ExecutorContext, logger } from '@nx/devkit'; +import { + cacheDir, + ExecutorContext, + getPackageManagerCommand, + logger, +} from '@nx/devkit'; import { exec, execSync } from 'child_process'; import { removeSync } from 'fs-extra'; import { createAsyncIterable } from '@nx/devkit/src/utils/async-iterable'; @@ -10,7 +15,8 @@ function getSwcCmd( { swcrcPath, srcPath, destPath }: SwcCliOptions, watch = false ) { - let swcCmd = `npx swc ${ + const packageManager = getPackageManagerCommand(); + let swcCmd = `${packageManager.exec} swc ${ // TODO(jack): clean this up when we remove inline module support // Handle root project srcPath === '.' ? 'src' : srcPath @@ -42,8 +48,6 @@ export async function compileSwc( normalizedOptions: NormalizedSwcExecutorOptions, postCompilationCallback: () => Promise ) { - const isRootProject = - context.projectGraph.nodes[context.projectName].data.root === '.'; logger.log(`Compiling with SWC for ${context.projectName}...`); if (normalizedOptions.clean) {