title: Babel 6 changes how it exports default
body: <p>Before, babel would add the line <code>module.exports = exports["default"]</code>. It no longer does this. What this means is before I could do:</p>
  
  <pre><code>var foo = require('./foo');
  // use foo
  </code></pre>
  
  <p>Now I have to do this:</p>
  
  <pre><code>var foo = require('./foo').default;
  // use foo
  </code></pre>
  
  <p>Not a huge deal (and I'm guessing this is what it should have been all along).
  The issue is that I have a lot of code that depended on the way that things used to work (I can convert most of it to ES6 imports, but not all of it). Can anyone give me tips on how to make the old way work without having to go through my project and fix this (or even some instruction on how to write a codemod to do this would be pretty slick).</p>
  
  <p>Thanks!</p>
  
  <p>Example:</p>
  
  <p>Input:</p>
  
  <pre><code>const foo = {}
  export default foo
  </code></pre>
  
  <p>Output with Babel 5</p>
  
  <pre><code>"use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  var foo = {};
  exports["default"] = foo;
  module.exports = exports["default"];
  </code></pre>
  
  <p>Output with Babel 6 (and es2015 plugin):</p>
  
  <pre><code>"use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  var foo = {};
  exports["default"] = foo;
  </code></pre>
  
  <p>Notice that the only difference in the output is the <code>module.exports = exports["default"]</code>.</p>
  
  <hr>
  
  <h1>Edit</h1>
  
  <p>You may be interested in this blogpost I wrote after solving my specific issue: <a href="https://kcd.im/tears" rel="noreferrer">Misunderstanding ES6 Modules, Upgrading Babel, Tears, and a Solution</a></p>