1. @cspell/dynamic-import
Dynamic Module Loader
@cspell/dynamic-import
Package: @cspell/dynamic-import
Created by: streetsidesoftware
Last modified: Fri, 03 May 2024 15:15:17 GMT
Version: 8.8.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

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin