<h2 dir="auto">Bug Report</h2>
<p dir="auto">I'm currently investigating <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="784348146" data-permission-text="Title is private" data-url="https://github.com/blitz-js/babel-plugin-superjson-next/issues/29" data-hovercard-type="issue" data-hovercard-url="/blitz-js/babel-plugin-superjson-next/issues/29/hovercard" href="https://github.com/blitz-js/babel-plugin-superjson-next/issues/29">blitz-js/babel-plugin-superjson-next#29</a>.<br>
It occurs since Next.js updated @babel/plugin-transform-react-jsx to 7.12.10.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TypeError: /[...]/babel-plugin-superjson-repro/pages/index.js: d(...) is not a function"><pre class="notranslate"><code class="notranslate">TypeError: /[...]/babel-plugin-superjson-repro/pages/index.js: d(...) is not a function
</code></pre></div>
<p dir="auto">It's caused by this code:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export function getServerSideProps() {
  return {
    props: {
      date: new Date(),
    },
  };
}

export default function Home(props) {
  return &lt;div&gt;hello world {props.date instanceof Date ? &quot;true&quot; : &quot;false&quot;}&lt;/div&gt;;
}"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">function</span> <span class="pl-en">getServerSideProps</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">return</span> <span class="pl-kos">{</span>
    <span class="pl-c1">props</span>: <span class="pl-kos">{</span>
      <span class="pl-c1">date</span>: <span class="pl-k">new</span> <span class="pl-smi">Date</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-k">function</span> <span class="pl-smi">Home</span><span class="pl-kos">(</span><span class="pl-s1">props</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">return</span> <span class="pl-kos">&lt;</span><span class="pl-smi">div</span><span class="pl-kos">&gt;</span><span class="pl-s1">hello</span> <span class="pl-s1">world</span> <span class="pl-kos">{</span><span class="pl-s1">props</span><span class="pl-kos">.</span><span class="pl-c1">date</span> <span class="pl-k">instanceof</span> <span class="pl-smi">Date</span> ? <span class="pl-s">"true"</span> : <span class="pl-s">"false"</span><span class="pl-kos">}</span><span class="pl-c1">&lt;</span><span class="pl-c1">/</span><span class="pl-smi">div</span><span class="pl-c1">&gt;</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">After being passed through <code class="notranslate">babel-plugin-superjson-next</code>, it looks like this:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { withSuperJSONPage as _withSuperJSONPage } from 'babel-plugin-superjson-next/tools';
import { withSuperJSONProps as _withSuperJSONProps } from 'babel-plugin-superjson-next/tools';

export const getServerSideProps = _withSuperJSONProps(
  function getServerSideProps() {
    return {
      props: {
         date: new Date(),
      },
    };
  }
);

function Page({ products }) {
  return &lt;div&gt;hello world {props.date instanceof Date ? &quot;true&quot; : &quot;false&quot;}&lt;/div&gt;;
}

export default _withSuperJSONPage(Page);"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">withSuperJSONPage</span> <span class="pl-k">as</span> <span class="pl-s1">_withSuperJSONPage</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'babel-plugin-superjson-next/tools'</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">withSuperJSONProps</span> <span class="pl-k">as</span> <span class="pl-s1">_withSuperJSONProps</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'babel-plugin-superjson-next/tools'</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-s1">getServerSideProps</span> <span class="pl-c1">=</span> <span class="pl-en">_withSuperJSONProps</span><span class="pl-kos">(</span>
  <span class="pl-k">function</span> <span class="pl-en">getServerSideProps</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">return</span> <span class="pl-kos">{</span>
      <span class="pl-c1">props</span>: <span class="pl-kos">{</span>
         <span class="pl-c1">date</span>: <span class="pl-k">new</span> <span class="pl-smi">Date</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">,</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">function</span> <span class="pl-smi">Page</span><span class="pl-kos">(</span><span class="pl-kos">{</span> products <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">return</span> <span class="pl-kos">&lt;</span><span class="pl-smi">div</span><span class="pl-kos">&gt;</span><span class="pl-s1">hello</span> <span class="pl-s1">world</span> <span class="pl-kos">{</span><span class="pl-s1">props</span><span class="pl-kos">.</span><span class="pl-c1">date</span> <span class="pl-k">instanceof</span> <span class="pl-smi">Date</span> ? <span class="pl-s">"true"</span> : <span class="pl-s">"false"</span><span class="pl-kos">}</span><span class="pl-c1">&lt;</span><span class="pl-c1">/</span><span class="pl-smi">div</span><span class="pl-c1">&gt;</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-en">_withSuperJSONPage</span><span class="pl-kos">(</span><span class="pl-smi">Page</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Interestingly, the error does not occur if you move the <code class="notranslate">export default</code> onto it's own line: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="784348146" data-permission-text="Title is private" data-url="https://github.com/blitz-js/babel-plugin-superjson-next/issues/29" data-hovercard-type="issue" data-hovercard-url="/blitz-js/babel-plugin-superjson-next/issues/29/hovercard?comment_id=760224611&amp;comment_type=issue_comment" href="https://github.com/blitz-js/babel-plugin-superjson-next/issues/29#issuecomment-760224611">blitz-js/babel-plugin-superjson-next#29 (comment)</a></p>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I would like to work on a fix! (provided you give me a hint in the right direction, and this is indeed a bug on Babel's side)</li>
</ul>

<p dir="auto"><strong>Current behavior</strong></p>

<p dir="auto">Repro: <a href="https://github.com/Skn0tt/babel-plugin-superjson-next-10.0.5-repro">Skn0tt/babel-plugin-superjson-next-10.0.5-repro</a></p>
<blockquote>
<p dir="auto">(FYI: Since Next bundles Babel, linking a local Babel package for debugging won't work.)</p>
</blockquote>
<p dir="auto"><strong>Expected behavior</strong><br>
I expected it not to crash.</p>
<p dir="auto"><strong>Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)</strong></p>
<p dir="auto">Next.js 10.0.5, babel-plugin-superjson-next.</p>
<p dir="auto"><strong>Environment</strong></p>
<ul dir="auto">
<li>Babel version(s): 7.12.10</li>
<li>Node/npm version: occurs on multiple versions</li>
<li>OS: occurs on multiple platforms</li>
<li>Monorepo: no</li>
<li>How you are using Babel: <code class="notranslate">webpack</code> / <code class="notranslate">next</code></li>
</ul>
<p dir="auto"><strong>Additional context</strong><br>
I was able to track the error down to this line:</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/babel/babel/blob/6e9a174e7f70180a7ae7b7c01a2c988849666cf0/packages/babel-plugin-transform-react-jsx/src/create-plugin.js#L277">babel/packages/babel-plugin-transform-react-jsx/src/create-plugin.js</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 277
      in
      <a data-pjax="true" class="commit-tease-sha" href="/babel/babel/commit/6e9a174e7f70180a7ae7b7c01a2c988849666cf0">6e9a174</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L277" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="277"></td>
          <td id="LC277" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">const</span> <span class="pl-s1">node</span> <span class="pl-c1">=</span> <span class="pl-s1">t</span><span class="pl-kos">.</span><span class="pl-en">callExpression</span><span class="pl-kos">(</span><span class="pl-en">get</span><span class="pl-kos">(</span><span class="pl-s1">pass</span><span class="pl-kos">,</span> <span class="pl-s">`id/<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">name</span><span class="pl-kos">}</span></span>`</span><span class="pl-kos">)</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-s1">args</span><span class="pl-kos">)</span><span class="pl-kos">;</span> </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">In my case, <code class="notranslate">name</code> is <code class="notranslate">"jsxs"</code>. So it tries to access <code class="notranslate">id/jsxs</code> from the plugin pass, which should have been defined here:</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/babel/babel/blob/6e9a174e7f70180a7ae7b7c01a2c988849666cf0/packages/babel-plugin-transform-react-jsx/src/create-plugin.js#L205">babel/packages/babel-plugin-transform-react-jsx/src/create-plugin.js</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 205
      in
      <a data-pjax="true" class="commit-tease-sha" href="/babel/babel/commit/6e9a174e7f70180a7ae7b7c01a2c988849666cf0">6e9a174</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L205" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="205"></td>
          <td id="LC205" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-en">define</span><span class="pl-kos">(</span><span class="pl-s">"id/jsxs"</span><span class="pl-kos">,</span> <span class="pl-s1">development</span> ? <span class="pl-s">"jsxDEV"</span> : <span class="pl-s">"jsxs"</span><span class="pl-kos">)</span><span class="pl-kos">;</span> </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">Since this is in <code class="notranslate">Program#enter</code>, this should have run before, but it didn't.</p>
<p dir="auto">I'm out of ideas and would very much appreciate your thoughts <g-emoji class="g-emoji" alias="relaxed" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/263a.png">☺️</g-emoji></p>
<h2 dir="auto">Bug Report</h2>
<p dir="auto">Hi there 👋  So from this morning around 08:30GMT we are seeing the following error when we try to compile our code with Rollup. Here is the stack trace that we are seeing.....</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/15871032/101793507-c8818380-3afd-11eb-9de5-1e2b510daa30.png"><img src="https://user-images.githubusercontent.com/15871032/101793507-c8818380-3afd-11eb-9de5-1e2b510daa30.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">It looks to be able the same time you published an update to @babel/plugin-transform-react-jsx recently.</p>
<p dir="auto">Here is the setup of Babel packages we are using.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&quot;@babel/cli&quot;: &quot;7.2.0&quot;,
&quot;@babel/core&quot;: &quot;7.2.0&quot;,
&quot;@babel/eslint-parser&quot;: &quot;^7.11.3&quot;,
&quot;@babel/plugin-proposal-class-properties&quot;: &quot;^7.2.0&quot;,
&quot;@babel/plugin-transform-runtime&quot;: &quot;^7.6.0&quot;,
&quot;@babel/plugin-transform-spread&quot;: &quot;7.2.0&quot;,
&quot;@babel/preset-env&quot;: &quot;7.2.0&quot;,
&quot;@babel/preset-react&quot;: &quot;7.0.0&quot;,
&quot;babel-core&quot;: &quot;7.0.0-bridge.0&quot;,
&quot;babel-loader&quot;: &quot;8.0.4&quot;,
&quot;babel-plugin-add-react-displayname&quot;: &quot;0.0.5&quot;,
&quot;babel-plugin-file-loader&quot;: &quot;1.1.1&quot;,
&quot;babel-plugin-inline-import-data-uri&quot;: &quot;1.0.1&quot;,
&quot;babel-plugin-inline-react-svg&quot;: &quot;1.1.0&quot;,
&quot;babel-plugin-lodash&quot;: &quot;^3.3.4&quot;,
&quot;babel-plugin-transform-replace-object-assign&quot;: &quot;^2.0.0&quot;,"><pre class="notranslate"><code class="notranslate">"@babel/cli": "7.2.0",
"@babel/core": "7.2.0",
"@babel/eslint-parser": "^7.11.3",
"@babel/plugin-proposal-class-properties": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.6.0",
"@babel/plugin-transform-spread": "7.2.0",
"@babel/preset-env": "7.2.0",
"@babel/preset-react": "7.0.0",
"babel-core": "7.0.0-bridge.0",
"babel-loader": "8.0.4",
"babel-plugin-add-react-displayname": "0.0.5",
"babel-plugin-file-loader": "1.1.1",
"babel-plugin-inline-import-data-uri": "1.0.1",
"babel-plugin-inline-react-svg": "1.1.0",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
</code></pre></div>
<p dir="auto">Is there anything you suggest we should do instead?</p>
<p dir="auto"><strong>Environment</strong></p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=""><pre class="notranslate"><code class="notranslate">
</code></pre></div>
<ul dir="auto">
<li>Node/npm version: 10.15.3</li>
<li>OS: Windows</li>
<li>Monorepo: No</li>
<li>How you are using Babel: Rollup</li>
</ul>