<p dir="auto">I suggest we add <code class="notranslate">"es6"</code> as an option to the "module" flag, and the result of using it is getting ES6-style modules (import, export, and default keywords). It should be an error to choose <code class="notranslate">"es6"</code> as the module emit type when targeting below ES6. When targeting ES6 or above, this can remain the default module emit type.</p>
<p dir="auto">A primary personal driver for this is bundling, as bundling to an ES6 module when targeting ES6 is awkward (but possible) but bundling to other formats while still using the remaining ES6 feature set is very desirable, and, additionally, plays well into starting to break things out for <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="105411159" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/4692" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/4692/hovercard" href="https://github.com/microsoft/TypeScript/issues/4692">#4692</a>. A real world use would be compiling targeting node 4 - it supports most of our ES6 features, but <em>not</em> ES6 modules, making our ES6 emit impossible to use without an additional transpiler. :(<br>
Additionally, it would bring us inline with the <a href="https://github.com/systemjs/builder"><code class="notranslate">systemjs</code> builder</a>'s output options, which are <code class="notranslate">amd</code>, <code class="notranslate">cjs</code>, and <code class="notranslate">es6</code>.</p>
<p dir="auto">As of August, 2015, there are several platforms that have JS implementations falling somewhere between ES5 and ES6. Chrome 45+ has block scoping, fat-arrow functions, Map/WeakMap/Set/WeakSet, and classes. io.js 3.x has all of these features as well except fat-arrow functions, but they're coming in Node.js 4.0 or so next month.</p>
<p dir="auto">The big common case here is that none of these platforms support ES6 modules yet -- I imagine none of them will for some time.</p>
<p dir="auto">Can we get a compiler mode to emit ES6 features selectively, or at least emit ES6 <em>except</em> for modules? <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mhegazy/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mhegazy">@mhegazy</a> mentioned in the TypeScript gitter that this would be effectively supporting <code class="notranslate">--t es6</code> alongside <code class="notranslate">--m commonjs</code> in terms of compiler flags.</p>