Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): set SWC_NODE_PROJECT before registering @swc-node/register #19239

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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