-
Notifications
You must be signed in to change notification settings - Fork 192
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
nodejs thinks it is in a browser environment #214
Comments
@devdoshi thanks for the bug report. I was thinking of detecting Node.js presence like this: /~https://github.com/flexdinesh/browser-or-node/blob/master/src/index.js#L11-L13 Fundamentally, our detection can never be perfect (as users can always define weird things like |
Thanks @josephlr - In my case I believe it was due to running the wasm module in Jest. I agree detection can never be perfect, but that logic you linked does look more robust. It would be nice to avoid the problem entirely though. Do you think there would be a convenient way to have it be explicitly decided by the caller, so something can pass from e.g. wasm-pack (which knows the target) all the way through to here and let it be decided at build time? Perhaps an additional feature that gets tacked on in addition to I appreciate the rapid response! |
Sounds good, if it's possible, see if #215 fixes your issue. Do you know if this would also require a backport to
I think adding this to the Rust+WASM tooling would be a good idea. Given that
I'm not aware of anything like this existing today, but if you want to file an issue upstream, I'd be happy to advocate for a solution and explain
We considered and rejected such an approach for |
to reproduce: $ OPTIC__BUILD_SKIP__UI=yes task postpull $ yarn workspace @useoptic/ui-v2 test
I'm not sure if this is something particular to my setup but I was running into:
panicked at 'from_entropy failed: Web API self.crypto is unavailable', /Users/dev/.cargo/registry/src/github.com-1ecc6299db9ec823/rand_core-0.6.2/src/lib.rs:381:13
when using a module created via
wasm-pack build --target nodejs ...
Based on my experimentation, it appears
getrandom/src/js.rs
Line 61 in 2471686
delete global.self
in my nodejs entry point resolved my issue. Thoughts?The text was updated successfully, but these errors were encountered: