fix(core): register ts transpiler when running .ts backed plugins (#19027)

This commit is contained in:
Craigory Coppola 2023-09-06 13:27:01 -05:00 committed by GitHub
parent f30174b677
commit 2526967fc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 };