# karma-esbuild

> ESBuild preprocessor for karma test runner

Latest version **2.3.0** (published 2023-11-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install karma-esbuild
pnpm add karma-esbuild
yarn add karma-esbuild
bun add karma-esbuild
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.0 |
| Published | 2023-11-06 |
| First published | 2021-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 28.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | Marvin Hagemeister |
| Maintainers | jridgewell, marvinhagemeister |
| Keywords | karma-plugin, karma-preprocessor, esbuild |

## Links

- npm: https://www.npmjs.com/package/karma-esbuild
- Repository: https://github.com/marvinhagemeister/karma-esbuild
- Homepage: https://github.com/marvinhagemeister/karma-esbuild#readme
- Issues: https://github.com/marvinhagemeister/karma-esbuild/issues
- npm.io page: https://npm.io/package/karma-esbuild

## Dependencies (2)

- [chokidar](https://npm.io/package/chokidar.md) ^3.5.1
- [source-map](https://npm.io/package/source-map.md) 0.6.1

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 2.3.0 (latest) — 2023-11-06
- 2.2.5 — 2022-09-08
- 2.2.4 — 2022-03-10
- 2.2.3 — 2022-03-10
- 2.2.2 — 2022-02-26
- 2.2.1 — 2022-02-17
- 2.2.0 — 2021-05-14
- 2.1.3 — 2021-03-23
- 2.1.2 — 2021-03-20
- 2.1.1 — 2021-03-11
- 2.1.0 — 2021-03-09
- 2.0.0 — 2021-03-08
- 1.1.5 — 2021-02-26
- 1.1.4 — 2021-02-13
- 1.1.3 — 2021-02-13
- … 11 more at https://npm.io/package/karma-esbuild/versions

## README

# karma-esbuild

An [esbuild](https://github.com/evanw/esbuild) preprocessor for the karma test runner. The main benefits of `esbuild` is speed and readability of the compiled output.

## Installation

```bash
npm install --save-dev karma-esbuild
```

## Usage

Add `esbuild` as your preprocessor inside your `karma.conf.js`:

```js
module.exports = function (config) {
	config.set({
		preprocessors: {
			// Add esbuild to your preprocessors
			"test/**/*.test.js": ["esbuild"],
		},
	});
};
```

### Advanced: Custom configuration

A custom esbuild configuration can be passed via an additional property on karma's config. Check out the [documentation for esbuild](https://esbuild.github.io/api/) for available options.

```js
module.exports = function (config) {
	config.set({
		preprocessors: {
			// Add esbuild to your preprocessors
			"test/**/*.test.js": ["esbuild"],
		},

		esbuild: {
			// Replace some global variables
			define: {
				COVERAGE: coverage,
				"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || ""),
				ENABLE_PERFORMANCE: true,
			},
			plugins: [createEsbuildPlugin()],

			// Karma-esbuild specific options
			singleBundle: true, // Merge all test files into one bundle(default: true)
		},
	});
};
```

## License

`MIT`, see [the LICENSE](./LICENSE) file.

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