-
Notifications
You must be signed in to change notification settings - Fork 144
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
Failing on Cloudflare Workers #212
Comments
Hi Tomé, There isn't any The But if you only need the WebAssembly version, you can compile a version leveraging WASI with the |
Thank you Denis, There are some |
This is the code emscripten generates to check the platform the module is running on: var ENVIRONMENT_IS_WEB = false;
var ENVIRONMENT_IS_WORKER = false;
var ENVIRONMENT_IS_NODE = false;
var ENVIRONMENT_IS_SHELL = false;
ENVIRONMENT_IS_WEB = typeof window === 'object';
ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function' && !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER;
ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER; You may be able to trick it by undefining |
Thank you again! Was able to use it as a shell. module: {
rules: [
{
test: require.resolve('libsodium-sumo'),
use:
'imports-loader?window=>undefined,importScripts=>undefined,process=>undefined',
},
],
},
plugins: [
new webpack.ProvidePlugin({
TextEncoder: ['text-encoding', 'TextEncoder'],
TextDecoder: ['text-encoding', 'TextDecoder'],
}),
], I had to also add the Tested a couple of functions and works very well. Thank you again for the work you have been doing on libsodium. |
Wow, thanks for the update! I didn't know that something like that was possible. Great! |
If someone needed here is fix when you are using TS make export {};
declare global {
const USERS: KVNamespace;
var window: any;
var importScripts: any;
} and set import libsodium from 'libsodium-wrappers';
globalThis.window = undefined;
globalThis.importScripts = undefined;
await libsodium.ready; |
Hi
When I try to use libsodium with Cloudflare workers, with
libsodium-sumo
module, I getTypeError: Cannot read property 'href' of undefined
.I think it has to do with it trying to use the worker sandbox as a browser.
Do you plan to ship
.wasm
files on this project? that would work!Kind Regards,
Tomé
The text was updated successfully, but these errors were encountered: