-
Notifications
You must be signed in to change notification settings - Fork 24
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
Issue that arise when using a webpack #27
Comments
Sorry to hear you're bumping into problems with this. If you're able to apply a small patch to that file, maybe you could check whether an approach like this would work? diff --git a/memory.js b/memory.js
index 4d8aa4f..25890f8 100644
--- a/memory.js
+++ b/memory.js
@@ -1,6 +1,12 @@
/* eslint-disable camelcase */
var MessageChannel = global.MessageChannel
-if (MessageChannel == null) ({ MessageChannel } = require('worker' + '_threads'))
+try {
+ ({ MessageChannel } = require('worker' + '_threads'))
+} catch (e) {
+ if (MessageChannel == null) {
+ throw e
+ }
+}
function sodium_malloc (n) {
return new Uint8Array(n) |
What the funky require line does above is bust browserify's static require resolution, but I guess webpack goes a bit beyond that. That module is not supposed to be loaded in a browser setting, but is a "hack" to get a place to throw Buffers away, in the same way that sodium-native's |
Yes, it works well. |
I love sodium-javascript. And I'm using it so well.
I met a problem like this. Please solve this problem.
Module not found: Error: Can't resolve 'worker_threads' in '/node_modules/sodium-javascript'
@ ./node_modules/sodium-javascript/memory.js 3:50-80
@ ./node_modules/sodium-javascript/index.js
The text was updated successfully, but these errors were encountered: