diff --git a/docs/v2/index.html b/docs/v2/index.html index c9309c2113..ef8711c58b 100644 --- a/docs/v2/index.html +++ b/docs/v2/index.html @@ -893,8 +893,7 @@

What’s New In CoffeeScript 2?

Compatibility

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:

@@ -4406,7 +4405,7 @@

Modules

-

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 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. 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 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; in other words, importing or exporting modules will automatically trigger bare mode for that file. This is because per the ES2015 spec, import or export statements must occur at the topmost scope.

diff --git a/documentation/sections/compatibility.md b/documentation/sections/compatibility.md index bed7669f48..a66ae9dc2d 100644 --- a/documentation/sections/compatibility.md +++ b/documentation/sections/compatibility.md @@ -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+. diff --git a/documentation/sections/modules.md b/documentation/sections/modules.md index f938c85ad9..fc361f6054 100644 --- a/documentation/sections/modules.md +++ b/documentation/sections/modules.md @@ -8,6 +8,6 @@ codeFor('modules')
-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.