Skip to content

Commit 0b0a9ef

Browse files
2.0.1 (#4719)
* 2.0.1 changelog * Version bump to 2.0.1
1 parent 9df1457 commit 0b0a9ef

25 files changed

+105
-80
lines changed

‎docs/v2/annotated-source/command.html

+36-55
Original file line numberDiff line numberDiff line change
@@ -862,19 +862,17 @@ <h1>command.coffee</h1>
862862
<a class="pilcrow" href="#section-26">&#182;</a>
863863
</div>
864864
<p>The user has requested that the CoffeeScript compiler also transpile
865-
via Babel. We use Babel as an <code>optionalDependency</code>; see
866-
<a href="https://docs.npmjs.com/files/package.json#optionaldependencies">https://docs.npmjs.com/files/package.json#optionaldependencies</a>.</p>
865+
via Babel. We don’t include Babel as a dependency because we want to
866+
avoid dependencies in general, and most users probably won’t be relying
867+
on us to transpile for them; we assume most users will probably either
868+
run CoffeeScript’s output without transpilation (modern Node or evergreen
869+
browsers) or use a proper build chain like Gulp or Webpack.</p>
867870

868871
</div>
869872

870873
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">try</span>
871874
<span class="hljs-built_in">require</span> <span class="hljs-string">'babel-core'</span>
872-
<span class="hljs-keyword">catch</span>
873-
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
874-
To use --transpile, you must have Babel installed and configured.
875-
See http://coffeescript.org/#transpilation
876-
'''</span>
877-
process.exit <span class="hljs-number">1</span></pre></div></div>
875+
<span class="hljs-keyword">catch</span></pre></div></div>
878876

879877
</li>
880878

@@ -885,14 +883,28 @@ <h1>command.coffee</h1>
885883
<div class="pilwrap ">
886884
<a class="pilcrow" href="#section-27">&#182;</a>
887885
</div>
888-
<p>We’re giving Babel only a string, not a filename or path to a file, so
889-
it doesn’t know where to search to find a <code>.babelrc</code> file or a <code>babel</code>
890-
key in a <code>package.json</code>. So if <code>opts.transpile</code> is an object, use that
891-
as Babel’s options; otherwise figure out what the options should be.</p>
886+
<p>Give appropriate instructions depending on whether <code>coffee</code> was run
887+
locally or globally.</p>
892888

893889
</div>
894890

895-
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> <span class="hljs-keyword">typeof</span> opts.transpile <span class="hljs-keyword">is</span> <span class="hljs-string">'object'</span></pre></div></div>
891+
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> <span class="hljs-built_in">require</span>.resolve(<span class="hljs-string">'.'</span>).indexOf(process.cwd()) <span class="hljs-keyword">is</span> <span class="hljs-number">0</span>
892+
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
893+
To use --transpile, you must have babel-core installed:
894+
npm install --save-dev babel-core
895+
And you must save options to configure Babel in one of the places it looks to find its options.
896+
See http://coffeescript.org/#transpilation
897+
'''</span>
898+
<span class="hljs-keyword">else</span>
899+
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
900+
To use --transpile with globally-installed CoffeeScript, you must have babel-core installed globally:
901+
npm install --global babel-core
902+
And you must save options to configure Babel in one of the places it looks to find its options, relative to the file being compiled or to the current folder.
903+
See http://coffeescript.org/#transpilation
904+
'''</span>
905+
process.exit <span class="hljs-number">1</span>
906+
907+
opts.transpile = {} <span class="hljs-keyword">unless</span> <span class="hljs-keyword">typeof</span> opts.transpile <span class="hljs-keyword">is</span> <span class="hljs-string">'object'</span></pre></div></div>
896908

897909
</li>
898910

@@ -903,46 +915,14 @@ <h1>command.coffee</h1>
903915
<div class="pilwrap ">
904916
<a class="pilcrow" href="#section-28">&#182;</a>
905917
</div>
906-
<p>Find the options based on the path to the file being compiled.</p>
918+
<p>Pass a reference to Babel into the compiler, so that the transpile option
919+
is available for the CLI. We need to do this so that tools like Webpack
920+
can <code>require(&#39;coffeescript&#39;)</code> and build correctly, without trying to
921+
require Babel.</p>
907922

908923
</div>
909924

910-
<div class="content"><div class='highlight'><pre><span class="hljs-function"> <span class="hljs-title">cantFindOptions</span> = -&gt;</span>
911-
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
912-
To use the transpile option, there must be a .babelrc file
913-
(or a package.json file with a "babel" key) in the path of the file
914-
to be compiled, or in the path of the current working directory.
915-
If you are compiling a string via the Node API, the transpile option
916-
must be an object with the options to pass to Babel.
917-
See http://coffeescript.org/#transpilation
918-
'''</span>
919-
process.exit <span class="hljs-number">1</span>
920-
921-
checkPath = <span class="hljs-keyword">if</span> filename
922-
path.dirname filename
923-
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> base
924-
base
925-
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> process?
926-
process.cwd()
927-
<span class="hljs-keyword">else</span>
928-
cantFindOptions()
929-
930-
<span class="hljs-keyword">loop</span>
931-
<span class="hljs-keyword">try</span>
932-
opts.transpile = JSON.parse fs.readFileSync path.join(checkPath, <span class="hljs-string">'.babelrc'</span>), <span class="hljs-string">'utf-8'</span>
933-
<span class="hljs-keyword">break</span>
934-
<span class="hljs-keyword">catch</span>
935-
<span class="hljs-keyword">try</span>
936-
packageJson = JSON.parse fs.readFileSync(path.join(checkPath, <span class="hljs-string">'package.json'</span>), <span class="hljs-string">'utf-8'</span>)
937-
<span class="hljs-keyword">if</span> packageJson.babel?
938-
opts.transpile = packageJson.babel
939-
<span class="hljs-keyword">break</span>
940-
941-
<span class="hljs-keyword">if</span> checkPath <span class="hljs-keyword">is</span> path.dirname checkPath <span class="hljs-comment"># We’ve reached the root.</span>
942-
cantFindOptions()
943-
<span class="hljs-keyword">break</span>
944-
<span class="hljs-keyword">else</span>
945-
checkPath = path.dirname checkPath</pre></div></div>
925+
<div class="content"><div class='highlight'><pre> opts.transpile.transpile = CoffeeScript.transpile</pre></div></div>
946926

947927
</li>
948928

@@ -953,14 +933,15 @@ <h1>command.coffee</h1>
953933
<div class="pilwrap ">
954934
<a class="pilcrow" href="#section-29">&#182;</a>
955935
</div>
956-
<p>Pass a reference to Babel into the compiler, so that the transpile option
957-
is available for the CLI. We need to do this so that tools like Webpack
958-
can <code>require(&#39;coffeescript&#39;)</code> and build correctly, without trying to
959-
require Babel.</p>
936+
<p>Babel searches for its options (a <code>.babelrc</code> file, a <code>.babelrc.js</code> file,
937+
a <code>package.json</code> file with a <code>babel</code> key, etc.) relative to the path
938+
given to it in its <code>filename</code> option. Make sure we have a path to pass
939+
along.</p>
960940

961941
</div>
962942

963-
<div class="content"><div class='highlight'><pre> opts.transpile.transpile = CoffeeScript.transpile
943+
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> opts.transpile.filename
944+
opts.transpile.filename = filename <span class="hljs-keyword">or</span> path.resolve(base <span class="hljs-keyword">or</span> process.cwd(), <span class="hljs-string">'&lt;anonymous&gt;'</span>)
964945
<span class="hljs-keyword">else</span>
965946
opts.transpile = <span class="hljs-literal">no</span>
966947

‎docs/v2/annotated-source/nodes.html

+15-3
Original file line numberDiff line numberDiff line change
@@ -3641,13 +3641,25 @@ <h3 id="class">Class</h3>
36413641
<a class="pilcrow" href="#section-148">&#182;</a>
36423642
</div>
36433643
<p>Add an expression to the class initializer</p>
3644-
<p>NOTE Currently, only methods and static methods are valid in ES class initializers.
3645-
When additional expressions become valid, this method should be updated to handle them.</p>
3644+
<p>This is the key method for determining whether an expression in a class
3645+
body should appear in the initializer or the executable body. If the given
3646+
<code>node</code> is valid in a class body the method will return a (new, modified,
3647+
or identical) node for inclusion in the class initializer, otherwise
3648+
nothing will be returned and the node will appear in the executable body.</p>
3649+
<p>At time of writing, only methods (instance and static) are valid in ES
3650+
class initializers. As new ES class features (such as class fields) reach
3651+
Stage 4, this method will need to be updated to support them. We
3652+
additionally allow <code>PassthroughLiteral</code>s (backticked expressions) in the
3653+
initializer as an escape hatch for ES features that are not implemented
3654+
(e.g. getters and setters defined via the <code>get</code> and <code>set</code> keywords as
3655+
opposed to the <code>Object.defineProperty</code> method).</p>
36463656

36473657
</div>
36483658

36493659
<div class="content"><div class='highlight'><pre> addInitializerExpression: <span class="hljs-function"><span class="hljs-params">(node)</span> -&gt;</span>
3650-
<span class="hljs-keyword">if</span> @validInitializerMethod node
3660+
<span class="hljs-keyword">if</span> node.unwrapAll() <span class="hljs-keyword">instanceof</span> PassthroughLiteral
3661+
node
3662+
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> @validInitializerMethod node
36513663
@addInitializerMethod node
36523664
<span class="hljs-keyword">else</span>
36533665
<span class="hljs-literal">null</span></pre></div></div>

‎docs/v2/annotated-source/public/fonts/roboto-black.eot

100755100644
File mode changed.

‎docs/v2/annotated-source/public/fonts/roboto-black.ttf

100755100644
File mode changed.

‎docs/v2/annotated-source/public/fonts/roboto-black.woff

100755100644
File mode changed.

‎docs/v2/browser-compiler/coffeescript.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/v2/index.html

+12-3
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@
645645
<section id="overview">
646646
<p><strong>CoffeeScript is a little language that compiles into JavaScript.</strong> Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.</p>
647647
<p>The golden rule of CoffeeScript is: <em>“It’s just JavaScript.”</em> The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa). The compiled output is readable, pretty-printed, and tends to run as fast or faster than the equivalent handwritten JavaScript.</p>
648-
<p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/2.0.0">2.0.0</a></p>
648+
<p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/2.0.1">2.0.1</a></p>
649649
<blockquote class="uneditable-code-block"><pre><code class="language-bash"><span class="comment"># Install locally for a project:</span>
650650
npm install --save-dev coffeescript
651651

@@ -4820,7 +4820,7 @@ <h2>Web Chat (IRC)</h2>
48204820
</section>
48214821
<section id="annotated-source">
48224822
<h2>Annotated Source</h2>
4823-
<p>You can browse the CoffeeScript 2.0.0 source in readable, annotated form <a href="annotated-source/">here</a>. You can also jump directly to a particular source file:</p>
4823+
<p>You can browse the CoffeeScript 2.0.1 source in readable, annotated form <a href="annotated-source/">here</a>. You can also jump directly to a particular source file:</p>
48244824
<ul>
48254825
<li><a href="annotated-source/grammar.html">Grammar Rules — src/grammar</a></li>
48264826
<li><a href="annotated-source/lexer.html">Lexing Tokens — src/lexer</a></li>
@@ -5448,10 +5448,19 @@ <h3>Argument parsing and shebang (<code>#!</code>) lines</h3>
54485448
</section>
54495449
<section id="changelog">
54505450
<h2>Changelog</h2>
5451+
<div class="anchor" id="2.0.1"></div>
5452+
<h2 class="header">
5453+
<a href="https://github.com/jashkenas/coffeescript/compare/2.0.0...2.0.1">2.0.1</a>
5454+
<span class="timestamp"> &mdash; <time datetime="2017-09-26">September 26, 2017</time></span>
5455+
</h2><ul>
5456+
<li><code>babel-core</code> is no longer listed in <code>package.json</code>, even as an <code>optionalDependency</code>, to avoid it being automatically installed for most users. If you wish to use <code>--transpile</code>, simply install <code>babel-core</code> manually. See <a href="#transpilation">Transpilation</a>.</li>
5457+
<li><code>--transpile</code> now relies on Babel to find its options, i.e. the <code>.babelrc</code> file in the path of the file(s) being compiled. (Previously the CoffeeScript compiler was duplicating this logic, so nothing has changed from a user’s perspective.) This provides automatic support for additional ways to pass options to Babel in future versions, such as the <code>.babelrc.js</code> file coming in Babel 7.</li>
5458+
<li>Backticked expressions in a class body, outside any class methods, are now output in the JavaScript class body itself. This allows for passing through experimental JavaScript syntax like the <a href="https://github.com/tc39/proposal-class-fields">class fields proposal</a>, assuming your <a href="https://babeljs.io/docs/plugins/transform-class-properties/">transpiler supports it</a>.</li>
5459+
</ul>
54515460
<div class="anchor" id="2.0.0"></div>
54525461
<h2 class="header">
54535462
<a href="https://github.com/jashkenas/coffeescript/compare/2.0.0-beta5...2.0.0">2.0.0</a>
5454-
<span class="timestamp"> &mdash; <time datetime="2017-09-17">September 17, 2017</time></span>
5463+
<span class="timestamp"> &mdash; <time datetime="2017-09-18">September 18, 2017</time></span>
54555464
</h2><ul>
54565465
<li>Added <code>--transpile</code> flag or <code>transpile</code> Node API option to tell the CoffeeScript compiler to pipe its output through Babel before saving or returning it; see <a href="#transpilation">Transpilation</a>. Also changed the <code>-t</code> short flag to refer to <code>--transpile</code> instead of <code>--tokens</code>.</li>
54575466
<li>Always populate source maps’ <code>sourcesContent</code> property.</li>

‎docs/v2/test.html

+15
Original file line numberDiff line numberDiff line change
@@ -3529,6 +3529,21 @@ <h1>CoffeeScript Test Suite</h1>
35293529
eq 2, b.s
35303530
eq 2, b.r
35313531

3532+
test "#4464: backticked expressions in class body", ->
3533+
class A
3534+
`get x() { return 42; }`
3535+
3536+
class B
3537+
`get x() { return 42; }`
3538+
constructor: ->
3539+
@y = 84
3540+
3541+
a = new A
3542+
eq 42, a.x
3543+
b = new B
3544+
eq 42, b.x
3545+
eq 84, b.y
3546+
35323547
</script>
35333548
<script type="text/x-coffeescript" class="test" id="cluster">
35343549
# Cluster Module

‎documentation/sections/changelog.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
## Changelog
22

33
```
4-
releaseHeader('2017-09-17', '2.0.0', '2.0.0-beta5')
4+
releaseHeader('2017-09-26', '2.0.1', '2.0.0')
5+
```
6+
7+
* `babel-core` is no longer listed in `package.json`, even as an `optionalDependency`, to avoid it being automatically installed for most users. If you wish to use `--transpile`, simply install `babel-core` manually. See [Transpilation](#transpilation).
8+
* `--transpile` now relies on Babel to find its options, i.e. the `.babelrc` file in the path of the file(s) being compiled. (Previously the CoffeeScript compiler was duplicating this logic, so nothing has changed from a user’s perspective.) This provides automatic support for additional ways to pass options to Babel in future versions, such as the `.babelrc.js` file coming in Babel 7.
9+
* Backticked expressions in a class body, outside any class methods, are now output in the JavaScript class body itself. This allows for passing through experimental JavaScript syntax like the [class fields proposal](https://github.com/tc39/proposal-class-fields), assuming your [transpiler supports it](https://babeljs.io/docs/plugins/transform-class-properties/).
10+
11+
```
12+
releaseHeader('2017-09-18', '2.0.0', '2.0.0-beta5')
513
```
614

715
* Added `--transpile` flag or `transpile` Node API option to tell the CoffeeScript compiler to pipe its output through Babel before saving or returning it; see [Transpilation](#transpilation). Also changed the `-t` short flag to refer to `--transpile` instead of `--tokens`.

‎lib/coffeescript/browser.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/coffeescript/cake.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/coffeescript/coffeescript.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/coffeescript/command.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/coffeescript/grammar.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/coffeescript/helpers.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/coffeescript/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/coffeescript/lexer.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/coffeescript/nodes.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/coffeescript/optparse.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/coffeescript/register.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/coffeescript/repl.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/coffeescript/rewriter.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/coffeescript/scope.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/coffeescript/sourcemap.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"compiler"
99
],
1010
"author": "Jeremy Ashkenas",
11-
"version": "2.0.0",
11+
"version": "2.0.1",
1212
"license": "MIT",
1313
"engines": {
1414
"node": ">=6"

0 commit comments

Comments
 (0)