2017-05-27 17:36:13 +02:00
|
|
|
require! {
|
|
|
|
'../library/fn/promise': Promise
|
|
|
|
'./config': {list, experimental, libraryBlacklist, es5SpecialCase, banner}
|
|
|
|
fs: {readFile, writeFile, unlink}
|
|
|
|
path: {join}
|
|
|
|
webpack, temp
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ({modules = [], blacklist = [], library = no, umd = on})->
|
|
|
|
resolve, reject <~! new Promise _
|
2016-11-03 01:33:53 +01:00
|
|
|
let @ = modules.reduce ((memo, it)-> memo[it] = on; memo), {}
|
|
|
|
if @exp => for experimental => @[..] = on
|
|
|
|
if @es5 => for es5SpecialCase => @[..] = on
|
|
|
|
for ns of @
|
|
|
|
if @[ns]
|
|
|
|
for name in list
|
|
|
|
if name.indexOf("#ns.") is 0 and name not in experimental
|
|
|
|
@[name] = on
|
|
|
|
|
|
|
|
if library => blacklist ++= libraryBlacklist
|
|
|
|
for ns in blacklist
|
|
|
|
for name in list
|
|
|
|
if name is ns or name.indexOf("#ns.") is 0
|
|
|
|
@[name] = no
|
|
|
|
|
2017-05-27 17:36:13 +02:00
|
|
|
TARGET = temp.path {suffix: '.js'}
|
|
|
|
|
2016-11-03 01:33:53 +01:00
|
|
|
err, info <~! webpack do
|
|
|
|
entry: list.filter(~> @[it]).map ~>
|
2017-05-27 17:36:13 +02:00
|
|
|
if library => join __dirname, '..', 'library', 'modules', it
|
|
|
|
else join __dirname, '..', 'modules', it
|
2016-11-03 01:33:53 +01:00
|
|
|
output:
|
|
|
|
path: ''
|
|
|
|
filename: TARGET
|
2017-05-27 17:36:13 +02:00
|
|
|
if err => return reject err
|
|
|
|
|
2016-11-03 01:33:53 +01:00
|
|
|
err, script <~! readFile TARGET
|
2017-05-27 17:36:13 +02:00
|
|
|
if err => return reject err
|
2017-04-20 03:09:25 +02:00
|
|
|
|
2017-05-27 17:36:13 +02:00
|
|
|
err <~! unlink TARGET
|
|
|
|
if err => return reject err
|
|
|
|
|
|
|
|
if umd
|
|
|
|
exportScript = """
|
|
|
|
// CommonJS export
|
|
|
|
if(typeof module != 'undefined' && module.exports)module.exports = __e;
|
|
|
|
// RequireJS export
|
|
|
|
else if(typeof define == 'function' && define.amd)define(function(){return __e});
|
|
|
|
// Export to global object
|
|
|
|
else __g.core = __e;
|
|
|
|
"""
|
|
|
|
else
|
|
|
|
exportScript = ""
|
|
|
|
|
|
|
|
resolve """
|
2016-11-03 01:33:53 +01:00
|
|
|
#banner
|
|
|
|
!function(__e, __g, undefined){
|
|
|
|
'use strict';
|
|
|
|
#script
|
2017-05-27 17:36:13 +02:00
|
|
|
#exportScript
|
2016-11-03 01:33:53 +01:00
|
|
|
}(1, 1);
|
2017-05-27 17:36:13 +02:00
|
|
|
"""
|