Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Rewrite all functions to arrow to optimize ESM size #208

Merged
merged 4 commits into from
May 21, 2020

Conversation

erykpiast
Copy link
Contributor

@erykpiast erykpiast commented Apr 27, 2020

It resolves #205.

Difference for concatenated size of ES6 code minified with Terser is -3,85 kB (-9,53%) 🎉

Details
name branch size diff to master
lib/**/*.js 37403 B -3942 B (-9.53%)
lib/minBy/index.js 78 B -17 B (-17.89%)
lib/mapT/index.js 39 B -18 B (-31.58%)
lib/takeWhileT/index.js 71 B -18 B (-20.22%)
lib/both/index.js 47 B -16 B (-25.40%)
lib/split/index.js 73 B -17 B (-18.89%)
lib/nth/index.js 126 B -8 B (-5.97%)
lib/lte/index.js 67 B -17 B (-20.24%)
lib/propSatisfies/index.js 72 B -17 B (-19.10%)
lib/init/index.js 62 B -18 B (-22.50%)
lib/filterT/index.js 43 B -18 B (-29.51%)
lib/useWith/index.js 98 B -16 B (-14.04%)
lib/_internal/_set/index.js 533 B -77 B (-12.62%)
lib/_internal/_a2p/index.js 95 B -18 B (-15.93%)
lib/_internal/_test/index.js 241 B 0 B (-)
lib/_internal/_merge/index.js 282 B -16 B (-5.37%)
lib/_internal/_words/index.js 145 B -9 B (-5.84%)
lib/_internal/_shallow_clone/index.js 132 B -9 B (-6.38%)
lib/_internal/_reduce/index.js 463 B -12 B (-2.53%)
lib/_internal/_curry1more/index.js 68 B -17 B (-20.00%)
lib/_internal/_nul/index.js 75 B -17 B (-18.48%)
lib/_internal/_reduceRight/index.js 278 B -13 B (-4.47%)
lib/_internal/_setAry/index.js 89 B -17 B (-16.04%)
lib/_internal/_curry2/index.js 242 B +3 B (+1.26%)
lib/_internal/helpers/performance.js 1690 B 0 B (-)
lib/_internal/_curry3/index.js 242 B +3 B (+1.26%)
lib/_internal/_p2a/index.js 99 B -18 B (-15.38%)
lib/apply/index.js 75 B -17 B (-18.48%)
lib/invert/index.js 92 B -9 B (-8.91%)
lib/pipeP/index.js 71 B 0 B (-)
lib/ceil/index.js 210 B -8 B (-3.67%)
lib/forEach/index.js 108 B -8 B (-6.90%)
lib/comparator/index.js 47 B -33 B (-41.25%)
lib/repeat/index.js 126 B -8 B (-5.97%)
lib/isNil/index.js 27 B -18 B (-40.00%)
lib/concat/index.js 154 B -17 B (-9.94%)
lib/mergeAll/index.js 93 B -9 B (-8.82%)
lib/indexBy/index.js 121 B -8 B (-6.20%)
lib/unary/index.js 27 B -18 B (-40.00%)
lib/__/index.js 18 B 0 B (-)
lib/curry/index.js 72 B -18 B (-20.00%)
lib/unfold/index.js 126 B -8 B (-5.97%)
lib/prop/index.js 67 B -17 B (-20.24%)
lib/applyTo/index.js 67 B -17 B (-20.24%)
lib/remove/index.js 105 B -8 B (-7.08%)
lib/either/index.js 47 B -16 B (-25.40%)
lib/adjust/adjust.js 73 B -8 B (-9.88%)
lib/adjust/index.js 81 B 0 B (-)
lib/inc/index.js 23 B -17 B (-42.50%)
lib/splitEvery/index.js 178 B -8 B (-4.30%)
lib/compact/index.js 54 B -18 B (-25.00%)
lib/unapply/index.js 74 B -17 B (-18.68%)
lib/negate/index.js 22 B -17 B (-43.59%)
lib/noop/index.js 51 B 0 B (-)
lib/pipe/index.js 70 B 0 B (-)
lib/reduceWhileRight/index.js 131 B -8 B (-5.76%)
lib/complement/index.js 36 B -17 B (-32.08%)
lib/lensPath/index.js 245 B -51 B (-17.23%)
lib/last/index.js 33 B -18 B (-35.29%)
lib/defaultTo/index.js 84 B -17 B (-16.83%)
lib/allPass/index.js 121 B -8 B (-6.20%)
lib/insert/index.js 107 B -8 B (-6.96%)
lib/mean/index.js 55 B -18 B (-24.66%)
lib/not/index.js 22 B -17 B (-43.59%)
lib/partialRight/index.js 70 B -16 B (-18.60%)
lib/transduceRight/index.js 79 B -17 B (-17.71%)
lib/gt/index.js 66 B -17 B (-20.48%)
lib/propOr/index.js 91 B -17 B (-15.74%)
lib/empty/index.js 184 B -9 B (-4.66%)
lib/join/index.js 72 B -17 B (-19.10%)
lib/identity/index.js 21 B -18 B (-46.15%)
lib/findIndex/findIndex.js 82 B -8 B (-8.89%)
lib/findIndex/index.js 84 B 0 B (-)
lib/uniqWith/index.js 180 B -8 B (-4.26%)
lib/ap/ap.js 122 B -8 B (-6.15%)
lib/ap/index.js 77 B 0 B (-)
lib/reject/index.js 81 B 0 B (-)
lib/reject/reject.js 116 B -17 B (-12.78%)
lib/countBy/index.js 121 B -17 B (-12.32%)
lib/throttle/index.js 92 B -8 B (-8.00%)
lib/test/index.js 72 B -17 B (-19.10%)
lib/partial/index.js 66 B -16 B (-19.51%)
lib/update/update.js 78 B -8 B (-9.30%)
lib/update/index.js 81 B 0 B (-)
lib/sort/index.js 80 B -17 B (-17.53%)
lib/subtract/index.js 66 B -17 B (-20.48%)
lib/toPairs/index.js 92 B -9 B (-8.91%)
lib/merge/index.js 104 B -17 B (-14.05%)
lib/multiply/index.js 66 B -17 B (-20.48%)
lib/hasIn/index.js 69 B -17 B (-19.77%)
lib/tapT/index.js 45 B -18 B (-28.57%)
lib/fill/index.js 92 B -17 B (-15.60%)
lib/dissoc/index.js 119 B -8 B (-6.30%)
lib/ascend/index.js 68 B -17 B (-20.00%)
lib/once/index.js 67 B -9 B (-11.84%)
lib/median/index.js 154 B -9 B (-5.52%)
lib/match/index.js 77 B -17 B (-18.09%)
lib/until/index.js 101 B -8 B (-7.34%)
lib/reduce/index.js 93 B 0 B (-)
lib/composeT/index.js 69 B -17 B (-19.77%)
lib/eqLens/index.js 112 B -17 B (-13.18%)
lib/debounce/index.js 253 B -51 B (-16.78%)
lib/innerJoin/index.js 170 B -8 B (-4.49%)
lib/takeT/index.js 61 B -18 B (-22.78%)
lib/always/index.js 25 B -17 B (-40.48%)
lib/unnest/index.js 61 B -18 B (-22.78%)
lib/mergeDeepWithKey/index.js 218 B -9 B (-3.96%)
lib/without/index.js 90 B -17 B (-15.89%)
lib/props/index.js 158 B -8 B (-4.82%)
lib/slice/index.js 174 B -17 B (-8.90%)
lib/times/index.js 133 B -8 B (-5.67%)
lib/zipWith/index.js 82 B 0 B (-)
lib/zipWith/zipWith.js 155 B -8 B (-4.91%)
lib/mapAccumRight/index.js 167 B -8 B (-4.57%)
lib/flattenObj/index.js 343 B 0 B (-)
lib/unzip/index.js 57 B -17 B (-22.97%)
lib/nthArg/index.js 49 B -17 B (-25.76%)
lib/path/index.js 79 B 0 B (-)
lib/path/path.js 93 B -8 B (-7.92%)
lib/tryCatch/index.js 116 B -23 B (-16.55%)
lib/forEachObjIndexed/index.js 121 B -8 B (-6.20%)
lib/pathEq/index.js 129 B -17 B (-11.64%)
lib/findLastIndex/index.js 123 B -8 B (-6.11%)
lib/takeLastWhile/index.js 142 B -8 B (-5.33%)
lib/divide/index.js 66 B -17 B (-20.48%)
lib/kebabCase/index.js 131 B -18 B (-12.08%)
lib/append/index.js 76 B -17 B (-18.28%)
lib/symmetricDifferenceWith/index.js 191 B -8 B (-4.02%)
lib/is/index.js 94 B -17 B (-15.32%)
lib/mapAccum/index.js 164 B -8 B (-4.65%)
lib/liftN/index.js 113 B -17 B (-13.08%)
lib/compose/index.js 55 B -17 B (-23.61%)
lib/mathMod/index.js 122 B -16 B (-11.59%)
lib/transpose/index.js 197 B -9 B (-4.37%)
lib/groupWith/index.js 204 B -8 B (-3.77%)
lib/dropT/index.js 61 B -18 B (-22.78%)
lib/includes/index.js 108 B -16 B (-12.90%)
lib/values/index.js 47 B -18 B (-27.69%)
lib/xprod/index.js 185 B -8 B (-4.15%)
lib/differenceWith/index.js 89 B 0 B (-)
lib/differenceWith/differenceWith.js 201 B -8 B (-3.83%)
lib/all/index.js 119 B -8 B (-6.30%)
lib/endsWith/index.js 83 B 0 B (-)
lib/endsWith/endsWith.js 165 B -8 B (-4.62%)
lib/pluck/index.js 77 B -17 B (-18.09%)
lib/over/index.js 79 B 0 B (-)
lib/over/over.js 62 B -8 B (-11.43%)
lib/lensProp/index.js 112 B -18 B (-13.85%)
lib/applySpec/index.js 167 B -9 B (-5.11%)
lib/flip/index.js 45 B -17 B (-27.42%)
lib/length/index.js 62 B -18 B (-22.50%)
lib/adjustIn/index.js 148 B -17 B (-10.30%)
lib/splitWhen/index.js 161 B -8 B (-4.73%)
lib/indexed/index.js 48 B -9 B (-15.79%)
lib/chain/index.js 211 B -8 B (-3.65%)
lib/snakeCase/index.js 111 B -18 B (-13.95%)
lib/invoker/index.js 127 B -17 B (-11.81%)
lib/dropRepeatsWith/index.js 163 B -8 B (-4.68%)
lib/reduceWhile/index.js 128 B -8 B (-5.88%)
lib/keysIn/index.js 64 B -9 B (-12.33%)
lib/splitAt/index.js 88 B -16 B (-15.38%)
lib/descend/index.js 68 B -17 B (-20.00%)
lib/converge/index.js 86 B -17 B (-16.50%)
lib/prepend/index.js 76 B -16 B (-17.39%)
lib/T/index.js 47 B 0 B (-)
lib/scan/index.js 152 B -8 B (-5.00%)
lib/uncurryN/index.js 115 B -23 B (-16.67%)
lib/product/index.js 42 B -18 B (-30.00%)
lib/evolve/index.js 131 B -6 B (-4.38%)
lib/tap/index.js 80 B -15 B (-15.79%)
lib/tail/index.js 44 B 0 B (-)
lib/F/index.js 47 B 0 B (-)
lib/o/index.js 72 B -17 B (-19.10%)
lib/cond/index.js 83 B -18 B (-17.82%)
lib/reverse/index.js 86 B -17 B (-16.50%)
lib/intersection/index.js 392 B -8 B (-2.00%)
lib/contains/index.js 112 B -17 B (-13.18%)
lib/max/max.js 30 B -17 B (-36.17%)
lib/max/index.js 78 B 0 B (-)
lib/omitBy/index.js 122 B -17 B (-12.23%)
lib/trim/index.js 28 B -18 B (-39.13%)
lib/omit/index.js 149 B -8 B (-5.10%)
lib/pickAll/index.js 96 B -17 B (-15.04%)
lib/ifElse/index.js 82 B -17 B (-17.17%)
lib/groupBy/index.js 155 B -8 B (-4.91%)
lib/pipeT/index.js 64 B -17 B (-20.99%)
lib/head/index.js 24 B -18 B (-42.86%)
lib/identityT/index.js 36 B -17 B (-32.08%)
lib/eqBy/index.js 109 B -17 B (-13.49%)
lib/project/index.js 163 B -8 B (-4.68%)
lib/fromPairs/index.js 82 B -9 B (-9.89%)
lib/uniq/index.js 100 B -18 B (-15.25%)
lib/difference/difference.js 111 B -17 B (-13.28%)
lib/difference/index.js 85 B 0 B (-)
lib/any/index.js 118 B -8 B (-6.35%)
lib/equals/equals.js 696 B +3 B (+0.43%)
lib/equals/index.js 81 B 0 B (-)
lib/memoize/index.js 122 B -16 B (-11.59%)
lib/zip/index.js 116 B -17 B (-12.78%)
lib/nAry/index.js 87 B -17 B (-16.35%)
lib/lens/index.js 56 B -17 B (-23.29%)
lib/mergeDeepLeft/mergeDeepLeft.js 148 B -6 B (-3.90%)
lib/mergeDeepLeft/index.js 88 B 0 B (-)
lib/drop/index.js 80 B -17 B (-17.53%)
lib/dropLastWhile/index.js 143 B -8 B (-5.30%)
lib/map/index.js 222 B -8 B (-3.48%)
lib/za/index.js 52 B -17 B (-24.64%)
lib/type/index.js 170 B -9 B (-5.03%)
lib/flatten/index.js 123 B -15 B (-10.87%)
lib/call/index.js 60 B -17 B (-22.08%)
lib/and/index.js 67 B -17 B (-20.24%)
lib/unless/index.js 77 B -17 B (-18.09%)
lib/add/index.js 69 B -16 B (-18.82%)
lib/reduceRight/index.js 120 B -8 B (-6.25%)
lib/clone/index.js 711 B -5 B (-0.70%)
lib/eqProps/index.js 109 B -17 B (-13.49%)
lib/objOf/index.js 89 B -8 B (-8.25%)
lib/clamp/index.js 80 B 0 B (-)
lib/clamp/clamp.js 38 B -17 B (-30.91%)
lib/sum/index.js 44 B -18 B (-29.03%)
lib/take/index.js 145 B -8 B (-5.23%)
lib/aperture/index.js 165 B -8 B (-4.62%)
lib/pathSatisfies/index.js 102 B -17 B (-14.29%)
lib/insertAll/index.js 125 B -15 B (-10.71%)
lib/maxBy/index.js 78 B -17 B (-17.89%)
lib/intersperse/index.js 159 B -8 B (-4.79%)
lib/uniqBy/index.js 199 B -8 B (-3.86%)
lib/toLower/index.js 35 B -18 B (-33.96%)
lib/juxt/index.js 87 B -17 B (-16.35%)
lib/unnestN/index.js 244 B -8 B (-3.17%)
lib/propEq/index.js 106 B -17 B (-13.82%)
lib/unionWith/index.js 157 B -8 B (-4.85%)
lib/propIs/index.js 117 B -17 B (-12.69%)
lib/transduce/index.js 74 B -17 B (-18.68%)
lib/mergeWithKey/index.js 124 B -17 B (-12.06%)
lib/assoc/index.js 80 B 0 B (-)
lib/assoc/assoc.js 140 B -8 B (-5.41%)
lib/dec/index.js 23 B -17 B (-42.50%)
lib/constructN/index.js 123 B -17 B (-12.14%)
lib/assocPath/assocPath.js 295 B -8 B (-2.64%)
lib/assocPath/index.js 84 B 0 B (-)
lib/view/index.js 73 B -17 B (-18.89%)
lib/into/index.js 151 B -23 B (-13.22%)
lib/lensIndex/index.js 69 B -18 B (-20.69%)
lib/invertObj/index.js 64 B -9 B (-12.33%)
lib/reduceBy/index.js 168 B -17 B (-9.19%)
lib/curryN/index.js 47 B 0 B (-)
lib/curryN/curryN.js 274 B +3 B (+1.11%)
lib/union/index.js 119 B -17 B (-12.50%)
lib/az/index.js 51 B -17 B (-25.00%)
lib/lastIndexOf/index.js 124 B -17 B (-12.06%)
lib/keys/index.js 34 B -18 B (-34.62%)
lib/identical/index.js 84 B 0 B (-)
lib/identical/identical.js 60 B -17 B (-22.08%)
lib/dropWhile/index.js 129 B -8 B (-5.84%)
lib/mapObjIndexed/index.js 116 B -17 B (-12.78%)
lib/takeWhile/index.js 131 B -8 B (-5.76%)
lib/has/index.js 82 B -17 B (-17.17%)
lib/binary/index.js 33 B -17 B (-34.00%)
lib/gte/index.js 67 B -17 B (-20.24%)
lib/toString/index.js 516 B +12 B (+2.38%)
lib/mergeDeepRight/index.js 89 B 0 B (-)
lib/mergeDeepRight/mergeDeepRight.js 75 B -17 B (-18.48%)
lib/memoizeWith/index.js 135 B -8 B (-5.59%)
lib/takeLast/index.js 144 B -8 B (-5.26%)
lib/isEmpty/index.js 108 B -9 B (-7.69%)
lib/pickBy/index.js 122 B -17 B (-12.23%)
lib/sortBy/index.js 81 B 0 B (-)
lib/sortBy/sortBy.js 40 B -17 B (-29.82%)
lib/dissocPath/index.js 175 B 0 B (-)
lib/find/index.js 118 B -8 B (-6.35%)
lib/replace/index.js 79 B -17 B (-17.71%)
lib/whereEq/index.js 168 B -8 B (-4.55%)
lib/toPairsIn/index.js 71 B -9 B (-11.25%)
lib/composeP/index.js 79 B -17 B (-17.71%)
lib/of/index.js 21 B -18 B (-46.15%)
lib/when/index.js 77 B -17 B (-18.09%)
lib/filter/index.js 81 B 0 B (-)
lib/filter/filter.js 230 B -17 B (-6.88%)
lib/pathOr/index.js 126 B -8 B (-5.97%)
lib/set/index.js 78 B 0 B (-)
lib/set/set.js 36 B -17 B (-32.08%)
lib/lt/index.js 66 B -17 B (-20.48%)
lib/partition/index.js 102 B -16 B (-13.56%)
lib/or/index.js 67 B -17 B (-20.24%)
lib/dropRepeats/index.js 87 B 0 B (-)
lib/range/index.js 111 B -17 B (-13.28%)
lib/dropWhileT/index.js 72 B -18 B (-20.00%)
lib/camelCase/index.js 155 B -18 B (-10.40%)
lib/mergeDeepWith/index.js 196 B -9 B (-4.39%)
lib/none/index.js 120 B -8 B (-6.25%)
lib/modulo/index.js 66 B -17 B (-20.48%)
lib/bind/index.js 72 B -17 B (-19.10%)
lib/sortWith/index.js 152 B -17 B (-10.06%)
lib/where/index.js 134 B -8 B (-5.63%)
lib/updateBy/index.js 148 B -17 B (-10.30%)
lib/toUpper/index.js 35 B -18 B (-33.96%)
lib/isInteger/index.js 67 B -17 B (-20.24%)
lib/mergeWith/index.js 153 B -8 B (-4.97%)
lib/min/index.js 78 B 0 B (-)
lib/min/min.js 30 B -17 B (-36.17%)
lib/dropLast/index.js 83 B 0 B (-)
lib/dropLast/dropLast.js 43 B -17 B (-28.33%)
lib/eqWith/index.js 71 B -17 B (-19.32%)
lib/pick/index.js 106 B -17 B (-13.82%)
lib/zipObj/index.js 58 B -17 B (-22.67%)
lib/startsWith/index.js 259 B -8 B (-3.00%)
lib/construct/index.js 62 B -18 B (-22.50%)
lib/findLast/index.js 121 B -8 B (-6.20%)
lib/anyPass/index.js 118 B -8 B (-6.35%)
lib/lift/lift.js 319 B +2 B (+0.63%)
lib/lift/index.js 112 B -18 B (-13.85%)
lib/addIndex/index.js 98 B -8 B (-7.55%)
lib/unzipWith/index.js 242 B -8 B (-3.20%)
lib/zipObjDeep/index.js 94 B -17 B (-15.32%)
lib/valuesIn/index.js 67 B -9 B (-11.84%)
lib/indexOf/index.js 82 B 0 B (-)
lib/indexOf/indexOf.js 57 B -17 B (-22.97%)
lib/pair/index.js 68 B -16 B (-19.05%)
lib/symmetricDifference/index.js 137 B -8 B (-5.52%)

