Skip to content

Fixing imports to improve tree shaking #21483

Closed
aasimkhan30 wants to merge 2 commits into
mainfrom
aasim/fix/treeShaking
Closed

Fixing imports to improve tree shaking #21483
aasimkhan30 wants to merge 2 commits into
mainfrom
aasim/fix/treeShaking

Conversation

@aasimkhan30
Copy link
Copy Markdown
Contributor

Description

This PR removes import * from "lib" patterns from our webviews.

Using import * can cause the bundler to include more of the library than necessary, which reduces tree shaking and adds unnecessary bundle bloat. By switching away from this pattern, we allow only the required imports to be included, helping reduce webview bundle size.

Code Changes Checklist

  • New or updated unit tests added
  • All existing tests pass (npm run test)
  • Code follows contributing guidelines
  • Telemetry/logging updated if relevant
  • No regressions or UX breakage

Reviewers: Please read our reviewer guidelines

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 reduces webview bundle bloat by replacing import * as ... patterns (which can inhibit tree-shaking) with direct/named imports, and in a couple of cases defers heavier dependencies to improve load performance.

Changes:

  • Replaced wildcard Fluent UI icon/component imports with direct named imports across multiple webview components.
  • Switched some utility/library imports to more tree-shakeable forms (e.g., lodash/isEqual, html-to-image named exports, @dagrejs/dagre named exports).
  • Lazy-loaded react-markdown in a couple of dialogs and wrapped rendering with Suspense.

Reviewed changes

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

Show a summary per file
File Description
extensions/mssql/src/reactviews/pages/TableDesigner/designerTable.tsx Replaces Fluent UI wildcard import with named component/type imports.
extensions/mssql/src/reactviews/pages/TableDesigner/designerChangesPreviewButton.tsx Lazy-loads react-markdown and renders it via Suspense.
extensions/mssql/src/reactviews/pages/SchemaDesigner/toolbar/undoRedoButton.tsx Replaces wildcard Fluent UI icon import with named imports.
extensions/mssql/src/reactviews/pages/SchemaDesigner/toolbar/publishChangesDialogButton.tsx Replaces wildcard icon import; lazy-loads react-markdown with Suspense.
extensions/mssql/src/reactviews/pages/SchemaDesigner/toolbar/exportDiagramButton.tsx Uses named exports from html-to-image and named icon import.
extensions/mssql/src/reactviews/pages/SchemaDesigner/model/flowLayout.ts Switches dagre usage to named imports (graphlib, layout).
extensions/mssql/src/reactviews/pages/SchemaDesigner/graph/schemaDesignerTableNode.tsx Replaces wildcard icon import with named imports.
extensions/mssql/src/reactviews/pages/SchemaDesigner/editor/schemaDesignerEditorTablePanel.tsx Replaces wildcard icon import with named imports.
extensions/mssql/src/reactviews/pages/SchemaDesigner/editor/schemaDesignerEditorForeignKeyPanel.tsx Removes wildcard icon import and uses direct icon imports.
extensions/mssql/src/reactviews/pages/SchemaDesigner/editor/schemaDesignerEditorDrawer.tsx Replaces wildcard icon import with named import.
extensions/mssql/src/reactviews/pages/SchemaDesigner/diff/diffUtils.ts Replaces lodash namespace import with lodash/isEqual.
extensions/mssql/src/reactviews/pages/SchemaDesigner/dab/dabToolbar.tsx Replaces wildcard icon import with named imports.
extensions/mssql/src/reactviews/pages/ExecutionPlan/executionPlanGraph.tsx Replaces azdataGraph namespace import with named mx import.
extensions/mssql/src/reactviews/common/theme.ts Replaces Fluent UI namespace import with named theme imports.
extensions/mssql/src/reactviews/common/searchableDropdown.component.tsx Replaces wildcard icon import with named imports.
extensions/mssql/src/reactviews/common/findWidget.component.tsx Replaces wildcard icon import with named imports.
extensions/mssql/src/reactviews/common/definitionPanel.tsx Replaces wildcard icon import with named imports.
.vscode/launch.json Modifies debugging env configuration (currently adds a hard-coded local path).

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

Comment thread .vscode/launch.json Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 6, 2026

PR Changes

Category Target Branch PR Branch Difference
vscode-mssql VSIX 6401 KB 6382 KB ⚪ -19 KB ( 0% )
sql-database-projects VSIX 7025 KB 7025 KB ⚪ 0 KB ( 0% )
data-workspace VSIX 535 KB 535 KB ⚪ 0 KB ( 0% )

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 70.37037% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.99%. Comparing base (81551ba) to head (3100bc7).
⚠️ Report is 76 commits behind head on main.

Files with missing lines Patch % Lines
...emaDesigner/toolbar/publishChangesDialogButton.tsx 68.75% 5 Missing ⚠️
extensions/mssql/src/reactviews/common/theme.ts 25.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #21483      +/-   ##
==========================================
- Coverage   72.54%   71.99%   -0.55%     
==========================================
  Files         330      330              
  Lines       98008    98016       +8     
  Branches     5438     5333     -105     
==========================================
- Hits        71096    70563     -533     
- Misses      26912    27453     +541     
Files with missing lines Coverage Δ
...ctviews/pages/ExecutionPlan/executionPlanGraph.tsx 80.23% <100.00%> (ø)
.../reactviews/pages/SchemaDesigner/diff/diffUtils.ts 48.64% <100.00%> (-47.49%) ⬇️
...eactviews/pages/SchemaDesigner/model/flowLayout.ts 100.00% <100.00%> (ø)
extensions/mssql/src/reactviews/common/theme.ts 7.63% <25.00%> (ø)
...emaDesigner/toolbar/publishChangesDialogButton.tsx 54.65% <68.75%> (+0.29%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Benjin
Copy link
Copy Markdown
Contributor

Benjin commented Mar 6, 2026

Can you add before/after screenshots of the bundle map or any size reductions to the PR description?

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