# with-loader

> wrap your code in with

Latest version **1.0.0** (published 2019-04-22) · 0 weekly downloads

## Install

```sh
npm install with-loader
pnpm add with-loader
yarn add with-loader
bun add with-loader
```

## 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 | 2019-04-22 |
| First published | 2019-04-22 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 1.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | mlrawlings |

## Links

- npm: https://www.npmjs.com/package/with-loader
- Repository: https://github.com/mlrawlings/with-loader
- Homepage: https://github.com/mlrawlings/with-loader#readme
- Issues: https://github.com/mlrawlings/with-loader/issues
- npm.io page: https://npm.io/package/with-loader

## Dependencies (1)

- [loader-utils](https://npm.io/package/loader-utils.md) ^1.2.3

## Recent versions

- 1.0.0 (latest) — 2019-04-22

## README

# `with-loader`

![image](https://img.shields.io/badge/🔥-Blazing%20Fast-red.svg)
![image](https://img.shields.io/badge/👌-Production%20Ready-00ddcc.svg)
![image](https://img.shields.io/badge/🐛-Bug%20Free-green.svg)
![image](https://img.shields.io/badge/🦄-Just%20Works-cc00cc.svg)

## Why

- 📦 reduce bundle size by eliminating property access
- 💄 less code === more beautiful code
- 💥 your co-workers won't know what hit them
- 🚀 totally not a bad idea

## Installation

```
npm i -D with-loader
```

## Example Usage

Within your webpack configuration object, you'll need to add the with-loader to the list of modules, like so:

```js
module: {
  rules: [
    {
      test: /\.js$/,
      use: {
        loader: 'with-loader',
        options: {
          contexts: ['Math', JSON.stringify({ radius:10 })]
        }
      }
    }
  ]
}
```

Now the code that we're bundling can access variables from `Math` and our custom object!

```js
const area = PI * pow(radius, 2);
```

![image](https://i.kym-cdn.com/photos/images/newsfeed/000/538/716/7f5.gif)

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