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

grunt-umd

v3.0.0

Published

Surrounds code with the universal module definition.

Downloads

3,801

Readme

grunt-umd

Grunt task to surround JavaScript code with the universal module definition.

Usage

Install this Grunt plugin next to your project's Gruntfile with: npm install grunt-umd

Add the following line to your project's Gruntfile:

grunt.loadNpmTasks('grunt-umd');

Then configure the task:

grunt.initConfig({
  umd: {
    all: {
      options: {
        src: 'path/to/input.js',
        dest: 'path/to/output.js', // optional, if missing the src will be used

        // optional, a template from templates subdir
        // can be specified by name (e.g. 'umd'); if missing, the templates/umd.hbs
        // file will be used from [libumd](https://github.com/bebraw/libumd)
        template: 'path/to/template.hbs',

        objectToExport: 'library', // optional, internal object that will be exported
        amdModuleId: 'id', // optional, if missing the AMD module will be anonymous
        globalAlias: 'alias', // optional, changes the name of the global variable

        deps: { // optional, `default` is used as a fallback for rest!
          'default': ['foo', 'bar'],
          amd: ['foobar', 'barbar'],
          cjs: ['foo', 'barbar'],
          global: ['foobar', {depName: 'param'}]
        }
      }
    }
  }
});

And finally use it:

grunt umd:all

Note! If you want to indent the output, consider using some other plugin for that. The output grunt-umd gives is functional but not entirely aesthetic.

Templates

The following predefined Handlebars-templates are available:

  • umd - the default template; the template is based on umd/returnExports.js
  • unit - the template that can be helpful to wrap standalone CommonJS/Node modules; it is slightly modified version of umd template; if objectToExport option is not specified then module.exports value will be used by default

The template that should be applied can be specified by template option (e.g. 'umd' or 'unit'). You can create and use your own template (see predefined templates for examples). The path to the template file should be set relative to Gruntfile.

Demo

  1. Install dependencies - npm install
  2. Go to demo - cd demo
  3. Go to some demo directory - cd <demo directory>
  4. Execute demo - grunt

You should see some /output after this. Study Gruntfile.js to understand how it generates.

Contributors

License

MIT. See LICENSE for more info.