Skip to content

Commit

Permalink
Remove references to Node's experimental modules support
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoffreyBooth committed Apr 27, 2018
1 parent 776e7e5 commit 6df8f5f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions docs/v2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,7 @@ <h3>What’s New In CoffeeScript 2?</h3>
<h3>Compatibility</h3>
<p>Most modern JavaScript features that CoffeeScript supports can run natively in Node 7.6+, meaning that Node can run CoffeeScript’s output without any further processing required. Here are some notable exceptions:</p>
<ul>
<li><a href="#jsx">JSX</a> always requires transpilation.</li>
<li><a href="#modules">Modules</a> (<code>import</code> and <code>export</code> statements) are supported by Node 10+, provided you specify an output filename with an <code>.mjs</code> extension (or rename the extensions of the generated <code>.js</code> files) and execute such files via <code>node</code>, not <code>coffee</code>.</li>
<li><a href="#modules">Modules</a> and <a href="#jsx">JSX</a> always require transpilation.</li>
<li><a href="http://coffeescript.org/#splats">Splats, a.k.a. object rest/spread syntax, for objects</a> are supported by Node 8.6+.</li>
<li>The <a href="https://github.com/tc39/proposal-regexp-dotall-flag">regular expression <code>s</code> (dotall) flag</a> is supported by Node 9+.</li>
</ul>
Expand Down Expand Up @@ -4406,7 +4405,7 @@ <h2>Modules</h2>

</aside>
<div id="modules-note" class="bookmark"></div>
<p>Note that the CoffeeScript compiler <strong>does not resolve modules</strong>; writing an <code>import</code> or <code>export</code> statement in CoffeeScript will produce an <code>import</code> or <code>export</code> statement in the resulting output. It is your responsibility to <a href="#transpilation">transpile</a> this ES2015 syntax into code that will work in your target runtimes, unless you know that your code will be executed by a runtime that supports <a href="https://nodejs.org/api/esm.html">ES modules</a>. Node supports such modules only for files with <code>.mjs</code> extensions; you can generate such an extension via the <code>coffee</code> command for a single file via <code>--output</code>, as in <code>coffee --compile --output index.mjs index.coffee</code>. When compiling folders or globs, it is your responsibility to rename the generated <code>.js</code> files as needed.</p>
<p>Note that the CoffeeScript compiler <strong>does not resolve modules</strong>; writing an <code>import</code> or <code>export</code> statement in CoffeeScript will produce an <code>import</code> or <code>export</code> statement in the resulting output. It is your responsibility to <a href="#transpilation">transpile</a> this ES2015 syntax into code that will work in your target runtimes.</p>
<p>Also note that any file with an <code>import</code> or <code>export</code> statement will be output without a <a href="#lexical-scope">top-level function safety wrapper</a>; in other words, importing or exporting modules will automatically trigger <a href="#usage">bare</a> mode for that file. This is because per the ES2015 spec, <code>import</code> or <code>export</code> statements must occur at the topmost scope.</p>

</section>
Expand Down
3 changes: 1 addition & 2 deletions documentation/sections/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

Most modern JavaScript features that CoffeeScript supports can run natively in Node 7.6+, meaning that Node can run CoffeeScript’s output without any further processing required. Here are some notable exceptions:

* [JSX](#jsx) always requires transpilation.
* [Modules](#modules) (`import` and `export` statements) are supported by Node 10+, provided you specify an output filename with an `.mjs` extension (or rename the extensions of the generated `.js` files) and execute such files via `node`, not `coffee`.
* [Modules](#modules) and [JSX](#jsx) always require transpilation.
* [Splats, a.k.a. object rest/spread syntax, for objects](http://coffeescript.org/#splats) are supported by Node 8.6+.
* The [regular expression `s` (dotall) flag](https://github.com/tc39/proposal-regexp-dotall-flag) is supported by Node 9+.

Expand Down
2 changes: 1 addition & 1 deletion documentation/sections/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ codeFor('modules')

<div id="modules-note" class="bookmark"></div>

Note that the CoffeeScript compiler **does not resolve modules**; writing an `import` or `export` statement in CoffeeScript will produce an `import` or `export` statement in the resulting output. It is your responsibility to [transpile](#transpilation) this ES2015 syntax into code that will work in your target runtimes, unless you know that your code will be executed by a runtime that supports [ES modules](https://nodejs.org/api/esm.html). Node supports such modules only for files with `.mjs` extensions; you can generate such an extension via the `coffee` command for a single file via `--output`, as in `coffee --compile --output index.mjs index.coffee`. When compiling folders or globs, it is your responsibility to rename the generated `.js` files as needed.
Note that the CoffeeScript compiler **does not resolve modules**; writing an `import` or `export` statement in CoffeeScript will produce an `import` or `export` statement in the resulting output. It is your responsibility to [transpile](#transpilation) this ES2015 syntax into code that will work in your target runtimes.

Also note that any file with an `import` or `export` statement will be output without a [top-level function safety wrapper](#lexical-scope); in other words, importing or exporting modules will automatically trigger [bare](#usage) mode for that file. This is because per the ES2015 spec, `import` or `export` statements must occur at the topmost scope.

0 comments on commit 6df8f5f

Please sign in to comment.