v86 icon indicating copy to clipboard operation
v86 copied to clipboard

SerialAdapterXtermJS doesn’t detect xterm.js in ESM builds (window.Terminal is undefined)

Open zero11-0203 opened this issue 5 months ago • 2 comments

In pure ESM import (import { Terminal } from '@xterm/xterm'), nothing is put on window, so the adapter never instantiates the terminal.

zero11-0203 avatar Jul 16 '25 15:07 zero11-0203

Possible solutions:

  • document that esm users need to add window["Terminal"] = Terminal somewhere
  • accept the Terminal constructor as a parameter to V86

Feel free to send a PR for either (or both)

copy avatar Jul 22 '25 13:07 copy

accept the Terminal constructor as a parameter to V86

Fixed in #1463.

import { Terminal } from "xterm";

window.onload = function()
{
    var emulator = window.emulator = new V86({
        serial_container_xtermjs: document.getElementById("terminal"),
        xterm_lib: Terminal,
    });
};

Also works with ghostty-web:

import { init, Terminal } from "ghostty-web";

window.onload = async function()
{
    await init();

    var emulator = window.emulator = new V86({
        serial_container_xtermjs: document.getElementById("terminal"),
        xterm_lib: Terminal,
    });
};

SuperMaxusa avatar Dec 05 '25 00:12 SuperMaxusa