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.

1.0.0
latest
Source
npmnpm
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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.