1. @cspell/dynamic-import
Dynamic Module Loader
@cspell/dynamic-import
Package: @cspell/dynamic-import
Created by: streetsidesoftware
Last modified: Wed, 10 Apr 2024 13:04:00 GMT
Version: 8.7.0
License: MIT
Downloads: 1,601,145
Repository: https://github.com/streetsidesoftware/cspell

Install

npm install @cspell/dynamic-import
yarn add @cspell/dynamic-import

@cspell/dynamic-import

A small library to assist with dynamically loading CommonJS and ESM Modules from either CommonJS or ESM Modules.

Install

 npm install -S @cspell/dynamic-import

Usage

Example ESM Package

Example loading chalk v5 which is an ESM only module.

TypeScript Common JS

 import { dynamicImport } from '@cspell/dynamic-import';

const pChalk = dynamicImport<typeof import('chalk')>('chalk', __dirname);

TypeScript ESM

 import { dynamicImport } from '@cspell/dynamic-import';

const pChalk = dynamicImport<typeof import('chalk')>('chalk', import.meta.url);

Example ESM files

TypeScript Common JS

 import { dynamicImport } from '@cspell/dynamic-import';

const pIndex = dynamicImport<typeof import('../esm/index.mjs')>('../esm/index.mjs', __dirname);


Brought to you by Street Side Software Logo Street Side Software

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code