Skip to content

Commit 1900caa

Browse files
authored
Bump dependencies and add web demo (#14)
* Bump various dependency versions * Deduplicate dependencies * Fix errors * Update CI workflow Includes WASM module and web build step for more complete testing. * Add GitHub Actions workflow for web demo CD
1 parent cd97386 commit 1900caa

File tree

5 files changed

+1162
-1601
lines changed

5 files changed

+1162
-1601
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,21 @@ jobs:
6969
node-version: 20
7070
cache: yarn
7171
cache-dependency-path: ./devices/wasm/web/yarn.lock
72+
- name: Setup Emscripten
73+
uses: mymindstorm/setup-emsdk@v14
7274
- name: Install dependencies
7375
working-directory: devices/wasm/web
7476
run: yarn install --frozen-lockfile
7577
- name: Lint
7678
working-directory: devices/wasm/web
7779
run: yarn lint
80+
- name: Build WASM module
81+
working-directory: devices/wasm
82+
run: |
83+
mkdir -p build
84+
cd build
85+
emcmake cmake ../wasm
86+
make -j$(nproc)
87+
- name: Ensure website builds
88+
working-directory: devices/wasm/web
89+
run: yarn build

.github/workflows/web.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Deploy web demo
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
- name: Install dependencies (apt)
18+
run: |
19+
sudo apt-get update && \
20+
sudo apt-get install -y --no-install-recommends \
21+
libxi-dev libgl1-mesa-dev
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 20
26+
cache: yarn
27+
cache-dependency-path: ./devices/wasm/web/yarn.lock
28+
- name: Setup Emscripten
29+
uses: mymindstorm/setup-emsdk@v14
30+
- name: Install dependencies
31+
working-directory: devices/wasm/web
32+
run: yarn install --frozen-lockfile
33+
- name: Build WASM module
34+
working-directory: devices/wasm
35+
run: |
36+
mkdir -p build
37+
cd build
38+
emcmake cmake ../wasm
39+
make -j$(nproc)
40+
- name: Build
41+
working-directory: devices/wasm/web
42+
run: yarn build
43+
- name: Deploy to GitHub Pages
44+
uses: peaceiris/actions-gh-pages@v3
45+
with:
46+
github_token: ${{ secrets.GITHUB_TOKEN }}
47+
publish_dir: devices/wasm/web/build

devices/wasm/web/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
},
1717
"devDependencies": {
1818
"cross-env": "^7.0.3",
19-
"eslint": "^8.0.0",
20-
"eslint-config-preact": "^1.1.4",
19+
"eslint": "^8.57.0",
20+
"eslint-config-preact": "^1.3.0",
2121
"jest": "^29.7.0",
22-
"preact-cli": "=3.3.0"
22+
"preact-cli": "^3.5.1"
2323
},
2424
"dependencies": {
2525
"file-saver": "^2.0.5",
2626
"js-slang": "^0.5.19",
27-
"preact": "^10.5.15",
28-
"react-ace": "^9.4.4"
27+
"preact": "^10.19.6",
28+
"react-ace": "^10.1.0"
2929
},
3030
"resolutions": {
3131
"**/gl": "^6.0.2"

devices/wasm/web/preact.config.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
export default (config, env, helpers) => {
1+
// @ts-check
2+
/**
3+
* Function that mutates the original webpack config.
4+
* Supports asynchronous changes when a promise is returned (or it's an async function).
5+
*
6+
* @param {import('preact-cli').Config} config - original webpack config
7+
* @param {import('preact-cli').Env} env - current environment and options pass to the CLI
8+
* @param {import('preact-cli').Helpers} helpers - object with useful helpers for working with the webpack config
9+
* @param {Record<string, unknown>} options - this is mainly relevant for plugins (will always be empty in the config), default to an empty object
10+
*/
11+
export default (config, env, helpers, options) => {
212
config.module.rules.push({
313
test: /\.wasm$/,
414
type: "javascript/auto",
@@ -9,13 +19,7 @@ export default (config, env, helpers) => {
919
config.node.Buffer = true;
1020
config.node.process = true;
1121

12-
let babelConfig = helpers.getLoadersByName(config, 'babel-loader')[0].rule.options;
13-
let babelPresetEnvPresets = babelConfig.presets.find(([path]) => path.includes("@babel/preset-env"))[1];
14-
babelPresetEnvPresets.targets = "Firefox ESR";
15-
babelPresetEnvPresets.loose = false;
16-
// console.log(babelPresetEnvPresets);
17-
18-
if (env.production) {
19-
config.output.publicPath = '';
22+
if (env.isProd) {
23+
config.output.publicPath = "";
2024
}
2125
};

0 commit comments

Comments
 (0)