# @macro-plugin/webpack

> Macro plugins integration for webpack

Latest version **1.2.1** (published 2023-06-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @macro-plugin/webpack
pnpm add @macro-plugin/webpack
yarn add @macro-plugin/webpack
bun add @macro-plugin/webpack
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2023-06-16 |
| First published | 2023-04-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 16.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Raven Satir |
| Maintainers | voorjaar |
| Keywords | webpack, macro, macro-plugin |

## Links

- npm: https://www.npmjs.com/package/@macro-plugin/webpack
- Repository: https://github.com/macro-plugin/macros
- Homepage: https://github.com/macro-plugin/macros/tree/main/packages/webpack
- Issues: https://github.com/macro-plugin/macros/issues
- npm.io page: https://npm.io/package/@macro-plugin/webpack

## Dependencies (2)

- [@macro-plugin/core](https://npm.io/package/@macro-plugin/core.md) 1.2.0
- [@macro-plugin/shared](https://npm.io/package/@macro-plugin/shared.md) 1.2.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

- 1.2.1 (latest) — 2023-06-16
- 1.2.0 — 2023-05-08
- 1.1.0 — 2023-05-03
- 1.0.6 — 2023-05-02
- 1.0.5 — 2023-04-27
- 1.0.4 — 2023-04-27
- 1.0.3 — 2023-04-24
- 1.0.2 — 2023-04-23
- 1.0.1 — 2023-04-22
- 1.0.0 — 2023-04-20

## README

# @macro-plugin/webpack

[Macro Plugin](https://github.com/macro-plugin) integration for vite. It supports transform macros and typescript and also jsx.

## Installation

```sh
# if you use npm
npm i -D @macro-plugin/webpack
# if you use pnpm
pnpm i -D @macro-plugin/webpack
# if you use yarn
yarn add -D @macro-plugin/webpack
```

## Usage

`webpack.config.js`:

```js
import { resolve } from "path"

/** @type { import("webpack").Configuration } */
export default {
  mode: "production",
  entry: resolve("./src/index.ts"),
  output: {
    path: resolve("./dist"),
    filename: "index.js"
  },
  module: {
    rules: [
      {
        test: /\.(t|j)sx?$/,
        exclude: /node_modules/,
        use: [
          {
            loader: "@macro-plugin/webpack"
          }
        ]
      }
    ]
  }
}
```

It will load the configuration from `macros.config.js` or `macros.config.ts` by default. You can also customize it:

```js
import { resolve } from "path"

/** @type { import("webpack").Configuration } */
export default {
  mode: "production",
  entry: resolve("./src/index.ts"),
  output: {
    path: resolve("./dist"),
    filename: "index.js"
  },
  module: {
    rules: [
      {
        test: /\.(t|j)sx?$/,
        exclude: /node_modules/,
        use: [
          {
            loader: "@macro-plugin/webpack",
            /** @type { import("@macro-plugin/core").Config } */
            options: {
              emitDts: true
            }
          }
        ]
      }
    ]
  }
}
```

`macros.config.ts`:

```js
import { defineConfig } from "@macro-plugin/core"

export default defineConfig({
  macros: [],
  emitDts: true,
  jsc: {
    parser: {
      syntax: "typescript"
    },
    target: "esnext",
  },
})
```

Or with commonjs

`macros.config.js`

```js
/** @type {import("@macro-plugin/core").Config} */
module.exports = {
  macros: [],
  emitDts: true,
  jsc: {
    parser: {
      syntax: "typescript"
    },
    target: "esnext",
  },
}
```

## License

MIT

[MacroPlugin]: https://github.com/macro-plugin

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