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

v2.0.3

Published

Converts a module written in various files and AMD format in an autonomous one-file module.

Downloads

16

Readme

Installation

Install package with NPM and add it to your development dependencies:

npm install --save-dev gulp-deamdify

Information

Inspiration

Suppose you are writing a library in Javascript (or in any other compile-to-javascript language) and you would want to split it in more than one file without having external dependencies.

In example, let's say you have this library

// Main.js
require(['file1', 'file3'], function(file1, file3) {
  file1('Hello world!');
})

// file3.js
define('file3', [], function() {
  return console.log;
})

// file2.js
define('file2', ['file3'], function(file3) {
  return file3;
})

// file1.js
define('file1', ['file2'], function(file2) {
  return function(e) {
    file2(e);
  }
})

This plugin polyfills the code with a tiny AMD library and concatenates the results in order to get an one-file script that does exactly what your original code does. Note that this plugin won't order your files, you'll have to use another plugin such as gulp-amd-optimizer

Reason to be

  1. It can be used with gulp-umd in order to take a library written under AMD format and compile it to UMD format, so it can be later used with RequireJs and CommonJs.

  2. It is possible to transpile Typescript to Javascript using AMD module resolution, and transform the result to code that does not depend on external dependencies.

  3. It is an alternative to Babel's deamdify, since it can be used with Typescript or CoffeeScript.

Usage

Usage with Javascript

var deamdify = require('gulp-deamdify');
var optimizer = require('gulp-amd-optimizer');

gulp.task('build', function() {
  return gulp.src('src/**/*.js')
    .pipe(optimizer({baseUrl: '/my-base-url/'}))
    .pipe(deamdify({
      outputs : 'my-library.js',
    }))
    .pipe(gulp.dest('dist/'));
});

Usage with Typescript

var deamdify = require('gulp-deamdify');
var ts = require('gulp-typescript');

gulp.task 'build', () ->
    return gulp.src('src/**/*.ts')
      .pipe(ts({
          "module": "amd",
          "target": "es5",
          "noImplicitAny": false,
          "sourceMap": false,
          "removeComments" : true,
          "outFile" : 'compiled.js'
      })).pipe(deamdify({outputs:'my-library.js'}))
      .pipe(gulp.dest('dist/'))

Usage with gulp-umd

var deamdify = require('gulp-deamdify');
var ts = require('gulp-typescript');
var umd = require('gulp-umd');
gulp.task('build', () => {
    return gulp
        .src('src/**/*.ts')
        .pipe(ts({
            "module": "amd",
            "target": "es5",
            "noImplicitAny": false,
            "sourceMap": false,
            "removeComments" : true,
            "outFile"  : 'compiled.js'
        }))
        .pipe(deamdify({outputs:'Cherry.js'}))
        .pipe(umd({
          'exports' : function(e) { return 'main'; }
        }))
        .pipe(gulp.dest('dist/'));
});

Contribute

Please feel free to fork or post and issue if you feel like.

License

Published under MIT License.