Skip to content

Commit

Permalink
fix(core): pick up changes to plugins configuration in daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Jun 21, 2024
1 parent efd0994 commit 5a74f2a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/nx/src/daemon/server/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
import { hashObject } from '../../hasher/file-hasher';
import { readNxJson } from '../../config/nx-json';
import {
LoadedNxPlugin,
loadNxPlugins,
} from '../../project-graph/plugins/internal-api';
import { workspaceRoot } from '../../utils/workspace-root';

let currentPluginsConfigurationHash: string;
let loadedPlugins: LoadedNxPlugin[];
let cleanup: () => void;

export async function getPlugins() {
if (loadedPlugins) {
const pluginsConfiguration = readNxJson().plugins ?? [];
const pluginsConfigurationHash = hashObject(pluginsConfiguration);

// If the plugins configuration has not changed, reuse the current plugins
if (
loadedPlugins &&
pluginsConfigurationHash === currentPluginsConfigurationHash
) {
return loadedPlugins;
}
const pluginsConfiguration = readNxJson().plugins ?? [];

// Cleanup current plugins before loading new ones
if (cleanup) {
cleanup();
}

currentPluginsConfigurationHash = pluginsConfigurationHash;
const [result, cleanupFn] = await loadNxPlugins(
pluginsConfiguration,
workspaceRoot
Expand Down

0 comments on commit 5a74f2a

Please sign in to comment.