plotly / react-pivottable

React-based drag'n'drop pivot table with Plotly.js charts
https://react-pivottable.js.org/
MIT License
972 stars 248 forks source link

Configure babel-preset-env target to modern browsers (no ie) #146

Open blikblum opened 2 years ago

blikblum commented 2 years ago

Basically removes support to IE11 out of box (those that still need this should compile on their side)

It dramatically improves performance of generated code. Below is an example in a hot code path (as specified by the comment)

before

      // this code is called in a tight loop
      var colKey = [];
      var rowKey = [];
      var _iteratorNormalCompletion3 = true;
      var _didIteratorError3 = false;
      var _iteratorError3 = undefined;

      try {
        for (var _iterator3 = Array.from(this.props.cols)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
          var x = _step3.value;

          colKey.push(x in record ? record[x] : 'null');
        }
      } catch (err) {
        _didIteratorError3 = true;
        _iteratorError3 = err;
      } finally {
        try {
          if (!_iteratorNormalCompletion3 && _iterator3.return) {
            _iterator3.return();
          }
        } finally {
          if (_didIteratorError3) {
            throw _iteratorError3;
          }
        }
      }

      var _iteratorNormalCompletion4 = true;
      var _didIteratorError4 = false;
      var _iteratorError4 = undefined;

      try {
        for (var _iterator4 = Array.from(this.props.rows)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
          var _x16 = _step4.value;

          rowKey.push(_x16 in record ? record[_x16] : 'null');
        }
      } catch (err) {
        _didIteratorError4 = true;
        _iteratorError4 = err;
      } finally {
        try {
          if (!_iteratorNormalCompletion4 && _iterator4.return) {
            _iterator4.return();
          }
        } finally {
          if (_didIteratorError4) {
            throw _iteratorError4;
          }
        }
      }

after

// this code is called in a tight loop
    const colKey = [];
    const rowKey = [];
    for (const x of Array.from(this.props.cols)) {
      colKey.push(x in record ? record[x] : 'null');
    }
    for (const x of Array.from(this.props.rows)) {
      rowKey.push(x in record ? record[x] : 'null');
    }