-
Notifications
You must be signed in to change notification settings - Fork 30
/
umd.jst
20 lines (19 loc) · 815 Bytes
/
umd.jst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<%
var stdDeps = ['require', 'exports', 'module'];
var amdDeps = _.pluck(deps, 'amdName');
var globalDeps = _.map(deps, function(dep) { return 'root.' + dep.globalName });
var cjsDeps = deps ? _.map(deps, function(dep) { return "require('" + dep.cjsName + "')" }) : stdDeps;
var depNames = deps ? _.pluck(deps, 'paramName') : stdDeps;
%>(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(<%= deps ? 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 (exports) { %><%= contents %>
return <%= exports %>;
<% } else { %>return <%= contents %>;
<% } %>}));