From cce995c3378c35b247ed2965e15eb92ffad9ea09 Mon Sep 17 00:00:00 2001 From: Andrew Dillon Date: Tue, 18 Dec 2018 08:22:52 -0600 Subject: [PATCH] Produce UMD and minified UMD builds --- .gitignore | 5 +++++ Makefile.js | 16 ++++++++++++---- package.json | 6 ++++-- rollup.config.js | 6 ++++++ yarn.lock | 49 +++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 75 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index e6a5c554..4cd08184 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,8 @@ coverage.html *.js.map .nyc_output yarn-error.log +fontkit.js +fontkit.min.js +trie.json +trieIndic.json +trieUse.json diff --git a/Makefile.js b/Makefile.js index 9ea72c7a..98763b6b 100644 --- a/Makefile.js +++ b/Makefile.js @@ -10,7 +10,8 @@ target.all = () => { target.clean(); target.generateTrieJson(); target.moveTrieJsonToRoot(); - target.rollupCjs(); + target.rollupUMD(); + target.rollupUMDMin(); }; target.generateTrieJson = () => { @@ -26,11 +27,18 @@ target.moveTrieJsonToRoot = () => { mv('src/opentype/shapers/trieIndic.json', 'trieIndic.json'); }; -target.rollupCjs = () => { +target.rollupUMD = () => { target.moveTrieJsonToRoot(); - exec('rollup -c rollup.config.js -o index.js'); + env.UGLIFY = false; + exec('rollup -c rollup.config.js -o fontkit.js'); +}; + +target.rollupUMDMin = () => { + target.moveTrieJsonToRoot(); + env.UGLIFY = true; + exec('rollup -c rollup.config.js -o fontkit.min.js'); }; target.clean = () => { - rm('-f', 'index.js', 'trie.json', 'trieUse.json', 'trieIndic.json', ) + rm('-f', 'fonkit.js', 'fontkit.min.js', 'trie.json', 'trieUse.json', 'trieIndic.json'); }; diff --git a/package.json b/package.json index 1bbcf98e..a97abbe7 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "coverage": "cross-env BABEL_ENV=cover nyc mocha", "build-bundle": "browserify --insert-globals --standalone fontkit ./index.js | uglifyjs --mangle -c > bundle.js" }, - "main": "bundle.js", + "main": "fonkit.js", "files": [ "src", "base.js", @@ -59,8 +59,10 @@ "mocha": "^2.0.1", "nyc": "^10.3.2", "rollup": "^0.68.0", + "rollup-plugin-analyzer": "^2.1.0", "rollup-plugin-babel": "^4.1.0", "rollup-plugin-json": "^3.1.0", - "rollup-plugin-local-resolve": "^1.0.7" + "rollup-plugin-local-resolve": "^1.0.7", + "rollup-plugin-uglify": "^6.0.0" } } diff --git a/rollup.config.js b/rollup.config.js index f5b8ebfc..90c158a6 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,6 +1,10 @@ import babel from 'rollup-plugin-babel'; import localResolve from 'rollup-plugin-local-resolve'; import json from 'rollup-plugin-json'; +import { uglify } from 'rollup-plugin-uglify'; +import { plugin as analyze } from 'rollup-plugin-analyzer'; + +const { UGLIFY } = process.env; export default { input: 'src/index.js', @@ -9,6 +13,7 @@ export default { format: 'umd', }, plugins: [ + // analyze(), localResolve(), json(), babel({ @@ -23,5 +28,6 @@ export default { ], runtimeHelpers: true }), + UGLIFY === 'true' && uglify(), ], }; diff --git a/yarn.lock b/yarn.lock index a099a328..12917a5b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1215,6 +1215,11 @@ commander@^2.8.1: resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a" integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg== +commander@~2.17.1: + version "2.17.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" + integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg== + commondir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" @@ -2290,6 +2295,13 @@ jade@0.26.3: commander "0.6.1" mkdirp "0.3.0" +jest-worker@^23.2.0: + version "23.2.0" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-23.2.0.tgz#faf706a8da36fae60eb26957257fa7b5d8ea02b9" + integrity sha1-+vcGqNo2+uYOsmlXJX+ntdjqArk= + dependencies: + merge-stream "^1.0.1" + js-levenshtein@^1.1.3: version "1.1.4" resolved "https://registry.yarnpkg.com/js-levenshtein/-/js-levenshtein-1.1.4.tgz#3a56e3cbf589ca0081eb22cd9ba0b1290a16d26e" @@ -2518,6 +2530,13 @@ merge-source-map@^1.0.2: dependencies: source-map "^0.6.1" +merge-stream@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-1.0.1.tgz#4041202d508a342ba00174008df0c251b8c135e1" + integrity sha1-QEEgLVCKNCugAXQAjfDCUbjBNeE= + dependencies: + readable-stream "^2.0.1" + micromatch@^2.3.11: version "2.3.11" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" @@ -3099,7 +3118,7 @@ readable-stream@1.1: isarray "0.0.1" string_decoder "~0.10.x" -readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.2.2: +readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.2.2: version "2.3.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" dependencies: @@ -3278,6 +3297,11 @@ rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.5.4, rimraf@^2.6.1: dependencies: glob "^7.0.5" +rollup-plugin-analyzer@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-analyzer/-/rollup-plugin-analyzer-2.1.0.tgz#81d82cafb5a992fb99617112bc73d2313dd18259" + integrity sha512-lryo+3+O6/QF2uoDfszbg+YHuKD1OBuUfcd6kjsbZPKho0ksKCTDStFKrbBH6bF1Rpx/F2jdH6gvDsNbYaEK6g== + rollup-plugin-babel@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/rollup-plugin-babel/-/rollup-plugin-babel-4.1.0.tgz#c97f50c82aa8e89ddaa116cdc5c832b8ba74db17" @@ -3297,6 +3321,16 @@ rollup-plugin-local-resolve@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/rollup-plugin-local-resolve/-/rollup-plugin-local-resolve-1.0.7.tgz#c486701716c15add2127565c2eaa101123320887" +rollup-plugin-uglify@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-uglify/-/rollup-plugin-uglify-6.0.0.tgz#15aa8919e5cdc63b7cfc9319c781788b40084ce4" + integrity sha512-XtzZd159QuOaXNvcxyBcbUCSoBsv5YYWK+7ZwUyujSmISst8avRfjWlp7cGu8T2O52OJnpEBvl+D4WLV1k1iQQ== + dependencies: + "@babel/code-frame" "^7.0.0" + jest-worker "^23.2.0" + serialize-javascript "^1.5.0" + uglify-js "^3.4.9" + rollup-pluginutils@^2.3.0, rollup-pluginutils@^2.3.1: version "2.3.3" resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.3.3.tgz#3aad9b1eb3e7fe8262820818840bf091e5ae6794" @@ -3340,6 +3374,11 @@ semver@^5.4.1: resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg== +serialize-javascript@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.5.0.tgz#1aa336162c88a890ddad5384baebc93a655161fe" + integrity sha512-Ga8c8NjAAp46Br4+0oZ2WxJCwIzwP60Gq1YPgU+39PiTVxyed/iKE/zyZI6+UlVYH5Q4PaQdHhcegIFPZTUfoQ== + set-blocking@^2.0.0, set-blocking@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" @@ -3723,6 +3762,14 @@ uglify-js@^2.6: optionalDependencies: uglify-to-browserify "~1.0.0" +uglify-js@^3.4.9: + version "3.4.9" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3" + integrity sha512-8CJsbKOtEbnJsTyv6LE6m6ZKniqMiFWmm9sRbopbkGs3gMPPfd3Fh8iIA4Ykv5MgaTbqHr4BaoGLJLZNhsrW1Q== + dependencies: + commander "~2.17.1" + source-map "~0.6.1" + uglify-to-browserify@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7"