# rollup-plugin-shim

> Plugin for rollup to provide a shim implementation for a module.

Latest version **1.0.0** (published 2017-07-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-shim
pnpm add rollup-plugin-shim
yarn add rollup-plugin-shim
bun add rollup-plugin-shim
```

## 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 | 1.0.0 |
| Published | 2017-07-15 |
| First published | 2017-07-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Patrick Hulce |
| Maintainers | patrickhulce |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-shim
- Repository: https://github.com/patrickhulce/rollup-plugin-shim
- Homepage: https://github.com/patrickhulce/rollup-plugin-shim#readme
- Issues: https://github.com/patrickhulce/rollup-plugin-shim/issues
- npm.io page: https://npm.io/package/rollup-plugin-shim

## Recent versions

- 1.0.0 (latest) — 2017-07-15

## README

# rollup-plugin-shim
[![NPM Package](https://badge.fury.io/js/rollup-plugin-shim.svg)](https://www.npmjs.com/package/rollup-plugin-shim)
[![Build Status](https://travis-ci.org/patrickhulce/rollup-plugin-shim.svg?branch=master)](https://travis-ci.org/patrickhulce/rollup-plugin-shim)
[![Coverage Status](https://coveralls.io/repos/github/patrickhulce/rollup-plugin-shim/badge.svg?branch=master)](https://coveralls.io/github/patrickhulce/rollup-plugin-shim?branch=master)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![Dependencies](https://david-dm.org/patrickhulce/rollup-plugin-shim.svg)](https://david-dm.org/patrickhulce/rollup-plugin-shim)

Plugin for rollup to provide a shim implementation for a module. Replaces required dependencies with the specified string instead, especially useful for shimming small dev-time APIs with a big footprint you don't want in production (like [debug](https://www.npmjs.com/package/debug)). For larger fully functional implementations that you want to use a file for you might want to consider the [rollup-plugin-alias](https://www.npmjs.com/package/rollup-plugin-alias) package instead.

## Usage

### Install

`yarn add -D rollup-plugin-shim`

### Shim

**src/main.js**

```js
import {writeFileSync} from 'fs'
import debug from 'debug'
import {bigFunction} from './local-dep'

const log = debug('mypackage:main')
// ...
```

**rollup.config.js**

```js
import {join} from 'path'
import shim from 'rollup-plugin-shim'

export default {
  entry: 'src/main.js',
  plugins: [
    shim({
      // replace fs with a noop shim
      fs: `export function writeFileSync() { }`,
      // replace debug to return a noop function
      debug: `export default () => () => undefined`,
      // replace a local dependency with a noop
      // can also use './local-dep' as the key if that's the only way it's required
      [join(__dirname, 'src/local-dep')]: `export function bigFunction() { }`,
    }),
  ],
}
```

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