Closed michaelessiet closed 5 months ago
Could you share a reproduction so I can look into this? I have minimal experience with wasm, and it would take a long time for me to maybe reproduce this on my own.
I also bumped into this, but I don't think this is related to wasm. It should happen anywhere you try to use top-level await, which is not supported by iife
modules. I have a simple repro available here.
Is there a reason to use iife
here over es
? I haven't tested it, but I would guess recent browsers would support ESM in browser extension scripts?
Edit: I'm wrong about recent browsers supporting ESM in extension scripts (at least for content scripts) [1][2].
That being said, there are workarounds to allow us to import ESMs as content and background scripts. It'd be helpful to me if it was possible to have the plugin only output ESM and I'd manually write the shim to import the module. Here's an example of that in action.
Summary
I'm currently building a web extension that makes use of tiny-secp256k1 by bitcoinjs. Prior to making use of this all I had to add to my vite config was the vite-wasm-plugin and vite-plugin-top-level-await. However, this plugin isn't compatible with WASM in turn making it incompatible with vite-wasm-plugin.
Please is there a way around this? I have dropped the error screenshot below. The error seems to be about the bundle target being iife instead of es, but I set esnext as my target in the vite.config.js
Environment