Package resolution when importing with ES module
WangNianyi2001 opened this issue · 1 comments
WangNianyi2001 commented
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
This is not really an unsolvable problem, but it did take me a while to figure the thing out, so I think it'd be helpful to write a issue of solution here for others to search for later.
So if you're using NPM and your project is in ES module flavor, the correct way to initialize Essentia should be:
import EssentiaPkg from 'essentia.js';
const { Essentia, EssentiaWASM: { EssentiaWASM } } = EssentiaPkg;
const essentia = new Essentia(EssentiaWASM);
Don't know why EssentiaWASM
is wrapped in one more layer, but it is what it is.
My installed version is essentia.js@0.1.3
.
jmarcosfer commented
Thanks so much @WangNianyi2001!
Importing is a bit awkward for now indeed, so it's good to have this here.