Skip to content

Switch to named imports without subpaths#561

Merged
Jesperholmbergmsft merged 5 commits into
microsoft:mainfrom
Jesperholmbergmsft:jh/namedImports
May 8, 2026
Merged

Switch to named imports without subpaths#561
Jesperholmbergmsft merged 5 commits into
microsoft:mainfrom
Jesperholmbergmsft:jh/namedImports

Conversation

@Jesperholmbergmsft
Copy link
Copy Markdown
Contributor

@Jesperholmbergmsft Jesperholmbergmsft commented May 7, 2026

While setting up some sample projects to repro & test a fix for bug 542, I realized that on older webpack I had to add babel configuration to work around subpath imports inside of the teams.ts libraries. I had to add the alias section here to my webpack.frontend.config.js just for a basic tab test app. Which is doable, but also unnecessary friction:

  resolve: {
    extensions: [".tsx", ".ts", ".js"],
    mainFields: ["main", "module", "browser"],
    alias: {
      "@microsoft/teams.common/http$": path.resolve(
        __dirname,
        "node_modules/@microsoft/teams.common/dist/http/index.js"
      ),
      "@microsoft/teams.common/logging$": path.resolve(
        __dirname,
        "node_modules/@microsoft/teams.common/dist/logging/index.js"
      ),
    },
  },

In addition, I noticed that we often use wildcard imports for readability, but on older bundlers this may impact tree shakability.

Let's clean up both of these and switch to named imports without subpaths. There are no code changes from this, just a bunch of routine imports & type alias changes.

How tested:

  • Built & packed the packages locally; npm installed them into my test project; verified that I could now remove the alias section
  • Build passes, linter passes, unit tests pass.
  • Verified that the diffs detected by Template Sync Verification are false positives, as they didn't have the same imports in the first place. skip-test-verification

