index.js
3.99 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Generated by LiveScript 1.4.0
(function(){
var Promise, ref$, list, experimental, libraryBlacklist, es5SpecialCase, banner, readFile, writeFile, unlink, basename, dirname, join, webpack, temp;
Promise = require('../library/fn/promise');
ref$ = require('./config'), list = ref$.list, experimental = ref$.experimental, libraryBlacklist = ref$.libraryBlacklist, es5SpecialCase = ref$.es5SpecialCase, banner = ref$.banner;
ref$ = require('fs'), readFile = ref$.readFile, writeFile = ref$.writeFile, unlink = ref$.unlink;
ref$ = require('path'), basename = ref$.basename, dirname = ref$.dirname, join = ref$.join;
webpack = require('webpack');
temp = require('temp');
module.exports = function(arg$){
var modules, ref$, blacklist, library, umd, this$ = this;
modules = (ref$ = arg$.modules) != null
? ref$
: [], blacklist = (ref$ = arg$.blacklist) != null
? ref$
: [], library = (ref$ = arg$.library) != null ? ref$ : false, umd = (ref$ = arg$.umd) != null ? ref$ : true;
return new Promise(function(resolve, reject){
(function(){
var i$, x$, ref$, len$, y$, ns, name, j$, len1$, TARGET, this$ = this;
if (this.exp) {
for (i$ = 0, len$ = (ref$ = experimental).length; i$ < len$; ++i$) {
x$ = ref$[i$];
this[x$] = true;
}
}
if (this.es5) {
for (i$ = 0, len$ = (ref$ = es5SpecialCase).length; i$ < len$; ++i$) {
y$ = ref$[i$];
this[y$] = true;
}
}
for (ns in this) {
if (this[ns]) {
for (i$ = 0, len$ = (ref$ = list).length; i$ < len$; ++i$) {
name = ref$[i$];
if (name.indexOf(ns + ".") === 0 && !in$(name, experimental)) {
this[name] = true;
}
}
}
}
if (library) {
blacklist = blacklist.concat(libraryBlacklist);
}
for (i$ = 0, len$ = blacklist.length; i$ < len$; ++i$) {
ns = blacklist[i$];
for (j$ = 0, len1$ = (ref$ = list).length; j$ < len1$; ++j$) {
name = ref$[j$];
if (name === ns || name.indexOf(ns + ".") === 0) {
this[name] = false;
}
}
}
TARGET = temp.path({
suffix: '.js'
});
webpack({
entry: list.filter(function(it){
return this$[it];
}).map(function(it){
if (library) {
return join(__dirname, '..', 'library', 'modules', it);
} else {
return join(__dirname, '..', 'modules', it);
}
}),
output: {
path: dirname(TARGET),
filename: basename("./" + TARGET)
}
}, function(err, info){
if (err) {
return reject(err);
}
readFile(TARGET, function(err, script){
if (err) {
return reject(err);
}
unlink(TARGET, function(err){
var exportScript;
if (err) {
return reject(err);
}
if (umd) {
exportScript = "// CommonJS export\nif (typeof module != 'undefined' && module.exports) module.exports = __e;\n// RequireJS export\nelse if (typeof define == 'function' && define.amd) define(function () { return __e; });\n// Export to global object\nelse __g.core = __e;";
} else {
exportScript = "";
}
resolve("" + banner + "\n!function(__e, __g, undefined){\n'use strict';\n" + script + "\n" + exportScript + "\n}(1, 1);");
});
});
});
}.call(modules.reduce(function(memo, it){
memo[it] = true;
return memo;
}, {})));
});
};
function in$(x, xs){
var i = -1, l = xs.length >>> 0;
while (++i < l) if (x === xs[i]) return true;
return false;
}
}).call(this);