wasmerio / webassembly.sh

Open-source and installable PWA terminal powered by WebAssembly, WAPM, and Wasmer-JS 🖥

Home Page:https://webassembly.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Fails (SOLVED)

sfranzyshen opened this issue · comments

My development environment:

  • Windows 11 Home (64bit) + WSL2
    • Ubuntu 20.04.2 LTS
      • node.js 14.17.3
      • npm 7.19.1
      • preact 3.2.2
$ sudo npm install -g preact-cli
(clone or download this project's repository)
$ cd webassembly.sh/
$ npm install
$ preact build
Unable to read file: /mnt/d/WASM/webassembly.sh-master/src/node_modules/@wasmer/wasm-terminal/lib/optimized/wasm-terminal.esm.js

the work around was to create a symbolic link in the src/ folder to point to node_modules/

$ cd src
$ ln -s ../node_modules/ node_modules
$ cd ..
$ preact build
ReferenceError: window is not defined

the work around here was to use the command line switch "--no-prerender" but this occurs
when evaluating a non-existent variable (window) ... the code should be change to use "typeof". typeof won't try to evaluate "window", it will only try to get its type ... for example in src/index.js it test the value of window in a if call ... and it should test for "typeof"
from:
if (window)
to:
if (typeof window !== "undefined")

next ...
$ preact build --no-prerender

ERROR Can't find self.__WB_MANIFEST in your SW source.

the work around here was to add "self.__WB_MANIFEST" to the src/sw.js file as follows ... change the first line in the file ...
from:
self.__precacheManifest = [].concat(self.__precacheManifest || []);
to:
self.__precacheManifest = [].concat(self.__precacheManifest || [self.__WB_MANIFEST]);

next ...
$ preact build --no-prerender
and finally I got a build ... next I kicked off a local web server and loaded the page ...

$ cd build
$ python3 -m http.server 8000
127.0.0.1 - - [15/Jul/2021 00:16:57] "GET /assets/wasm-terminal/xterm.css HTTP/1.1" 404 -
127.0.0.1 - - [15/Jul/2021 00:17:09] "GET /assets/wasm-terminal/process.worker.js HTTP/1.1" 404 -

the work around here was to copy the xterm.css & process.worker.js files into the build/assets folder

$ mkdir assets/wasm-terminal
$ cp ../node_modules/@wasmer/wasm-terminal/lib/workers/process.worker.js assets/wasm-terminal/
$ cp ../node_modules/xterm/css/xterm.css assets/wasm-terminal/

I also copied these files into the src/assets folder so subsequent builds have them ...

$ mkdir ../src/assets/wasm-terminal
$ cp ../node_modules/@wasmer/wasm-terminal/lib/workers/process.worker.js ../src/assets/wasm-terminal/
$ cp ../node_modules/xterm/css/xterm.css ../src/assets/wasm-terminal/

finally got it working ...
$ python3 -m http.server 8000

Hope this helps someone else ... and perhaps show light onto problems for the developers ...

Thanks @sfranzyshen - this was super helpful