azure-sdk-for-js
azure-sdk-for-js copied to clipboard
[identity] Decouple identity plugin code from identity source code
Identity CI builds started failing because of build errors in identity-cache-persistence.
This is due to an implicit dependency on @azure/core-client via pulling in of source files from identity directly:
Because the plugin packages have a runtime dependency on a published version of identity, they pull in source files directly from the source tree. That means that if the version of identity on disk has not been built, core-client will not be built (like when identity in the repo is a major version bump or beta). As a result, trying to build the plugin package causes:
../identity/src/client/identityClient.ts(6,31): error TS2307: Cannot find module '@azure/core-client' or its corresponding type declarations.
../identity/src/client/identityClient.ts(75,38): error TS2339: Property 'userAgentOptions' does not exist on type 'TokenCredentialOptions'.
../identity/src/client/identityClient.ts(76,20): error TS2339: Property 'userAgentOptions' does not exist on type 'TokenCredentialOptions'.
../identity/src/client/identityClient.ts(105,33): error TS2339: Property 'sendRequest' does not exist on type 'IdentityClient'.
../identity/src/client/identityClient.ts(262,33): error TS2339: Property 'sendRequest' does not exist on type 'IdentityClient'.
../identity/src/client/identityClient.ts(286,33): error TS2339: Property 'sendRequest' does not exist on type 'IdentityClient'.
../identity/src/credentials/managedIdentityCredential/arcMsi.ts(85,41): error TS2339: Property 'sendRequest' does not exist on type 'IdentityClient'.
../identity/src/credentials/managedIdentityCredential/imdsMsi.ts(138,43): error TS2339: Property 'sendRequest' does not exist on type 'IdentityClient'.
../identity/src/credentials/managedIdentityCredential/index.ts(123,7): error TS2353: Object literal may only specify known properties, and 'retryOptions' does not exist in type 'TokenCredentialOptions'.
../identity/src/tokenCredentialOptions.ts(4,37): error TS2307: Cannot find module '@azure/core-client' or its corresponding type declarations.
Rush is not aware of the build dependency so it's not guaranteed that core-client will be built.
To repro:
- Remove @azure/core-client from @azure/identity-cache-persistence's devDependency list
- Clean out build cache: I use the dangerous
git clean -dfx
command to clear the entire state - Run
rush update && rush build -t @azure/identity-cache-persistence
To resolve:
We should decouple the plugin packages from Identity's source files.
The source dependency is types only. It's a small surface area that IMO can be easily copied over. It's a small duplication cost The test dependencies are a little more involved, but ideally we should not be pulling any files from outside of the plugin directory.