Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit e355dc6

Browse files
committed
Fix yew app build
1 parent c0273c7 commit e355dc6

File tree

3 files changed

+34
-28
lines changed

3 files changed

+34
-28
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ jobs:
7777
- name: Install Deno
7878
uses: denoland/setup-deno@v1
7979

80+
- name: Setup rust
81+
uses: hecrj/setup-rust-action@v1
82+
with:
83+
rust-version: stable
84+
85+
- uses: jetli/[email protected]
86+
with:
87+
version: latest
88+
8089
- name: Build App
8190
env:
8291
ALEPH_PKG_URI: https://raw.githubusercontent.com/alephjs/aleph.js/${{ github.sha }}

examples/yew-app/build.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
async function existsFile(path: string): Promise<boolean> {
2+
try {
3+
const stat = await Deno.lstat(path);
4+
return stat.isFile;
5+
} catch (err) {
6+
if (err instanceof Deno.errors.NotFound) {
7+
return false;
8+
}
9+
throw err;
10+
}
11+
}
12+
13+
export default async function build(forceBuild?: boolean) {
14+
if (forceBuild || !(await existsFile("./pkg/package.json"))) {
15+
const p = Deno.run({
16+
cmd: ["wasm-pack", "build", "--target", "web"],
17+
stdout: "inherit",
18+
stderr: "inherit",
19+
});
20+
await p.status();
21+
p.close();
22+
}
23+
}

examples/yew-app/server.ts

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,17 @@
11
import { serve } from "aleph/server";
22
import init, { ssr } from "./pkg/yew_app.js";
3+
import build from "./build.ts";
34

45
await init(await Deno.readFile("./pkg/yew_app_bg.wasm"));
56

6-
async function buildWASM(forceBuild?: boolean) {
7-
if (forceBuild || !existsFile("./pkg/package.json")) {
8-
const p = Deno.run({
9-
cmd: ["wasm-pack", "build", "--target", "web"],
10-
stdout: "inherit",
11-
stderr: "inherit",
12-
});
13-
await p.status();
14-
p.close();
15-
}
16-
}
17-
18-
async function existsFile(path: string): Promise<boolean> {
19-
try {
20-
const stat = await Deno.lstat(path);
21-
return stat.isFile;
22-
} catch (err) {
23-
if (err instanceof Deno.errors.NotFound) {
24-
return false;
25-
}
26-
throw err;
27-
}
28-
}
29-
307
serve({
318
devServer: {
329
watchFS: (_kind, specifier) => {
3310
if (specifier.startsWith("./src/") && specifier.endsWith(".rs")) {
34-
buildWASM(true);
11+
build(true);
3512
}
3613
},
3714
},
38-
build: {
39-
preBuild: buildWASM,
40-
},
4115
ssr: {
4216
render: (_ctx) => ssr(),
4317
},

0 commit comments

Comments
 (0)