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

gulp-distributor

v0.1.0-alpha6

Published

Plugin for creating various distributions of a package

Downloads

5

Readme

#Gulp Distributor

status: in alpha

Create multiple module distributions from your JavaScript source files.

You should clone this library to your local machine and run the default gulptask to see how the module works.

  • $ git clone https://github.com/michaelherndon/gulp-distributor.git
  • $ cd gulp-distributor
  • $ npm install
  • $ gulp

//  src/
//     - array-copy-src.js
//     - base-class-src.js
//     - sub-class-src.js



var gulp = require("gulp"),
	distribute = require("./lib/index"),
	runSequence = require("run-sequence");




gulp.task("distribute", function() {
	return gulp.src(["src/*-src.js"])
				.pipe(distribute({
					files: {
						'base-class': {
					        exports: ['BaseClass'] // class to export
					    },
					    'sub-class': {
					    	deps: ["bass-class"],  // file/module to import.
					    	exports: ["SubClass"]
					    },
					    'array-copy': {
					    	exports: ['self']      // self will set exports = arrayCopy;
					    },
					},
					namespace: "kit",
					license: "license.js",
					pattern: "$file-src"
				}));
});

gulp.task('default', function(cb) {
	runSequence("distribute");
});

// will generate files in the following

// lib/
//    - array-copy.js
//    - base-class.js
//    - sub-class.js

// dist/amd/lib
//    - array-copy.js
//    - base-class.js
//    - sub-class.js

// dist/browser/lib
//    - array-copy.js
//    - base-class.js
//    - sub-class.js

Options

dist

  • src - a variable location for the distribution files. Defaults to "/dist" and replaces the $src var.
  • amd - the location for the amd distribution files. Defaults to $src/amd/lib
  • browser - the location for the browser distribution files. Defaults to $src/browser/lib
  • commonjs - the location for the commonjs distribution files. Defaults to /lib
  • es6 - (Not Implemented) the location for the es6 distribution files. Defaults to $src/es6/lib

templates

  • src - a variable location for the template folder. Defaults to __dirname + "/templates" and replaces the $src var.
  • amd - the location for the amd distribution files. Defaults to $src/amd.tpl
  • browser - the location for the browser distribution files. Defaults to $src/browser.tpl
  • commonjs - the location for the commonjs distribution files. Defaults to $src/lib.tpl
  • es6 - (Not Implemented) the location for the es6 distribution files. Defaults to $src/es6.tpl

newLine

  • default: "\n"
  • amd: "\n\t"
  • browser: "\n\t"

distro

Instructs which distributions that will be created. The available options are:

  • all
  • amd
  • browser
  • commonjs
  • es6 (Not Implemented)

If you wish to remove an option, set the template option to false i.e.

   return gulp.src(["src/*-src.js"])
   			.pipe(distribute({
   				templates: {
   					commonjs: false,
   					amd: false
   				},  
   				distro: "all",
   				license: "license.js",
   			}));

If you wish to add an option for a distro, add a template

   return gulp.src(["src/*-src.js"])
   			.pipe(distribute({
   				dist: {
   					hybrid: "$src/hybrid/lib"
   				},
   				templates: {
   					hybrid: "src/templates/hybrid.tpl"
   				},  
   				distro: "all",
   				license: "license.js",
   			}));

namespace

This will instruct the browser distributions to append exports to a global namespace/ variable for source files.

exports

An export variable that will be present in all files.

templateEngine

Allows you to define the template engine that will create your module distributions.

The value must be a function that takes a content string and object for template variables.


 templateEngine: function() {
     return require("lodash").template;
 };

files

Configures source files and dependencies.

// src
//   router-src.js
// node_modules/ux-lexer

  return gulp.src(["src/*-src.js"])
   			.pipe(distribute({
   				files: {
   					'router': {
   				        exports: ['Router'],

   				        // distributor will attempt to see if the file 
   				        // has any configuration, otherwise it will assume
   				        // a simple require for dependencies.  
   				        deps: ['lexer', 'parser'] 
   				    },
   				    'lexer': {
   				    	require: ['ux-lexer'],
   				    	exports: ['Lexer', 'Token']
   					}
   				},
   				namespace: "kit",  
   				distro: "all",
   				license: "license.js",
   				pattern: "$file-src"
   			}));
sample output for commonjs
   var d0 = require("ux-lexer"),
   	Lexer = d0.Lexer,
   	Token = d0.Token;

   var parser = require("parser");

   // router code
   var Router = function() {

   };

   exports.Router = Router;
	module.exports = exports;

license

The the license file that should be prepended to each distribution file.

data

Default values that will be injected into the distribution templates.