MTG / essentia.js

JavaScript library for music/audio analysis and processing powered by Essentia WebAssembly
https://essentia.upf.edu/essentiajs
GNU Affero General Public License v3.0
628 stars 41 forks source link

Cannot import node module on Electron. #49

Closed lane203m closed 2 years ago

lane203m commented 3 years ago

due to the size of the wasm file, I cannot require the essentia.js module on my electron application. How may I work around this? I do not understand how to use web workers for this purpose.

grofit commented 2 years ago

Did you ever solve this? I am just messing around with the library in electron at the moment and I cant run it in main process as that doesn't have an implementation of AudioContext and cant run it in renderer process as the wasm cant be imported and all workarounds with workers seem to throw some issue or other, and cant include it via script tags as they all get stripped via webpack.

lane203m commented 2 years ago

I did

See https://github.com/lane203m/SoundByte/blob/master/Soundbyte-App/src/main.ts

onReady must set webPreferences: {nodeIntegration: true, enableRemoteModule: true, nodeIntegrationInWorker: true}

Here is an example of my web workers https://github.com/lane203m/SoundByte/tree/master/Soundbyte-App/src/Initialization/buildJSON https://github.com/lane203m/SoundByte/blob/master/Soundbyte-App/src/Initialization/buildJSON/workers/primes/essentiaWorker.js

Here is the project https://github.com/lane203m/SoundByte

grofit commented 2 years ago

Thanks for information, I still cant get it working as webpack complains it cant resolve path which makes sense as the umd module seems to require it, anyway its another source to draw from to try and get it working, thanks again.

jmarcosfer commented 2 years ago

Sorry, we still haven't tried the library with Electron. Thanks a lot @lane203m for sharing your solution!