Skip to content

Commit

Permalink
fix(core): nx plugin cache should load new plugins (#15072)
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder authored Feb 17, 2023
1 parent 1e6a4f8 commit e575c49
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/nx/src/utils/nx-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface NxPlugin {
// holding resolved nx plugin objects.
// Allows loadNxPlugins to be called multiple times w/o
// executing resolution mulitple times.
let nxPluginCache: NxPlugin[] = null;
let nxPluginCache: Map<string, NxPlugin> = new Map();

function loadNxPlugin(moduleName: string, paths: string[], root: string) {
let pluginPath: string;
Expand Down Expand Up @@ -98,13 +98,16 @@ export function loadNxPlugins(
result.push(jsPlugin as NxPlugin);

plugins ??= [];
if (!nxPluginCache) {
nxPluginCache = plugins.map((moduleName) =>
loadNxPlugin(moduleName, paths, root)
);
for (const plugin of plugins) {
let pluginModule = nxPluginCache.get(plugin);
if (!pluginModule) {
pluginModule = loadNxPlugin(plugin, paths, root);
nxPluginCache.set(plugin, pluginModule);
}
result.push(pluginModule);
}

return result.concat(nxPluginCache);
return result;
}

export function mergePluginTargetsWithNxTargets(
Expand Down

1 comment on commit e575c49

@vercel
Copy link

@vercel vercel bot commented on e575c49 Feb 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev
nx-dev-nrwl.vercel.app

Please sign in to comment.