diff --git a/docs/generated/devkit/NxJsonConfiguration.md b/docs/generated/devkit/NxJsonConfiguration.md index 630091b22a9b9..31acb770eae97 100644 --- a/docs/generated/devkit/NxJsonConfiguration.md +++ b/docs/generated/devkit/NxJsonConfiguration.md @@ -32,7 +32,7 @@ Nx.json configuration - [nxCloudEncryptionKey](../../devkit/documents/NxJsonConfiguration#nxcloudencryptionkey): string - [nxCloudUrl](../../devkit/documents/NxJsonConfiguration#nxcloudurl): string - [parallel](../../devkit/documents/NxJsonConfiguration#parallel): number -- [plugins](../../devkit/documents/NxJsonConfiguration#plugins): PluginDefinition[] +- [plugins](../../devkit/documents/NxJsonConfiguration#plugins): PluginConfiguration[] - [pluginsConfig](../../devkit/documents/NxJsonConfiguration#pluginsconfig): Record<string, Record<string, unknown>> - [release](../../devkit/documents/NxJsonConfiguration#release): NxReleaseConfiguration - [targetDefaults](../../devkit/documents/NxJsonConfiguration#targetdefaults): TargetDefaults @@ -198,7 +198,7 @@ Specifies how many tasks can be run in parallel. ### plugins -• `Optional` **plugins**: `PluginDefinition`[] +• `Optional` **plugins**: [`PluginConfiguration`](../../devkit/documents/PluginConfiguration)[] Plugins for extending the project graph diff --git a/docs/generated/devkit/PluginConfiguration.md b/docs/generated/devkit/PluginConfiguration.md new file mode 100644 index 0000000000000..cbc972d9c02d6 --- /dev/null +++ b/docs/generated/devkit/PluginConfiguration.md @@ -0,0 +1,3 @@ +# Type alias: PluginConfiguration + +Ƭ **PluginConfiguration**: `string` \| { `options?`: `unknown` ; `plugin`: `string` } diff --git a/docs/generated/devkit/README.md b/docs/generated/devkit/README.md index 9ff7a125e01a0..8c894d00c6771 100644 --- a/docs/generated/devkit/README.md +++ b/docs/generated/devkit/README.md @@ -77,6 +77,7 @@ It only uses language primitives and immutable objects - [NxPluginV1](../../devkit/documents/NxPluginV1) - [NxPluginV2](../../devkit/documents/NxPluginV2) - [PackageManager](../../devkit/documents/PackageManager) +- [PluginConfiguration](../../devkit/documents/PluginConfiguration) - [ProjectGraphNode](../../devkit/documents/ProjectGraphNode) - [ProjectTargetConfigurator](../../devkit/documents/ProjectTargetConfigurator) - [ProjectType](../../devkit/documents/ProjectType) diff --git a/docs/generated/devkit/Workspace.md b/docs/generated/devkit/Workspace.md index b10eb82517971..0862d7d733ad2 100644 --- a/docs/generated/devkit/Workspace.md +++ b/docs/generated/devkit/Workspace.md @@ -30,7 +30,7 @@ use ProjectsConfigurations or NxJsonConfiguration - [nxCloudEncryptionKey](../../devkit/documents/Workspace#nxcloudencryptionkey): string - [nxCloudUrl](../../devkit/documents/Workspace#nxcloudurl): string - [parallel](../../devkit/documents/Workspace#parallel): number -- [plugins](../../devkit/documents/Workspace#plugins): PluginDefinition[] +- [plugins](../../devkit/documents/Workspace#plugins): PluginConfiguration[] - [pluginsConfig](../../devkit/documents/Workspace#pluginsconfig): Record<string, Record<string, unknown>> - [projects](../../devkit/documents/Workspace#projects): Record<string, ProjectConfiguration> - [release](../../devkit/documents/Workspace#release): NxReleaseConfiguration @@ -254,7 +254,7 @@ Specifies how many tasks can be run in parallel. ### plugins -• `Optional` **plugins**: `PluginDefinition`[] +• `Optional` **plugins**: [`PluginConfiguration`](../../devkit/documents/PluginConfiguration)[] Plugins for extending the project graph diff --git a/docs/generated/packages/devkit/documents/nx_devkit.md b/docs/generated/packages/devkit/documents/nx_devkit.md index 9ff7a125e01a0..8c894d00c6771 100644 --- a/docs/generated/packages/devkit/documents/nx_devkit.md +++ b/docs/generated/packages/devkit/documents/nx_devkit.md @@ -77,6 +77,7 @@ It only uses language primitives and immutable objects - [NxPluginV1](../../devkit/documents/NxPluginV1) - [NxPluginV2](../../devkit/documents/NxPluginV2) - [PackageManager](../../devkit/documents/PackageManager) +- [PluginConfiguration](../../devkit/documents/PluginConfiguration) - [ProjectGraphNode](../../devkit/documents/ProjectGraphNode) - [ProjectTargetConfigurator](../../devkit/documents/ProjectTargetConfigurator) - [ProjectType](../../devkit/documents/ProjectType) diff --git a/packages/nx/src/config/nx-json.ts b/packages/nx/src/config/nx-json.ts index 1abe6235872a6..2d2d52ca7b1ec 100644 --- a/packages/nx/src/config/nx-json.ts +++ b/packages/nx/src/config/nx-json.ts @@ -167,7 +167,7 @@ export interface NxJsonConfiguration { /** * Plugins for extending the project graph */ - plugins?: PluginDefinition[]; + plugins?: PluginConfiguration[]; /** * Configuration for Nx Plugins @@ -225,9 +225,9 @@ export interface NxJsonConfiguration { useDaemonProcess?: boolean; } -export type PluginDefinition = +export type PluginConfiguration = | string - | { plugin: string; options?: Record }; + | { plugin: string; options?: unknown }; export function readNxJson(root: string = workspaceRoot): NxJsonConfiguration { const nxJson = join(root, 'nx.json'); diff --git a/packages/nx/src/devkit-exports.ts b/packages/nx/src/devkit-exports.ts index a14192dbc115f..c3d4b39ba1563 100644 --- a/packages/nx/src/devkit-exports.ts +++ b/packages/nx/src/devkit-exports.ts @@ -69,6 +69,7 @@ export type { ImplicitDependencyEntry, ImplicitJsonSubsetDependency, NxJsonConfiguration, + PluginConfiguration, TargetDefaults, NxAffectedConfig, } from './config/nx-json'; diff --git a/packages/nx/src/project-graph/nx-deps-cache.ts b/packages/nx/src/project-graph/nx-deps-cache.ts index 93a8aa54acfc0..b5cfc9a7ff062 100644 --- a/packages/nx/src/project-graph/nx-deps-cache.ts +++ b/packages/nx/src/project-graph/nx-deps-cache.ts @@ -2,7 +2,7 @@ import { existsSync } from 'fs'; import { ensureDirSync, renameSync } from 'fs-extra'; import { join } from 'path'; import { performance } from 'perf_hooks'; -import { NxJsonConfiguration, PluginDefinition } from '../config/nx-json'; +import { NxJsonConfiguration, PluginConfiguration } from '../config/nx-json'; import { FileData, FileMap, @@ -328,7 +328,7 @@ function processProjectNode( type PluginData = { name: string; version: string; - options?: Record; + options?: unknown; }; function getNxJsonPluginsData( diff --git a/packages/nx/src/utils/nx-plugin.ts b/packages/nx/src/utils/nx-plugin.ts index d40116aac866a..94998916f6d71 100644 --- a/packages/nx/src/utils/nx-plugin.ts +++ b/packages/nx/src/utils/nx-plugin.ts @@ -27,7 +27,7 @@ import { normalizePath } from './path'; import { dirname, join } from 'path'; import { getNxRequirePaths } from './installation-directory'; import { readTsConfig } from '../plugins/js/utils/typescript'; -import { NxJsonConfiguration, PluginDefinition } from '../config/nx-json'; +import { NxJsonConfiguration, PluginConfiguration } from '../config/nx-json'; import type * as ts from 'typescript'; import { retrieveProjectConfigurationsWithoutPluginInference } from '../project-graph/utils/retrieve-workspace-files'; @@ -194,14 +194,14 @@ function getPluginPathAndName( } export async function loadNxPluginAsync( - pluginDefinition: PluginDefinition, + pluginConfiguration: PluginConfiguration, paths: string[], root: string ): Promise { const { plugin: moduleName, options } = - typeof pluginDefinition === 'object' - ? pluginDefinition - : { plugin: pluginDefinition, options: undefined }; + typeof pluginConfiguration === 'object' + ? pluginConfiguration + : { plugin: pluginConfiguration, options: undefined }; let pluginModule = nxPluginCache.get(moduleName); if (pluginModule) { return { plugin: pluginModule, options }; @@ -217,14 +217,14 @@ export async function loadNxPluginAsync( } function loadNxPluginSync( - pluginDefinition: PluginDefinition, + pluginConfiguration: PluginConfiguration, paths: string[], root: string ): LoadedNxPlugin { const { plugin: moduleName, options } = - typeof pluginDefinition === 'object' - ? pluginDefinition - : { plugin: pluginDefinition, options: undefined }; + typeof pluginConfiguration === 'object' + ? pluginConfiguration + : { plugin: pluginConfiguration, options: undefined }; let pluginModule = nxPluginCache.get(moduleName); if (pluginModule) { return { plugin: pluginModule, options }; @@ -280,7 +280,7 @@ export function loadNxPluginsSync( } export async function loadNxPlugins( - plugins: PluginDefinition[], + plugins: PluginConfiguration[], paths = getNxRequirePaths(), root = workspaceRoot ): Promise {