forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathumd.template.jst
36 lines (33 loc) · 1.15 KB
/
umd.template.jst
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
<%
var stdDeps = ['require', 'exports', 'module'];
var amdDeps = stdDeps.concat(_.pluck(deps, 'amdName'));
var cjsDeps = _.without(_.pluck(deps, 'cjsName'), stdDeps);
cjsDeps = cjsDeps ? stdDeps.concat(_.map(cjsDeps, function(dep) { return "require('" + dep + "')" })) : stdDeps;
var depNames = deps ? stdDeps.concat(_.pluck(deps, 'paramName')) : stdDeps;
var globalDeps = deps ? stdDeps.concat(_.map(deps, function(dep) { return 'root.' + dep.globalName })) : stdDeps;
%>
(function(root, factory) {
var require, exports, module;
if (typeof define === 'function' && define.amd) {
define('<%= namespace %>', <%= amdDeps ? JSON.stringify(amdDeps) + ', ' : '[], ' %>factory);
} else if (typeof exports === 'object') {
module.exports = factory(<%= cjsDeps.join(', ') %>);
} else {
root.<%= namespace %> = factory(<%= globalDeps.join(', ') %>);
}
}(this, function(<%= depNames.join(', ') %>) {
if (!require) {
require = function(name) {
return (typeof window !== "undefined" ? window : global)[name];
}
}
if (!exports) {
var exports = {};
}
<% if (exports) { %>
<%= contents %>
return <%= exports %>;
<% } else { %>
return <%= contents %>;
<% } %>
}));