@Jesperholmbergmsft Jesperholmbergmsft marked this pull request as ready for review May 7, 2026 03:18
Copilot AI review requested due to automatic review settings May 7, 2026 03:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes imports across the repo by removing @microsoft/* subpath imports (e.g. @microsoft/teams.common/http, @microsoft/teams.common/logging) and replacing wildcard imports with named imports to reduce bundler friction (notably with older webpack setups) and improve tree-shakability.

Changes:

  • Replaced @microsoft/teams.common/* subpath imports with @microsoft/teams.common named imports across packages, templates, and examples.
  • Replaced some namespace (import * as …) usage with named imports (notably @azure/msal-browser, @microsoft/teams-js, @microsoft/teams.graph, @microsoft/teams.api).
  • Updated Jest mocks to target @microsoft/teams.common instead of subpath modules.

Reviewed changes

Copilot reviewed 55 out of 55 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
packages/openai/src/chat.ts Switch logging imports to @microsoft/teams.common root.
packages/openai/src/audio.ts Switch logging imports to @microsoft/teams.common root.
packages/graph/src/utils/url.ts Replace http subpath type usage with RequestConfig from @microsoft/teams.common.
packages/graph/src/types.ts Replace http subpath type usage with RequestConfig from @microsoft/teams.common.
packages/graph/src/index.ts Replace http subpath module import with HttpClient/HttpClientOptions from @microsoft/teams.common.
packages/graph/src/index.spec.ts Update Jest mocking/imports to mock @microsoft/teams.common root.
packages/devtools/src/components/Logger/Logger.ts Switch ConsoleLogger import to @microsoft/teams.common root.
packages/dev/src/routes/context.ts Switch ILogger import to @microsoft/teams.common root.
packages/client/src/msal-utils.ts Replace MSAL namespace import with named imports; switch ILogger import to @microsoft/teams.common root.
packages/client/src/graph-utils.ts Switch http/logging imports to @microsoft/teams.common root and graph client to named import.
packages/client/src/graph-utils.spec.ts Update Jest mocking to mock @microsoft/teams.common root.
packages/client/src/app.ts Replace MSAL/teams-js/http/logging/graph namespace imports with named imports from package roots.
packages/client/src/app.spec.ts Update Jest mocking to mock @microsoft/teams.common root.
packages/cli/templates/typescript/tab/src/index.ts Switch ConsoleLogger import to @microsoft/teams.common root.
packages/cli/templates/typescript/ai/src/index.ts Switch LocalStorage import to @microsoft/teams.common root.
packages/botbuilder/src/plugin.ts Replace http subpath import with HttpClient named import from @microsoft/teams.common.
packages/apps/src/middleware/strip-mentions-text.ts Replace @microsoft/teams.api namespace import with named imports and alias.
packages/apps/src/contexts/activity.ts Switch logging/storage imports to @microsoft/teams.common root.
packages/apps/src/contexts/activity.test.ts Switch logging/storage imports to @microsoft/teams.common root.
packages/apps/src/app.ts Collapse events/http/logging/storage imports into a single @microsoft/teams.common named import.
packages/apps/src/app.plugin.spec.ts Switch ConsoleLogger import to @microsoft/teams.common root.
packages/apps/src/app.oauth.ts Switch graph namespace import to named Client import.
packages/apps/src/api.ts Replace local re-aliasing with direct re-exports of Client from api/graph packages.
packages/apps/src/activity-sender.ts Replace http subpath import with HttpClient named import from @microsoft/teams.common.
packages/apps/src/activity-sender.spec.ts Replace http subpath import with HttpClient named import from @microsoft/teams.common.
packages/api/src/clients/user/token.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/user/token.spec.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/user/index.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/team.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/team.spec.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/reaction/reaction.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/reaction/reaction.spec.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/meeting.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/meeting.spec.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/index.ts Switch http subpath imports to @microsoft/teams.common root and rename to HttpClient.
packages/api/src/clients/conversation/members.spec.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/conversation/member.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/conversation/index.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/conversation/activity.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/conversation/activity.spec.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/bot/sign-in.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/bot/sign-in.spec.ts Switch http subpath imports to @microsoft/teams.common root.
packages/api/src/clients/bot/index.ts Switch http subpath imports to @microsoft/teams.common root.
examples/threading/src/index.ts Switch ConsoleLogger import to @microsoft/teams.common root.
examples/targeted-messages/src/index.ts Switch ConsoleLogger import to @microsoft/teams.common root.
examples/tab/src/index.ts Switch ConsoleLogger import to @microsoft/teams.common root.
examples/reactions/src/index.ts Switch ConsoleLogger import to @microsoft/teams.common root.
examples/proactive-messaging/src/index.ts Switch ConsoleLogger import to @microsoft/teams.common root.
examples/message-extensions/src/index.ts Switch ConsoleLogger import to @microsoft/teams.common root.
examples/meetings/src/index.ts Switch ConsoleLogger import to @microsoft/teams.common root.
examples/mcp-server/src/app.ts Switch ConsoleLogger import to @microsoft/teams.common root.
examples/lights/src/index.ts Switch ConsoleLogger/LocalStorage imports to @microsoft/teams.common root.
examples/graph/src/index.ts Switch ConsoleLogger import to @microsoft/teams.common root; minor comment whitespace fix.
examples/echo/src/index.ts Switch ConsoleLogger import to @microsoft/teams.common root.
examples/botbuilder/src/index.ts Switch ConsoleLogger import to @microsoft/teams.common root.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/graph/src/index.ts
Comment thread packages/apps/src/app.ts
Comment thread packages/client/src/graph-utils.ts Outdated
Comment thread packages/api/src/clients/index.ts Outdated
Comment thread packages/apps/src/middleware/strip-mentions-text.ts
Comment thread packages/client/src/msal-utils.ts
Comment thread packages/client/src/app.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 55 out of 55 changed files in this pull request and generated 2 comments.

Comment thread packages/client/src/app.ts
Comment thread packages/apps/src/activity-sender.spec.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 55 out of 55 changed files in this pull request and generated 1 comment.

Comment thread packages/api/src/clients/user/token.ts Outdated
@Jesperholmbergmsft Jesperholmbergmsft requested a review from Copilot May 7, 2026 14:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 55 out of 55 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (4)

packages/client/src/graph-utils.ts:1

  • There’s an extra nested block scope inside buildGraphClient ({ on line 10) that doesn’t provide value and adds visual noise. Removing the redundant block will simplify the function body without changing behavior.
    packages/client/src/app.ts:1
  • This import has inconsistent spacing (import␠␠{ ... }). Please normalize spacing to match typical formatting (single space after import and inside braces) to avoid churn in auto-formatters and keep style consistent.
    packages/graph/src/index.spec.ts:1
  • The named import is missing a space before } (HttpClient}). Please normalize spacing to keep imports consistent and reduce formatter diffs.
    packages/dev/src/routes/context.ts:1
  • ILogger is a type-only symbol in this file context. Prefer import type { ILogger } ... to ensure the import is always elided under verbatimModuleSyntax/ESM settings and to make intent explicit.

Comment thread packages/apps/src/app.oauth.ts Outdated
Comment thread packages/client/src/app.ts Outdated
Comment thread packages/graph/src/index.spec.ts Outdated
Comment thread examples/graph/src/index.ts
Copy link
Copy Markdown
Collaborator

@heyitsaamir heyitsaamir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ty for cleaning up!

Copy link
Copy Markdown
Collaborator

@corinagum corinagum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few nits. Thank you!

@Jesperholmbergmsft Jesperholmbergmsft merged commit 3391d49 into microsoft:main May 8, 2026
4 checks passed
corinagum added a commit that referenced this pull request May 27, 2026
## Summary

Brings `origin/main` into `release` for the **2.0.12** release. **No
carve-outs this time** — Quoted Replies is included.

`version.json`: `2.0.12-preview.{height}` → `2.0.12`.

Aligns with teams.py 2.0.12 (PR #442 already on PyPI / pending publish).

## What's in this release (delta from 2.0.11)

**Features**
- Quoted Replies + new quotes features — previously held back via the
2.0.11 carve-out (#576)
- SuggestedActionSubmitActivity for `suggestedAction/submit` invoke
(#591)
- Default targeted replies for targeted inbound messages (#592)
- Filter colliding keys before `Object.assign` in `ActivityContext`
(#596)
- Prompt Preview support (#536)
- A2A sample (#584)
- AI/MCPClient (#572)
- Allow passing custom HTTP client via `AppOptions`-equivalent
- Reactions API marked GA (#575), Rename `ReactionClient.remove()` →
`delete()` (#567)

**Security & fixes**
- Security hardening: tighten cross-origin policies (#595)
- Lock JsonWebToken trust-boundary contract (#586)
- `fix(deps)`: npm audit fix — clears all high-severity advisories
(#599)
- `fix(apps)`: log inbound activities at info, warn on missing
Authorization (#568)
- `fix`: App user-agent merging (#573)
- `fix`: Add null checks in `local-memory.ts` to prevent role crash
(#438)
- `fix`: `@microsoft/teams.client` import error in webpack 5 (#566)
- Switch to named imports without subpaths (#561)

**Deprecations / package changes**
- Deprecate `DevtoolsPlugin` in favor of Microsoft 365 Agents Playground
(#593)
- Remove in-repo Teams CLI package (#580) — moved to
`teams-sdk/packages/cli`
- Deprecate AI Libraries (#588)
- Correct imports + return types in misc. packages (#589)

**Dependency bumps**
- turbo 2.8.11 → 2.9.14 (#587)
- qs 6.15.0 → 6.15.2 (#594)
- hono 4.12.14 → 4.12.16 (#562)
- npm audit fix bundle (#599): axios 1.13.5 → 1.16.1, fast-uri 3.1.0 →
3.1.2, ws 8.19.0 → 8.21.0, @azure/msal-node hoisted 5.2.2, uuid 11.1.0 →
11.1.1, @azure/identity 4.13.0 → 4.13.1, express-rate-limit, ip-address,
brace-expansion, etc.

## Quoted Replies inclusion notes

- Teams client rendering is in-sync with the wire format as of
2026-05-06.
- APX QR rollout completed: Public 2026-04-10, GCCH/DoD/Gallatin
2026-04-14.
- No SDK-side carve-outs needed; this matches the teams.py 2.0.12 (PR
#442) decision.

## Branch structure note

`prep-release/2.0.12` is reset to `origin/main` + a one-line
`version.json` bump. Diff against `release` (this PR) shows the full
delta from 2.0.11. We deliberately did not use a 2-parent merge commit —
the auto-merge tried to interleave non-overlapping hunks from main's QR
additions with release's QR carve-outs in `activity.ts`, producing a
semantically broken file. Reset-to-main + version bump is the clean way
to express "release should equal main."

## Test plan

- [x] `npm install` clean (post-audit-fix lockfile)
- [x] `npm run build` — 33/33 targets clean
- [x] `npm test` — 14/14 task targets, 279+ tests pass
- [x] E2E echo bot smoke test against `cg-test-bot-py` via canary ABS —
done on `cg/audit-deps-ts` (now merged); covers axios + msal-node code
paths
- [ ] Pipeline Build + Test stages green on `release` after merge
- [ ] Publish pipeline run with **Public** → ESRP → npm
`@microsoft/teams.*@2.0.12`
- [ ] Smoke install: `npm view @microsoft/teams.apps@2.0.12` after
publish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants