title: Babelifying JavaScript Module Pattern with ES6 Arrow Functions
body: <p>Babel is choking on code that uses the module pattern with an arrow function.</p>
  
  <p>If I try to process a file which reads:</p>
  
  <pre><code>const lib = (() =&gt; {
    function sum(a, b)  { return a + b; }
    function mult(a, b) { return a * b; }
  
    return {
      sum,
      mult
    };
  }());
  </code></pre>
  
  <p>Babel gives a <code>SyntaxError</code></p>
  
  <pre><code>{ SyntaxError: /home/david/Sync/ebs/office/fake.js: Unexpected token, expected "," (9:1)
  
     7 |     mult
     8 |   };
  &gt;  9 | }());
       |  ^
    10 | 
      at Parser.raise (/home/david/Sync/ebs/office/node_modules/@babel/parser/lib/index.js:3939:15)
      at Parser.unexpected (/home/david/Sync/ebs/office/node_modules/@babel/parser/lib/index.js:5248:16)
      at Parser.expect (/home/david/Sync/ebs/office/node_modules/@babel/parser/lib/index.js:5236:28)
      at Parser.parseParenAndDistinguishExpression (/home/david/Sync/ebs/office/node_modules/@babel/parser/lib/index.js:6454:14)
      at Parser.parseExprAtom (/home/david/Sync/ebs/office/node_modules/@babel/parser/lib/index.js:6284:21)
      at Parser.parseExprSubscripts (/home/david/Sync/ebs/office/node_modules/@babel/parser/lib/index.js:5924:21)
      at Parser.parseMaybeUnary (/home/david/Sync/ebs/office/node_modules/@babel/parser/lib/index.js:5903:21)
      at Parser.parseExprOps (/home/david/Sync/ebs/office/node_modules/@babel/parser/lib/index.js:5812:21)
      at Parser.parseMaybeConditional (/home/david/Sync/ebs/office/node_modules/@babel/parser/lib/index.js:5784:21)
      at Parser.parseMaybeAssign (/home/david/Sync/ebs/office/node_modules/@babel/parser/lib/index.js:5731:21)
    pos: 137,
    loc: Position { line: 9, column: 1 },
    code: 'BABEL_PARSE_ERROR' }
  </code></pre>
  
  <p>However, if I change the code to use an older style function, like</p>
  
  <pre><code>const lib = (function () {
    function sum(a, b)  { return a + b; }
    function mult(a, b) { return a * b; }
  
    return {
      sum,
      mult
    };
  }());
  </code></pre>
  
  <p>Babel seems to process the file with no issues.</p>
  
  <p>What am I doing wrong? Is there a genuine syntax problem with the arrow function code I am not aware of?</p>