Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-a2umd

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-a2umd

Converts umd to amd pattern

  • 0.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

a2umd

Converts an AMD module definition to an UMD one.

I like the umd wrappers like grunt-umd, however, I don't like defining my dependencies in a gruntfile.

AMD is a nice way to define your dependencies. As a developer, I always just write AMD modules. As consumers of the modules don't necesarily use AMD, I want a wrapper to be able to use the modules globally.

a2umd converts amd style modules to umd style, using the same concepts as grunt-umd. Since the dependencies are already defined in the AMD style, there is no need to define them again.

So start with an AMD module:

define(['pathA','pathB'],function GlobalName(a,b) {
    return {

    };
});

And use the following grunt config:

{
    'a2umd': {
        all: {
            files: [
                src: 'src/foo.js',
                dest: 'dest/foo.js'
            ]
        }
    }
}

You will end up with a wrapped module:

(function(root, factory) {
    if(typeof define === 'function' && define.amd) {
        define(['pathA','pathB'], factory);
    } else {
        root.GlobalName = factory(root.a,root.b);
    }
}(this, function GlobalName() {
    return {

    };
}));

Specific features

  • leaves the factory function exactly intact (plain copy)
  • extracts dependency paths
  • extracts local dependency names
  • keeps AMD name if given (as first argument in the define())
  • use the factory function name as global name
  • allows to define custom templates instead of the default one

Dependencies

  • esprima: used for parsing the source file and extracting the relevant parts
  • handlebars: used as a template engine to create an UMD style module

FAQs

Package last updated on 11 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc