1 | [![build status](https://secure.travis-ci.org/bebraw/libumd.png)](http://travis-ci.org/bebraw/libumd)
|
2 |
|
3 | [![Sauce Test Status](https://saucelabs.com/buildstatus/libumd)](https://saucelabs.com/u/libumd)
|
4 |
|
5 | # libumd - Wraps given JavaScript code with UMD
|
6 |
|
7 | ## Usage
|
8 |
|
9 | ```js
|
10 | var umdify = require('libumd');
|
11 |
|
12 | ...
|
13 |
|
14 | var result = umdify(js, options);
|
15 | ```
|
16 |
|
17 | options (all are optional by default):
|
18 |
|
19 | ```js
|
20 | {
|
21 | template: 'path to template or template name', // defaults to 'umd'
|
22 | amdModuleId: 'test', // optional AMD module id. defaults to anonymous (not set)
|
23 | globalAlias: 'alias', // name of the global variable
|
24 | deps: { // dependencies - `default` acts as a fallback for each!
|
25 | 'default': ['foo', 'bar'],
|
26 | amd: ['foobar', 'barbar'],
|
27 | cjs: ['foo', 'barbar'],
|
28 | global: ['foobar', 'bar']
|
29 | }
|
30 | }
|
31 | ```
|
32 |
|
33 | > Note! `libumd` doesn't guarantee pretty formatting. It is better to use something like [js-beautify](https://www.npmjs.com/package/js-beautify) to deal with that.
|
34 |
|
35 | ## Default Templates
|
36 |
|
37 | The library comes with a couple of UMD variants. See `/templates`. In addition you may use one of your own as long as it is formatted using Handlebars syntax and follows the same naming conventions as the ones provided with the project.
|
38 |
|
39 | ## Contributors
|
40 |
|
41 | * [Stéphane Bachelier](https://github.com/stephanebachelier) - Use existing `objectToExport` instead of hardcoded value `returnExportsGlobal` for AMD
|
42 |
|
43 | ## License
|
44 |
|
45 | `libumd` is available under MIT. See LICENSE for more details.
|
46 |
|