Search code examples
javascriptbabeljslodash

How to resolve "Lodash chain sequences are not supported by babel-plugin-lodash"


I am using Lodash chain and am running into the above issue when building my service.


Solution

  • The issue comes from babel-plugin-lodash not supporting lodash chains.

    To solve the issue, you must use lodash's flow operator instead.

    Here is an example:

    // using chain
    const result = _.chain(array)
      .map(fn1)
      .filter(fn2)
      .value();
    
    // using flow
    const result = _.flow([
      arr => _.map(arr, fn1),
      arr => _.filter(arr, fn2)
    ])(array);