From 71bd3e13ada518412477eb78b3a7e8f206ea747a Mon Sep 17 00:00:00 2001 From: Chau Tran Date: Sun, 13 Mar 2022 22:07:09 -0500 Subject: [PATCH] fix(js): default swcCwd to '.' to prevent ENOENT error when invoking swc cli (#9256) Co-authored-by: Chau Tran --- packages/js/src/executors/swc/swc.impl.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/js/src/executors/swc/swc.impl.ts b/packages/js/src/executors/swc/swc.impl.ts index 7ca464435ee5d..0b860dc195c9f 100644 --- a/packages/js/src/executors/swc/swc.impl.ts +++ b/packages/js/src/executors/swc/swc.impl.ts @@ -42,7 +42,9 @@ function normalizeOptions( // We pop the last part of the `projectRoot` to pass // the last part (projectDir) and the remainder (projectRootParts) to swc const projectDir = projectRootParts.pop(); - const swcCwd = projectRootParts.join('/'); + // default to current directory if projectRootParts is []. + // Eg: when a project is at the root level, outside of layout dir + const swcCwd = projectRootParts.join('/') || '.'; const swcCliOptions = { srcPath: projectDir,