From 22dadbc9b4bbb7039e8336b150fcb4e791b0de36 Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Wed, 6 Sep 2023 13:27:01 -0500 Subject: [PATCH] fix(core): register ts transpiler when running .ts backed plugins (#19027) (cherry picked from commit 2526967fc5fc841a33bc77ff347bd1869d2f442a) --- packages/nx/src/utils/nx-plugin.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/nx/src/utils/nx-plugin.ts b/packages/nx/src/utils/nx-plugin.ts index b86d1c414730ca..8beadb54df6918 100644 --- a/packages/nx/src/utils/nx-plugin.ts +++ b/packages/nx/src/utils/nx-plugin.ts @@ -172,8 +172,16 @@ function getPluginPathAndName( } const packageJsonPath = path.join(pluginPath, 'package.json'); + const extension = path.extname(pluginPath); + + // Register the ts-transpiler if we are pointing to a + // plain ts file that's not part of a plugin project + if (extension === '.ts' && !tsNodeAndPathsRegistered) { + registerPluginTSTranspiler(); + } + const { name } = - !['.ts', '.js'].some((x) => x === path.extname(pluginPath)) && // Not trying to point to a ts or js file + !['.ts', '.js'].some((x) => x === extension) && // Not trying to point to a ts or js file existsSync(packageJsonPath) // plugin has a package.json ? readJsonFile(packageJsonPath) // read name from package.json : { name: moduleName };