index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Generated by LiveScript 1.4.0
  2. (function(){
  3. var Promise, ref$, list, experimental, libraryBlacklist, es5SpecialCase, banner, readFile, writeFile, unlink, basename, dirname, join, webpack, temp;
  4. Promise = require('../library/fn/promise');
  5. ref$ = require('./config'), list = ref$.list, experimental = ref$.experimental, libraryBlacklist = ref$.libraryBlacklist, es5SpecialCase = ref$.es5SpecialCase, banner = ref$.banner;
  6. ref$ = require('fs'), readFile = ref$.readFile, writeFile = ref$.writeFile, unlink = ref$.unlink;
  7. ref$ = require('path'), basename = ref$.basename, dirname = ref$.dirname, join = ref$.join;
  8. webpack = require('webpack');
  9. temp = require('temp');
  10. module.exports = function(arg$){
  11. var modules, ref$, blacklist, library, umd, this$ = this;
  12. modules = (ref$ = arg$.modules) != null
  13. ? ref$
  14. : [], blacklist = (ref$ = arg$.blacklist) != null
  15. ? ref$
  16. : [], library = (ref$ = arg$.library) != null ? ref$ : false, umd = (ref$ = arg$.umd) != null ? ref$ : true;
  17. return new Promise(function(resolve, reject){
  18. (function(){
  19. var i$, x$, ref$, len$, y$, ns, name, j$, len1$, TARGET, this$ = this;
  20. if (this.exp) {
  21. for (i$ = 0, len$ = (ref$ = experimental).length; i$ < len$; ++i$) {
  22. x$ = ref$[i$];
  23. this[x$] = true;
  24. }
  25. }
  26. if (this.es5) {
  27. for (i$ = 0, len$ = (ref$ = es5SpecialCase).length; i$ < len$; ++i$) {
  28. y$ = ref$[i$];
  29. this[y$] = true;
  30. }
  31. }
  32. for (ns in this) {
  33. if (this[ns]) {
  34. for (i$ = 0, len$ = (ref$ = list).length; i$ < len$; ++i$) {
  35. name = ref$[i$];
  36. if (name.indexOf(ns + ".") === 0 && !in$(name, experimental)) {
  37. this[name] = true;
  38. }
  39. }
  40. }
  41. }
  42. if (library) {
  43. blacklist = blacklist.concat(libraryBlacklist);
  44. }
  45. for (i$ = 0, len$ = blacklist.length; i$ < len$; ++i$) {
  46. ns = blacklist[i$];
  47. for (j$ = 0, len1$ = (ref$ = list).length; j$ < len1$; ++j$) {
  48. name = ref$[j$];
  49. if (name === ns || name.indexOf(ns + ".") === 0) {
  50. this[name] = false;
  51. }
  52. }
  53. }
  54. TARGET = temp.path({
  55. suffix: '.js'
  56. });
  57. webpack({
  58. entry: list.filter(function(it){
  59. return this$[it];
  60. }).map(function(it){
  61. if (library) {
  62. return join(__dirname, '..', 'library', 'modules', it);
  63. } else {
  64. return join(__dirname, '..', 'modules', it);
  65. }
  66. }),
  67. output: {
  68. path: dirname(TARGET),
  69. filename: basename("./" + TARGET)
  70. }
  71. }, function(err, info){
  72. if (err) {
  73. return reject(err);
  74. }
  75. readFile(TARGET, function(err, script){
  76. if (err) {
  77. return reject(err);
  78. }
  79. unlink(TARGET, function(err){
  80. var exportScript;
  81. if (err) {
  82. return reject(err);
  83. }
  84. if (umd) {
  85. 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;";
  86. } else {
  87. exportScript = "";
  88. }
  89. resolve("" + banner + "\n!function(__e, __g, undefined){\n'use strict';\n" + script + "\n" + exportScript + "\n}(1, 1);");
  90. });
  91. });
  92. });
  93. }.call(modules.reduce(function(memo, it){
  94. memo[it] = true;
  95. return memo;
  96. }, {})));
  97. });
  98. };
  99. function in$(x, xs){
  100. var i = -1, l = xs.length >>> 0;
  101. while (++i < l) if (x === xs[i]) return true;
  102. return false;
  103. }
  104. }).call(this);