# @istanbuljs/esm-loader-hook

> Loader hook for ESM instrumentation (experimental!!)

Latest version **0.3.0** (published 2024-12-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install @istanbuljs/esm-loader-hook
pnpm add @istanbuljs/esm-loader-hook
yarn add @istanbuljs/esm-loader-hook
bun add @istanbuljs/esm-loader-hook
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2024-12-27 |
| First published | 2020-03-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=16.12.0 |
| Dependencies | 7 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Maintainers | coreyfarrell, bcoe, jakxz, gotwarlost, oss-bot |

## Links

- npm: https://www.npmjs.com/package/@istanbuljs/esm-loader-hook
- Repository: https://github.com/istanbuljs/esm-loader-hook
- Homepage: https://github.com/istanbuljs/esm-loader-hook#readme
- Issues: https://github.com/istanbuljs/esm-loader-hook/issues
- npm.io page: https://npm.io/package/@istanbuljs/esm-loader-hook

## Dependencies (7)

- [@babel/core](https://npm.io/package/@babel/core.md) ^7.8.7
- [test-exclude](https://npm.io/package/test-exclude.md) ^6.0.0
- [@istanbuljs/schema](https://npm.io/package/@istanbuljs/schema.md) ^0.1.3
- [babel-plugin-istanbul](https://npm.io/package/babel-plugin-istanbul.md) ^6.0.0
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.26.0
- [@istanbuljs/load-nyc-config](https://npm.io/package/@istanbuljs/load-nyc-config.md) ^1.1.0
- [@babel/plugin-syntax-decorators](https://npm.io/package/@babel/plugin-syntax-decorators.md) ^7.25.9

## Recent versions

- 0.3.0 (latest) — 2024-12-27
- 0.2.0 — 2022-07-15
- 0.1.2 — 2020-05-31
- 0.1.1 — 2020-05-20
- 0.1.0 — 2020-03-17

## README

# @istanbuljs/esm-loader-hook

![Tests][tests-status]
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![ISC][license-image]](LICENSE)

This [loader hook](https://nodejs.org/dist/latest/docs/api/esm.html#esm_hooks)
makes it relatively easy to use NYC to check coverage of ESM running in node.js
16.12.0.  Note this makes use of **experimental** node.js features and thus may
stop working upon release of new versions of node.js.  Until the node.js feature
is stabilized breakage should not be unexpected.

For more stable options to test coverage you can:
* Use [c8]
* Pre-instrument your code (run `nyc instrument` then test the output)


## Adding to processes

To install this hook into a process the module must be provided through the
`--experimental-loader` flag.

The following can be used for your `npm test` script to enable live instrumentation
of ES modules being tested with mocha:

```sh
cross-env 'NODE_OPTIONS=--experimental-loader @istanbuljs/esm-loader-hook' nyc mocha
```


## Configuration

This module executes [babel-plugin-istanbul] in a loader hook.  No
options are provided to the babel plugin and babel configuration files are not honored.
Normally configuration will be provided by the currently running instance of nyc.  If
this module is run outside nyc then it will use `@istanbuljs/load-nyc-config` to load
options, defaults from `@istanbuljs/schema` will apply to missing options or if no
configuration is found.


[tests-status]: https://github.com/cfware/node-preload/workflows/Tests/badge.svg
[npm-image]: https://img.shields.io/npm/v/@istanbuljs/esm-loader-hook.svg
[npm-url]: https://npmjs.org/package/@istanbuljs/esm-loader-hook
[downloads-image]: https://img.shields.io/npm/dm/@istanbuljs/esm-loader-hook.svg
[downloads-url]: https://npmjs.org/package/@istanbuljs/esm-loader-hook
[license-image]: https://img.shields.io/github/license/istanbuljs/esm-loader-hook

[babel-plugin-istanbul]: https://github.com/istanbuljs/babel-plugin-istanbul#readme
[c8]: https://github.com/bcoe/c8#readme

---
_Source: https://npm.io/package/@istanbuljs/esm-loader-hook · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
