Skip to content

Commit

Permalink
Produce UMD and minified UMD builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Hopding committed Dec 18, 2018
1 parent 855307d commit cce995c
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ coverage.html
*.js.map
.nyc_output
yarn-error.log
fontkit.js
fontkit.min.js
trie.json
trieIndic.json
trieUse.json
16 changes: 12 additions & 4 deletions Makefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ target.all = () => {
target.clean();
target.generateTrieJson();
target.moveTrieJsonToRoot();
target.rollupCjs();
target.rollupUMD();
target.rollupUMDMin();
};

target.generateTrieJson = () => {
Expand All @@ -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');
};
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
6 changes: 6 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -9,6 +13,7 @@ export default {
format: 'umd',
},
plugins: [
// analyze(),
localResolve(),
json(),
babel({
Expand All @@ -23,5 +28,6 @@ export default {
],
runtimeHelpers: true
}),
UGLIFY === 'true' && uglify(),
],
};
49 changes: 48 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit cce995c

Please sign in to comment.