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
627 stars 41 forks source link

Webpack: error for missing modules in WASM version #141

Open daFish opened 2 months ago

daFish commented 2 months ago

What is the issue about?

What part(s) of Essentia.js is involved?

Description

I'm using webpack to bundle my scripts and I get the following warning/errors:

Module build failed: Module not found:
"./node_modules/essentia.js/dist/essentia-wasm.es.js" contains a reference to the file "crypto".
This file can not be found, please check it for typos or update it if the file got moved.

 ERROR  Failed to compile with 2 errors                                                                                                                                                                                            12:06:27

Module build failed: Module not found:
"./node_modules/essentia.js/dist/essentia-wasm.es.js" contains a reference to the file "path".
This file can not be found, please check it for typos or update it if the file got moved.

"./node_modules/essentia.js/dist/essentia-wasm.es.js" contains a reference to the file "fs".
This file can not be found, please check it for typos or update it if the file got moved.

Is there anything I can do to prevent such an error? Note: The script is working however.

Steps to reproduce / Code snippets / Screenshots

Small sample script:

import Essentia from 'essentia.js/dist/essentia.js-core.es';
import { EssentiaWASM } from 'essentia.js/dist/essentia-wasm.es.js';

export default class EssentiaProcessor {
    essentia: Essentia;

    constructor() {
        this.essentia = new Essentia(EssentiaWASM, process.env.NODE_ENV === 'development');
    }
}

System info

daFish commented 2 months ago

After some more research I found a solution(?). The errors are caused by the WASM integration and the configuration of the following experiments in my webpack.config.js:

module.exports = {
  //...
    experiments = {
        asyncWebAssembly: true,
        futureDefaults: true,
        lazyCompilation: true,
        outputModule: true,
        syncWebAssembly: true,
    }
};

I'll test this further and report, when I find issues.

Update: Nevermind, doesn't work.