npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lernetz/gulp-typescript-bundle

v0.3.1

Published

Wraps several Gulp plugins into a reusable task for compiling and bundling TypeScript code.

Downloads

32

Readme

@lernetz/gulp-typescript-bundle

This package wraps several gulp plugins 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 an as small as possible file size. Rollup is set up to also bundle 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.1.x version with Gulp 4.0 this module exports a bundle function, which you can register with gulp.task() in your Gulpfile.

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 - non-minified .js bundle
  • main.js.map - accompanying sourcemap file
  • main.min.js - minified .js bundle The resulting .js files expose the exported functions/variables of Main.ts under the global name main.
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/gulp-typescript-bundle' );

// define your own task
gulp.task( 'bundle', bundle( { dest:'public', src:'Main.ts', name:'main' } ) );

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

Options

The task accepts a parameter object with the following attributes:

{
    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
}