@plesiecki
Copy link

@erykpiast You never cease to amaze 👏 🚀

? a.join('.')
: typeof a === 'string' || typeof a === 'number' ? '' + a : ''
}
export default (a) => Array.isArray(a)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With often used static methods imported from separate module, in this case export const { isArray } = Array, the whole thing should minify even better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're completely right! If only @Beraliv likes that, I'd love to implement it!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With often used static methods imported from separate module, in this case export const { isArray } = Array, the whole thing should minify even better.

@plesiecki This is good for functions which have the same number of arguments as our implementation (and the same order)

You're completely right! If only @Beraliv likes that, I'd love to implement it!

@erykpiast so yeah, you should change that for sure! 🚀

@@ -12,6 +12,7 @@
"@babel/plugin-transform-arrow-functions",
"@babel/plugin-transform-function-name",
"@babel/plugin-transform-spread",
"@babel/plugin-transform-parameters"
"@babel/plugin-transform-parameters",
"@babel/plugin-transform-shorthand-properties"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you okay with that? I think this transform produces code of reasonable size. It's no bigger than handwritten ES5. And ES6+ version is much more concise :)

Copy link
Member

@Beraliv Beraliv Apr 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No, this is right because cjs cannot support it right now but definitely should

@@ -1,4 +1,4 @@
function reduceIterable(cb, acc, gen) {
const reduceIterable = (cb, acc, gen) => {
Copy link
Member

@Beraliv Beraliv Apr 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 this is good helpers still have names, because stack trace will be readable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I try to care about it as much as about a bundle size! :)

@erykpiast
Copy link
Contributor Author

@Beraliv do you have any issues with yarn installation on this branch? I can see some comments regarding this in e-mail notifications, but not on GitHub 😕

Copy link
Member

@Beraliv Beraliv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your changes, they are really great ❤️

I have several questions in comments, so let's solve them first and I will approve them as I totally support your idea

lib/memoize/index.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
SIZES.md Outdated Show resolved Hide resolved
@@ -1,6 +1,6 @@
import mean from '../mean'

export default (list) => {
const median = (list) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

lib/debounce/index.js Outdated Show resolved Hide resolved
@Beraliv
Copy link
Member

Beraliv commented Apr 28, 2020

@erykpiast do you have the public project where I can see Terser minification? Or is it private?

I have an idea to follow changes with the custom project which will tell us how much it costs with Terser

Copy link
Member

@Beraliv Beraliv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Thank you so much for your help!

I will merge it after #211 🕑

@erykpiast
Copy link
Contributor Author

@erykpiast do you have the public project where I can see Terser minification? Or is it private?

I've handwritten a bash script for that :) If you wish, I could add it to size.js script. It seems it should be a part of size-limit package. We could do something like

const sizeLimit = name => {
  const index = getIndex(name);
  const ramda = getSize(getRamda(name));
  return Promise.all([
    getSize(index),
    getSize(index, { terser: true }),
    getSize(ramda).catch(() => 'n/a'),
    getSize(ramda, { terser: true }).catch(() => 'n/a'),
  ]).then(([size, minifiedSize, ramdaSize, ramdaMinifiedSize]) => ({
    name,
    size,
    minifiedSize,
    ramdaSize,
    ramdaMinifiedSize
 }));
};

What do you think?

@erykpiast
Copy link
Contributor Author

I've added an issue to ai/size-limit#178. Support will be appreciated! :)

@Beraliv
Copy link
Member

Beraliv commented Apr 28, 2020

@erykpiast do you have the public project where I can see Terser minification? Or is it private?

I've handwritten a bash script for that :) If you wish, I could add it to size.js script. It seems it should be a part of size-limit package. We could do something like

const sizeLimit = name => {
  const index = getIndex(name);
  const ramda = getSize(getRamda(name));
  return Promise.all([
    getSize(index),
    getSize(index, { terser: true }),
    getSize(ramda).catch(() => 'n/a'),
    getSize(ramda, { terser: true }).catch(() => 'n/a'),
  ]).then(([size, minifiedSize, ramdaSize, ramdaMinifiedSize]) => ({
    name,
    size,
    minifiedSize,
    ramdaSize,
    ramdaMinifiedSize
 }));
};

What do you think?

I think we should first create an issue in size-limit and then try to implement it here (with size-limit which would be better or not if it's not possible for some reason)

Here I created an issue #212

UPDATE:

I've added an issue to ai/size-limit#178. Support will be appreciated! :)

Sure!

@erykpiast
Copy link
Contributor Author

erykpiast commented May 17, 2020

@Beraliv I've added one more thing - marked the package as side-effects-free. As far as I understand it's completely safe for nanoutils. What do you think?

One of the non-obvious benefits of this would be the exports analysis section available at bundlephobia. See one for ramda.

@Beraliv
Copy link
Member

Beraliv commented May 20, 2020

@Beraliv I've added one more thing - marked the package as side-effects-free. As far as I understand it's completely safe for nanoutils. What do you think?

One of the non-obvious benefits of this would be the exports analysis section available at bundlephobia. See one for ramda.

Yeah, I've had a look at it recently, good you've already added it 🎉

Also, there's a plugin for babel babel-plugin-annotate-pure-calls, which adds #__PURE__ for better UglifyJS optimisation, did you here about that?

That can also decrease the size of the modules

Check out the issue - #215

@Beraliv
Copy link
Member

Beraliv commented May 20, 2020

@erykpiast you can resolve conflicts here and we can finally merge this to master 🔥

@erykpiast
Copy link
Contributor Author

Done! I'll go with that pure plugin stuff with the next PR. If we just add it to .babelrc it applies only to CommonJS build. ESM isn't transpiled at all and this one has to be changed.

@erykpiast
Copy link
Contributor Author

@Beraliv I've written an article where I recommend nanoutils as a replacement for lodash (along other stuff). If you like it, please share :) Here is the link: https://dev.to/erykpiast/the-story-about-a-few-imports-40jm

@Beraliv
Copy link
Member

Beraliv commented May 21, 2020

@Beraliv I've written an article where I recommend nanoutils as a replacement for lodash (along other stuff). If you like it, please share :) Here is the link: https://dev.to/erykpiast/the-story-about-a-few-imports-40jm

Thanks, really interesting article, followed the details till the end 😊

Btw did you find any inconvenience in library usage except for tree-shaking?

@Beraliv Beraliv merged commit 7336145 into nanoutils:master May 21, 2020
@erykpiast
Copy link
Contributor Author

I'm glad to hear 😊

No, so far no issues! I used nanoutils in a couple of different projects of various size and the experience was smooth as peanut butter.

The only thing you probably noticed in the article - I recommended more generic Babel plugin than babel-plugin-nanoutils. That's because I had some problems with that one. I cannot recall what specifically but at the moment of trying there were no issues open on GitHub and I had quite a complex Babel setup, so I assumed it probably affects only me and quickly moved on to another plugin that I already used for something else. Maybe it's nothing, maybe it's worth investigating :)

@Beraliv
Copy link
Member

Beraliv commented Aug 5, 2020

I'm glad to hear 😊

No, so far no issues! I used nanoutils in a couple of different projects of various size and the experience was smooth as peanut butter.

The only thing you probably noticed in the article - I recommended more generic Babel plugin than babel-plugin-nanoutils. That's because I had some problems with that one. I cannot recall what specifically but at the moment of trying there were no issues open on GitHub and I had quite a complex Babel setup, so I assumed it probably affects only me and quickly moved on to another plugin that I already used for something else. Maybe it's nothing, maybe it's worth investigating :)

Yeah, I've seen that
You can share the config and we will have a look at it

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Arrow functions
4 participants