7 files changed
lines changed
| Original file line number | Diff line number | Diff line change |
|---|
@@ -452,6 +452,7 @@ runTests = (CoffeeScript) ->
|
452 | 452 | skipUnless 'async () => {}', ['async.coffee', 'async_iterators.coffee'] |
453 | 453 | skipUnless 'async function* generator() { yield 42; }', ['async_iterators.coffee'] |
454 | 454 | skipUnless 'var a = 2 ** 2; a **= 3', ['exponentiation.coffee'] |
| 455 | +skipUnless '/foo.bar/s.test("foo\tbar")', ['regex_dotall.coffee'] |
455 | 456 | files = fs.readdirSync('test').filter (filename) -> |
456 | 457 | filename not in testFilesToSkip |
457 | 458 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | ### Compatibility |
2 | 2 | |
3 | | -With the exception of [modules](#modules) (`import` and `export` statements) and [JSX](#jsx), all the 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. You can [run the tests in your browser](test.html) to see if your browser can do the same. For older browsers or older versions of Node, however, [transpilation](#transpilation) is required. |
| 3 | +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: |
4 | 4 | |
5 | | -Support for modern JavaScript syntax is important to ensure compatibility with frameworks that assume modern features. Now that CoffeeScript compiles classes to the `class` keyword, it’s possible to `extend` a JavaScript class; that wasn’t possible in CoffeeScript 1. Parity in how language features work is also important on its own; CoffeeScript “is just JavaScript,” and so things like [function parameter default values](#breaking-changes-default-values) should behave the same in CoffeeScript as in JavaScript. Some such features behave slightly differently in JavaScript than they did in CoffeeScript 1; in such cases we are conforming with the JavaScript spec, and we’ve documented the differences as [breaking changes](#breaking-changes). |
| 5 | +* [JSX](#jsx) always requires transpilation. |
| 6 | +* [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`. |
| 7 | +* [Splats, a.k.a. object rest/spread syntax, for objects](http://coffeescript.org/#splats) are supported by Node 8.6+. |
| 8 | +* The [regular expression `s` (dotall) flag](https://github.com/tc39/proposal-regexp-dotall-flag) is supported by Node 9+. |
| 9 | + |
| 10 | +This list may be incomplete, and excludes versions of Node that support newer features behind flags; please refer to [node.green](http://node.green/) for full details. You can [run the tests in your browser](test.html) to see what your browser supports. It is your responsibility to ensure that your runtime supports the modern features you use; or that you [transpile](#transpilation) your code. When in doubt, transpile. |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -8,6 +8,6 @@ codeFor('modules')
|
8 | 8 | |
9 | 9 | <div id="modules-note" class="bookmark"></div> |
10 | 10 | |
11 | | -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 attach another transpiler, such as [Traceur Compiler](https://github.com/google/traceur-compiler), [Babel](http://babeljs.io/) or [Rollup](https://github.com/rollup/rollup), to convert this ES2015 syntax into code that will work in your target runtimes. |
| 11 | +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. |
12 | 12 | |
13 | 13 | 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. |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1261,7 +1261,7 @@ REGEX = /// ^
|
1261 | 1261 | /// |
1262 | 1262 | |
1263 | 1263 | REGEX_FLAGS = /^\w*/ |
1264 | | -VALID_FLAGS = /^(?!.*(.).*\1)[imguy]*$/ |
| 1264 | +VALID_FLAGS = /^(?!.*(.).*\1)[gimsuy]*$/ |
1265 | 1265 | |
1266 | 1266 | HEREGEX = /// ^ |
1267 | 1267 | (?: |
|
File renamed without changes.
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +# Regex “dotall” flag, or `s`, is only supported in Node 9+, so put tests for |
| 2 | +# the feature in their own file. The feature detection in `Cakefile` that |
| 3 | +# causes this test to load is adapted from |
| 4 | +# https://github.com/tc39/proposal-regexp-dotall-flag#proposed-solution. |
| 5 | + |
| 6 | +test "dotall flag", -> |
| 7 | +doesNotThrow -> /a.b/s.test 'a\nb' |