1.0.1 • Published 1 year ago

simple-umd v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Simple UniversalModuleDefinition

License NPM Fork on github

Universal Module Definition - or UMD for short - is a way of defining modules that work in both CommonJS, AMD, and browser globals.

Although the idea was conceived years ago, no simple API was ever created. Every time you needed to define a UMD module you would have to recreate the system based on the templates. This library proposes a solution for that.

Installation

You can install UMD through npm:

npm i umd

Usage

You can import UMD through whatever module system you like:

// Browser Globals
umd;

// CommonJS
const umd = require('umd');

// AMD
define( ['umd'], function(umd){} );

// ES6 Modules
import umd from 'path/to/umd.module.js';

There are plenty of ways to define your module, but they all follow the same structure:

umd.define({
 moduleName: 'module',
 dependencies: [ /* ... */ ],
 factory: () => {
  // some code...
 }
})

For more details you can view the documentation

Documentation

You can view the documentation on this library's github page.