1.0.0 • Published 1 year ago

@flystorage/dynamic-import v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Utility for dynamically importing ESM code

The 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.

Installation

Install all the required packages

npm install --save @flystorage/dynamic-import

Usage

const {dynamicallyImport} = require('@flystorage/dynamic-import');

async function useFileType() {
    const {fileTypeFromBuffer} = await dynamicallyImport<typeof import('file-type')>('file-type');
}

useFileType();
1.0.0

1 year ago

0.1.0

1 year ago