# default-import

> Properly handle CJS imports in ESM.

Latest version **3.0.1** (published 2026-10-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install default-import
pnpm add default-import
yarn add default-import
bun add default-import
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2026-10-05 |
| First published | 2022-05-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=24 |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 9 |
| Author | JacobLey |
| Maintainers | jacobley |
| Keywords | default, import, esm, cjs, module |

## Links

- npm: https://www.npmjs.com/package/default-import
- Repository: https://github.com/JacobLey/leyman
- Homepage: https://github.com/JacobLey/leyman/tree/main/tools/default-import#readme
- Issues: https://github.com/JacobLey/leyman/issues
- npm.io page: https://npm.io/package/default-import

## Recent versions

- 3.0.1 (latest) — 2026-10-05
- 1.1.5-dev.949cf02aa5b98b0d1512b784c55cdbc8a505dde2851cff95f3e24b14a8b2f62b (dev) — 2022-08-15
- 3.0.0 — 2026-10-04
- 2.0.8 — 2025-02-17
- 2.0.7 — 2025-01-05
- 2.0.6 — 2024-12-31
- 2.0.5 — 2024-12-31
- 2.0.4 — 2024-11-01
- 2.0.3 — 2024-10-26
- 2.0.2 — 2024-10-23
- 2.0.1 — 2024-08-08
- 2.0.0 — 2024-08-08
- 1.1.7 — 2024-08-08
- 1.1.6 — 2024-08-04
- 1.1.5 — 2022-08-15
- … 41 more at https://npm.io/package/default-import/versions

## README

# Leyman

An Nx monorepo of TypeScript libraries and tools for Node.js ESM environments.

> **First time here?** Open this repo in VSCode — it will prompt you to reopen in the [DevContainer](.devcontainer/), which sets up Node, PNPM, and all tooling automatically. Day-to-day work happens in git worktrees; see the [worktrees skill](./.claude/skills/worktrees/SKILL.md).

## Packages

Published to npm:

| Package | Description | Source |
|---|---|---|
| [`barrelify`](https://www.npmjs.com/package/barrelify) | Generate and CI-verify TypeScript barrel (index.ts) files with the correct ESM/CJS import extensions. | [`apps/barrelify`](./apps/barrelify) |
| [`common-proxy`](https://www.npmjs.com/package/common-proxy) | Wrap an ESM import so it is synchronously available as a promise-returning function in CommonJS. | [`tools/common-proxy`](./tools/common-proxy) |
| [`constant-consistent-hash`](https://www.npmjs.com/package/constant-consistent-hash) | Consistent hashing in constant time with no loops: stateless, evenly balanced, and only moves keys to new buckets. Portable across languages. | [`tools/constant-consistent-hash/constant-consistent-hash`](./tools/constant-consistent-hash/constant-consistent-hash) |
| [`default-import`](https://www.npmjs.com/package/default-import) | Properly handle CJS imports in ESM. | [`tools/default-import`](./tools/default-import) |
| [`entry-script`](https://www.npmjs.com/package/entry-script) | Modular control for entry script execution. | [`tools/entry-script`](./tools/entry-script) |
| [`enum-to-array`](https://www.npmjs.com/package/enum-to-array) | Convert Typescript Enums to a strongly typed array. | [`tools/enum-to-array`](./tools/enum-to-array) |
| [`find-import`](https://www.npmjs.com/package/find-import) | Find and load first instance of js/json in parent directories. | [`tools/find-import`](./tools/find-import) |
| [`format-file`](https://www.npmjs.com/package/format-file) | Utility API to format files via biome | [`tools/format-file`](./tools/format-file) |
| [`generated-signature`](https://www.npmjs.com/package/generated-signature) | Sign generated files so hand edits are detected, while keeping manual sections editable | [`tools/generated-signature/generated-signature`](./tools/generated-signature/generated-signature) |
| [`genever`](https://www.npmjs.com/package/genever) | Generate TypeScript types from JSON Schema files and OpenAPI documents, with strict schema checks and the same types Juniper infers. | [`apps/genever`](./apps/genever) |
| [`haywire`](https://www.npmjs.com/package/haywire) | Compile-time checked dependency injection for TypeScript — no decorators, no reflect-metadata, no global state. | [`tools/haywire`](./tools/haywire) |
| [`haywire-launcher`](https://www.npmjs.com/package/haywire-launcher) | Instantiate and execute your script in one line. | [`tools/haywire-launcher`](./tools/haywire-launcher) |
| [`iso-crypto`](https://www.npmjs.com/package/iso-crypto) | Isomorphic cryptography for browsers and Node.js — one API over WebCrypto and node:crypto for hashing, AES (including GCM), PBKDF2/HKDF key derivation and ECDH. | [`tools/iso-crypto`](./tools/iso-crypto) |
| [`juniper`](https://www.npmjs.com/package/juniper) | Build JSON Schemas in TypeScript with inferred static types — strict, Ajv-ready, JSON Schema 2020-12 and OpenAPI 3.0 output. | [`apps/juniper`](./apps/juniper) |
| [`juniper-validator`](https://www.npmjs.com/package/juniper-validator) | StandardSchema compliance for juniper. | [`apps/juniper-validator`](./apps/juniper-validator) |
| [`lease-cache`](https://www.npmjs.com/package/lease-cache) | Read-through caching on Valkey or Redis with leases: one load per key across every instance, and a load that finishes after an invalidation never caches its outdated value. | [`tools/lease-cache`](./tools/lease-cache) |
| [`load-populate-files`](https://www.npmjs.com/package/load-populate-files) | Load and dynamically populate file content | [`apps/populate-files/load-populate-files`](./apps/populate-files/load-populate-files) |
| [`mocha-chain`](https://www.npmjs.com/package/mocha-chain) | Chain mocha BDD methods together for deterministic and type safe tests. | [`tools/test-chain/mocha-chain`](./tools/test-chain/mocha-chain) |
| [`normalized-react-query`](https://www.npmjs.com/package/normalized-react-query) | Type-safe query definitions for TanStack Query — define each key and fetcher once, and link related queries so they prefetch together. | [`tools/normalized-react-query`](./tools/normalized-react-query) |
| [`nx-lifecycle`](https://www.npmjs.com/package/nx-lifecycle) | Nx plugin that derives every dependsOn from declared lifecycle stages (build, test, …) and the targets bound to them. | [`apps/nx-lifecycle`](./apps/nx-lifecycle) |
| [`parse-cwd`](https://www.npmjs.com/package/parse-cwd) | Convert relative path or URL to full path | [`tools/parse-cwd`](./tools/parse-cwd) |
| [`pg-dolly`](https://www.npmjs.com/package/pg-dolly) | A fresh Postgres database for every test, cloned from a template built once from your schema's SQL. | [`tools/pg-dolly`](./tools/pg-dolly) |
| [`pg-dolly-schema`](https://www.npmjs.com/package/pg-dolly-schema) | Keep a schema.sql of what your Postgres migrations build: migrate an empty database, dump it, and fail CI when the committed file is stale. | [`apps/pg-dolly-schema`](./apps/pg-dolly-schema) |
| [`populate-files`](https://www.npmjs.com/package/populate-files) | Dynamically populate file content | [`apps/populate-files/populate-files`](./apps/populate-files/populate-files) |
| [`punycode-esm`](https://www.npmjs.com/package/punycode-esm) | Typescript + ESM version of punycode.js | [`tools/punycode-esm`](./tools/punycode-esm) |
| [`static-emitter`](https://www.npmjs.com/package/static-emitter) | Statically typed event emitter. | [`tools/static-emitter`](./tools/static-emitter) |
| [`test-chain-core`](https://www.npmjs.com/package/test-chain-core) | Framework-agnostic internals for chaining test hooks with typed context | [`tools/test-chain/test-chain-core`](./tools/test-chain/test-chain-core) |
| [`unknown-error`](https://www.npmjs.com/package/unknown-error) | Turn any caught `unknown` into a real Error without throwing, even for hostile values, other realms and deep or circular cause chains. | [`tools/unknown-error`](./tools/unknown-error) |
| [`vitest-chain`](https://www.npmjs.com/package/vitest-chain) | Chain vitest methods together for deterministic and type safe tests | [`tools/test-chain/vitest-chain`](./tools/test-chain/vitest-chain) |
| [`weighted-rendezvous-hash`](https://www.npmjs.com/package/weighted-rendezvous-hash) | Weighted rendezvous hashing: any set of nodes, in any order, sized by proportion, moving few keys when the set changes. | [`tools/constant-consistent-hash/weighted-rendezvous-hash`](./tools/constant-consistent-hash/weighted-rendezvous-hash) |

Private workspace packages (shared configs and tooling) are listed in the [projects skill](./.claude/skills/projects/SKILL.md).

Packages that have been removed from the repo but are still on npm are listed in [`DEPRECATED_PACKAGES.md`](./DEPRECATED_PACKAGES.md).

A documentation site, with every code example type-checked, is in [`docs/`](./docs) (`barrelify`, `entry-script`, `generated-signature`, `genever`, `haywire`, `haywire-launcher`, `juniper`, `juniper-validator`, `lease-cache`, `mocha-chain`, `normalized-react-query`, `nx-lifecycle`, `populate-files`, `unknown-error` and `vitest-chain` so far), plus the demos.

## Demos

Worked examples of putting open-source projects and services together well, in [`demos/`](./demos). They are never published: the code and its write-up are the point. Each is tested against real services (devcontainer sidecars, and the same images in CI) with 100% coverage, with every feature behind a [haywire](./tools/haywire) binding so each can be tested on its own. Also on the [docs site](https://jacobley.github.io/leyman/demos/).

| Demo | What it shows | Source |
|---|---|---|
| [OpenAPI, spec to server](./demos/openapi) | A spec built with [Juniper](./apps/juniper), a client and a server typed by [genever](./apps/genever), the server validating every request and response against `openapi.json` with bearer auth, on Postgres with Drizzle, tested with [`pg-dolly`](./tools/pg-dolly). | [`demos/openapi`](./demos/openapi) |
| [Read-through cache](https://jacobley.github.io/leyman/demos/read-through-cache) | BentoCache on Valkey: a memory tier kept in sync, stale-while-revalidate, one load per key across instances with [`lease-cache`](./tools/lease-cache), and sharding with [`weighted-rendezvous-hash`](./tools/constant-consistent-hash/weighted-rendezvous-hash). | [`demos/read-through-cache`](./demos/read-through-cache) |

## Getting Started

```bash
# Install dependencies
pnpm i

# Build and test everything
test-ci
```

> **Nx is not globally installed.** It ships with `@leyman/main` and is on `PATH` automatically. Use `nx` directly — not `npx nx` or `pnpm exec nx`.

See [`AGENTS.md`](./AGENTS.md) for the full skill index.

## CI

This repo uses [Dagger](https://dagger.io/) for CI. To replicate CI locally:

```bash
dagger-test
# or equivalently:
dagger call --mod ./dagger test
```

Run `test-ci` first — it's faster for iteration. Use Dagger to confirm before pushing.

See all aliased (added to `PATH` by [`devcontainer.json`](./.devcontainer/devcontainer.json)) scripts in the [/scripts/commands](./scripts/commands) directory.

## Coding Agents

Agent docs start at [`AGENTS.md`](./AGENTS.md) (also linked as `CLAUDE.md`). In the devcontainer, Claude Code config (credentials, settings, memory) lives in `<main checkout>-worktrees/.shared/claude-config`, outside version control and shared by every worktree. See the [worktrees skill](./.claude/skills/worktrees/SKILL.md).

(If you use a different coding agent, PRs are welcome to support those directories).

## Contributing

Contributions are welcome! See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for setup, conventions and how to submit a pull request. In short:

1. Make your changes
2. Run `test-ci` to verify
3. Run `changeset` and follow the prompts to document your changes
4. Submit a PR — GitHub Actions runs Dagger automatically

This project follows the [Contributor Covenant Code of Conduct](./CODE_OF_CONDUCT.md). To report a security vulnerability, see [`SECURITY.md`](./SECURITY.md).

## Tooling

| Tool | Role |
|------|------|
| [PNPM](https://pnpm.io/) | Package manager with workspace support |
| [Nx](https://nx.dev/) | Task runner with caching and dependency graph |
| [TypeScript](https://www.typescriptlang.org/) | Language (ESM, strict mode) |
| [SWC](https://swc.rs/) | Fast TypeScript compiler |
| [ESLint](https://eslint.org/) | Linting (opinionated, 15+ plugins) |
| [Biome](https://biomejs.dev/) | Formatting |
| [Mocha](https://mochajs.org/) + [Chai](https://www.chaijs.com/) (via `@leyman/expect`) | Testing |
| [C8](https://github.com/bcoe/c8) | Coverage (100% required) |
| [Dagger](https://dagger.io/) | CI pipeline |
| [Changesets](https://github.com/changesets/changesets) | Versioning and changelogs |

## License

[MIT](./LICENSE) © Jacob Ley

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