rollup / babel-preset-es2015-rollup

babel-preset-es2015, minus modules, plus helpers
48 stars 17 forks source link

Generating a lots of newlines between helpers #28

Open bali182 opened 7 years ago

bali182 commented 7 years ago

I'm not really sure that this plugin is the culprit, but when building with a config like this:

import babel from 'rollup-plugin-babel'

export default {
  entry: 'src/index.js',
  format: 'cjs',
  plugins: [babel({
    babelrc: false,
    presets: [
      ['es2015-rollup']
    ]
  })],
  dest: 'index.js'
}

The generated source ends up like this:

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
  return typeof obj;
} : function (obj) {
  return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};

// [19 newlines]

var defineProperty = function (obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
};

// [34 newlines]

var toConsumableArray = function (arr) {
  if (Array.isArray(arr)) {
    for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];

    return arr2;
  } else {
    return Array.from(arr);
  }
};

// my code properly rolled up

Any idea why?