<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>Current Behavior</strong><br>
babel/preset-env with option of targets={esmodules: true} generates infinite recursive call for async super method calls.</p>
<p dir="auto"><strong>Input Code</strong></p>
<ul dir="auto">
<li>REPL or Repo link if applicable:<br>
<a href="https://codesandbox.io/s/sparkling-sky-qqc0z" rel="nofollow">https://codesandbox.io/s/sparkling-sky-qqc0z</a></li>
</ul>
<p dir="auto">Example code:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class A {
  async foo() {
    console.log(&quot;A#foo&quot;);
  }
}

class B extends A {
  async foo() {
    console.log(&quot;B#foo&quot;);
    await super.foo();
  }
}

new B().foo();"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">A</span> <span class="pl-kos">{</span>
  <span class="pl-k">async</span> <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">"A#foo"</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">class</span> <span class="pl-v">B</span> <span class="pl-k">extends</span> <span class="pl-v">A</span> <span class="pl-kos">{</span>
  <span class="pl-k">async</span> <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">"B#foo"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">await</span> <span class="pl-smi">super</span><span class="pl-kos">.</span><span class="pl-en">foo</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">new</span> <span class="pl-v">B</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">The transpiled result of above becomes:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;use strict&quot;;

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, &quot;next&quot;, value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, &quot;throw&quot;, err); } _next(undefined); }); }; }

