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(misc): pass tsconfig to ts-node register #29129

Open
wants to merge 1 commit into
base: 20.1.x
Choose a base branch
from
Open
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
16 changes: 12 additions & 4 deletions packages/nx/src/plugins/js/utils/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,21 @@ export function getSwcTranspiler(
}

export function getTsNodeTranspiler(
compilerOptions: CompilerOptions
compilerOptions: CompilerOptions,
tsConfigRaw?: unknown
): (...args: unknown[]) => unknown {
const { register } = require('ts-node') as typeof import('ts-node');
const tsConfigRegisterOptions = filterRecognizedTsConfigTsNodeOptions(
tsConfigRaw?.['ts-node']
).recognized;
// ts-node doesn't provide a cleanup method
const service = register({
...tsConfigRegisterOptions,
transpileOnly: true,
compilerOptions: getTsNodeCompilerOptions(compilerOptions),
compilerOptions: getTsNodeCompilerOptions({
...tsConfigRegisterOptions.compilerOptions,
...compilerOptions,
}),
// we already read and provide the compiler options, so prevent ts-node from reading them again
skipProject: true,
});
Expand Down Expand Up @@ -266,7 +274,7 @@ export function getTranspiler(
: undefined;

if (_getTranspiler) {
const transpilerCleanup = _getTranspiler(compilerOptions);
const transpilerCleanup = _getTranspiler(compilerOptions, tsConfigRaw);
const currRegistrationEntry = {
refCount: 1,
cleanup: () => {
Expand Down Expand Up @@ -297,7 +305,7 @@ export function registerTranspiler(
tsConfigRaw?: unknown
): () => void {
// Function to register transpiler that returns cleanup function
const transpiler = getTranspiler(compilerOptions);
const transpiler = getTranspiler(compilerOptions, tsConfigRaw);

if (!transpiler) {
warnNoTranspiler();
Expand Down