I have been attempting to modify the source code of xterm.js and test my changes before submitting a PR. Unfortunately, I have not been able to generate a functional 'distribution.'
(I apologize if my terminology is incorrect -- I am still fairly new to web development)
Setup
I have set up a basic test website with the following index.html
<!doctype html>
<html>
<head>
<script src="%PUBLIC_URL%/xterm.js"></script>
</head>
<body>
<div id="terminal"></div>
<script>
console.log(Terminal);
var term = new Terminal();
term.open(document.getElementById('terminal'));
term.write('Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ')
</script>
</body>
</html>
In place of %PUBLIC_URL%
, I intend to include a JS source file xterm.js
from either of the following locations:
node_modules/xterm/dist/xterm.js
- added through npmxterm.js/lib/xterm.js
- built from the GitHub repository
To build a local version of xterm.js
, I followed these steps:
git clone https://github.com/xtermjs/xterm.js.git xterm-local
cd xterm-local
npm install
npm run package
(Please note: I encountered difficulties building xterm.js on Windows or Mac -- I only succeeded on Ubuntu 18.04)
All the commands ran successfully, and the last one generated xterm-local/lib
which includes xterm.js
. I utilized this file to replace the copy obtained from the NPM installation.
Results
With NPM Distribution
Using the NPM dist/xterm.js
, I managed to render my terminal element with the log displaying:
ƒ Terminal(options) {
this._core = new Terminal_1.Terminal(options);
this._addonManager = new AddonManager_1.AddonManager();
}
With Local Build
However, when utilizing my locally built output from xterm-local/lib/xterm.js
, the terminal element was not rendered, and I encountered an error:
Uncaught TypeError: Terminal is not a constructor
. The log displayed:
{Terminal: ƒ, __esModule: true}
Terminal: ƒ e(e)
__esModule: true
__proto__: Object
Expectations
After building my local version of xterm.js, I anticipated being able to use it interchangeably with the NPM distribution. However, I am curious as to why the command npm run package
did not generate the dist
folder but a lib
folder instead. Are there further steps that I am overlooking in order to create a functional copy of xterm.js
?