title: Babel parser not showing proper filename for sytax error
body: <p>So I've tried everywhere but can't find any answers to this. I am trying to add some custom functionality to a Gatsby build process that runs on node.js which requires me to get file content and parse into an ast. I am using <code>@babel/parser</code> successfully, however whenever the parser runs into syntax errors it throws an error referencing the file running the parser instead of the file being parsed (i.e. where the syntax error is actually located).</p>
  
  <p>Here is an example from <code>gatsby-node.js</code> where I am trying to run the parsing function:</p>
  
  <pre><code>const contents = fs.readFileSync( file, 'utf-8' );
  
  const ast = parser.parse( contents, {
    errorRecovery: true,
    plugins: [ 'jsx' ],
    sourceFilename: 'SHOWME.js',
    sourceType: 'module',
  } );
  </code></pre>
  
  <p>Here is the actual syntax error in the file being parsed named <code>Page.js</code>:</p>
  
  <pre><code>import React from 'react';
  import { useGroqQuery } = 'this should break';
  </code></pre>
  
  <p>And here is the error as displayed in terminal:</p>
  
  <pre><code>"gatsby-node.js" threw an error while running the createPages lifecycle:
  
  Unexpected token (2:24)
  
    119 | 
    120 | const contents = fs.readFileSync( file, 'utf-8' );
  &gt; 121 | const ast = parser.parse( contents, {
        |                    ^
    122 |   errorRecovery: true,
    123 |   plugins: [ 'jsx' ],
    124 |   sourceFilename: 'SHOWME.js',
  
  File: gatsby-node.js:121:20
  
  
  
    SyntaxError: Unexpected token (2:24)
  
    - index.js:742 Object._raise
      [gatsby-groq]/[@babel]/parser/lib/index.js:742:17
  
    - index.js:735 Object.raiseWithData
      [gatsby-groq]/[@babel]/parser/lib/index.js:735:17
  
    - index.js:729 Object.raise
      [gatsby-groq]/[@babel]/parser/lib/index.js:729:17
  
  
  </code></pre>
  
  <p>As you can see, it's showing me neither the syntax error itself or the filename, only the line and column numbers. Pretty frustrating to debug. I have tried using the parser's <code>errorRecovery</code> and <code>sourceFilename</code> options but they aren't making a difference here.</p>
  
  <p>Has anyone run into anything similar?</p>