shadow-function
Version:
ioing lib - shadow Function, worker Function
59 lines (54 loc) • 1.33 kB
JavaScript
const sh = require('./util').sh
const rollup = require('rollup').rollup
const rollupConfig = require('./rollup.config')
const typescript = require('rollup-plugin-typescript2')
const merge = require('lodash.merge')
function rollupEach (options) {
options.forEach(async options => {
const bundle = await rollup(genRollupConfig(options.output, options.config))
await bundle.write(options.output)
})
}
function genRollupConfig (output, config) {
const currentRollupConfig = merge({}, rollupConfig, { output })
currentRollupConfig.plugins[0] = typescript({
verbosity: 1,
tsconfigOverride: {
compilerOptions: Object.assign({
declaration: false
}, config)
}
})
return currentRollupConfig
}
async function build () {
await sh('npm run clean && npx rollup -c scripts/rollup.config.js')
rollupEach([
{
output: {
name: 'ioing',
file: 'dist/index.common.js',
format: 'cjs'
},
config: {
module: 'esnext'
}
},
{
output: {
name: 'ioing',
file: 'dist/index.mjs',
format: 'es'
},
config: {
module: 'esnext',
target: 'es2016'
}
}
])
await sh(`npx uglifyjs dist/index.js \
-c hoist_funs,hoist_vars \
-m \
-o dist/index.min.js`)
}
build()