-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build with a .wasm file instead of minified+compressed+inlined wasm #92
Comments
That might be a good feature, but the built in wasm code is heavily integrated throughout this library. What's the limitation with Cloudflare Workers that doesn't allow this? If there's some error, it might be easier to fix that than to make this change. |
Yes, I realize it would require an entirely different build script, that's what I've done locally. The workers environment simply does not allow instantiating from an arbitrary byte source- they want their compiler to evaluate the .wasm file. I think some other hosts might have this limitation, possibly Fastly. One solution might be to make it possible to pass in the .wasm file when instantiating a Decoder, and use that instead of the inlined one. The asm exports would have to be exactly the same, though, so it would be beneficial to have a build script that produces both artifacts (or rather, doesn't delete the original .wasm file after inlining). That way I could |
Ah, there's another problem that I just remembered that is related to CF: There is (ironically) no |
Is this environment using NodeJS or something else? Do you have a link to a doc on how they expect WASM to compile? This seems very unusual to me. Either way you're supplying the same WASM code to the compiler when calling WebAssembly.compile() regardless of where it comes from...
If you want to put together a fork or example with this that would be helpful. I think your idea of another export would work. I don't want to increase the export size of the package unless at a last resort, so being able to tree shake this out would be ideal.
I have some code that toggles on a NodeJS
|
This is the environment: https://github.com/cloudflare/workerd They don't really document the limitation anywhere. The error it gives is
Yes, using separate exports in package.json would achieve this. I'll put together a fork.
Unfortunately no, it seems to choke even at the mention of any global scope objects that don't exist, so this kind of feature sniffing doesn't work. The separate export I think is the only way. |
I think there should be an issue in their repo for this. Either way, the developer provides the same code whether in a file or as a byte array, so I don't see what this would protect from a security standpoint. At the minimum, they should update their docs :) It looks like that project is still in beta, so now would be a good time to get this fixed.
A try / catch might work here. If you want to try that, and put in a PR if it works, that would be awesome. |
Hi,
I'm working with Cloudflare Workers, and in that environment you can't dynamically load wasm from base64 or gzipped data- just the
import wasmContent from './wasmfile.wasm'
style of importing. I've mangled a local version of the build to work with this but I was wondering if it'd make sense to try to work this upstream into your repo somehow, maybe as a different export inside each package? Thanks!The text was updated successfully, but these errors were encountered: