# @cspell/dynamic-import

> Dynamic Module Loader

Latest version **10.3.3** (published 2026-09-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cspell/dynamic-import
pnpm add @cspell/dynamic-import
yarn add @cspell/dynamic-import
bun add @cspell/dynamic-import
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 10.3.3 |
| Published | 2026-09-16 |
| First published | 2023-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.18.0 |
| Dependencies | 2 |
| Unpacked size | 8.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1684 |
| Author | Jason Dent |
| Maintainers | jason-dent |
| Keywords | module, esm, cjs, import, require |

## Links

- npm: https://www.npmjs.com/package/@cspell/dynamic-import
- Repository: https://github.com/streetsidesoftware/cspell
- Homepage: https://github.com/streetsidesoftware/cspell/tree/main/packages/dynamic-import#readme
- Issues: https://github.com/streetsidesoftware/cspell
- npm.io page: https://npm.io/package/@cspell/dynamic-import

## Dependencies (2)

- [@cspell/url](https://npm.io/package/@cspell/url.md) 10.3.3
- [import-meta-resolve](https://npm.io/package/import-meta-resolve.md) ^4.2.0

## Recent versions

- 10.3.3 (latest) — 2026-09-16
- 10.3.4-alpha.0 (next) — 2026-09-17
- 10.3.2 — 2026-09-15
- 10.3.2-alpha.0 — 2026-09-13
- 10.3.1 — 2026-09-13
- 10.3.1-alpha.1 — 2026-09-12
- 10.3.1-alpha.0 — 2026-09-12
- 10.3.0 — 2026-09-08
- 10.3.0-alpha.0 — 2026-09-04
- 10.2.2 — 2026-09-04
- 10.2.1 — 2026-09-03
- 10.2.0 — 2026-08-31
- 10.2.0-alpha.7 — 2026-08-30
- 10.2.0-alpha.5 — 2026-08-30
- 10.2.0-alpha.4 — 2026-08-30
- … 141 more at https://npm.io/package/@cspell/dynamic-import/versions

## README

# `@cspell/dynamic-import`

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

## Install

```sh
npm install -S @cspell/dynamic-import
```

## Usage

### Example ESM Package

Example loading [chalk v5](https://www.npmjs.com/package/chalk), which is an ESM-only module.

**TypeScript CommonJS**

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

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

**TypeScript ESM**

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

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

### Example ESM files

**TypeScript CommonJS**

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

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

<!--- @@inject: ../../static/footer.md --->

<br/>

---

<p align="center">Brought to you by<a href="https://streetsidesoftware.com" title="Street Side Software"><img width="16" alt="Street Side Software Logo" src="https://i.imgur.com/CyduuVY.png" /> Street Side Software</a></p>

<!--- @@inject-end: ../../static/footer.md --->

<!--- cspell:dictionaries typescript --->

---
_Source: https://npm.io/package/@cspell/dynamic-import · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
