Fixing imports to improve tree shaking #21483
Conversation
There was a problem hiding this comment.
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-imagenamed exports,@dagrejs/dagrenamed exports). - Lazy-loaded
react-markdownin a couple of dialogs and wrapped rendering withSuspense.
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.
PR Changes
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ 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
🚀 New features to boost your workflow:
|
|
Can you add before/after screenshots of the bundle map or any size reductions to the PR description? |
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
npm run test)Reviewers: Please read our reviewer guidelines