# lernetz-typescript-gulp-task

> This node module that wraps several gulp plugins into a reusable gulp task with options to complie typscript code

Latest version **0.5.0** (published 2018-11-14) · ISC license · 0 weekly downloads

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

## Install

```sh
npm install lernetz-typescript-gulp-task
pnpm add lernetz-typescript-gulp-task
yarn add lernetz-typescript-gulp-task
bun add lernetz-typescript-gulp-task
```

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2018-11-14 |
| First published | 2015-04-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Michael Heimann |
| Maintainers | lernetz-mich |
| Keywords | gulp, task, typescript, lernetz, rollup, require, bundle, package |

## Links

- npm: https://www.npmjs.com/package/lernetz-typescript-gulp-task
- Repository: https://github.com/legoheld/lernetz-typescript-gulp-task
- Issues: https://github.com/legoheld/lernetz-typescript-gulp-task/issues
- npm.io page: https://npm.io/package/lernetz-typescript-gulp-task

## Dependencies (9)

- [gulp](https://npm.io/package/gulp.md) ^4.0.0
- [merge](https://npm.io/package/merge.md) ^1.2.1
- [rollup](https://npm.io/package/rollup.md) ^0.56.5
- [typescript](https://npm.io/package/typescript.md) ^2.9.2
- [gulp-rename](https://npm.io/package/gulp-rename.md) ^1.4.0
- [gulp-uglify-es](https://npm.io/package/gulp-uglify-es.md) ^1.0.4
- [rollup-plugin-commonjs](https://npm.io/package/rollup-plugin-commonjs.md) ^9.2.0
- [rollup-plugin-typescript2](https://npm.io/package/rollup-plugin-typescript2.md) ^0.12.0
- [rollup-plugin-node-resolve](https://npm.io/package/rollup-plugin-node-resolve.md) ^3.4.0

## 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

- 0.5.0 (latest) — 2018-11-14
- 0.4.2 — 2018-04-09
- 0.4.1 — 2018-03-08
- 0.4.0 — 2018-02-23
- 0.3.2 — 2018-02-22
- 0.2.2 — 2018-01-10
- 0.2.1 — 2017-02-08
- 0.2.0 — 2017-02-08
- 0.1.2 — 2016-05-16
- 0.1.1 — 2016-04-14
- 0.1.0 — 2015-12-21
- 0.0.3 — 2015-11-04
- 0.0.2-b — 2015-07-28
- 0.0.2-a — 2015-07-28
- 0.0.2 — 2015-07-28
- … 3 more at https://npm.io/package/lernetz-typescript-gulp-task/versions

## README

# lernetz-typescript-gulp-task
This node module wraps several gulp plugins executions into one reusable gulp task.
The main goal of the task is to compile a set of typescript files into a single js file.
It automatically creates a minified version and injects the sourcemaps.
It internally uses rollup with treeshaking for a smallest as possible filesize.
Rollup is setup to bundle also npm packages. This allows to use npm packages in our source typescript.
You need to install the required types for typescript see: https://blogs.msdn.microsoft.com/typescript/2016/06/15/the-future-of-declaration-files/
And also install the library itself with npm so rollup can find and bundle it.

In the 0.4.x version with gulp 4.0 this module will automatically register two gulp tasks: `ln:bundle`, `ln:minify`.
You can use them directly in your gulp file or from outside. See `npx gulp --tasks`. 


## Usage
The following example will compile the file `Main.ts` and bundle all its dependencies into to the output folder `public`.
It creates the following js files:
* main.js - the uncompressed js source
* main.js.map - the sourcemap file
* main.min.js - the minified js file
The resulting js file exposes the exported functions/variables of `Main.ts` under the globalName: `main`.

```javascript
var gulp = require('gulp');

// this will automatically register to gulp tasks: ln:bundle, ln:minify and returns them as gulp.series( 'ln:bundle', 'ln:minify' )
var bundle = require( 'lernetz-typescript-gulp-task' )( { dest:'public', src:'Main.ts', name:'main' } );

// either define your own task
gulp.task( 'bundle', bundle );

// or use it directly in your watch statement
gulp.task('default', function() {
    gulp.watch( 'typescript/**/*.ts', bundle );
    // or 
    gulp.watch( 'typescript/**/*.ts', gulp.series( 'ln:bundle', 'ln:minify' ) );
});

// or directly call:
// npx gulp ln:bundle
// npx gulp ln:minify
```

## Options
The task accepts an parameter object with the following attributes:
```javascript
{
    name: 'main', // the name of the js file to create and also the globalname 
	dest: 'public', // the destination used in gulp.dest( .. )
    src: './src/main.ts', // the source the the main typescript file
    rollup: {
        // the default input options used for rollup. see: https://rollupjs.org/guide/en#javascript-api
        inputOptions: {
            input: options.src, // autogenerated if not defined
            plugins: [
                typescript( { check:false } ),
                resolve( { jsnext: true, main: true, browser:true } ),
                commonjs(),
            ]
        },
        // the default output options used for rollup. see: https://rollupjs.org/guide/en#javascript-api
        outputOptions: { 
            file: options.dest + '/' + options.name + '.js', // autogenerated if not defined
            name: options.name,  // autogenerated if not defined
            format: 'iife',
            sourcemap: true
        }
    },
    uglify: {} // the default options for the ugify task: https://www.npmjs.com/package/gulp-uglify-es
}
```

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