Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@flystorage/dynamic-import

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flystorage/dynamic-import

Utility to dynamically import ESM packages from CommonJS without tsc messing things up.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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();

FAQs

Package last updated on 12 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts