EssentiaWASM.EssentiaJS is not a constructor
ng-jim opened this issue · 1 comments
What is the issue about?
- Usage question
What part(s) of Essentia.js is involved?
Initialisation
Description
I'm sure I'm doing something fairly obviously wrong here, but can't get past it :(
I have a web worker with the following code ....
`//import { Essentia, EssentiaWASM } from "essentia.js";
const ess = require("essentia.js");
function testEssentia() {
const essentia = new ess.Essentia(ess.EssentiaWASM, true);
}
/* eslint-disable no-restricted-globals */
self.onmessage = ({ data: { question } }) => {
testEssentia();
self.postMessage({
answer: 42,
});
};`
Which always hits an error in essentia.js-core.umd.js here :
That error being :
"Uncaught TypeError: EssentiaWASM.EssentiaJS is not a constructor
at new Essentia (essentia.js-core.umd.js:95:1)"
Does not seem to matter whether I use the Import or the require syntax.
I've tried everything I can think of, it's no doubt something rather simple that I'm just ignorant about,
I'm afraid my web skills are a bit rusty and out of date.
Many thanks in advance!
System info
MacOS, node version v16.15.0, webpack 5 under Create React App, chrome canary : Version 104.0.5091.0 (Official Build) canary (x86_64)
Hi @ng-jim
I have a similar setup running essentia.js in a web worker (with Vue). Try accessing EssentiaWASM
as EssentiaWASM.EssentiaWASM
. In your example that would be:
// import { Essentia, EssentiaWASM } from "essentia.js";
const ess = require("essentia.js");
function testEssentia() {
const essentia = new ess.Essentia(ess.EssentiaWASM.EssentiaWASM, true);
}
This is due to a quirk in the library to make it work with different JS module systems.
Let me know if this works!