Replies: 2 comments 1 reply
-
ESM export is a pretty recent change and not yet reflected in the official versions. You can try to use a beta version instead (e.g. version 5.6.0-beta.66 already contains the ESM directives). |
Beta Was this translation helpful? Give feedback.
-
Thank you, @jerch, that does the trick on the import. Here's the working skeleton I've built. The context is a project started with import { LitElement, html, css } from 'lit';
import { customElement } from 'lit/decorators.js';
import { Terminal } from '@xterm/xterm';
@customElement('hasak-xterm')
export class HasakXterm extends LitElement {
static styles = css`
/* insert contents of xterm.css here so it will be visible inside the component */
`;
terminal: Terminal;
constructor() {
super();
this.terminal = new Terminal();
}
containerElement() {
return (this.renderRoot as DocumentFragment).getElementById('terminal');
}
firstUpdated() {
this.terminal.open(this.containerElement()!);
this.terminal.write('Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ');
}
render() {
return html`<div id="terminal" > </div>`;
}
} The contensts of I'm going to continue by modifying this skeleton to see if it can serve my specifforic purposes. But there's a more generally useful continuation which would reflect the options of the terminal as properties of the component and use the reactive facilities of Thanks for the code and the help. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to build a web component wrapping xterm.js.
When I attempt to include xterm as a module using:
it generates this runtime error if I'm using the development server:
and it generates this error if I'm running rollup to build a distribution image:
this is using @xterm/xterm 5.5.0
What is the correct way to import Terminal into an ecmascript module?
Beta Was this translation helpful? Give feedback.
All reactions