# vite-plugin-bundle

> Create plugins to improve bundeling external chunks.

Latest version **1.1.1** (published 2022-01-21) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install vite-plugin-bundle
pnpm add vite-plugin-bundle
yarn add vite-plugin-bundle
bun add vite-plugin-bundle
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2022-01-21 |
| First published | 2021-08-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 20.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Sebastian Krüger |
| Maintainers | mathe42 |
| Keywords | vite, bundle, helpers |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-bundle
- Repository: https://github.com/mathe42/vite-plugin-bundle
- npm.io page: https://npm.io/package/vite-plugin-bundle

## Dependencies (1)

- [magic-string](https://npm.io/package/magic-string.md) ^0.25.7

## 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.1.1 (latest) — 2022-01-21
- 1.1.0 — 2022-01-21
- 1.0.1 — 2021-09-24
- 1.0.0 — 2021-09-24
- 0.3.0 — 2021-09-24
- 0.2.0 — 2021-08-28
- 0.1.0 — 2021-08-28

## README

# vite-plugin-bundle

Create plugins to improve bundeling external chunks.

### Install

```sh
npm i --save-dev vite-plugin-bundle # yarn add -D vite-plugin-comlink
```

## What is this plugin?
> This plugin is more like a "meta-plugin" that can be used by other plugins. Directly using this Plugin is not possible.

This plugin exports a few things:
1. `bundleHelper` This returns a SINGLE instance of a plugin that has to be in the vite config EXACTLY once.
2. `bundle` This is the main function used by other plugins it returns a Promise of a string wich is a filename for a new bundle. This bundle can be inlined (build only); bundled as a iife or module and might have a static filename (use case for that is a serviceWorker). Also the build can be watched (only relevant for iife build).
3. `setPluginContext` can set the context in wich specific plugins can / should run.
4. `inlineURLRevoke` A helper to revoke inline URLs after usage.

## API
```ts
function bundle(
  pluginContext: PluginContext, 
  entry: string, 
  ctx: string, 
  result_type?: "iife" | "module", 
  inline?: boolean, 
  watch_files?: boolean, 
  static_file?: string | false
): Promise<string>;
```

## Specify used plugins
You can set Plugins to run in specific context. Use

```ts
setPluginContext(plugin: Plugin, ctx: string[], overwrite = true)
```

to set the context for a plugin.

ctx is a Array of context-strings. If overwrrite is `false` the array is appended if there is a config set.


If a plugin doesn't have any `setPluginContext` applied to it, it is used in all contexts.

## HMR
This plugin has not any kind of HMR build into it. I use this plugin for 2 other plugins so that might change if something is needed.

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