Skip to content

Commit 319d778

Browse files
committed
fix(neural): bundle onnxruntime-web — the deployed demo could not load the ML engine
rolldownOptions.external listed onnxruntime-web (a build-noise workaround for the uninstalled @litertjs/core), leaving a bare specifier the browser cannot resolve: the deployed /neural demo failed with 'Failed to resolve module specifier'. @litertjs/core is now a real dependency and only the node-only backend stays external; the ORT runtime and its wasm binaries bundle (ort.bundle.min.*.js + ort-wasm-*.wasm in dist). New live e2e spec (LIVE_NEURAL=1) downloads the real 95MB lite artifact and asserts vocalized output — passing against a local preview.
1 parent 2481737 commit 319d778

4 files changed

Lines changed: 46 additions & 73 deletions

File tree

astro.config.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ export default defineConfig({
2323
// imports; the transliteration path never loads them, but the dev
2424
// scanner and rolldown still try to resolve them.
2525
optimizeDeps: { exclude: ["interscript-ts"] },
26+
// onnxruntime-web must NOT be externalized: the /neural demo loads
27+
// the ML engine lazily in the browser, and an externalized bare
28+
// specifier is unresolvable at runtime (the deployed demo failed
29+
// with "Failed to resolve module specifier 'onnxruntime-web'").
30+
// Node-only backends stay external — the client never imports them.
2631
build: {
2732
rolldownOptions: {
28-
external: ["onnxruntime-web", "@litertjs/core", "onnxruntime-node"],
33+
external: ["onnxruntime-node"],
2934
},
3035
},
3136
},

e2e/neural-live.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// LIVE /neural verification — downloads the real artifact through the
2+
// assets proxy and decodes in the browser. Opt-in (LIVE_NEURAL=1) so
3+
// CI never pulls 95MB; run against the deployed site:
4+
// LIVE_NEURAL=1 npx playwright test e2e/neural-live.spec.ts
5+
import { expect, test } from "@playwright/test"
6+
7+
test.skip(!process.env.LIVE_NEURAL, "live download test — set LIVE_NEURAL=1")
8+
9+
test("lite int4 tier downloads, verifies, and vocalizes in the browser", async ({ page }) => {
10+
test.setTimeout(420_000)
11+
await page.goto(`${process.env.LIVE_NEURAL_BASE ?? "https://interscript.org"}/neural`)
12+
await page.selectOption("#model", "ara-diac-layerdrop-1.0-int4")
13+
await page.fill("#input", "قوله فحكمها في الوفاة")
14+
await page.click("#run")
15+
// progress must appear (index resolve + download), then the model decodes
16+
await expect(page.locator("#progress")).toBeVisible({ timeout: 30_000 })
17+
const output = page.locator("#output")
18+
await expect(output).not.toBeEmpty({ timeout: 420_000 })
19+
const text = (await output.textContent()) ?? ""
20+
// fully vocalized output carries haraqat bytes and no error surface
21+
expect(text).toMatch(/[ً-ْٰٓ-ٕ]/)
22+
expect(text).not.toMatch(/Error|cause:/)
23+
})

package-lock.json

Lines changed: 16 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@fontsource/jetbrains-mono": "^5.3.0",
3232
"@iso24229/iso15924-data": "^0.2.0",
3333
"@iso24229/iso639-data": "^0.2.0",
34+
"@litertjs/core": "^2.5.3",
3435
"@tailwindcss/vite": "^4.0.0",
3536
"astro": "^7.0.0",
3637
"interscript": "^5.2.1",

0 commit comments

Comments
 (0)