# gulp-webundler

> A JavaScript bundler which uses the internals of browserify to achieve in memory bundling.

Latest version **2.1.4** (published 2018-02-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-webundler
pnpm add gulp-webundler
yarn add gulp-webundler
bun add gulp-webundler
```

## 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.1.4 |
| Published | 2018-02-15 |
| First published | 2016-03-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 13 |
| Unpacked size | 151.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Teun van Gisbergen |
| Maintainers | panthus |
| Keywords | gulp, gulpplugin, webundler, browserify, bundle |

## Links

- npm: https://www.npmjs.com/package/gulp-webundler
- Repository: https://gitlab.com/panthus/gulp-webundler
- Issues: https://gitlab.com/panthus/gulp-webundler/issues
- npm.io page: https://npm.io/package/gulp-webundler

## Dependencies (13)

- [resolve](https://npm.io/package/resolve.md) ^1.5.0
- [through2](https://npm.io/package/through2.md) ^2.0.3
- [gulp-util](https://npm.io/package/gulp-util.md) ^3.0.8
- [@types/node](https://npm.io/package/@types/node.md) ^9.4.5
- [module-deps](https://npm.io/package/module-deps.md) ^6.0.0
- [@types/vinyl](https://npm.io/package/@types/vinyl.md) ^2.0.2
- [browser-pack](https://npm.io/package/browser-pack.md) ^6.0.4
- [@types/resolve](https://npm.io/package/@types/resolve.md) 0.0.6
- [@types/through2](https://npm.io/package/@types/through2.md) ^2.0.33
- [@types/gulp-util](https://npm.io/package/@types/gulp-util.md) ^3.0.34
- [@types/browser-pack](https://npm.io/package/@types/browser-pack.md) ^6.0.4
- [vinyl-source-stream](https://npm.io/package/vinyl-source-stream.md) ^2.0.0
- [@types/vinyl-source-stream](https://npm.io/package/@types/vinyl-source-stream.md) 0.0.30

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.1.4 (latest) — 2018-02-15
- 2.1.3 — 2016-09-14
- 2.1.2 — 2016-09-14
- 2.1.1 — 2016-09-14
- 2.1.0 — 2016-09-14
- 2.0.2 — 2016-07-14
- 2.0.1 — 2016-05-11
- 2.0.0 — 2016-04-10
- 1.0.2 — 2016-03-23
- 1.0.1 — 2016-03-22
- 1.0.0 — 2016-03-19

## README

# Gulp-webundler

A utility which uses the internals from [Browserify](http://browserify.org/) to create web-bundles from an input stream of JavaScript files in [vinyl](https://github.com/gulpjs/vinyl) format. It tries to find the modules used for bundling inside the input stream. If a module cannot be found the NodeJs require algorithm is used to locate it.

## Usage
The following sample `gulpfile.js` should get you going.
```javascript
"use strict";
const gulp = require("gulp");
const ts = require("gulp-typescript");
const bundler = require("gulp-webundler").default;

const tsProject = ts.createProject({
	target: "ES5",
	module: "commonjs",
	noExternalResolve: true
});

gulp.task("build", () => {
    return gulp.src("*.ts")
	    .pipe(ts(tsProject))
	    .pipe(bundler([
            { name: "bundles/Common", include: ["Event", "Maybe"] },
            { name: "bundles/MainModel", include: ["TestModel"], exclude: ["bundles/Common"]}
 	    ]))
        .pipe(gulp.dest("dist"));
});
```

## API

The entry point of the utility consists of the `bundle` function in `Bundler.ts`.
```typescript
/**
 * Creates the stream which transforms the vinyl files into a buffer and
 * outputs bundles.
 * @param bundleSpecification The specifications of the bundles which should
 * be generated from the inputted vinyl files.
 * @returns Returns the stream.
 */
bundle(bundleSpecification: IBundleSpecification[]): stream.Transform;
```

It takes an array of `IBundleSpecification` objects.
```typescript
/**
 * Specifies which modules should make up the specified bundle.
 */
interface IBundleSpecification {
    /**
     * The name of the bundle without extension. The '.js' extension is
     * automatically added. If it is a path, then the specified folders will be
     * created in the output directory.
     */
    name: string;

    /**
     * The paths to the root modules to include in the bundle or module 
     * specification objects. Any dependent modules are automatically included
     * in the bundle. File extensions should be exluded.
     */
    include: (string | IModuleSpecification)[];

    /**
     * The paths to the root modules or bundle names to exclude from the bundle.
     * File extensions should be exluded.
     */
    exclude?: string[];
}

/**
 * Specifies how a module should be resolved.
 */
interface IModuleSpecification {
    /**
     * The path to the root module to include in the bundle. File extensions
     * should be excluded.
     */
    id: string;

    /**
     * The name the module should be exposed as in the bundle.
     */
    name: string;
}
```

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