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