Utility to dynamically import ESM packages from CommonJS without tsc messing things up.
npm install @flystorage/dynamic-importThe TypeScript compiler turns dynamic import statements into require calls. This breaks importing
ESM packages in CommonJS code.
This utility helps to work around this by provided a JavaScript function to do the actual importing.
Install all the required packages
``bash`
npm install --save @flystorage/dynamic-import
`typescript
const {dynamicallyImport} = require('@flystorage/dynamic-import');
async function useFileType() {
const {fileTypeFromBuffer} = await dynamicallyImport
}
useFileType();
``