-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
area/apiarea/performancetype/debtTechnical debt that could slow us down in the long runTechnical debt that could slow us down in the long runtype/enhancementFeatures or improvements to existing featuresFeatures or improvements to existing features
Description
Coming from #5251 (comment)
Currently using Event, Disposable etc. from the vs/*
path in addons adds ~50kB on addons. We should investigate, if and how we can save some binary size on addons by exposing crucial parts on the API, so the impls dont have to be copied over for every single addon.
Metadata
Metadata
Assignees
Labels
area/apiarea/performancetype/debtTechnical debt that could slow us down in the long runTechnical debt that could slow us down in the long runtype/enhancementFeatures or improvements to existing featuresFeatures or improvements to existing features
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
Tyriar commentedon Jan 7, 2025
Good idea for common things like
Event
👍jerch commentedon Jan 7, 2025
Looking through the list of addons, these would benefit from exposing event/emitter stuff on the API:
jerch commentedon Jan 8, 2025
@Tyriar Did some further digging around Event/Emitter and Disposable:
new Emitter<T>()
callactivate
, where the addon gets a hold of the terminal objectclass extends Disposable
Given the list of addons using
vs/*
imports those are the potential savings on the minified bundles:Tyriar commentedon Jan 8, 2025
@jerch if you don't extend the typical thing is to use DisposableStore as a property instead. That's less convenient sometimes but if it'll save a bunch we can use that approach exclusively in addons instead of extends? Example:
https://github.com/microsoft/vscode/blob/decaa08e9945fad06912b5aafbd8f0f0e88e11c2/src/vs/workbench/contrib/terminal/browser/terminalView.ts#L69
Did you want to take a stab at a PR for this or want me to, since I introduced the problem? 😉
jerch commentedon Jan 8, 2025
Oh ic, yeah that might be the easier pattern then. Although I found a pattern with runtime
extends
leading to the same inheritance chain, schematically:It works basically the same as before, but now needs a terminal arg at the fake ctor already to derive the Disposable impl from there. Its not nicely abstracted yet, the
helperCls
looks like a code smell but is needed as the base class is abstract. Beside that it fully maintains the correct inheritance chain with a workingsuper()
. It is somewhat a class mixin pattern, but also relies on ES5new
behavior. Maybe the class factory aspect could be stated more clearly by separating the concerns, whatever if preferrable.Up to you. I can try to formalize that idea, though I am not 100% sure yet, if this works properly in all circumstances. At the moment this is a full drop-in replacement with only the
terminal
argument as difference.Edit: To get
instanceof
properly working the class factory part should be separated from the instantiation for sure.Tyriar commentedon Jan 8, 2025
Runtime extends looks pretty confusing to me. The composition approach isn't quite as convenient but it's super clear how it works. We could also have a special
AddonDisposable
helper inshared/
that just wraps the API object?That way only the class in shared/ will be pulled into the addon bundle
jerch commentedon Jan 8, 2025
Yepp, +1 to composition. It also needs less awkward APi additions.
jerch commentedon Jan 9, 2025
@Tyriar Would we need a separate xterm-shared for external addon creators, or will installing the xterm package with extended API be enough in the end to build an external addon? To me it seems quite involved if the full xterm source would be needed just to build a tiny addon xy.
Tyriar commentedon Jan 9, 2025
@jerch I don't think so, it'll be a very small wrapper and they'll only be gaining things by having new stuff exposed on the API.
7 remaining items