From f53a4569712ab165e5e1e6621c7e69cf3c5a6735 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Thu, 6 Sep 2018 22:36:32 -0700 Subject: [PATCH] build UMD bundle; Closes #7 --- builder.js | 6 ++++++ package.json | 2 ++ 2 files changed, 8 insertions(+) diff --git a/builder.js b/builder.js index 80e6207..c70c490 100644 --- a/builder.js +++ b/builder.js @@ -21,4 +21,10 @@ mkdir('dist').then(_ => { const { code } = minify(data); const int = sizer.sync(code); console.log(`> gzip size: ${pretty(int)}`); + + // Write UMD bundle + const name = 'dset'; + 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 a083fbc..37d0dee 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,8 @@ "version": "1.0.1", "repository": "lukeed/dset", "description": "A tiny (144B) utility for safely writing deep Object values~!", + "unpkg": "dist/dset.min.js", + "umd:main": "dist/dset.min.js", "module": "dist/dset.es.js", "main": "dist/dset.js", "license": "MIT",