Skip to content

Commit

Permalink
fix(core): set SWC_NODE_PROJECT before registering `@swc-node/registe…
Browse files Browse the repository at this point in the history
…r` (#19239)
  • Loading branch information
Cammisuli authored Sep 20, 2023
1 parent 3300fbd commit 9a919a0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/nx/src/plugins/js/utils/register.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -44,6 +46,11 @@ export function getSwcTranspiler(
const register = require('@swc-node/register/register')
.register as ISwcRegister;

let rootTsConfig = join(workspaceRoot, 'tsconfig.base.json');
if (existsSync(rootTsConfig)) {
process.env.SWC_NODE_PROJECT = rootTsConfig;
}

const cleanupFn = register(compilerOptions);

return typeof cleanupFn === 'function' ? cleanupFn : () => {};
Expand Down

0 comments on commit 9a919a0

Please sign in to comment.