<p dir="auto">I would love to start using Babel to develop apps but I really need AMD support. Everything works great until I want to use the <code class="notranslate">--optional runtime</code> flag on my build.</p>
<p dir="auto">Here is a sample file.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import Foo from 'foo';

export default &quot;bar&quot;;"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-v">Foo</span> <span class="pl-k">from</span> <span class="pl-s">'foo'</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-s">"bar"</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">And the compiled output.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;use strict&quot;;

define([&quot;exports&quot;, &quot;module&quot;, &quot;foo&quot;, &quot;babel-runtime/helpers&quot;], function (exports, module, _foo, _babelRuntimeHelpers) {
  var _babelHelpers = _babelRuntimeHelpers[&quot;default&quot;];

  var Foo = _babelHelpers.interopRequire(_foo);

  module.exports = &quot;bar&quot;;
});"><pre class="notranslate"><span class="pl-s">"use strict"</span><span class="pl-kos">;</span>

<span class="pl-en">define</span><span class="pl-kos">(</span><span class="pl-kos">[</span><span class="pl-s">"exports"</span><span class="pl-kos">,</span> <span class="pl-s">"module"</span><span class="pl-kos">,</span> <span class="pl-s">"foo"</span><span class="pl-kos">,</span> <span class="pl-s">"babel-runtime/helpers"</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">exports</span><span class="pl-kos">,</span> <span class="pl-s1">module</span><span class="pl-kos">,</span> <span class="pl-s1">_foo</span><span class="pl-kos">,</span> <span class="pl-s1">_babelRuntimeHelpers</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">var</span> <span class="pl-s1">_babelHelpers</span> <span class="pl-c1">=</span> <span class="pl-s1">_babelRuntimeHelpers</span><span class="pl-kos">[</span><span class="pl-s">"default"</span><span class="pl-kos">]</span><span class="pl-kos">;</span>

  <span class="pl-k">var</span> <span class="pl-v">Foo</span> <span class="pl-c1">=</span> <span class="pl-s1">_babelHelpers</span><span class="pl-kos">.</span><span class="pl-en">interopRequire</span><span class="pl-kos">(</span><span class="pl-s1">_foo</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-s1">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span> <span class="pl-c1">=</span> <span class="pl-s">"bar"</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">This all looks good and everything loads fine once I add a package called <code class="notranslate">babel-runtime</code> to my config.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="      var dojoConfig = {
        packages: [
          {
            name: 'babel-runtime',
            location: '/node_modules/babel-runtime'
          }
        ]
      };"><pre class="notranslate">      <span class="pl-k">var</span> <span class="pl-s1">dojoConfig</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
        <span class="pl-c1">packages</span>: <span class="pl-kos">[</span>
          <span class="pl-kos">{</span>
            <span class="pl-c1">name</span>: <span class="pl-s">'babel-runtime'</span><span class="pl-kos">,</span>
            <span class="pl-c1">location</span>: <span class="pl-s">'/node_modules/babel-runtime'</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">But none of the runtime modules are actually AMD modules so they cant be loaded. For example helpers.js looks like this.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;use strict&quot;;

var _core = require(&quot;babel-runtime/core-js&quot;)[&quot;default&quot;];

var helpers = exports[&quot;default&quot;] = {};
exports.__esModule = true;"><pre class="notranslate"><span class="pl-s">"use strict"</span><span class="pl-kos">;</span>

<span class="pl-k">var</span> <span class="pl-s1">_core</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">"babel-runtime/core-js"</span><span class="pl-kos">)</span><span class="pl-kos">[</span><span class="pl-s">"default"</span><span class="pl-kos">]</span><span class="pl-kos">;</span>

<span class="pl-k">var</span> <span class="pl-s1">helpers</span> <span class="pl-c1">=</span> <span class="pl-s1">exports</span><span class="pl-kos">[</span><span class="pl-s">"default"</span><span class="pl-kos">]</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">exports</span><span class="pl-kos">.</span><span class="pl-c1">__esModule</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Would it be possible to convert the runtime files to UMD so they could support AMD loaders and build systems?</p>
<p dir="auto">requirejs does not work using the option <code class="notranslate">--modules amd --optional selfContained</code>. The <code class="notranslate">6to5-runtime/helpers</code> file does not export the helpers functions using the amd syntax, it can be used only in a nodejs/browserify environment.<br>
There should be a way to avoid the following output using the amd modules option</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="define(&quot;myModule&quot;, [&quot;exports&quot;, &quot;module&quot;, &quot;6to5-runtime/helpers&quot;],function(6to5Helpers){
  var _6to5helpers = 6to5Helpers;
});"><pre class="notranslate"><span class="pl-en">define</span><span class="pl-kos">(</span><span class="pl-s">"myModule"</span><span class="pl-kos">,</span> <span class="pl-kos">[</span><span class="pl-s">"exports"</span><span class="pl-kos">,</span> <span class="pl-s">"module"</span><span class="pl-kos">,</span> <span class="pl-s">"6to5-runtime/helpers"</span><span class="pl-kos">]</span><span class="pl-kos">,</span><span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-c1">6</span><span class="pl-s1">to5Helpers</span><span class="pl-kos">)</span><span class="pl-kos">{</span>
  <span class="pl-k">var</span> <span class="pl-s1">_6to5helpers</span> <span class="pl-c1">=</span> <span class="pl-c1">6</span><span class="pl-s1">to5Helpers</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">The output should be similar to something like this:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="define(&quot;myModule&quot;, [&quot;exports&quot;, &quot;module&quot;],function(){
  var _6to5helpers = global.6to5Helpers;
});"><pre class="notranslate"><span class="pl-en">define</span><span class="pl-kos">(</span><span class="pl-s">"myModule"</span><span class="pl-kos">,</span> <span class="pl-kos">[</span><span class="pl-s">"exports"</span><span class="pl-kos">,</span> <span class="pl-s">"module"</span><span class="pl-kos">]</span><span class="pl-kos">,</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">_6to5helpers</span> <span class="pl-c1">=</span> <span class="pl-s1">global</span><span class="pl-c1">.6</span><span class="pl-s1">to5Helpers</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>