MTG/essentia.js

Webpack: error for missing modules in WASM version

Opened this issue · 1 comments

What is the issue about?

  • Bug
  • Feature request
  • Usage question
  • Documentation
  • Contributing / Development

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

  • essentia.js-core (vanilla algorithms)
  • essentia.js-model (machine learning algorithms)
  • essentia.js-plot (plotting utility module)
  • essentia.js-extractor (typical algorithm combinations utility)

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

  • essentia.js-Version: 0.1.3
  • Webpack: 5.74.0
  • NodeJS: v21.7.2

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.