class A {
  foo() {
    return _asyncToGenerator(function* () {
      console.log(&quot;A#foo&quot;);
    })();
  }

}

class B extends A {
  foo() {
    var _superprop_callFoo = function _superprop_callFoo() {
      return _superprop_callFoo(...arguments);
    };

    return _asyncToGenerator(function* () {
      console.log(&quot;B#foo&quot;);
      yield _superprop_callFoo();
    })();
  }

}

new B().foo();"><pre class="notranslate"><span class="pl-s">"use strict"</span><span class="pl-kos">;</span>

<span class="pl-k">function</span> <span class="pl-en">asyncGeneratorStep</span><span class="pl-kos">(</span><span class="pl-s1">gen</span><span class="pl-kos">,</span> <span class="pl-s1">resolve</span><span class="pl-kos">,</span> <span class="pl-s1">reject</span><span class="pl-kos">,</span> <span class="pl-s1">_next</span><span class="pl-kos">,</span> <span class="pl-s1">_throw</span><span class="pl-kos">,</span> <span class="pl-s1">key</span><span class="pl-kos">,</span> <span class="pl-s1">arg</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">try</span> <span class="pl-kos">{</span> <span class="pl-k">var</span> <span class="pl-s1">info</span> <span class="pl-c1">=</span> <span class="pl-s1">gen</span><span class="pl-kos">[</span><span class="pl-s1">key</span><span class="pl-kos">]</span><span class="pl-kos">(</span><span class="pl-s1">arg</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-k">var</span> <span class="pl-s1">value</span> <span class="pl-c1">=</span> <span class="pl-s1">info</span><span class="pl-kos">.</span><span class="pl-c1">value</span><span class="pl-kos">;</span> <span class="pl-kos">}</span> <span class="pl-k">catch</span> <span class="pl-kos">(</span><span class="pl-s1">error</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-s1">reject</span><span class="pl-kos">(</span><span class="pl-s1">error</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-kos">}</span> <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">info</span><span class="pl-kos">.</span><span class="pl-c1">done</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-s1">resolve</span><span class="pl-kos">(</span><span class="pl-s1">value</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-kos">{</span> <span class="pl-v">Promise</span><span class="pl-kos">.</span><span class="pl-en">resolve</span><span class="pl-kos">(</span><span class="pl-s1">value</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-s1">_next</span><span class="pl-kos">,</span> <span class="pl-s1">_throw</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-en">_asyncToGenerator</span><span class="pl-kos">(</span><span class="pl-s1">fn</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">var</span> <span class="pl-s1">self</span> <span class="pl-c1">=</span> <span class="pl-smi">this</span><span class="pl-kos">,</span> <span class="pl-s1">args</span> <span class="pl-c1">=</span> <span class="pl-smi">arguments</span><span class="pl-kos">;</span> <span class="pl-k">return</span> <span class="pl-k">new</span> <span class="pl-v">Promise</span><span class="pl-kos">(</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">resolve</span><span class="pl-kos">,</span> <span class="pl-s1">reject</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">var</span> <span class="pl-s1">gen</span> <span class="pl-c1">=</span> <span class="pl-s1">fn</span><span class="pl-kos">.</span><span class="pl-en">apply</span><span class="pl-kos">(</span><span class="pl-s1">self</span><span class="pl-kos">,</span> <span class="pl-s1">args</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-k">function</span> <span class="pl-en">_next</span><span class="pl-kos">(</span><span class="pl-s1">value</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-en">asyncGeneratorStep</span><span class="pl-kos">(</span><span class="pl-s1">gen</span><span class="pl-kos">,</span> <span class="pl-s1">resolve</span><span class="pl-kos">,</span> <span class="pl-s1">reject</span><span class="pl-kos">,</span> <span class="pl-s1">_next</span><span class="pl-kos">,</span> <span class="pl-s1">_throw</span><span class="pl-kos">,</span> <span class="pl-s">"next"</span><span class="pl-kos">,</span> <span class="pl-s1">value</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-en">_throw</span><span class="pl-kos">(</span><span class="pl-s1">err</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-en">asyncGeneratorStep</span><span class="pl-kos">(</span><span class="pl-s1">gen</span><span class="pl-kos">,</span> <span class="pl-s1">resolve</span><span class="pl-kos">,</span> <span class="pl-s1">reject</span><span class="pl-kos">,</span> <span class="pl-s1">_next</span><span class="pl-kos">,</span> <span class="pl-s1">_throw</span><span class="pl-kos">,</span> <span class="pl-s">"throw"</span><span class="pl-kos">,</span> <span class="pl-s1">err</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-kos">}</span> <span class="pl-en">_next</span><span class="pl-kos">(</span><span class="pl-c1">undefined</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">class</span> <span class="pl-v">A</span> <span class="pl-kos">{</span>
  <span class="pl-en">foo</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-en">_asyncToGenerator</span><span class="pl-kos">(</span><span class="pl-k">function</span><span class="pl-c1">*</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">"A#foo"</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">class</span> <span class="pl-v">B</span> <span class="pl-k">extends</span> <span class="pl-v">A</span> <span class="pl-kos">{</span>
  <span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">var</span> <span class="pl-en">_superprop_callFoo</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-en">_superprop_callFoo</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-en">_superprop_callFoo</span><span class="pl-kos">(</span>...<span class="pl-smi">arguments</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">return</span> <span class="pl-en">_asyncToGenerator</span><span class="pl-kos">(</span><span class="pl-k">function</span><span class="pl-c1">*</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">"B#foo"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
      <span class="pl-k">yield</span> <span class="pl-en">_superprop_callFoo</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">new</span> <span class="pl-v">B</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">foo</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Executed result of above:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ babel-node src/index.js
B#foo
(node:2329) UnhandledPromiseRejectionWarning: RangeError: Maximum call stack size exceeded
    at Arguments.values (&lt;anonymous&gt;)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
(node:2329) UnhandledPromiseRejectionWarning: Unhandled promise rejection. Thiserror originated either by throwing inside of an async function without a catchblock, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2329) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code."><pre class="notranslate"><code class="notranslate">$ babel-node src/index.js
B#foo
(node:2329) UnhandledPromiseRejectionWarning: RangeError: Maximum call stack size exceeded
    at Arguments.values (&lt;anonymous&gt;)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
    at _superprop_callFoo (/sandbox/src/index.js:8:15)
(node:2329) UnhandledPromiseRejectionWarning: Unhandled promise rejection. Thiserror originated either by throwing inside of an async function without a catchblock, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2329) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
</code></pre></div>
<p dir="auto"><strong>Expected behavior</strong></p>
<p dir="auto">Expected result of the above example would be like this (if target is default es5 shows so).</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="B#foo
A#foo"><pre class="notranslate"><code class="notranslate">B#foo
A#foo
</code></pre></div>
<p dir="auto"><strong>Babel Configuration (.babelrc, package.json, cli command)</strong></p>
<ul dir="auto">
<li><code class="notranslate">babel.config.js</code></li>
</ul>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="module.exports = {
  presets: [
    [
      &quot;@babel/env&quot;,
      {
        targets: { esmodules: true }
      }
    ]
  ]
};"><pre class="notranslate"><span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
  <span class="pl-c1">presets</span>: <span class="pl-kos">[</span>
    <span class="pl-kos">[</span>
      <span class="pl-s">"@babel/env"</span><span class="pl-kos">,</span>
      <span class="pl-kos">{</span>
        <span class="pl-c1">targets</span>: <span class="pl-kos">{</span> <span class="pl-c1">esmodules</span>: <span class="pl-c1">true</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></pre></div>
<p dir="auto"><strong>Environment</strong></p>
<ul dir="auto">
<li>Babel version(s): 7.4.4</li>
<li>Node/npm version: Node 10.15.3/yarn 1.13.0</li>
<li>How you are using Babel: cli</li>
</ul>
<p dir="auto"><strong>Possible Solution</strong></p>

<p dir="auto"><strong>Additional context/Screenshots</strong></p>
<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>Current Behavior</strong><br>
I have error <code class="notranslate">RangeError: Maximum call stack size exceeded</code> when I used a <code class="notranslate">super</code> in my async method</p>
<p dir="auto"><strong>Input Code</strong><br>
<a href="https://babeljs.io/repl/#?babili=false&amp;browsers=Chrome%20%3E%3D%2060%2C%20Safari%20%3E%3D%2011%2C%20iOS%20%3E%3D%2010.3%2C%20Firefox%20%3E%3D%2055%2C%20Edge%20%3E%3D%2016&amp;build=&amp;builtIns=false&amp;spec=false&amp;loose=false&amp;code_lz=MYGwhgzhAECyCeBhcVoFMAeAXNA7AJjAEKRrKQwDeAUNNJPLsNCAPZj4CiuWAllvAAUASmg06dLAAteEAHQB3NACMI_NNAC89BWH7RpsuWw4B1FWpwiA3LQmH5AJzQAHVo6xyIaLIlYBbFzBcIQdFC3U5YACgkOFbCWgIAFcXNEdjdi4efiF4uwBfagKgA&amp;debug=false&amp;forceAllTransforms=false&amp;shippedProposals=false&amp;circleciRepo=&amp;evaluate=false&amp;fileSize=false&amp;timeTravel=false&amp;sourceType=module&amp;lineWrap=true&amp;presets=env&amp;prettier=false&amp;targets=&amp;version=7.4.4&amp;externalPlugins=" rel="nofollow">REPL</a></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class MyClass extends BaseClass {
  async loadEntity() {
    this.website = await this.loadWebsite();
    this.report.setCompany(this.website.company);
    super.loadEntity();
  }
}"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">MyClass</span> <span class="pl-k">extends</span> <span class="pl-v">BaseClass</span> <span class="pl-kos">{</span>
  <span class="pl-k">async</span> <span class="pl-en">loadEntity</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">website</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-en">loadWebsite</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">report</span><span class="pl-kos">.</span><span class="pl-en">setCompany</span><span class="pl-kos">(</span><span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">website</span><span class="pl-kos">.</span><span class="pl-c1">company</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-smi">super</span><span class="pl-kos">.</span><span class="pl-en">loadEntity</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></pre></div>
<p dir="auto"><strong>Expected behavior/code</strong><br>
It should work without looping</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class MyClass extends BaseClass {
  loadEntity() {
    var _this = this,
        _superprop_callLoadEntity = function _superprop_callLoadEntity() {
      return _superprop_callLoadEntity(...arguments); // &lt;= HERE I HAVE LOOPING :(
    };

    return _asyncToGenerator(function* () {
      _this.website = yield _this.loadWebsite();

      _this.report.setCompany(_this.website.company);

      _superprop_callLoadEntity();
    })();
  }

}"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">MyClass</span> <span class="pl-k">extends</span> <span class="pl-v">BaseClass</span> <span class="pl-kos">{</span>
  <span class="pl-en">loadEntity</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">var</span> <span class="pl-s1">_this</span> <span class="pl-c1">=</span> <span class="pl-smi">this</span><span class="pl-kos">,</span>
        <span class="pl-en">_superprop_callLoadEntity</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-en">_superprop_callLoadEntity</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-en">_superprop_callLoadEntity</span><span class="pl-kos">(</span>...<span class="pl-smi">arguments</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// &lt;= HERE I HAVE LOOPING :(</span>
    <span class="pl-kos">}</span><span class="pl-kos">;</span>

    <span class="pl-k">return</span> <span class="pl-en">_asyncToGenerator</span><span class="pl-kos">(</span><span class="pl-k">function</span><span class="pl-c1">*</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-s1">_this</span><span class="pl-kos">.</span><span class="pl-c1">website</span> <span class="pl-c1">=</span> <span class="pl-k">yield</span> <span class="pl-s1">_this</span><span class="pl-kos">.</span><span class="pl-en">loadWebsite</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

      <span class="pl-s1">_this</span><span class="pl-kos">.</span><span class="pl-c1">report</span><span class="pl-kos">.</span><span class="pl-en">setCompany</span><span class="pl-kos">(</span><span class="pl-s1">_this</span><span class="pl-kos">.</span><span class="pl-c1">website</span><span class="pl-kos">.</span><span class="pl-c1">company</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

      <span class="pl-en">_superprop_callLoadEntity</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></pre></div>