Skip to content

danielFHcode/simple-umd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A warper for the UniversalModuleDefinition.

Resources

Stars

Watchers

Forks

Packages

No packages published