Skip to content

Commit 0068a75

Browse files
committed
feat: add Vite plugins for WASM support and top-level await functionality
1 parent 12dc29d commit 0068a75

3 files changed

Lines changed: 234 additions & 1 deletion

File tree

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
"svelte-check": "^4.0.0",
7878
"typescript": "~5.6.2",
7979
"vite": "^6.0.3",
80+
"vite-plugin-top-level-await": "^1.5.0",
81+
"vite-plugin-wasm": "^3.4.1",
8082
"vitest": "^4.1.4"
8183
}
8284
}

pnpm-lock.yaml

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

vite.config.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { defineConfig } from "vite";
22
import { sveltekit } from "@sveltejs/kit/vite";
3+
import wasm from "vite-plugin-wasm";
4+
import topLevelAwait from "vite-plugin-top-level-await";
35
import { execSync, spawnSync } from "child_process";
46
import { readFileSync, existsSync } from "fs";
57
import path from "path";
@@ -58,7 +60,27 @@ export default defineConfig(async ({ command }) => {
5860
(isBuild && process.env.OMNIGET_I18N_STRICT !== "0");
5961

6062
return {
61-
plugins: [i18nKeysPlugin({ strict: strictI18n }), sveltekit()],
63+
plugins: [
64+
i18nKeysPlugin({ strict: strictI18n }),
65+
wasm(),
66+
topLevelAwait(),
67+
sveltekit(),
68+
],
69+
70+
// PlantUML / Graphviz packages ship WASM + workers that need special
71+
// handling. `optimizeDeps.exclude` keeps the dep optimizer out of the way
72+
// so vite-plugin-wasm gets to handle the wasm imports. The graphviz
73+
// package internally spawns a worker — Vite 6 requires worker.format=es
74+
// for code-splitting builds, otherwise it errors with "Invalid value 'iife'".
75+
optimizeDeps: {
76+
exclude: [
77+
"@kookyleo/plantuml-little-web",
78+
"@kookyleo/graphviz-anywhere-web",
79+
],
80+
},
81+
worker: {
82+
format: "es",
83+
},
6284

6385
define: {
6486
__COMMIT_HASH__: JSON.stringify(gitInfo.hash),

0 commit comments

Comments
 (0)