Skip to content

chore(vscode-ext-webview): add sideEffects flag and clarify optional peers#786

Closed
tnaum-ms wants to merge 4 commits into
mainfrom
dev/tnaum/webview-api-tweak
Closed

chore(vscode-ext-webview): add sideEffects flag and clarify optional peers#786
tnaum-ms wants to merge 4 commits into
mainfrom
dev/tnaum/webview-api-tweak

Conversation

@tnaum-ms

@tnaum-ms tnaum-ms commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two small, publish-readiness tweaks to the @microsoft/vscode-ext-webview package, following review feedback on the webview API migration (PR #766).

1. "sideEffects": false in package.json

The package is fully side-effect free (verified by scanning every non-test source file — only pure declarations, a WeakMap allocation, and a pure initTRPC().create() builder). Declaring "sideEffects": false lets consumers' bundlers (webpack / Rollup / esbuild / Vite) safely drop unused exports, giving cleaner tree-shaking. Combined with the existing subpath exports (., ./host, ./webview, ./react), a consumer only pays for what they import.

engines was intentionally not added — it's optional for a bundler-consumed library and risks spurious EBADENGINE warnings.

2. Doc clarification: optional peer dependencies

react and vscode-webview are already declared optional via peerDependenciesMeta, but the README install prose omitted vscode-webview and didn't call out which peers are optional. Reconciled the prose and the peer-dependency table so host-only / non-React consumers know those peers aren't required.

Verification

  • npm run build (tsc) — ✅ clean
  • npx prettier --check — ✅ clean
  • npm test (jest) — ✅ 89/89 tests, 11 suites

Notes

No code/runtime behaviour changes — metadata + docs only.

tnaum-ms and others added 3 commits July 6, 2026 21:47
Reconcile the install prose and peer-dependency table with the actual
peerDependenciesMeta: list all four peers and mark react and
vscode-webview as optional, so host-only / non-React consumers know they
are not required.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tnaum-ms tnaum-ms marked this pull request as ready for review July 6, 2026 22:09
@tnaum-ms tnaum-ms requested a review from a team as a code owner July 6, 2026 22:09
Copilot AI review requested due to automatic review settings July 6, 2026 22:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Publish-readiness tweaks for the @microsoft/vscode-ext-webview workspace package, focused on improving consumer bundling behavior and clarifying install-time expectations for peer dependencies.

Changes:

  • Declare "sideEffects": false in packages/vscode-ext-webview/package.json to enable more effective tree-shaking in consumer bundlers.
  • Update packages/vscode-ext-webview/README.md to explicitly document which peer dependencies are optional and why.
  • Add an internal PR note under docs/ai-and-plans/PRs/786-webview-api-tweak/ capturing rationale and verification steps.

Reviewed changes

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

File Description
packages/vscode-ext-webview/package.json Adds "sideEffects": false to support consumer tree-shaking.
packages/vscode-ext-webview/README.md Clarifies peer dependency requirements/optionality and updates the peer table.
docs/ai-and-plans/PRs/786-webview-api-tweak/webview-api-tweak-notes.md Internal notes documenting rationale and verification for the tweaks.

Comment thread packages/vscode-ext-webview/README.md Outdated
Address Copilot review feedback: the install prose implied a
framework-agnostic ./webview consumer needs vscode-webview, which
contradicted the peer-dependency table. Only src/react/WebviewContext.tsx
imports vscode-webview; the ./webview transport uses its own structural
VsCodeApiLike. Reword the prose and table row to scope both optional
peers to the ./react surface, and record the review round in the notes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

✅ Code Quality Checks

Check Status How to fix
Localization (l10n) ✅ Passed
ESLint ✅ Passed
Prettier formatting ✅ Passed

This comment is updated automatically on each push.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

📦 Build Size Report

Metric Base (main) PR Delta
VSIX (vscode-documentdb-0.9.1.vsix) 8.01 MB 8.01 MB ✅ 0 KB (0.0%)
Webview bundle (views.js) 5.88 MB 5.88 MB ✅ 0 KB (0.0%)

Download artifact · updated automatically on each push.

@tnaum-ms

tnaum-ms commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #787, which supersedes this PR — it includes both changes here plus an additional WithTelemetry documentation fix.

@tnaum-ms tnaum-ms closed this Jul 7, 2026
auto-merge was automatically disabled July 7, 2026 09:26

Pull request was closed

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.

2 participants