build.ls 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. require! {'./config': {banner}, fs: {readFile, writeFile, unlink}, path, webpack}
  2. list = <[
  3. es5
  4. es6.symbol
  5. es6.object.assign
  6. es6.object.is
  7. es6.object.set-prototype-of
  8. es6.object.to-string
  9. es6.object.freeze
  10. es6.object.seal
  11. es6.object.prevent-extensions
  12. es6.object.is-frozen
  13. es6.object.is-sealed
  14. es6.object.is-extensible
  15. es6.object.get-own-property-descriptor
  16. es6.object.get-prototype-of
  17. es6.object.keys
  18. es6.object.get-own-property-names
  19. es6.function.name
  20. es6.function.has-instance
  21. es6.number.constructor
  22. es6.number.epsilon
  23. es6.number.is-finite
  24. es6.number.is-integer
  25. es6.number.is-nan
  26. es6.number.is-safe-integer
  27. es6.number.max-safe-integer
  28. es6.number.min-safe-integer
  29. es6.number.parse-float
  30. es6.number.parse-int
  31. es6.math.acosh
  32. es6.math.asinh
  33. es6.math.atanh
  34. es6.math.cbrt
  35. es6.math.clz32
  36. es6.math.cosh
  37. es6.math.expm1
  38. es6.math.fround
  39. es6.math.hypot
  40. es6.math.imul
  41. es6.math.log10
  42. es6.math.log1p
  43. es6.math.log2
  44. es6.math.sign
  45. es6.math.sinh
  46. es6.math.tanh
  47. es6.math.trunc
  48. es6.string.from-code-point
  49. es6.string.raw
  50. es6.string.trim
  51. es6.string.code-point-at
  52. es6.string.ends-with
  53. es6.string.includes
  54. es6.string.repeat
  55. es6.string.starts-with
  56. es6.string.iterator
  57. es6.array.from
  58. es6.array.of
  59. es6.array.iterator
  60. es6.array.species
  61. es6.array.copy-within
  62. es6.array.fill
  63. es6.array.find
  64. es6.array.find-index
  65. es6.regexp.constructor
  66. es6.regexp.flags
  67. es6.regexp.match
  68. es6.regexp.replace
  69. es6.regexp.search
  70. es6.regexp.split
  71. es6.promise
  72. es6.map
  73. es6.set
  74. es6.weak-map
  75. es6.weak-set
  76. es6.reflect.apply
  77. es6.reflect.construct
  78. es6.reflect.define-property
  79. es6.reflect.delete-property
  80. es6.reflect.enumerate
  81. es6.reflect.get
  82. es6.reflect.get-own-property-descriptor
  83. es6.reflect.get-prototype-of
  84. es6.reflect.has
  85. es6.reflect.is-extensible
  86. es6.reflect.own-keys
  87. es6.reflect.prevent-extensions
  88. es6.reflect.set
  89. es6.reflect.set-prototype-of
  90. es6.date.to-string
  91. es6.typed.array-buffer
  92. es6.typed.data-view
  93. es6.typed.int8-array
  94. es6.typed.uint8-array
  95. es6.typed.uint8-clamped-array
  96. es6.typed.int16-array
  97. es6.typed.uint16-array
  98. es6.typed.int32-array
  99. es6.typed.uint32-array
  100. es6.typed.float32-array
  101. es6.typed.float64-array
  102. es7.array.includes
  103. es7.string.at
  104. es7.string.pad-left
  105. es7.string.pad-right
  106. es7.string.trim-left
  107. es7.string.trim-right
  108. es7.regexp.escape
  109. es7.object.get-own-property-descriptors
  110. es7.object.values
  111. es7.object.entries
  112. es7.map.to-json
  113. es7.set.to-json
  114. web.immediate
  115. web.dom.iterable
  116. web.timers
  117. core.dict
  118. core.get-iterator-method
  119. core.get-iterator
  120. core.is-iterable
  121. core.delay
  122. core.function.part
  123. core.object.is-object
  124. core.object.classof
  125. core.object.define
  126. core.object.make
  127. core.number.iterator
  128. core.string.escape-html
  129. core.string.unescape-html
  130. core.log
  131. js.array.statics
  132. ]>
  133. experimental = <[
  134. es6.date.to-string
  135. es6.typed.array-buffer
  136. es6.typed.data-view
  137. es6.typed.int8-array
  138. es6.typed.uint8-array
  139. es6.typed.uint8-clamped-array
  140. es6.typed.int16-array
  141. es6.typed.uint16-array
  142. es6.typed.int32-array
  143. es6.typed.uint32-array
  144. es6.typed.float32-array
  145. es6.typed.float64-array
  146. ]>
  147. libraryBlacklist = <[
  148. es6.object.to-string
  149. es6.function.name
  150. es6.regexp.constructor
  151. es6.regexp.flags
  152. es6.regexp.match
  153. es6.regexp.replace
  154. es6.regexp.search
  155. es6.regexp.split
  156. es6.number.constructor
  157. ]>
  158. es5SpecialCase = <[
  159. es6.object.freeze
  160. es6.object.seal
  161. es6.object.prevent-extensions
  162. es6.object.is-frozen
  163. es6.object.is-sealed
  164. es6.object.is-extensible
  165. es6.string.trim
  166. ]>
  167. module.exports = ({modules = [], blacklist = [], library = no}, next)!->
  168. let @ = modules.reduce ((memo, it)-> memo[it] = on; memo), {}
  169. check = (err)->
  170. if err
  171. next err, ''
  172. on
  173. if @exp => for experimental => @[..] = on
  174. if @es5 => for es5SpecialCase => @[..] = on
  175. for ns of @
  176. if @[ns]
  177. for name in list
  178. if name.indexOf("#ns.") is 0 and name not in experimental
  179. @[name] = on
  180. if library => blacklist ++= libraryBlacklist
  181. for ns in blacklist
  182. for name in list
  183. if name is ns or name.indexOf("#ns.") is 0
  184. @[name] = no
  185. TARGET = "./__tmp#{ Math.random! }__.js"
  186. err, info <~! webpack do
  187. entry: list.filter(~> @[it]).map ~>
  188. path.join(__dirname, '../', "#{ if library => '/library' else '' }/modules/#it")
  189. output:
  190. path: ''
  191. filename: TARGET
  192. if check err => return
  193. err, script <~! readFile TARGET
  194. if check err => return
  195. err <~! unlink TARGET
  196. if check err => return
  197. next null """
  198. #banner
  199. !function(__e, __g, undefined){
  200. 'use strict';
  201. #script
  202. // CommonJS export
  203. if(typeof module != 'undefined' && module.exports)module.exports = __e;
  204. // RequireJS export
  205. else if(typeof define == 'function' && define.amd)define(function(){return __e});
  206. // Export to global object
  207. else __g.core = __e;
  208. }(1, 1);
  209. """