forked from gitana/alpaca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathumd-wrapper.txt
52 lines (46 loc) · 1.44 KB
/
umd-wrapper.txt
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
<%
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)
{
var umdEnabled = true;
if (root && typeof(root.umd) != "undefined") {
umdEnabled = root.umd;
}
if (umdEnabled && typeof exports === 'object')
{
// common js
module.exports = factory(<%= cjsDeps.join(', ') %>);
}
else if (umdEnabled && typeof define === 'function' && define.amd)
{
// amd
define("alpaca", <%= deps ? JSON.stringify(amdDeps) + ', ' : '' %>factory);
}
else
{
// global
root["<%= namespace %>"] = factory(<%= globalDeps.join(', ') %>);
}
}(this, function (<%= depNames.join(', ') %>) {
//jQuery = $;
<% if (exports) { %>
<%= contents %>
<% if (typeof defaultView != 'undefined') { %>
<%= exports %>.defaultView = '<%= defaultView %>';
<% } %>
return <%= exports %>;
<% } else { %>
var exports = (function() {
<%= contents %>
})();
<% if (typeof defaultView != 'undefined') { %>
exports.defaultView = '<%= defaultView %>';
<% } %>
return exports;
<% } %>
}));