JSPM

umd-generator

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q26906F
  • License ISC

Generates boiler plate for a javascript Universal Module Definition. Defines your module in CommonJS, AMD and the browser depending on the environment it detects.

Package Exports

  • umd-generator

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (umd-generator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

umd-generator

npm version

Generates boiler plate for a javascript Universal Module Definition. Defines your module in CommonJS, AMD and the browser depending on the environment it detects.

Example

Simply require and call it...

var umd = require("umd-generator");
var dir = "myModules/";
var name = "awesomeness";

umd(dir, name);

Then it will output like so...

(function(root, factory) {
    if (typeof define === "function" && define.amd) {
        // Define for AMD (RequireJs for example) 
        define([/* dependencies */], function() {
        return (root.awesomeness = factory(/* dependencies */));
        });
    } else if (typeof module === "object" && module.exports) {
        // Export for CommonJs (Node.js for example) 
        module.exports = (root.awesomeness = factory(/* dependencies */));
    }
    else {
        // Define on root (this would be 'window' in a browser environment for example)
        root.awesomeness = factory(/* dependencies */);
    }
}(this, function(/* dependencies */) {
    var awesomeness = {
        // MODULE CODE HERE....
    }
    return awesomeness;
}));