Skip to content

Commit

Permalink
fix(core): improve local plugin loading by reading only tsconfig comp…
Browse files Browse the repository at this point in the history
…ile options
  • Loading branch information
jogelin committed Nov 27, 2024
1 parent b018b94 commit 8a8b3a5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
3 changes: 1 addition & 2 deletions packages/nx/src/plugins/js/utils/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ export function getTranspiler(
* @returns cleanup method
*/
export function registerTranspiler(
compilerOptions: CompilerOptions,
tsConfigRaw?: unknown
compilerOptions: CompilerOptions
): () => void {
// Function to register transpiler that returns cleanup function
const transpiler = getTranspiler(compilerOptions);
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/plugins/js/utils/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function readTsConfig(tsConfigPath: string) {
);
}

function readTsConfigOptions(tsConfigPath: string) {
export function readTsConfigOptions(tsConfigPath: string) {
if (!tsModule) {
tsModule = require('typescript');
}
Expand Down
21 changes: 9 additions & 12 deletions packages/nx/src/project-graph/plugins/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
registerTsConfigPaths,
} from '../../plugins/js/utils/register';
import {
ProjectRootMappings,
findProjectForPath,
ProjectRootMappings,
} from '../utils/find-project-for-path';
import { normalizePath } from '../../utils/path';
import { logger } from '../../utils/logger';
Expand All @@ -29,8 +29,8 @@ import { PluginConfiguration } from '../../config/nx-json';
import { retrieveProjectConfigurationsWithoutPluginInference } from '../utils/retrieve-workspace-files';
import { LoadedNxPlugin } from './internal-api';
import { LoadPluginError } from '../error-types';
import { readTsConfigOptions } from '../../plugins/js/utils/typescript';
import path = require('node:path/posix');
import { readTsConfig } from '../../plugins/js/utils/typescript';

export function readPluginPackageJson(
pluginName: string,
Expand Down Expand Up @@ -92,19 +92,16 @@ export function registerPluginTSTranspiler() {
return;
}

const tsConfig: Partial<ts.ParsedCommandLine> = tsConfigName
? readTsConfig(tsConfigName)
const tsConfigOptions: ts.CompilerOptions = tsConfigName
? readTsConfigOptions(tsConfigName)
: {};
const cleanupFns = [
registerTsConfigPaths(tsConfigName),
registerTranspiler(
{
experimentalDecorators: true,
emitDecoratorMetadata: true,
...tsConfig.options,
},
tsConfig.raw
),
registerTranspiler({
experimentalDecorators: true,
emitDecoratorMetadata: true,
...tsConfigOptions,
}),
];
unregisterPluginTSTranspiler = () => {
cleanupFns.forEach((fn) => fn?.());
Expand Down

0 comments on commit 8a8b3a5

Please sign in to comment.