Currently if you import the 'wavefile' package from an ES module in Node, Node will use the CommonJS module in dist/wavefile.js and treat the object exported there as the default export.
This means that in order to get the WaveFile class, you will need to do:
import waveFileModule from 'wavefile';
const { WaveFile } = waveFileModule;
rather than the expected pattern of:
import { WaveFile } from 'wavefile';
The change in this PR re-exports WaveFile in a ESM wrapper module.
Following the approach recommended in the Node.js documentation:
https://nodejs.org/api/packages.html#approach-1-use-an-es-module-wrapper
Reason for change
Currently if you import the
'wavefile'
package from an ES module in Node, Node will use the CommonJS module indist/wavefile.js
and treat the object exported there as the default export. This means that in order to get theWaveFile
class, you will need to do:rather than the expected pattern of:
The change in this PR re-exports
WaveFile
in a ESM wrapper module.