1 | {{!--
|
2 | Uses Node, AMD or browser globals to create a module. This example creates
|
3 | a global even when AMD is used. This is useful if you have some scripts
|
4 | that are loaded by an AMD loader, but they still want access to globals.
|
5 | If you do not need to export a global for the AMD case,
|
6 | see returnExports.js.
|
7 |
|
8 | If you want something that will work in other stricter CommonJS environments,
|
9 | or if you need to create a circular dependency, see commonJsStrictGlobal.js
|
10 |
|
11 | Defines a module "returnExportsGlobal" that depends another module called
|
12 | "b". Note that the name of the module is implied by the file name. It is
|
13 | best if the file name and the exported global have matching names.
|
14 |
|
15 | If the 'b' module also uses this type of boilerplate, then
|
16 | in the browser, it will create a global .b that is used below.
|
17 | --}}
|
18 |
|
19 | (function (root, factory) {
|
20 | if (typeof define === 'function' && define.amd) {
|
21 | {{! AMD. Register as an anonymous module. }}
|
22 | define({{#if amdModuleId}}'{{amdModuleId}}', {{/if}}[{{{amdDependencies}}}], function ({{dependencies}}) {
|
23 | return ({{#if globalAlias}} root['{{{globalAlias}}}'] = {{/if}}factory({{dependencies}}));
|
24 | });
|
25 | } else if (typeof exports === 'object') {
|
26 | {{!--
|
27 | Node. Does not work with strict CommonJS, but
|
28 | only CommonJS-like enviroments that support module.exports,
|
29 | like Node.
|
30 | --}}
|
31 | var module_exports = factory({{{cjsDependencies}}});
|
32 | module.exports = module_exports;
|
33 |
|
34 | {{! FIX FOR BROWSERIFY: Set global alias if we in browserify. }}
|
35 | {{#if globalAlias}}
|
36 | if(typeof window !== "undefined"){
|
37 | window['{{{globalAlias}}}'] = module_exports;
|
38 | }
|
39 | {{/if}}
|
40 | } else {
|
41 | {{! Browser globals }}
|
42 | {{#if globalAlias}}root['{{{globalAlias}}}'] = {{/if}}factory({{{globalDependencies}}});
|
43 | }
|
44 | }(this, function ({{dependencies}}) {
|
45 |
|
46 | {{{code}}}
|
47 |
|
48 | {{!--
|
49 | Just return a value to define the module export.
|
50 | This example returns an object, but the module
|
51 | can return a function as the exported value.
|
52 | --}}
|
53 |
|
54 | return {{{objectToExport}}};
|
55 |
|
56 | }));
|
57 |
|
\ | No newline at end of file |