Skip to content

Commit

Permalink
fix(js): ensure compile swc uses current package manager
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Jul 26, 2023
1 parent 1dadb3d commit c57c15b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/js/src/utils/swc/compile-swc.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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
Expand Down Expand Up @@ -42,8 +48,6 @@ export async function compileSwc(
normalizedOptions: NormalizedSwcExecutorOptions,
postCompilationCallback: () => Promise<void>
) {
const isRootProject =
context.projectGraph.nodes[context.projectName].data.root === '.';
logger.log(`Compiling with SWC for ${context.projectName}...`);

if (normalizedOptions.clean) {
Expand Down

0 comments on commit c57c15b

Please sign in to comment.