From 4ee554a4f9ba23cbac2009089d2d64b3c9209f76 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Fri, 11 Jan 2019 11:17:27 -0800 Subject: [PATCH] chore: import builder --- builder.js | 27 --------------------------- package.json | 9 +++------ 2 files changed, 3 insertions(+), 33 deletions(-) delete mode 100644 builder.js diff --git a/builder.js b/builder.js deleted file mode 100644 index f81ff44..0000000 --- a/builder.js +++ /dev/null @@ -1,27 +0,0 @@ -const fs = require('fs'); -const mkdir = require('mk-dirs'); -const pretty = require('pretty-bytes'); -const { minify } = require('terser'); -const sizer = require('gzip-size'); -const pkg = require('./package'); - -let data = fs.readFileSync('src/index.js', 'utf8'); - -mkdir('dist').then(() => { - // Copy as is for ESM - fs.writeFileSync(pkg.module, data); - - // Mutate exports for CJS - data = data.replace(/export default/, 'module.exports ='); - fs.writeFileSync(pkg.main, data); - - // Minify & print gzip-size - let { code } = minify(data, { toplevel:true }); - console.log(`> gzip size: ${pretty(sizer.sync(code))}`); - - // Write UMD bundle - let name = pkg['umd:name'] || pkg.name; - let UMD = `!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.${name}=t()}(this,function(){`; - UMD += code.replace(/module.exports=/, 'return ') + '});'; - fs.writeFileSync(pkg.unpkg, UMD); -}); diff --git a/package.json b/package.json index ad073e4..7ec3769 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "node": ">=6" }, "scripts": { - "build": "node builder", + "build": "bundt", "pretest": "npm run build", "test": "tape test/*.js | tap-spec" }, @@ -31,11 +31,8 @@ "classnames" ], "devDependencies": { - "gzip-size": "^3.0.0", - "mk-dirs": "^1.0.0", - "pretty-bytes": "^4.0.2", + "bundt": "^0.1.1", "tap-spec": "^5.0.0", - "tape": "^4.9.1", - "terser": "^3.10.0" + "tape": "^4.9.1" } }