fix(core): nx plugin cache should load new plugins (#15072)

This commit is contained in:
Craigory Coppola 2023-02-17 16:17:03 -05:00 committed by GitHub
parent 1e6a4f8e65
commit e575c49c3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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