Repository navigation
Fix dual ESM/CJS output, Azure Monitor disable flag - #30
Merged
Hector Hernandez (hectorhdzg) merged 3 commits intoApr 22, 2026
Merged
Hector Hernandez (hectorhdzg) merged 3 commits into
Hector Hernandez (hectorhdzg) merged 3 commits into
Conversation
Hector Hernandez (hectorhdzg)
commented
Apr 22, 2026
Member
- Add post-build CJS fixups (scripts/fixup-cjs.cjs):
- dist/commonjs/package.json with {type:commonjs} so Node respects CJS
- Copy module-cjs.cts polyfill over module.ts (import.meta.url is ESM-only)
- Fix Azure Functions default-import in CJS output (__importDefault double-wrap)
- Fix Azure Functions import for ESM: use default-import + destructure because the package is a webpack bundle and Node ESM cannot extract named exports
- Add enabled flag to AzureMonitorOpenTelemetryOptions (default true) so consumers can run the distro without Azure Monitor
- Make all Azure Monitor handlers conditional in distro.ts
- Add missing re-exports to index.ts: Modality, InvocationRole, A365_MESSAGE_SCHEMA_VERSION, TextPart, ToolCallRequestPart, ToolCallResponsePart, ReasoningPart
- Add post-build CJS fixups (scripts/fixup-cjs.cjs):
* dist/commonjs/package.json with {type:commonjs} so Node respects CJS
* Copy module-cjs.cts polyfill over module.ts (import.meta.url is ESM-only)
* Fix Azure Functions default-import in CJS output (__importDefault double-wrap)
- Fix Azure Functions import for ESM: use default-import + destructure
because the package is a webpack bundle and Node ESM cannot extract named exports
- Add enabled flag to AzureMonitorOpenTelemetryOptions (default true)
so consumers can run the distro without Azure Monitor
- Make all Azure Monitor handlers conditional in distro.ts
- Add missing re-exports to index.ts: Modality, InvocationRole,
A365_MESSAGE_SCHEMA_VERSION, TextPart, ToolCallRequestPart,
ToolCallResponsePart, ReasoningPart
Hector Hernandez (hectorhdzg)
requested review from
Jackson Weber (JacksonWeber),
Nev (MSNev),
Leighton Chen (lzchen) and
Radhika Gupta (rads-1996)
as code owners
April 22, 2026 01:00
Copilot started reviewing on behalf of
Hector Hernandez (hectorhdzg)
April 22, 2026 01:01
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the package’s dual ESM/CJS distribution behavior (especially around Azure Functions + CJS semantics) and introduces an azureMonitor.enabled flag so consumers can run the distro without Azure Monitor while still using other components.
Changes:
- Add a post-build step to patch
dist/commonjsso Node treats it as CJS and to fix Azure Functions import output. - Add
azureMonitor.enabled?: boolean(default true) and conditionally initialize Azure Monitor components/handlers inuseMicrosoftOpenTelemetry(). - Add missing public re-exports from the A365 surface and adjust tests to explicitly disable Azure Functions instrumentation where needed.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/internal/unit/traces/traceHandler.test.ts | Explicitly disables azureFunctions instrumentation in relevant test configs. |
| src/types.ts | Adds AzureMonitorOpenTelemetryOptions.enabled?: boolean to support disabling Azure Monitor. |
| src/index.ts | Re-exports additional A365 enums/constants/types from the top-level entrypoint. |
| src/distro/distro.ts | Makes Azure Monitor setup conditional and avoids registering its handlers when disabled. |
| src/azureMonitor/traces/handler.ts | Switches Azure Functions instrumentation import style to work in Node ESM for a bundled CJS module. |
| scripts/fixup-cjs.cjs | New post-build script to correct CJS output behavior in dist/commonjs. |
| package.json | Wires fixup-cjs into the build script. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…tro-javascript into hectorhdzg/distro-fixes
Radhika Gupta (rads-1996)
approved these changes
Apr 22, 2026
Hector Hernandez (hectorhdzg)
merged commit Apr 22, 2026
2b461db
into
microsoft:main
5 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.