From 6876e6583819e18ac726806693b52eae96f5af67 Mon Sep 17 00:00:00 2001 From: Jonathan Cammisuli Date: Tue, 19 Sep 2023 13:40:06 -0400 Subject: [PATCH 1/2] fix(core): set SWC_NODE_PROJECT for swc registering --- packages/nx/src/plugins/js/utils/register.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/nx/src/plugins/js/utils/register.ts b/packages/nx/src/plugins/js/utils/register.ts index 47bd4dfcd6512..f9692d51f11e4 100644 --- a/packages/nx/src/plugins/js/utils/register.ts +++ b/packages/nx/src/plugins/js/utils/register.ts @@ -1,6 +1,8 @@ import { dirname, join } from 'path'; import type { CompilerOptions } from 'typescript'; import { logger, NX_PREFIX, stripIndent } from '../../../utils/logger'; +import { existsSync } from 'fs'; +import { workspaceRoot } from '../../../utils/workspace-root'; const swcNodeInstalled = packageIsInstalled('@swc-node/register'); const tsNodeInstalled = packageIsInstalled('ts-node/register'); @@ -44,6 +46,10 @@ export function getSwcTranspiler( const register = require('@swc-node/register/register') .register as ISwcRegister; + if (existsSync(join(workspaceRoot, 'tsconfig.base.json'))) { + process.env.SWC_NODE_PROJECT = 'tsconfig.base.json'; + } + const cleanupFn = register(compilerOptions); return typeof cleanupFn === 'function' ? cleanupFn : () => {}; From 5a537c1c059b1c6e6bbd58b36e71a6f76f5b0e18 Mon Sep 17 00:00:00 2001 From: Jonathan Cammisuli Date: Tue, 19 Sep 2023 13:56:45 -0400 Subject: [PATCH 2/2] fix(core): set the full path to the tsconfig.base.json --- packages/nx/src/plugins/js/utils/register.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/nx/src/plugins/js/utils/register.ts b/packages/nx/src/plugins/js/utils/register.ts index f9692d51f11e4..f60d7bbde2bf1 100644 --- a/packages/nx/src/plugins/js/utils/register.ts +++ b/packages/nx/src/plugins/js/utils/register.ts @@ -46,8 +46,9 @@ export function getSwcTranspiler( const register = require('@swc-node/register/register') .register as ISwcRegister; - if (existsSync(join(workspaceRoot, 'tsconfig.base.json'))) { - process.env.SWC_NODE_PROJECT = 'tsconfig.base.json'; + let rootTsConfig = join(workspaceRoot, 'tsconfig.base.json'); + if (existsSync(rootTsConfig)) { + process.env.SWC_NODE_PROJECT = rootTsConfig; } const cleanupFn = register(compilerOptions);