From 9b2873d3e602f8ec49b1e015187446040b0d7ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Mon, 11 Mar 2024 11:51:05 +0100 Subject: [PATCH] fix(js): use NodeJs moduleResolution with ts-node to support CommonJS module and TS 4.x --- packages/nx/src/plugins/js/utils/register.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nx/src/plugins/js/utils/register.ts b/packages/nx/src/plugins/js/utils/register.ts index 6377452f9d239..6f4a3439328ce 100644 --- a/packages/nx/src/plugins/js/utils/register.ts +++ b/packages/nx/src/plugins/js/utils/register.ts @@ -112,7 +112,9 @@ export function getTranspiler(compilerOptions: CompilerOptions) { compilerOptions.lib = ['es2021']; compilerOptions.module = ts.ModuleKind.CommonJS; - compilerOptions.moduleResolution = ts.ModuleResolutionKind.Node10; + // use NodeJs module resolution until support for TS 4.x is dropped and then + // we can switch to Node10 + compilerOptions.moduleResolution = ts.ModuleResolutionKind.NodeJs; compilerOptions.target = ts.ScriptTarget.ES2021; compilerOptions.inlineSourceMap = true; compilerOptions.skipLibCheck = true;