fix(otel): mark peer dependencies as optional #1812
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What was changed
Mark
@temporalio/*peer dependencies as optional when they are not required in all cases.@temporalio/commonis still a required peer dep as all interceptors require it.Only special handling of
@temporalio/workflowis needed as the rest of the peer dependencies are only used for types and do not actually get loaded at runtime. If any of the workflow interceptors are constructed without the dependency, it will rethrow the original module resolution error.It should be noted that this approach only works due to the fact we're producing CJS. If we want to produce both CJS and ESM we will need to change our approach.
Why?
If workers/clients are split up into different packages, the client package does not need a dependency on
@temporalio/workflowin order to properly use the client only OTEL interceptors.Checklist
Closes [Bug] Remove peer dependencies from @temporalio/interceptors-opentelemetry #1785
How was this tested:
Made a quick example project without
@temporalio/workflowas a peer dep:Adding the dependency:
Updated doc comments for workflow interceptors.