From 24a55c018f4e949be056ae58ff922448e44fd5b6 Mon Sep 17 00:00:00 2001 From: Alix von Schirp Date: Thu, 19 Feb 2026 20:38:55 +0100 Subject: [PATCH] fix: make vite 7 compliant Signed-off-by: Alix von Schirp --- build.sh | 2 -- scripts/replace.js | 27 --------------------------- vite.config.ts | 21 +++++++-------------- 3 files changed, 7 insertions(+), 43 deletions(-) delete mode 100644 scripts/replace.js diff --git a/build.sh b/build.sh index f5e657f..3ae3b83 100755 --- a/build.sh +++ b/build.sh @@ -12,8 +12,6 @@ cd ffprobe-wasm-app docker-compose run ffprobe-wasm make cd .. cp -R ffprobe-wasm-app/dist dist -mv dist/ffprobe-wasm.js dist/ffprobe-wasm.mjs -node scripts/replace.js cp src/*.d.* dist # Build browser/node workers diff --git a/scripts/replace.js b/scripts/replace.js deleted file mode 100644 index b7aa25d..0000000 --- a/scripts/replace.js +++ /dev/null @@ -1,27 +0,0 @@ -const { readFile, writeFile } = require("fs/promises"); -const { dirname, resolve } = require("path"); - -main(); - -async function main() { - const root = dirname(__dirname); - - const wasmJsPath = resolve(root, "dist/ffprobe-wasm.mjs"); - - let content = await readFile(wasmJsPath, { encoding: "utf8" }); - - content = `\ -import initWasmInstance from "./ffprobe-wasm.wasm"; -const initWasm = (info) => - initWasmInstance(info).then((exports) => ({ instance: { exports } })); -${content}`; - - content = content.replace(`import.meta.url`, `''`); - - content = content.replace( - `instantiateAsync().catch(readyPromiseReject)`, - `initWasm(info).then(receiveInstantiatedSource, readyPromiseReject)` - ); - - await writeFile(wasmJsPath, content, { encoding: "utf8" }); -} diff --git a/vite.config.ts b/vite.config.ts index d386970..108e07b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -21,18 +21,11 @@ export default defineConfig({ wasm(), topLevelAwait() ], - // worker: { - // plugins: [ - // // { - // // name: "append-source-url", - // // generateBundle(options, bundle) { - // // Object.entries(bundle).forEach(([file, output]) => { - // // if (output.type === "chunk") { - // // output.code += `\n//# sourceURL=${file}`; - // // } - // // }); - // // }, - // // }, - // ], - // }, + worker: { + plugins: () => [ + wasm(), + topLevelAwait(), + ], + format: "es" + }, });