fix: enhance tree shaking behavior of LLS : W-19346529#618
Merged
Conversation
madhur310
commented
Sep 11, 2025
madhur310
commented
Sep 11, 2025
daphne-sfdc
reviewed
Sep 18, 2025
daphne-sfdc
reviewed
Sep 18, 2025
daphne-sfdc
approved these changes
Sep 19, 2025
Contributor
daphne-sfdc
left a comment
There was a problem hiding this comment.
In lightning-language-server:
yarn installyarn link-lsp
In salesforcedx-vscode madhur/bump-lls-v branch:
npm installnpm run link-lspnpm run compile
Aura LSP
- Auto-completion ✅
- Go to Definition ✅
- Hover Documentation ✅
LWC LSP
- Auto-completion ✅
- Hover Documentation (html) ✅
- Hover Documentation (javascript) ✅
- Go to definition (html) ✅
- Go to definition (javascript) ✅
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.
What does this PR do?
This PR refactors the code to allow better tree shaking:
npm run analyze:alland couple scripts in PR). I kept this scripts for reference, but can remove them if folks think not needed.Seeing some good potential improvements (per generated scripts):
🚀 LSP Package Tree Shaking Analysis
==================================================
📦 Analyzing LSP Package Sizes
🔍 packages/lightning-lsp-common/lib:
base-context.js: 19.77 KB
utils.js: 10.36 KB
index.js: 7.28 KB
shared.js: 5.41 KB
namespace-utils.js: 3.24 KB
indexer/tagInfo.js: 3.21 KB
logger.js: 1.14 KB
indexer/attributeInfo.js: 0.89 KB
decorators/index.js: 0.31 KB
📊 Total: 51.62 KB
🔍 packages/aura-language-server/lib:
tern/plugin/node.js: 189.12 KB
tern/lib/infer.js: 77.62 KB
tern/plugin/angular.js: 45.94 KB
tern/lib/tern.js: 40.54 KB
tern/lib/def.js: 25.04 KB
tern/plugin/requirejs.js: 19.14 KB
tern/plugin/doc_comment.js: 19.08 KB
tern-server/tern-aura.js: 17.33 KB
aura-utils.js: 15.44 KB
tern/plugin/modules.js: 13.62 KB
tests/aura-utils.test.js: 13.39 KB
aura-server.js: 13.05 KB
tern-server/tern-server.js: 12.72 KB
aura-indexer/indexer.js: 10.19 KB
tern/lib/condense.js: 10.14 KB
context/aura-context.js: 7.12 KB
tern/plugin/commonjs.js: 6.55 KB
tern-server/tests/string-util.test.js: 6.35 KB
aura-indexer/tests/indexer.spec.js: 5.42 KB
tern/plugin/es_modules.js: 4.51 KB
tests/package-dependencies.test.js: 3.76 KB
tern-server/string-util.js: 3.34 KB
util/component-util.js: 3.30 KB
tern/lib/comment.js: 2.82 KB
tern/plugin/webpack.js: 2.80 KB
tern/plugin/node_resolve.js: 2.68 KB
tern/plugin/complete_strings.js: 2.39 KB
tern-server/tests/ternCompletion.spec.js: 1.94 KB
markup/auraTags.js: 1.54 KB
tern/lib/signal.js: 1.54 KB
decorators/index.js: 1.02 KB
indexer/index.js: 1.02 KB
tern-server/tern-indexer.js: 0.96 KB
index.js: 0.83 KB
server.js: 0.37 KB
decorators/sharedTypes.js: 0.32 KB
indexer/sharedTypes.js: 0.32 KB
constants.js: 0.18 KB
📊 Total: 583.42 KB
🔍 packages/lwc-language-server/lib:
tests/lwc-server.test.js: 28.53 KB
lwc-server.js: 19.12 KB
javascript/type-mapping.js: 16.82 KB
tests/component-indexer.test.js: 11.99 KB
component-indexer.js: 10.18 KB
javascript/tests/compiler.test.js: 10.00 KB
tag.js: 9.67 KB
tests/typing-indexer.test.js: 8.90 KB
typing-indexer.js: 8.84 KB
context/lwc-context.js: 8.33 KB
javascript/compiler.js: 8.00 KB
tests/tag.test.js: 7.08 KB
tests/lwc-context.test.js: 5.10 KB
tests/typing.test.js: 4.82 KB
tests/lwc-data-provider.test.js: 3.84 KB
tests/package-dependencies.test.js: 3.76 KB
typing.js: 3.67 KB
lwc-data-provider.js: 3.45 KB
javascript/tests/type-mapping.test.js: 3.36 KB
template/linter.js: 3.31 KB
tests/test-utils.js: 2.81 KB
base-indexer.js: 2.09 KB
template/tests/linter.test.js: 1.40 KB
decorators/index.js: 1.03 KB
aura-data-provider.js: 1.00 KB
constants.js: 0.48 KB
server.js: 0.36 KB
decorators/lwc-decorators.js: 0.32 KB
📊 Total: 188.27 KB
🔍 Analyzing Export Structure
📤 Total exports in lightning-lsp-common: 87
🎯 Available subpath exports:
.
./utils
./base-context
./decorators
./logger
./namespace-utils
./indexer/attributeInfo
./indexer/tagInfo
🎯 Tree Shaking Simulation
📋 VS Code Extension (LWC only):
Only imports LWC context and base utilities
Imports: @salesforce/lwc-language-server/context, @salesforce/lightning-lsp-common/base-context, @salesforce/lightning-lsp-common/utils
🎯 Estimated bundle size reduction: 78%
📋 Custom Build Tool (Indexers only):
Only imports indexer functionality
Imports: @salesforce/lwc-language-server/component-indexer, @salesforce/aura-language-server/indexer, @salesforce/lightning-lsp-common/utils
🎯 Estimated bundle size reduction: 96%
📋 Template Linter (Template only):
Only imports template linting functionality
Imports: @salesforce/lwc-language-server/template, @salesforce/lightning-lsp-common/decorators
🎯 Estimated bundle size reduction: 63%
💡 Recommendations:
🌍 Real-World Tree Shaking Analysis
============================================================
📋 VS Code Extension (LWC Support)
A VS Code extension that only needs LWC language support
📦 Old bundle size: 233.4 KB
📦 New bundle size: 46.0 KB
🎯 Size reduction: 80.3% (187.4 KB saved)
📥 Old imports: @salesforce/lwc-language-server, @salesforce/lightning-lsp-common
📥 New imports: @salesforce/lwc-language-server/context, @salesforce/lwc-language-server/server, @salesforce/lightning-lsp-common/base-context, @salesforce/lightning-lsp-common/utils
📋 Custom Build Tool (Component Indexing)
A build tool that only needs component indexing functionality
📦 Old bundle size: 814.4 KB
📦 New bundle size: 48.4 KB
🎯 Size reduction: 94.1% (766.0 KB saved)
📥 Old imports: @salesforce/lwc-language-server, @salesforce/aura-language-server, @salesforce/lightning-lsp-common
📥 New imports: @salesforce/lwc-language-server/component-indexer, @salesforce/aura-language-server/indexer, @salesforce/lightning-lsp-common/utils
📋 Template Linter (HTML/JSX Support)
A linter that only needs template and decorator functionality
📦 Old bundle size: 233.4 KB
📦 New bundle size: 38.3 KB
🎯 Size reduction: 83.6% (195.1 KB saved)
📥 Old imports: @salesforce/lwc-language-server, @salesforce/lightning-lsp-common
📥 New imports: @salesforce/lwc-language-server/template, @salesforce/lwc-language-server/decorators, @salesforce/lightning-lsp-common/decorators
📋 JavaScript Compiler (JS Processing)
A tool that only processes JavaScript files
📦 Old bundle size: 233.4 KB
📦 New bundle size: 19.3 KB
🎯 Size reduction: 91.7% (214.1 KB saved)
📥 Old imports: @salesforce/lwc-language-server, @salesforce/lightning-lsp-common
📥 New imports: @salesforce/lwc-language-server/javascript, @salesforce/lightning-lsp-common/decorators
🔍 Module Breakdown Analysis
============================================================
📦 lightning-lsp-common (51.44 KB total):
base-context.js: 19.77 KB (38.4%) - Workspace management
utils.js: 10.36 KB (20.1%) - Utility functions
index.js: 6.96 KB (13.5%) - Main exports
shared.js: 5.36 KB (10.4%) - Shared constants
namespace-utils.js: 3.24 KB (6.3%) - Namespace resolution
indexer/tagInfo.js: 3.24 KB (6.3%) - Tag information
logger.js: 1.14 KB (2.2%) - Logging utilities
indexer/attributeInfo.js: 1.06 KB (2.1%) - Attribute information
decorators/index.js: 0.31 KB (0.6%) - Decorator types
📦 lwc-language-server (181.95 KB total):
lwc-server.js: 19.01 KB (10.4%) - Main LWC server
javascript/type-mapping.js: 16.83 KB (9.2%) - Type mapping
component-indexer.js: 9.86 KB (5.4%) - Component indexing
context/lwc-context.js: 8.33 KB (4.6%) - LWC workspace context
javascript/compiler.js: 7.87 KB (4.3%) - JavaScript compilation
tag.js: 7.36 KB (4.0%) - Tag handling
typing-indexer.js: 5.46 KB (3.0%) - TypeScript indexing
template/linter.js: 3.31 KB (1.8%) - Template linting
decorators/index.js: 1.03 KB (0.6%) - LWC decorators
⚡ Performance Impact Analysis
============================================================
📋 VS Code Extension Startup:
Bundle size: 233.39 KB → 57.47 KB (75.4% reduction)
Performance: 75% faster startup time
📋 Build Tool Execution:
Bundle size: 814.39 KB → 30.65 KB (96.2% reduction)
Performance: 96% faster execution
📋 Template Linter:
Bundle size: 233.39 KB → 4.65 KB (98.0% reduction)
Performance: 98% faster linting
💡 Key Takeaways:
What issues does this PR fix or reference?
@W-19346529@