title: Babel.js Class is not a constructor
body: <p>I need to compile my API libs with babel.js from ES6. Compilation is fine, but after simple calling new RichEditorApi(xx); I getting error:</p>
  
  <pre><code>TypeError: _richEditorApi.RichEditorApi is not a constructor
  </code></pre>
  
  <p>I've tried to find answer, but I had no luck.</p>
  
  <p><strong>Here is my gulp task:</strong></p>
  
  <pre><code>    gulp.task('buildAPI', () =&gt; {
      return gulp.src('./src/components/**/api/*.js')        
          .pipe(babel({
              presets: ['es2015']
          }))
          .on('error', console.error.bind(console))                
          .pipe(gulp.dest('./test/lib'));
  });
  </code></pre>
  
  <p><strong>Simply compiling api:</strong></p>
  
  <pre><code>    /** 
   * 
   * @export
   * @class TextImageApi
   */
  export class RichEditorApi {
  
      /**
       * Creates an instance of RichEditorApi.
       * 
       * @param {any} app
       * @param {any} database
       */
      constructor(app) {
          this.app = app;
          this.database = "";
      }
  
      /**
       * Register component API
       */
      register() {                
          this.app.get('/cms/api/:sectionId', function (req, res, next) {
              var sectionId = req.params.sectionId;
              var data = this.database.loadComponentData(sectionId);
              res.json(data);
          });
  
          // REST API update component content 
          this.app.put('/cms/api/', function (req, res, next) {
  
              var sectionId = req.body.sectionId;
              var result = {
                  "data": { sectionId: sectionId }
              }
  
              var data = {
                  error : false,
                  message : "success",
              };
  
              this.database.saveComponentData(result, (err) =&gt; {
                  if (err) {
                      data.error = true;
                      data.message = err;
                  }
              });
  
              res.json(data);
          });
      }
  }
  </code></pre>
  
  <p><strong>Recompiled with Babel.js look like this:</strong></p>
  
  <pre><code>    'use strict';
  
  Object.defineProperty(exports, "__esModule", {
      value: true
  });
  
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i &lt; props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  
  /** 
   * 
   * @export
   * @class TextImageApi
   */
  var RichEditorApi = exports.RichEditorApi = function () {
  
      /**
       * Creates an instance of RichEditorApi.
       * 
       * @param {any} app
       * @param {any} database
       */
      function RichEditorApi(app) {
          _classCallCheck(this, RichEditorApi);
  
          this.app = app;
          this.database = "";
      }
  
      /**
       * Register component API
       */
  
  
      _createClass(RichEditorApi, [{
          key: 'register',
          value: function register() {
              this.app.get('/cms/api/:sectionId', function (req, res, next) {
                  var sectionId = req.params.sectionId;
                  var data = this.database.loadComponentData(sectionId);
                  res.json(data);
              });
  
              // REST API update component content 
              this.app.put('/cms/api/', function (req, res, next) {
  
                  var sectionId = req.body.sectionId;
                  var result = {
                      "data": { sectionId: sectionId }
                  };
  
                  var data = {
                      error: false,
                      message: "success"
                  };
  
                  this.database.saveComponentData(result, function (err) {
                      if (err) {
                          data.error = true;
                          data.message = err;
                      }
                  });
  
                  res.json(data);
              });
          }
      }]);
  
      return RichEditorApi;
  }();
  </code></pre>
  
  <p><strong>So, now I want to simple call new instance of my RichEditorApi:</strong></p>
  
  <pre><code> import { RichEditorApi } from "./lib/richEditor/api/richEditorApi";
  ...
   //let richEditorApi = new RichEditorApi(app);
   //richEditorApi.register();
  console.log(new RichEditorApi(app));
  </code></pre>
  
  <p><strong>after this, I'll get this:</strong></p>
  
  <pre><code>&gt; console.log(new _richEditorApi.RichEditorApi(app));
              ^
  
  TypeError: _richEditorApi.RichEditorApi is not a constructor
      at Object.&lt;anonymous&gt; (test.js:37:13)
      at Module._compile (module.js:541:32)
      at loader (/Users/petrtomasek/Projects/cmsComponents/node_modules/babel-register/lib/node.js:148:5)
      at Object.require.extensions.(anonymous function) [as .js] (/Users/petrtomasek/Projects/cmsComponents/node_modules/babel-register/lib/node.js:158:7)
      at Module.load (module.js:458:32)
      at tryModuleLoad (module.js:417:12)
      at Function.Module._load (module.js:409:3)
      at Function.Module.runMain (module.js:575:10)
      at /Users/petrtomasek/Projects/cmsComponents/node_modules/babel-cli/lib/_babel-node.js:160:24
      at Object.&lt;anonymous&gt; (/Users/petrtomasek/Projects/cmsComponents/node_modules/babel-cli/lib/_babel-node.js:161:7)
  </code></pre>
  
  <p>What is wrong?
  Thank you</p>