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" + }, });