gmcquistin / react-throttle

80 stars 8 forks source link

Use `babel-plugin-lodash` #10

Open kenany opened 7 years ago

kenany commented 7 years ago

This patch introduces the babel-plugin-lodash plugin in order to rewrite the lodash imports from, say:

import _ from 'lodash';

export default function(func) {
    return _.isFunction(func) && func.name === 'debounced';
}

to:

import isFunction from 'lodash/isFunction';

export default function(func) {
    return isFunction(func) && func.name === 'debounced';
}

This helps to reduce bundle size. Bundle size before patch:

$ browserify lib | gzip -9 | wc -c | pretty-bytes
132 kB

Bundle size with this patch:

$ browserify lib | gzip -9 | wc -c | pretty-bytes
62.9 kB

Fixes https://github.com/gmcquistin/react-throttle/issues/5

kenany commented 6 years ago

Rebased.

kenany commented 6 years ago

Without patch:

$ browserify lib | gzip -9 | wc -c | pretty-bytes
117 kB

With patch:

$ browserify lib | gzip -9 | wc -c | pretty-bytes
48.1 kB