Skip to content

Make Monaco Editor compatible with Vite #249962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make Monaco Editor compatible with Vite
Monaco Editor uses some static properties that reference the class they
are defined in. This is equivalent to `this`. Monaco Editor also uses
decorators. TypeScript compiles this in a way that works (with some
small boilerplate code). In Vite however, this compiles to broken code.

This change replaces self-references via in static properties via their
identifier with `this`.

The changes were cherry-picked from #249616.
  • Loading branch information
remcohaszing committed May 28, 2025
commit 101b2a09002f2a32cbf71e178575c556dbbac822
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { IObservableViewZone, PlaceholderViewZone, ViewZoneOverlayWidget, applyO
*/
export class HideUnchangedRegionsFeature extends Disposable {
private static readonly _breadcrumbsSourceFactory = observableValue<((textModel: ITextModel, instantiationService: IInstantiationService) => IDiffEditorBreadcrumbsSource)>(
HideUnchangedRegionsFeature, () => ({
this, () => ({
dispose() {
},
getBreadcrumbItems(startRange, reader) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { InlineCompletionContextKeys } from './inlineCompletionContextKeys.js';
export class InlineCompletionsController extends Disposable {
private static readonly _instances = new Set<InlineCompletionsController>();

public static hot = createHotClass(InlineCompletionsController);
public static hot = createHotClass(this);
public static ID = 'editor.contrib.inlineCompletionsController';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const inlineSuggestionHintsNextIcon = registerIcon('inline-suggestion-hints-next
const inlineSuggestionHintsPreviousIcon = registerIcon('inline-suggestion-hints-previous', Codicon.chevronLeft, localize('parameterHintsPreviousIcon', 'Icon for show previous parameter hint.'));

export class InlineSuggestionHintsContentWidget extends Disposable implements IContentWidget {
public static readonly hot = createHotClass(InlineSuggestionHintsContentWidget);
public static readonly hot = createHotClass(this);

private static _dropDownVisible = false;
public static get dropDownVisible() { return this._dropDownVisible; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const GHOST_TEXT_CLASS_NAME = 'ghost-text';
export class GhostTextView extends Disposable {
private readonly _isDisposed;
private readonly _editorObs;
public static hot = createHotClass(GhostTextView);
public static hot = createHotClass(this);

private _warningState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { InlineEditsView } from './inlineEditsView.js';
import { InlineEditTabAction } from './inlineEditsViewInterface.js';

export class InlineEditsViewAndDiffProducer extends Disposable { // TODO: This class is no longer a diff producer. Rename it or get rid of it
public static readonly hot = createHotClass(InlineEditsViewAndDiffProducer);
public static readonly hot = createHotClass(this);

private readonly _editorObs: ObservableCodeEditor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { IEditorService } from '../../../services/editor/common/editorService.js
import { ILanguageStatusService } from '../../../services/languageStatus/common/languageStatusService.js';

export class InlineCompletionLanguageStatusBarContribution extends Disposable implements IWorkbenchContribution {
public static readonly hot = createHotClass(InlineCompletionLanguageStatusBarContribution);
public static readonly hot = createHotClass(this);

public static Id = 'vs.contrib.inlineCompletionLanguageStatusBarContribution';
public static readonly languageStatusBarDisposables = new Set<DisposableStore>();
Expand Down