'use strict';

const buble = require('buble');

class BrunchBuble {
  constructor({ plugins: { buble } }) {
    this.config = buble || {};
  }

  compile({ data }) {
    try {
      const { code } = buble.transform(data, this.config);
      return Promise.resolve(code);
    } catch (error) {
      return Promise.reject(error);
    }
  }
}

BrunchBuble.prototype.brunchPlugin = true;
BrunchBuble.prototype.type = 'javascript';
BrunchBuble.prototype.extension = 'js';
BrunchBuble.prototype.pattern = /\.js$/;

module.exports = BrunchBuble;

'use strict';

const buble = require('buble');

class BrunchBuble {
  constructor(config) {
    this.config = config && config.plugins && config.plugins.buble || {};
  }

  compile(file) {
    try {
      const transform = buble.transform(file.data, this.config);
      return Promise.resolve(transform.code);
    } catch (error) {
      return Promise.reject(error);
    }
  }
}

BrunchBuble.prototype.brunchPlugin = true;
BrunchBuble.prototype.type = 'javascript';
BrunchBuble.prototype.extension = 'js';
BrunchBuble.prototype.pattern = /\.js$/;

module.exports = BrunchBuble;

Improve the compatibility with older versions of node
Improve the compatibility with older versions of node
