mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-13 16:57:54 -05:00
Compare commits
200 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61d408f093 | ||
|
|
ba41b4417d | ||
|
|
33bbef963c | ||
|
|
c4f0c9ed06 | ||
|
|
8677a0dbc4 | ||
|
|
ee2a107f3c | ||
|
|
8fb5c1ba4f | ||
|
|
b2b2f97873 | ||
|
|
0045cb21ba | ||
|
|
a8273bf980 | ||
|
|
3e7c570679 | ||
|
|
a34c0c9502 | ||
|
|
2ab714b4fe | ||
|
|
56eec0bc4e | ||
|
|
f528e5e754 | ||
|
|
bdcb2c73af | ||
|
|
9b37f16f11 | ||
|
|
26351096a6 | ||
|
|
a091bb82f9 | ||
|
|
a6d4bf1982 | ||
|
|
0e51cdaccd | ||
|
|
d4b7bd3a1f | ||
|
|
559e735994 | ||
|
|
09caa217c2 | ||
|
|
a35df430db | ||
|
|
05d45e9b27 | ||
|
|
69521b97ce | ||
|
|
c7e538a624 | ||
|
|
44be72a4d9 | ||
|
|
9cfcf8623c | ||
|
|
25c23786af | ||
|
|
47bf5d962b | ||
|
|
a30e6807b1 | ||
|
|
d735c81da0 | ||
|
|
f56515b100 | ||
|
|
74d6635f95 | ||
|
|
e8d0deae78 | ||
|
|
95d6ec7492 | ||
|
|
09c95394e1 | ||
|
|
ddb5dac49d | ||
|
|
265b251a7d | ||
|
|
7539f7af2e | ||
|
|
2f27225e8c | ||
|
|
99ad0cc16c | ||
|
|
70c2c4706f | ||
|
|
9d1af43c91 | ||
|
|
c6fdde8834 | ||
|
|
0174ee082c | ||
|
|
82b7bd3a92 | ||
|
|
1f22c16bee | ||
|
|
f33d4dd4f1 | ||
|
|
9c913f86fa | ||
|
|
f0bb59790a | ||
|
|
391fcc4afa | ||
|
|
7b2fb18a0b | ||
|
|
5596a5c209 | ||
|
|
71750554c3 | ||
|
|
0574b664e8 | ||
|
|
ca0ac814b3 | ||
|
|
c0b3217766 | ||
|
|
12a5271489 | ||
|
|
f4fcf65750 | ||
|
|
92f69b2bca | ||
|
|
742224471f | ||
|
|
086430840e | ||
|
|
82f92fea97 | ||
|
|
d23919c430 | ||
|
|
ada35d8951 | ||
|
|
7e0eb6a92d | ||
|
|
28a1a1d304 | ||
|
|
0c2d3673d3 | ||
|
|
e6f6aa8c85 | ||
|
|
c09d8fbedb | ||
|
|
730a4bcdad | ||
|
|
7466c81414 | ||
|
|
b79ea321a3 | ||
|
|
ae2f72e15d | ||
|
|
f6d63776c3 | ||
|
|
b982b7cd0e | ||
|
|
0b5bac666f | ||
|
|
41b31c7293 | ||
|
|
eaeb77a527 | ||
|
|
ec034e2673 | ||
|
|
ff24e5ce52 | ||
|
|
4549f9a4c5 | ||
|
|
d0be6391c6 | ||
|
|
f70f4f09b7 | ||
|
|
3f5abb3c60 | ||
|
|
ca275c2a1c | ||
|
|
99b7826f1b | ||
|
|
806a442894 | ||
|
|
63ffe0aead | ||
|
|
74e0798f89 | ||
|
|
247b511c6a | ||
|
|
6a8e6a4078 | ||
|
|
42402da526 | ||
|
|
42622b15a9 | ||
|
|
1879af6585 | ||
|
|
a7b1fa51e7 | ||
|
|
38c8b2f35f | ||
|
|
4392d26985 | ||
|
|
2f82b75862 | ||
|
|
459814f58d | ||
|
|
088659f893 | ||
|
|
0e37130f2e | ||
|
|
fb539579c3 | ||
|
|
7c54532010 | ||
|
|
5d57ea785c | ||
|
|
94e29c9a95 | ||
|
|
fe7377aed5 | ||
|
|
e934a42e75 | ||
|
|
294bb4754e | ||
|
|
5eab5f1d22 | ||
|
|
8b775c95ad | ||
|
|
251700549a | ||
|
|
3fbf76e135 | ||
|
|
ca04dd6e47 | ||
|
|
a82f869453 | ||
|
|
f932206213 | ||
|
|
849dd53287 | ||
|
|
e03a87da04 | ||
|
|
29aa9b36fe | ||
|
|
c6472fa617 | ||
|
|
1bbbca6496 | ||
|
|
6b1e9bb82b | ||
|
|
eb22196850 | ||
|
|
3b1c49240b | ||
|
|
ea33c28f1b | ||
|
|
7b251f493d | ||
|
|
0be8c5d161 | ||
|
|
617a2d5b65 | ||
|
|
e1625a0d31 | ||
|
|
4c6cc8d060 | ||
|
|
e6153d9841 | ||
|
|
6e86b67818 | ||
|
|
b4dceaea67 | ||
|
|
d83b95bd39 | ||
|
|
4ba1be131c | ||
|
|
8dabec0f9b | ||
|
|
e679cbccf7 | ||
|
|
b18e91f936 | ||
|
|
c31a30d3fa | ||
|
|
99b2578aa7 | ||
|
|
ddfde6810c | ||
|
|
71350d67c4 | ||
|
|
13857a5d71 | ||
|
|
6225627579 | ||
|
|
c4245e50c2 | ||
|
|
6ce1d36acd | ||
|
|
b2669abecc | ||
|
|
db86dc4d8b | ||
|
|
98b2a69416 | ||
|
|
16b4448fe8 | ||
|
|
af82c1f41f | ||
|
|
3e089ca59d | ||
|
|
7f8b36a8bd | ||
|
|
812571843c | ||
|
|
8a25195442 | ||
|
|
70f6cb70e2 | ||
|
|
be702d67f3 | ||
|
|
68302e6da7 | ||
|
|
0e7677ad62 | ||
|
|
7cf739e2b6 | ||
|
|
41185ca7ac | ||
|
|
7dbdca8c54 | ||
|
|
8e66ae404e | ||
|
|
7beb631694 | ||
|
|
c2792e4840 | ||
|
|
d82272b6c2 | ||
|
|
fe7554828a | ||
|
|
708e57586c | ||
|
|
8061ecf0e2 | ||
|
|
6df8f5ff17 | ||
|
|
776e7e5328 | ||
|
|
871079b25c | ||
|
|
be2b24310f | ||
|
|
1f9cd4eaf7 | ||
|
|
47c491ffa1 | ||
|
|
195a46ab77 | ||
|
|
e5aa758dda | ||
|
|
001f97ac39 | ||
|
|
ce66a499de | ||
|
|
0268505119 | ||
|
|
5a43b2d7c5 | ||
|
|
820942c3d0 | ||
|
|
1869f3121d | ||
|
|
4c0363fb7c | ||
|
|
746b0c7cc6 | ||
|
|
b2fe7772c5 | ||
|
|
23479eb486 | ||
|
|
63b8543d73 | ||
|
|
7542a75ff8 | ||
|
|
0875039d52 | ||
|
|
e0833c29ce | ||
|
|
72ab6feb2f | ||
|
|
eb7009268d | ||
|
|
571e9df335 | ||
|
|
a73f66bc11 | ||
|
|
ba094126e2 | ||
|
|
794f65fbd7 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@ parser.output
|
||||
/node_modules
|
||||
npm-debug.log*
|
||||
yarn.lock
|
||||
.DS_Store
|
||||
|
||||
10
.travis.yml
10
.travis.yml
@@ -3,16 +3,20 @@ language: node_js
|
||||
node_js:
|
||||
- 6
|
||||
- 8
|
||||
- 10
|
||||
- 12
|
||||
- node # Latest
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
|
||||
script:
|
||||
- node ./bin/cake test
|
||||
- node --harmony ./bin/cake test
|
||||
- node ./bin/cake test:browser
|
||||
- node ./bin/cake test:integrations
|
||||
- node ./bin/cake build:except-parser
|
||||
- node ./bin/cake build:parser
|
||||
- node ./bin/cake build:full
|
||||
- node ./bin/cake build:browser
|
||||
- node ./bin/cake test
|
||||
- node ./bin/cake test:browser
|
||||
- node ./bin/cake test:integrations
|
||||
|
||||
46
CODE_OF_CONDUCT.md
Normal file
46
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at maintainers@coffeescript.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
@@ -6,4 +6,9 @@
|
||||
|
||||
* Use the same coding style as the rest of the [codebase](https://github.com/jashkenas/coffeescript/tree/master/src). If you’re just getting started with CoffeeScript, there’s a nice [style guide](https://github.com/polarmobile/coffeescript-style-guide).
|
||||
|
||||
* In your pull request, do not add documentation to `index.html` or re-build the minified `coffeescript.js` file. We’ll do those things before cutting a new release. You _should,_ however, commit the updated compiled JavaScript files in `lib`.
|
||||
* In your pull request, do not add documentation to `index.html` or re-build the minified `coffeescript.js` file. We’ll do those things before cutting a new release. You _should,_ however, commit the updated compiled JavaScript files in `lib`.
|
||||
|
||||
* To get started, read the guides in the wiki:
|
||||
* [Hacking on the CoffeeScript Compiler](https://github.com/jashkenas/coffeescript/wiki/%5BHowTo%5D-Hacking-on-the-CoffeeScript-Compiler)
|
||||
* [How parsing works](https://github.com/jashkenas/coffeescript/wiki/%5BHowTo%5D-How-parsing-works)
|
||||
* [Update the docs](https://github.com/jashkenas/coffeescript/wiki/%5BHowTo%5D-Update-the-docs)
|
||||
|
||||
121
Cakefile
121
Cakefile
@@ -19,9 +19,9 @@ unless process.env.NODE_DISABLE_COLORS
|
||||
header = """
|
||||
/**
|
||||
* CoffeeScript Compiler v#{CoffeeScript.VERSION}
|
||||
* http://coffeescript.org
|
||||
* https://coffeescript.org
|
||||
*
|
||||
* Copyright 2011, Jeremy Ashkenas
|
||||
* Copyright 2011-#{new Date().getFullYear()}, Jeremy Ashkenas
|
||||
* Released under the MIT License
|
||||
*/
|
||||
"""
|
||||
@@ -66,18 +66,23 @@ build = (callback) ->
|
||||
buildParser()
|
||||
buildExceptParser callback
|
||||
|
||||
transpile = (code) ->
|
||||
babel = require 'babel-core'
|
||||
transpile = (code, options = {}) ->
|
||||
options.minify = process.env.MINIFY isnt 'false'
|
||||
options.transform = process.env.TRANSFORM isnt 'false'
|
||||
options.sourceType ?= 'script'
|
||||
babel = require '@babel/core'
|
||||
presets = []
|
||||
# Exclude the `modules` plugin in order to not break the `}(this));`
|
||||
# at the end of the `build:browser` code block.
|
||||
presets.push ['env', {modules: no}] unless process.env.TRANSFORM is 'false'
|
||||
presets.push 'minify' unless process.env.MINIFY is 'false'
|
||||
presets.push ['@babel/env', {modules: no}] if options.transform
|
||||
presets.push ['minify', {mangle: no, evaluate: no, removeUndefined: no}] if options.minify
|
||||
babelOptions =
|
||||
compact: process.env.MINIFY isnt 'false'
|
||||
presets: presets
|
||||
sourceType: 'script'
|
||||
{ code } = babel.transform code, babelOptions unless presets.length is 0
|
||||
compact: options.minify
|
||||
minified: options.minify
|
||||
comments: not options.minify
|
||||
sourceType: options.sourceType
|
||||
{ code } = babel.transformSync code, babelOptions unless presets.length is 0
|
||||
code
|
||||
|
||||
testBuiltCode = (watch = no) ->
|
||||
@@ -140,13 +145,18 @@ task 'build:browser', 'merge the built scripts into a single file for use in a b
|
||||
return module.exports;
|
||||
})();
|
||||
"""
|
||||
# From here, we generate two outputs: a legacy script output for all browsers
|
||||
# and a module output for browsers that support `<script type="module">`.
|
||||
code = """
|
||||
var CoffeeScript = function() {
|
||||
function require(path){ return require[path]; }
|
||||
#{code}
|
||||
return require['./browser'];
|
||||
}();
|
||||
"""
|
||||
scriptCode = transpile """
|
||||
(function(root) {
|
||||
var CoffeeScript = function() {
|
||||
function require(path){ return require[path]; }
|
||||
#{code}
|
||||
return require['./browser'];
|
||||
}();
|
||||
#{code}
|
||||
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(function() { return CoffeeScript; });
|
||||
@@ -155,10 +165,25 @@ task 'build:browser', 'merge the built scripts into a single file for use in a b
|
||||
}
|
||||
}(this));
|
||||
"""
|
||||
code = transpile code
|
||||
outputFolder = "docs/v#{majorVersion}/browser-compiler"
|
||||
fs.mkdirSync outputFolder unless fs.existsSync outputFolder
|
||||
fs.writeFileSync "#{outputFolder}/coffeescript.js", header + '\n' + code
|
||||
moduleCode = transpile """
|
||||
#{code}
|
||||
|
||||
export default CoffeeScript;
|
||||
const { VERSION, compile, eval: evaluate, load, run, runScripts } = CoffeeScript;
|
||||
export { VERSION, compile, evaluate as eval, load, run, runScripts };
|
||||
""", {sourceType: 'module'}
|
||||
outputFolders = [
|
||||
"docs/v#{majorVersion}/browser-compiler-legacy"
|
||||
"docs/v#{majorVersion}/browser-compiler-modern"
|
||||
"lib/coffeescript-browser-compiler-legacy"
|
||||
"lib/coffeescript-browser-compiler-modern"
|
||||
]
|
||||
for outputFolder in outputFolders
|
||||
fs.mkdirSync outputFolder unless fs.existsSync outputFolder
|
||||
fs.writeFileSync "#{outputFolder}/coffeescript.js", """
|
||||
#{header}
|
||||
#{if outputFolder.includes('legacy') then scriptCode else moduleCode}
|
||||
"""
|
||||
|
||||
task 'build:browser:full', 'merge the built scripts into a single file for use in a browser, and test it', ->
|
||||
invoke 'build:browser'
|
||||
@@ -174,26 +199,19 @@ task 'build:watch:harmony', 'watch and continually rebuild the CoffeeScript comp
|
||||
|
||||
buildDocs = (watch = no) ->
|
||||
# Constants
|
||||
indexFile = 'documentation/site/index.html'
|
||||
siteSourceFolder = "documentation/site"
|
||||
sectionsSourceFolder = 'documentation/sections'
|
||||
examplesSourceFolder = 'documentation/examples'
|
||||
outputFolder = "docs/v#{majorVersion}"
|
||||
indexFile = 'documentation/site/index.html'
|
||||
siteSourceFolder = "documentation/site"
|
||||
sectionsSourceFolder = 'documentation/sections'
|
||||
changelogSourceFolder = 'documentation/sections/changelog'
|
||||
examplesSourceFolder = 'documentation/examples'
|
||||
outputFolder = "docs/v#{majorVersion}"
|
||||
|
||||
# Helpers
|
||||
releaseHeader = (date, version, prevVersion) ->
|
||||
monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
|
||||
|
||||
formatDate = (date) ->
|
||||
date.replace /^(\d\d\d\d)-(\d\d)-(\d\d)$/, (match, $1, $2, $3) ->
|
||||
"#{monthNames[$2 - 1]} #{+$3}, #{$1}"
|
||||
|
||||
"""
|
||||
<div class="anchor" id="#{version}"></div>
|
||||
<h2 class="header">
|
||||
#{prevVersion and "<a href=\"https://github.com/jashkenas/coffeescript/compare/#{prevVersion}...#{version}\">#{version}</a>" or version}
|
||||
<span class="timestamp"> — <time datetime="#{date}">#{formatDate date}</time></span>
|
||||
</h2>
|
||||
<h3>#{prevVersion and "<a href=\"https://github.com/jashkenas/coffeescript/compare/#{prevVersion}...#{version}\">#{version}</a>" or version}
|
||||
<span class="timestamp"> — <time datetime="#{date}">#{date}</time></span>
|
||||
</h3>
|
||||
"""
|
||||
|
||||
codeFor = require "./documentation/site/code.coffee"
|
||||
@@ -224,7 +242,7 @@ buildDocs = (watch = no) ->
|
||||
"<blockquote class=\"uneditable-code-block\">#{defaultFence.apply @, arguments}</blockquote>"
|
||||
|
||||
(file, bookmark) ->
|
||||
md = fs.readFileSync "#{sectionsSourceFolder}/#{file}.md", 'utf-8'
|
||||
md = fs.readFileSync "#{sectionsSourceFolder}/#{file.replace /\//g, path.sep}.md", 'utf-8'
|
||||
md = md.replace /<%= releaseHeader %>/g, releaseHeader
|
||||
md = md.replace /<%= majorVersion %>/g, majorVersion
|
||||
md = md.replace /<%= fullVersion %>/g, CoffeeScript.VERSION
|
||||
@@ -269,7 +287,7 @@ buildDocs = (watch = no) ->
|
||||
catch exception
|
||||
|
||||
if watch
|
||||
for target in [indexFile, siteSourceFolder, examplesSourceFolder, sectionsSourceFolder]
|
||||
for target in [indexFile, siteSourceFolder, examplesSourceFolder, sectionsSourceFolder, changelogSourceFolder]
|
||||
fs.watch target, interval: 200, renderIndex
|
||||
log 'watching...', green
|
||||
|
||||
@@ -425,12 +443,6 @@ runTests = (CoffeeScript) ->
|
||||
catch err
|
||||
onFail description, fn, err
|
||||
|
||||
global.supportsAsync = try
|
||||
new Function('async () => {}')()
|
||||
yes
|
||||
catch
|
||||
no
|
||||
|
||||
helpers.extend global, require './test/support/helpers'
|
||||
|
||||
# When all the tests have run, collect and print errors.
|
||||
@@ -448,10 +460,22 @@ runTests = (CoffeeScript) ->
|
||||
console.log " #{source}" if source
|
||||
return
|
||||
|
||||
# Run every test in the `test` folder, recording failures.
|
||||
files = fs.readdirSync 'test'
|
||||
unless global.supportsAsync # Except for async tests, if async isn’t supported.
|
||||
files = files.filter (filename) -> filename isnt 'async.coffee'
|
||||
# Run every test in the `test` folder, recording failures, except for files
|
||||
# we’re skipping because the features to be tested are unsupported in the
|
||||
# current Node runtime.
|
||||
testFilesToSkip = []
|
||||
skipUnless = (featureDetect, filenames) ->
|
||||
unless (try new Function featureDetect)
|
||||
testFilesToSkip = testFilesToSkip.concat filenames
|
||||
skipUnless 'async () => {}', ['async.coffee', 'async_iterators.coffee']
|
||||
skipUnless 'async function* generator() { yield 42; }', ['async_iterators.coffee']
|
||||
skipUnless 'var a = 2 ** 2; a **= 3', ['exponentiation.coffee']
|
||||
skipUnless 'var {...a} = {}', ['object_rest_spread.coffee']
|
||||
skipUnless '/foo.bar/s.test("foo\tbar")', ['regex_dotall.coffee']
|
||||
skipUnless '1_2_3', ['numeric_literal_separators.coffee']
|
||||
skipUnless '1n', ['numbers_bigint.coffee']
|
||||
files = fs.readdirSync('test').filter (filename) ->
|
||||
filename not in testFilesToSkip
|
||||
|
||||
startTime = Date.now()
|
||||
for file in files when helpers.isCoffee file
|
||||
@@ -472,7 +496,7 @@ task 'test', 'run the CoffeeScript language test suite', ->
|
||||
|
||||
|
||||
task 'test:browser', 'run the test suite against the merged browser script', ->
|
||||
source = fs.readFileSync "docs/v#{majorVersion}/browser-compiler/coffeescript.js", 'utf-8'
|
||||
source = fs.readFileSync "lib/coffeescript-browser-compiler-legacy/coffeescript.js", 'utf-8'
|
||||
result = {}
|
||||
global.testingBrowser = yes
|
||||
(-> eval source).call result
|
||||
@@ -490,6 +514,9 @@ task 'test:integrations', 'test the module integrated with other libraries and e
|
||||
webpack = require 'webpack'
|
||||
webpack {
|
||||
entry: './'
|
||||
optimization:
|
||||
# Webpack’s minification causes the CoffeeScript module to fail some tests.
|
||||
minimize: off
|
||||
output:
|
||||
path: tmpdir
|
||||
filename: 'coffeescript.js'
|
||||
|
||||
62
ISSUE_TEMPLATE.md
Normal file
62
ISSUE_TEMPLATE.md
Normal file
@@ -0,0 +1,62 @@
|
||||
<!---
|
||||
Thanks for filing an issue 😄! Before you submit, please read the following:
|
||||
|
||||
Search open/closed issues before submitting since someone might have asked the same thing before!
|
||||
Our issues history stretches back to 2009, so the odds are good that your topic has come up.
|
||||
|
||||
If you have a support request or question please use Stack Overflow:
|
||||
https://stackoverflow.com/questions/tagged/coffeescript
|
||||
|
||||
Issues on GitHub are only related to problems of the CoffeeScript compiler itself and we cannot answer
|
||||
support questions here.
|
||||
-->
|
||||
|
||||
Choose one: is this a bug report or feature request?
|
||||
|
||||
<!---
|
||||
Provide a general summary of the issue in the title above.
|
||||
|
||||
For bugs, please also preface your title with “Bug:”. For feature requests, please preface your title
|
||||
with “Proposal:”. Once your issue is reviewed, a maintainer will edit the title to refer to the part
|
||||
of the codebase most relevant to the issue (if applicable).
|
||||
|
||||
If your request is that CoffeeScript support a new feature recently arrived to JavaScript, please note
|
||||
that we generally only add features that have reached Stage 4 in the specification (in other words,
|
||||
the syntax is finalized and the feature is approved to be part of the next ES release). You can still
|
||||
open an issue, but it will likely be tagged with “[Awaiting Stage 4]” until the relevant ES feature is
|
||||
approved for release. See https://coffeescript.org/#contributing
|
||||
|
||||
There are also a handful of JavaScript features that CoffeeScript intentionally does not support.
|
||||
Please do not open issues regarding these. They’re listed in https://coffeescript.org/#unsupported
|
||||
-->
|
||||
|
||||
### Input Code
|
||||
<!--- If you're describing a bug, please let us know which sample code reproduces your problem. -->
|
||||
<!--- If you have link from https://coffeescript.org/#try or a standalone repo please include that! -->
|
||||
|
||||
```coffee
|
||||
your (code) => here
|
||||
```
|
||||
|
||||
### Expected Behavior
|
||||
<!--- If you’re describing a bug, tell us what should happen. -->
|
||||
<!--- If you’re suggesting a change/improvement, tell us how it should work. -->
|
||||
|
||||
### Current Behavior
|
||||
<!--- If describing a bug, tell us what happens instead of the expected behavior. -->
|
||||
<!--- If suggesting a change/improvement, explain the difference from current behavior. -->
|
||||
|
||||
### Possible Solution
|
||||
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
|
||||
<!--- or ideas how to implement the addition or change. -->
|
||||
|
||||
### Context
|
||||
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
||||
<!--- Providing context helps us come up with a solution that is most useful in the real world. -->
|
||||
|
||||
### Environment
|
||||
<!--- For bugs, please let us know what version of CoffeeScript you’re running: `coffee -v`. -->
|
||||
<!--- If you think it might be relevant, please also let us know your version of Node. -->
|
||||
|
||||
* CoffeeScript version:
|
||||
* Node.js version:
|
||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2009-2017 Jeremy Ashkenas
|
||||
Copyright (c) 2009-2018 Jeremy Ashkenas
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
|
||||
22
PULL_REQUEST_TEMPLATE.md
Normal file
22
PULL_REQUEST_TEMPLATE.md
Normal file
@@ -0,0 +1,22 @@
|
||||
<!--
|
||||
Before making a PR please make sure to read our contributing guidelines:
|
||||
https://coffeescript.org/#contributing
|
||||
|
||||
For issue references: Add a comma-separated list of a
|
||||
[closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by
|
||||
the ticket number fixed by the PR. It should be underlined in the preview if done correctly.
|
||||
|
||||
All new features require tests. All but the most trivial bug fixes should also have new or updated tests.
|
||||
|
||||
Ensure that all new code you add to the compiler can be run in the minimum version of Node listed in
|
||||
`package.json`. New tests can require newer Node runtimes, but you may need to ensure that such tests
|
||||
only run in supported runtimes; see `Cakefile` for examples of how to filter out certain tests in
|
||||
runtimes that don’t support them.
|
||||
|
||||
Please follow the code style of the rest of the CoffeeScript codebase. Write comments in complete
|
||||
sentences using Markdown, as the comments become the [annotated source](https://coffeescript.org/#annotated-source).
|
||||
For tests proving a bug is fixed, please mention the issue number in the test description (see examples
|
||||
in the codebase).
|
||||
|
||||
Describe your changes below in as much detail as possible.
|
||||
-->
|
||||
60
README.md
60
README.md
@@ -1,27 +1,29 @@
|
||||
@@@@@@@ @@@@ @@@@@
|
||||
{ @@@@@@@@@@ @@@ @@@
|
||||
} } { @@@@ @@ @@@ @@@
|
||||
{ { } } @@@@ @@@@@@@ @@@ @@@ @@@@@@ @@@@@@
|
||||
} }{ { @@@@ @@@ @@ @@@@@ @@@@@@ @@@ @@ @@@@ @@
|
||||
{ }{ } } @@@@ @@@@ @@ @@@ @@@ @@@ @@@ @@@ @@@
|
||||
{ }{ }{ { } @@@@ @@@@ @@ @@@ @@@ @@@@@@@@ @@@@@@@@
|
||||
{ { } { } { } } @@@@@ @@@@ @@ @@@ @@@ @@@ @@@
|
||||
{ } { } { } @@@@@@@@@@ @@@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@@
|
||||
@@@@@@ { } { } @@@@@@@ @@@@@ @@@ @@@ @@@@@ @@@@@
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@ @@@
|
||||
@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@ @@@ @@@
|
||||
@@ @@@@@@@@@@@@@@@@@@@@@@@@ @@@@ @@ @@@ @@@@
|
||||
@@@ @@@@@@@@@@@@@@@@@@@@@ @@@@ @@@ @@ @@@@
|
||||
@@@ @@@@@@@@@@@@@@@@@@ @@@@@ @@@@@ @@ @@ @@@ @@@@@@@ @@@@@
|
||||
@@@ @@@@@@@@@@@@@@@@ @@@@@ @@@ @@@ @@@@@@@@ @@@@ @@@@ @@@@@@@
|
||||
@@@@@@@@@@@@@@ @@@@@ @@@ @@@@ @@@@ @@@ @@@ @@@
|
||||
@@@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@
|
||||
@@@ @@@@ @@@ @@@@ @@@@ @@@ @@@@ @@@@
|
||||
@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@
|
||||
@@@@@@@@@ @@@@@@ @@@@ @@@@ @@@@@@@@@ @@@@
|
||||
@@@ @@@@
|
||||
@@@
|
||||
@@@
|
||||
```
|
||||
@@@@@@@ @@@@ @@@@@
|
||||
@@@@@@@@@@ @@@ @@@ {
|
||||
@@@@ @@ @@@ @@@ } } {
|
||||
@@@@ @@@@@@@ @@@ @@@ @@@@@@ @@@@@@ { { } }
|
||||
@@@@ @@@ @@ @@@@@ @@@@@@ @@@ @@ @@@@ @@ } }{ {
|
||||
@@@@ @@@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ { }{ } }
|
||||
@@@@ @@@@ @@ @@@ @@@ @@@@@@@@ @@@@@@@@ { }{ }{ { }
|
||||
@@@@@ @@@@ @@ @@@ @@@ @@@ @@@ { { } { } { } }
|
||||
@@@@@@@@@@ @@@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@@ { } { } { }
|
||||
@@@@@ @@@ @@@ @@@@@ @@@@@ @@@@@@ { } { } @@@@@@@
|
||||
@@@ @@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
@@@@@@ @@@ @@@ @@ @@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
@@@@ @@ @@@ @@@@ @@ @@@@@@@@@@@@@@@@@@@@@@@@
|
||||
@@@@ @@@ @@ @@@@ @@@ @@@@@@@@@@@@@@@@@@@@@
|
||||
@@@@@ @@@@@ @@ @@ @@@ @@@@@@@ @@@@@ @@@ @@@@@@@@@@@@@@@@@@
|
||||
@@@@@ @@@ @@@ @@@@@@@@ @@@@ @@@@ @@@@@@@ @@@ @@@@@@@@@@@@@@@@
|
||||
@@@@@ @@@ @@@@ @@@@ @@@ @@@ @@@ @@@@@@@@@@@@@@
|
||||
@@@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@
|
||||
@@@ @@@@ @@@ @@@@ @@@@ @@@ @@@@ @@@@
|
||||
@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@
|
||||
@@@@@@@@@ @@@@@@ @@@@ @@@@ @@@@@@@@@ @@@@
|
||||
@@@ @@@@
|
||||
@@@
|
||||
@@@
|
||||
```
|
||||
|
||||
CoffeeScript is a little language that compiles into JavaScript.
|
||||
|
||||
@@ -30,11 +32,13 @@ CoffeeScript is a little language that compiles into JavaScript.
|
||||
Once you have Node.js installed:
|
||||
|
||||
```shell
|
||||
# Install locally for a project:
|
||||
npm install --save-dev coffeescript
|
||||
|
||||
# Install globally to execute .coffee files anywhere:
|
||||
npm install --global coffeescript
|
||||
```
|
||||
|
||||
Leave off the `--global` if you don’t wish to install globally.
|
||||
|
||||
## Getting Started
|
||||
|
||||
Execute a script:
|
||||
@@ -49,7 +53,7 @@ Compile a script:
|
||||
coffee -c /path/to/script.coffee
|
||||
```
|
||||
|
||||
For documentation, usage, and examples, see: http://coffeescript.org/
|
||||
For documentation, usage, and examples, see: https://coffeescript.org/
|
||||
|
||||
To suggest a feature or report a bug: https://github.com/jashkenas/coffeescript/issues
|
||||
|
||||
@@ -57,6 +61,6 @@ If you’d like to chat, drop by #coffeescript on Freenode IRC.
|
||||
|
||||
The source repository: https://github.com/jashkenas/coffeescript.git
|
||||
|
||||
Changelog: http://coffeescript.org/#changelog
|
||||
Changelog: https://coffeescript.org/#changelog
|
||||
|
||||
Our lovely and talented contributors are listed here: https://github.com/jashkenas/coffeescript/contributors
|
||||
|
||||
11
appveyor.yml
11
appveyor.yml
@@ -2,7 +2,9 @@ environment:
|
||||
matrix:
|
||||
- nodejs_version: '6'
|
||||
- nodejs_version: '8'
|
||||
- nodejs_version: '' # Installs latest.
|
||||
- nodejs_version: '10'
|
||||
- nodejs_version: '12'
|
||||
- nodejs_version: '' # Latest
|
||||
|
||||
install:
|
||||
- ps: Install-Product node $env:nodejs_version
|
||||
@@ -14,13 +16,14 @@ cache:
|
||||
- node_modules
|
||||
|
||||
test_script:
|
||||
- node ./bin/cake test
|
||||
- node --harmony ./bin/cake test
|
||||
- node ./bin/cake test:browser
|
||||
- node ./bin/cake test:integrations
|
||||
- node ./bin/cake build:except-parser
|
||||
- node ./bin/cake build:parser
|
||||
- node ./bin/cake build:full
|
||||
- node ./bin/cake build:browser
|
||||
- node ./bin/cake test
|
||||
- node ./bin/cake test:browser
|
||||
- node ./bin/cake test:integrations
|
||||
|
||||
build: off
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
coffeescript.org
|
||||
coffeescript.org
|
||||
@@ -1 +1 @@
|
||||
v2/browser-compiler
|
||||
v2/browser-compiler-legacy
|
||||
1
docs/browser-compiler-legacy
Symbolic link
1
docs/browser-compiler-legacy
Symbolic link
@@ -0,0 +1 @@
|
||||
v2/browser-compiler-legacy
|
||||
1
docs/browser-compiler-modern
Symbolic link
1
docs/browser-compiler-modern
Symbolic link
@@ -0,0 +1 @@
|
||||
v2/browser-compiler-modern
|
||||
@@ -124,7 +124,7 @@ We add support for loading remote Coffee scripts via <strong>XHR</strong>, and
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffeescript'</span>
|
||||
compile = CoffeeScript.compile</pre></div></div>
|
||||
{ compile } = CoffeeScript</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -135,13 +135,17 @@ compile = CoffeeScript.compile</pre></div></div>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>Use standard JavaScript <code>eval</code> to eval code.</p>
|
||||
<p>Use <code>window.eval</code> to evaluate code, rather than just <code>eval</code>, to run the
|
||||
script in a clean global scope rather than inheriting the scope of the
|
||||
CoffeeScript compiler. (So that <code>cake test:browser</code> also works in Node,
|
||||
use either <code>window.eval</code> or <code>global.eval</code> as appropriate).</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.eval = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -></span>
|
||||
options.bare ?= <span class="hljs-literal">on</span>
|
||||
eval compile code, options</pre></div></div>
|
||||
globalRoot = <span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>? <span class="hljs-keyword">then</span> <span class="hljs-built_in">window</span> <span class="hljs-keyword">else</span> <span class="hljs-built_in">global</span>
|
||||
globalRoot[<span class="hljs-string">'eval'</span>] compile code, options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -258,7 +262,7 @@ This happens on page load.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">runScripts</span> = -></span>
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.runScripts = <span class="hljs-function">-></span>
|
||||
scripts = <span class="hljs-built_in">window</span>.<span class="hljs-built_in">document</span>.getElementsByTagName <span class="hljs-string">'script'</span>
|
||||
coffeetypes = [<span class="hljs-string">'text/coffeescript'</span>, <span class="hljs-string">'text/literate-coffeescript'</span>]
|
||||
coffees = (s <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> scripts <span class="hljs-keyword">when</span> s.type <span class="hljs-keyword">in</span> coffeetypes)
|
||||
@@ -317,14 +321,19 @@ only one CoffeeScript script block to parse.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Listen for window load, both in decent browsers and in IE.</p>
|
||||
<p>Listen for window load, both in decent browsers and in IE.
|
||||
Only attach this event handler on startup for the
|
||||
non-ES module version of the browser compiler, to preserve
|
||||
backward compatibility while letting the ES module version
|
||||
be importable without side effects.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>.addEventListener
|
||||
<span class="hljs-built_in">window</span>.addEventListener <span class="hljs-string">'DOMContentLoaded'</span>, runScripts, <span class="hljs-literal">no</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-built_in">window</span>.attachEvent <span class="hljs-string">'onload'</span>, runScripts</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-keyword">this</span> <span class="hljs-keyword">is</span> <span class="hljs-built_in">window</span>
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>.addEventListener
|
||||
<span class="hljs-built_in">window</span>.addEventListener <span class="hljs-string">'DOMContentLoaded'</span>, CoffeeScript.runScripts, <span class="hljs-literal">no</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-built_in">window</span>.attachEvent <span class="hljs-string">'onload'</span>, CoffeeScript.runScripts</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
@@ -282,6 +282,32 @@ it’s not likely to be used. Save in form of <code>filename</code>: [<code>(sou
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>This is exported to enable an external module to implement caching of
|
||||
compilation results. When the compiled js source is loaded from cache, the
|
||||
original coffee code should be added with this method in order to enable the
|
||||
Error.prepareStackTrace below to correctly adjust the stack trace for the
|
||||
corresponding file (the source map will be generated on demand).</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.registerCompiled = registerCompiled = <span class="hljs-function"><span class="hljs-params">(filename, source, sourcemap)</span> -></span>
|
||||
|
||||
sources[filename] ?= []
|
||||
sources[filename].push source
|
||||
|
||||
<span class="hljs-keyword">if</span> sourcemap?
|
||||
sourceMaps[filename] ?= []
|
||||
sourceMaps[filename].push sourcemap</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>Compile CoffeeScript code to JavaScript, using the Coffee/Jison compiler.</p>
|
||||
<p>If <code>options.sourceMap</code> is specified, then <code>options.filename</code> must also be
|
||||
specified. All options that can be passed to <code>SourceMap#generate</code> may also
|
||||
@@ -298,11 +324,11 @@ doing programmatic lookups.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>Clone <code>options</code>, to avoid mutating the <code>options</code> object passed in.</p>
|
||||
|
||||
@@ -313,11 +339,11 @@ doing programmatic lookups.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>Always generate a source map if no filename is passed in, since without a
|
||||
a filename we have no way to retrieve this source later in the event that
|
||||
@@ -330,8 +356,6 @@ we need to recompile it to get a source map for <code>prepareStackTrace</code>.<
|
||||
|
||||
checkShebangLine filename, code
|
||||
|
||||
sources[filename] ?= []
|
||||
sources[filename].push code
|
||||
map = <span class="hljs-keyword">new</span> SourceMap <span class="hljs-keyword">if</span> generateSourceMap
|
||||
|
||||
tokens = lexer.tokenize code, options</pre></div></div>
|
||||
@@ -339,11 +363,11 @@ we need to recompile it to get a source map for <code>prepareStackTrace</code>.<
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Pass a list of referenced variables, so that generated variables won’t get
|
||||
the same name.</p>
|
||||
@@ -357,11 +381,11 @@ the same name.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>Check for import or export; if found, force bare mode.</p>
|
||||
|
||||
@@ -373,7 +397,41 @@ the same name.</p>
|
||||
options.bare = <span class="hljs-literal">yes</span>
|
||||
<span class="hljs-keyword">break</span>
|
||||
|
||||
fragments = parser.parse(tokens).compileToFragments options
|
||||
nodes = parser.parse tokens</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>If all that was requested was a POJO representation of the nodes, e.g.
|
||||
the abstract syntax tree (AST), we can stop now and just return that
|
||||
(after fixing the location data for the root/<code>File</code>»<code>Program</code> node,
|
||||
which might’ve gotten misaligned from the original source due to the
|
||||
<code>clean</code> function in the lexer).</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> options.ast
|
||||
nodes.allCommentTokens = helpers.extractAllCommentTokens tokens
|
||||
sourceCodeNumberOfLines = (code.match(<span class="hljs-regexp">/\r?\n/g</span>) <span class="hljs-keyword">or</span> <span class="hljs-string">''</span>).length + <span class="hljs-number">1</span>
|
||||
sourceCodeLastLine = <span class="hljs-regexp">/.*$/</span>.exec(code)[<span class="hljs-number">0</span>] <span class="hljs-comment"># `.*` matches all but line break characters.</span>
|
||||
ast = nodes.ast options
|
||||
range = [<span class="hljs-number">0</span>, code.length]
|
||||
ast.start = ast.program.start = range[<span class="hljs-number">0</span>]
|
||||
ast.end = ast.program.end = range[<span class="hljs-number">1</span>]
|
||||
ast.range = ast.program.range = range
|
||||
ast.loc.start = ast.program.loc.start = {line: <span class="hljs-number">1</span>, column: <span class="hljs-number">0</span>}
|
||||
ast.loc.end.line = ast.program.loc.end.line = sourceCodeNumberOfLines
|
||||
ast.loc.end.column = ast.program.loc.end.column = sourceCodeLastLine.length
|
||||
ast.tokens = tokens
|
||||
<span class="hljs-keyword">return</span> ast
|
||||
|
||||
fragments = nodes.compileToFragments options
|
||||
|
||||
currentLine = <span class="hljs-number">0</span>
|
||||
currentLine += <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> options.header
|
||||
@@ -385,11 +443,11 @@ the same name.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<li id="section-17">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>Update the sourcemap with data from each fragment.</p>
|
||||
|
||||
@@ -400,11 +458,11 @@ the same name.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>Do not include empty, whitespace, or semicolon-only fragments.</p>
|
||||
|
||||
@@ -425,11 +483,11 @@ the same name.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-17">
|
||||
<li id="section-19">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>Copy the code from each fragment into the final JavaScript.</p>
|
||||
|
||||
@@ -443,8 +501,6 @@ the same name.</p>
|
||||
|
||||
<span class="hljs-keyword">if</span> generateSourceMap
|
||||
v3SourceMap = map.generate options, code
|
||||
sourceMaps[filename] ?= []
|
||||
sourceMaps[filename].push map
|
||||
|
||||
<span class="hljs-keyword">if</span> options.transpile
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> options.transpile <span class="hljs-keyword">isnt</span> <span class="hljs-string">'object'</span></pre></div></div>
|
||||
@@ -452,11 +508,11 @@ the same name.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<li id="section-20">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<p>This only happens if run via the Node API and <code>transpile</code> is set to
|
||||
something other than an object.</p>
|
||||
@@ -468,11 +524,11 @@ something other than an object.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<li id="section-21">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
</div>
|
||||
<p>Get the reference to Babel that we have been passed if this compiler
|
||||
is run via the CLI or Node API.</p>
|
||||
@@ -487,11 +543,11 @@ is run via the CLI or Node API.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>See <a href="https://github.com/babel/babel/issues/827#issuecomment-77573107">https://github.com/babel/babel/issues/827#issuecomment-77573107</a>:
|
||||
Babel can take a v3 source map object as input in <code>inputSourceMap</code>
|
||||
@@ -512,6 +568,8 @@ and it will return an <em>updated</em> v3 source map object in its output.</p>
|
||||
sourceURL = <span class="hljs-string">"//# sourceURL=<span class="hljs-subst">#{options.filename ? <span class="hljs-string">'coffeescript'</span>}</span>"</span>
|
||||
js = <span class="hljs-string">"<span class="hljs-subst">#{js}</span>\n<span class="hljs-subst">#{sourceMapDataURI}</span>\n<span class="hljs-subst">#{sourceURL}</span>"</span>
|
||||
|
||||
registerCompiled filename, code, map
|
||||
|
||||
<span class="hljs-keyword">if</span> options.sourceMap
|
||||
{
|
||||
js
|
||||
@@ -524,11 +582,11 @@ and it will return an <em>updated</em> v3 source map object in its output.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-21">
|
||||
<li id="section-23">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
</div>
|
||||
<p>Tokenize a string of CoffeeScript code, and return the array of tokens.</p>
|
||||
|
||||
@@ -540,11 +598,11 @@ and it will return an <em>updated</em> v3 source map object in its output.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>Parse a string of CoffeeScript code or an array of lexed tokens, and
|
||||
return the AST. You can then compile it by calling <code>.compile()</code> on the root,
|
||||
@@ -553,19 +611,17 @@ or traverse it by using <code>.traverseChildren()</code> with a callback.</p>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.nodes = withPrettyErrors (source, options) ->
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> source <span class="hljs-keyword">is</span> <span class="hljs-string">'string'</span>
|
||||
parser.parse lexer.tokenize source, options
|
||||
<span class="hljs-keyword">else</span>
|
||||
parser.parse source</pre></div></div>
|
||||
source = lexer.tokenize source, options <span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> source <span class="hljs-keyword">is</span> <span class="hljs-string">'string'</span>
|
||||
parser.parse source</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<li id="section-25">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
</div>
|
||||
<p>This file used to export these methods; leave stubs that throw warnings
|
||||
instead. These methods have been moved into <code>index.coffee</code> to provide
|
||||
@@ -581,11 +637,11 @@ environment.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-24">
|
||||
<li id="section-26">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
</div>
|
||||
<p>Instantiate a Lexer for our use here.</p>
|
||||
|
||||
@@ -596,19 +652,23 @@ environment.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-25">
|
||||
<li id="section-27">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
</div>
|
||||
<p>The real Lexer produces a generic stream of tokens. This object provides a
|
||||
thin wrapper around it, compatible with the Jison API. We can then pass it
|
||||
directly as a “Jison lexer”.</p>
|
||||
directly as a “Jison lexer.”</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>parser.lexer =
|
||||
yylloc:
|
||||
range: []
|
||||
options:
|
||||
ranges: <span class="hljs-literal">yes</span>
|
||||
lex: <span class="hljs-function">-></span>
|
||||
token = parser.tokens[@pos++]
|
||||
<span class="hljs-keyword">if</span> token
|
||||
@@ -626,11 +686,11 @@ directly as a “Jison lexer”.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-26">
|
||||
<li id="section-28">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
<a class="pilcrow" href="#section-28">¶</a>
|
||||
</div>
|
||||
<p>Make all the AST nodes visible to the parser.</p>
|
||||
|
||||
@@ -641,11 +701,11 @@ directly as a “Jison lexer”.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-27">
|
||||
<li id="section-29">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
<a class="pilcrow" href="#section-29">¶</a>
|
||||
</div>
|
||||
<p>Override Jison’s default error handling function.</p>
|
||||
|
||||
@@ -656,11 +716,11 @@ directly as a “Jison lexer”.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-28">
|
||||
<li id="section-30">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-28">¶</a>
|
||||
<a class="pilcrow" href="#section-30">¶</a>
|
||||
</div>
|
||||
<p>Disregard Jison’s message, it contains redundant line number information.
|
||||
Disregard the token, we take its value directly from the lexer in case
|
||||
@@ -684,11 +744,11 @@ the error is caused by a generated token which might refer to its origin.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-29">
|
||||
<li id="section-31">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-29">¶</a>
|
||||
<a class="pilcrow" href="#section-31">¶</a>
|
||||
</div>
|
||||
<p>The second argument has a <code>loc</code> property, which should have the location
|
||||
data for this token. Unfortunately, Jison seems to send an outdated <code>loc</code>
|
||||
@@ -702,11 +762,11 @@ from the lexer.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-30">
|
||||
<li id="section-32">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-30">¶</a>
|
||||
<a class="pilcrow" href="#section-32">¶</a>
|
||||
</div>
|
||||
<p>Based on <a href="http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js">http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js</a>
|
||||
Modified to handle sourceMap</p>
|
||||
@@ -734,11 +794,11 @@ Modified to handle sourceMap</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-31">
|
||||
<li id="section-33">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-31">¶</a>
|
||||
<a class="pilcrow" href="#section-33">¶</a>
|
||||
</div>
|
||||
<p>Check for a sourceMap position</p>
|
||||
|
||||
@@ -781,11 +841,11 @@ Modified to handle sourceMap</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-32">
|
||||
<li id="section-34">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-32">¶</a>
|
||||
<a class="pilcrow" href="#section-34">¶</a>
|
||||
</div>
|
||||
<p>Skip files that we didn’t compile, like Node system files that appear in
|
||||
the stack trace, as they never have source maps.</p>
|
||||
@@ -800,11 +860,11 @@ the stack trace, as they never have source maps.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-33">
|
||||
<li id="section-35">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-33">¶</a>
|
||||
<a class="pilcrow" href="#section-35">¶</a>
|
||||
</div>
|
||||
<p>CoffeeScript compiled in a browser or via <code>CoffeeScript.compile</code> or <code>.run</code>
|
||||
may get compiled with <code>options.filename</code> that’s missing, which becomes
|
||||
@@ -819,11 +879,11 @@ filename of the script file. See if we have a source map cached under
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-34">
|
||||
<li id="section-36">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-34">¶</a>
|
||||
<a class="pilcrow" href="#section-36">¶</a>
|
||||
</div>
|
||||
<p>Work backwards from the most recent anonymous source maps, until we find
|
||||
one that works. This isn’t foolproof; there is a chance that multiple
|
||||
@@ -840,11 +900,11 @@ and it’s not foolproof either.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-35">
|
||||
<li id="section-37">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-35">¶</a>
|
||||
<a class="pilcrow" href="#section-37">¶</a>
|
||||
</div>
|
||||
<p>If all else fails, recompile this source to get a source map. We need the
|
||||
previous section (for <code><anonymous></code>) despite this option, because after it
|
||||
@@ -867,11 +927,11 @@ time the source map we want is the last one.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-36">
|
||||
<li id="section-38">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-36">¶</a>
|
||||
<a class="pilcrow" href="#section-38">¶</a>
|
||||
</div>
|
||||
<p>Based on <a href="http://goo.gl/ZTx1p">michaelficarra/CoffeeScriptRedux</a>
|
||||
NodeJS / V8 have no support for transforming positions in stack traces using
|
||||
|
||||
@@ -199,12 +199,14 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>SWITCHES = [
|
||||
[ <span class="hljs-string">'--ast'</span>, <span class="hljs-string">'generate an abstract syntax tree of nodes'</span>]
|
||||
[<span class="hljs-string">'-b'</span>, <span class="hljs-string">'--bare'</span>, <span class="hljs-string">'compile without a top-level function wrapper'</span>]
|
||||
[<span class="hljs-string">'-c'</span>, <span class="hljs-string">'--compile'</span>, <span class="hljs-string">'compile to JavaScript and save as .js files'</span>]
|
||||
[<span class="hljs-string">'-e'</span>, <span class="hljs-string">'--eval'</span>, <span class="hljs-string">'pass a string from the command line as input'</span>]
|
||||
[<span class="hljs-string">'-h'</span>, <span class="hljs-string">'--help'</span>, <span class="hljs-string">'display this help message'</span>]
|
||||
[<span class="hljs-string">'-i'</span>, <span class="hljs-string">'--interactive'</span>, <span class="hljs-string">'run an interactive CoffeeScript REPL'</span>]
|
||||
[<span class="hljs-string">'-j'</span>, <span class="hljs-string">'--join [FILE]'</span>, <span class="hljs-string">'concatenate the source CoffeeScript before compiling'</span>]
|
||||
[<span class="hljs-string">'-l'</span>, <span class="hljs-string">'--literate'</span>, <span class="hljs-string">'treat stdio as literate style coffeescript'</span>]
|
||||
[<span class="hljs-string">'-m'</span>, <span class="hljs-string">'--map'</span>, <span class="hljs-string">'generate source map and save as .js.map files'</span>]
|
||||
[<span class="hljs-string">'-M'</span>, <span class="hljs-string">'--inline-map'</span>, <span class="hljs-string">'generate source map and include it directly in output'</span>]
|
||||
[<span class="hljs-string">'-n'</span>, <span class="hljs-string">'--nodes'</span>, <span class="hljs-string">'print out the parse tree that the parser produces'</span>]
|
||||
@@ -214,7 +216,6 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
|
||||
[<span class="hljs-string">'-p'</span>, <span class="hljs-string">'--print'</span>, <span class="hljs-string">'print out the compiled JavaScript'</span>]
|
||||
[<span class="hljs-string">'-r'</span>, <span class="hljs-string">'--require [MODULE*]'</span>, <span class="hljs-string">'require the given module before eval or REPL'</span>]
|
||||
[<span class="hljs-string">'-s'</span>, <span class="hljs-string">'--stdio'</span>, <span class="hljs-string">'listen for and compile scripts over stdio'</span>]
|
||||
[<span class="hljs-string">'-l'</span>, <span class="hljs-string">'--literate'</span>, <span class="hljs-string">'treat stdio as literate style coffeescript'</span>]
|
||||
[<span class="hljs-string">'-t'</span>, <span class="hljs-string">'--transpile'</span>, <span class="hljs-string">'pipe generated JavaScript through Babel'</span>]
|
||||
[ <span class="hljs-string">'--tokens'</span>, <span class="hljs-string">'print out the tokens that the lexer/rewriter produce'</span>]
|
||||
[<span class="hljs-string">'-v'</span>, <span class="hljs-string">'--version'</span>, <span class="hljs-string">'display the version number'</span>]
|
||||
@@ -460,6 +461,9 @@ requested options. If evaluating the script directly, set <code>__filename</code
|
||||
printTokens CoffeeScript.tokens task.input, task.options
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> opts.nodes
|
||||
printLine CoffeeScript.nodes(task.input, task.options).toString().trim()
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> opts.ast
|
||||
compiled = CoffeeScript.compile task.input, task.options
|
||||
printLine JSON.stringify(compiled, <span class="hljs-literal">null</span>, <span class="hljs-number">2</span>)
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> opts.run
|
||||
CoffeeScript.register()
|
||||
CoffeeScript.eval opts.prelude, task.options <span class="hljs-keyword">if</span> opts.prelude
|
||||
@@ -875,8 +879,11 @@ browsers) or use a proper build chain like Gulp or Webpack.</p>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">try</span>
|
||||
<span class="hljs-built_in">require</span> <span class="hljs-string">'babel-core'</span>
|
||||
<span class="hljs-keyword">catch</span></pre></div></div>
|
||||
<span class="hljs-built_in">require</span> <span class="hljs-string">'@babel/core'</span>
|
||||
<span class="hljs-keyword">catch</span>
|
||||
<span class="hljs-keyword">try</span>
|
||||
<span class="hljs-built_in">require</span> <span class="hljs-string">'babel-core'</span>
|
||||
<span class="hljs-keyword">catch</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -892,21 +899,21 @@ locally or globally.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
|
||||
To use --transpile, you must have babel-core installed:
|
||||
npm install --save-dev babel-core
|
||||
And you must save options to configure Babel in one of the places it looks to find its options.
|
||||
See http://coffeescript.org/#transpilation
|
||||
'''</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
|
||||
To use --transpile with globally-installed CoffeeScript, you must have babel-core installed globally:
|
||||
npm install --global babel-core
|
||||
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.
|
||||
See http://coffeescript.org/#transpilation
|
||||
'''</span>
|
||||
process.exit <span class="hljs-number">1</span>
|
||||
<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>
|
||||
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
|
||||
To use --transpile, you must have @babel/core installed:
|
||||
npm install --save-dev @babel/core
|
||||
And you must save options to configure Babel in one of the places it looks to find its options.
|
||||
See https://coffeescript.org/#transpilation
|
||||
'''</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
|
||||
To use --transpile with globally-installed CoffeeScript, you must have @babel/core installed globally:
|
||||
npm install --global @babel/core
|
||||
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.
|
||||
See https://coffeescript.org/#transpilation
|
||||
'''</span>
|
||||
process.exit <span class="hljs-number">1</span>
|
||||
|
||||
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>
|
||||
|
||||
@@ -957,6 +964,7 @@ along.</p>
|
||||
transpile: opts.transpile
|
||||
sourceMap: opts.map
|
||||
inlineMap: opts[<span class="hljs-string">'inline-map'</span>]
|
||||
ast: opts.ast
|
||||
|
||||
<span class="hljs-keyword">if</span> filename
|
||||
<span class="hljs-keyword">if</span> base
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -383,9 +383,12 @@ If <code>last</code> is not provided, this will simply return <code>first</code>
|
||||
first_column: first.first_column
|
||||
last_line: last.last_line
|
||||
last_column: last.last_column
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">buildLocationHash</span> = <span class="hljs-params">(loc)</span> -></span>
|
||||
<span class="hljs-string">"<span class="hljs-subst">#{loc.first_line}</span>x<span class="hljs-subst">#{loc.first_column}</span>-<span class="hljs-subst">#{loc.last_line}</span>x<span class="hljs-subst">#{loc.last_column}</span>"</span></pre></div></div>
|
||||
last_line_exclusive: last.last_line_exclusive
|
||||
last_column_exclusive: last.last_column_exclusive
|
||||
range: [
|
||||
first.range[<span class="hljs-number">0</span>]
|
||||
last.range[<span class="hljs-number">1</span>]
|
||||
]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -396,14 +399,19 @@ If <code>last</code> is not provided, this will simply return <code>first</code>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>This returns a function which takes an object as a parameter, and if that
|
||||
object is an AST node, updates that object’s locationData.
|
||||
The object is returned either way.</p>
|
||||
<p>Build a list of all comments attached to tokens.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.addDataToNode = <span class="hljs-function"><span class="hljs-params">(parserState, first, last)</span> -></span>
|
||||
(obj) -></pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre>exports.extractAllCommentTokens = <span class="hljs-function"><span class="hljs-params">(tokens)</span> -></span>
|
||||
allCommentsObj = {}
|
||||
<span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens <span class="hljs-keyword">when</span> token.comments
|
||||
<span class="hljs-keyword">for</span> comment <span class="hljs-keyword">in</span> token.comments
|
||||
commentKey = comment.locationData.range[<span class="hljs-number">0</span>]
|
||||
allCommentsObj[commentKey] = comment
|
||||
sortedKeys = Object.keys(allCommentsObj).sort (a, b) -> a - b
|
||||
<span class="hljs-keyword">for</span> key <span class="hljs-keyword">in</span> sortedKeys
|
||||
allCommentsObj[key]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -414,12 +422,15 @@ The object is returned either way.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>Add location data</p>
|
||||
<p>Get a lookup hash for a token based on its location data.
|
||||
Multiple tokens might have the same location hash, but using exclusive
|
||||
location data distinguishes e.g. zero-length generated tokens from
|
||||
actual source tokens.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> obj?.updateLocationDataIfMissing? <span class="hljs-keyword">and</span> first?
|
||||
obj.updateLocationDataIfMissing buildLocationData(first, last)</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">buildLocationHash</span> = <span class="hljs-params">(loc)</span> -></span>
|
||||
<span class="hljs-string">"<span class="hljs-subst">#{loc.range[<span class="hljs-number">0</span>]}</span>-<span class="hljs-subst">#{loc.range[<span class="hljs-number">1</span>]}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -430,24 +441,109 @@ The object is returned either way.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>Add comments data</p>
|
||||
<p>Build a dictionary of extra token properties organized by tokens’ locations
|
||||
used as lookup hashes.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> parserState.tokenComments
|
||||
parserState.tokenComments = {}
|
||||
<span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> parserState.parser.tokens <span class="hljs-keyword">when</span> token.comments
|
||||
tokenHash = buildLocationHash token[<span class="hljs-number">2</span>]
|
||||
<span class="hljs-keyword">unless</span> parserState.tokenComments[tokenHash]?
|
||||
parserState.tokenComments[tokenHash] = token.comments
|
||||
<span class="hljs-keyword">else</span>
|
||||
parserState.tokenComments[tokenHash].push token.comments...
|
||||
<div class="content"><div class='highlight'><pre>exports.buildTokenDataDictionary = buildTokenDataDictionary = <span class="hljs-function"><span class="hljs-params">(tokens)</span> -></span>
|
||||
tokenData = {}
|
||||
<span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens <span class="hljs-keyword">when</span> token.comments
|
||||
tokenHash = buildLocationHash token[<span class="hljs-number">2</span>]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>Multiple tokens might have the same location hash, such as the generated
|
||||
<code>JS</code> tokens added at the start or end of the token stream to hold
|
||||
comments that start or end a file.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> tokenData[tokenHash] ?= {}
|
||||
<span class="hljs-keyword">if</span> token.comments <span class="hljs-comment"># `comments` is always an array.</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>For “overlapping” tokens, that is tokens with the same location data
|
||||
and therefore matching <code>tokenHash</code>es, merge the comments from both/all
|
||||
tokens together into one array, even if there are duplicate comments;
|
||||
they will get sorted out later.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> (tokenData[tokenHash].comments ?= []).push token.comments...
|
||||
tokenData</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<p>This returns a function which takes an object as a parameter, and if that
|
||||
object is an AST node, updates that object’s locationData.
|
||||
The object is returned either way.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.addDataToNode = <span class="hljs-function"><span class="hljs-params">(parserState, firstLocationData, firstValue, lastLocationData, lastValue, forceUpdateLocation = <span class="hljs-literal">yes</span>)</span> -></span>
|
||||
(obj) -></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-21">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
</div>
|
||||
<p>Add location data.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> locationData = buildLocationData(firstValue?.locationData ? firstLocationData, lastValue?.locationData ? lastLocationData)
|
||||
<span class="hljs-keyword">if</span> obj?.updateLocationDataIfMissing? <span class="hljs-keyword">and</span> firstLocationData?
|
||||
obj.updateLocationDataIfMissing locationData, forceUpdateLocation
|
||||
<span class="hljs-keyword">else</span>
|
||||
obj.locationData = locationData</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>Add comments, building the dictionary of token data if it hasn’t been
|
||||
built yet.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> parserState.tokenData ?= buildTokenDataDictionary parserState.parser.tokens
|
||||
<span class="hljs-keyword">if</span> obj.locationData?
|
||||
objHash = buildLocationHash obj.locationData
|
||||
<span class="hljs-keyword">if</span> parserState.tokenComments[objHash]?
|
||||
attachCommentsToNode parserState.tokenComments[objHash], obj
|
||||
|
||||
<span class="hljs-keyword">if</span> parserState.tokenData[objHash]?.comments?
|
||||
attachCommentsToNode parserState.tokenData[objHash].comments, obj
|
||||
obj
|
||||
|
||||
exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function"><span class="hljs-params">(comments, node)</span> -></span>
|
||||
@@ -458,11 +554,11 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<li id="section-23">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
</div>
|
||||
<p>Convert jison location data to a string.
|
||||
<code>obj</code> can be a token, or a locationData.</p>
|
||||
@@ -482,11 +578,11 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>A <code>.coffee.md</code> compatible version of <code>basename</code>, that returns the file sans-extension.</p>
|
||||
|
||||
@@ -505,11 +601,11 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<li id="section-25">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
</div>
|
||||
<p>Determine if a filename represents a CoffeeScript file.</p>
|
||||
|
||||
@@ -520,11 +616,11 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-21">
|
||||
<li id="section-26">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
</div>
|
||||
<p>Determine if a filename represents a Literate CoffeeScript file.</p>
|
||||
|
||||
@@ -535,11 +631,11 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<li id="section-27">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
</div>
|
||||
<p>Throws a SyntaxError from a given location.
|
||||
The error’s <code>toString</code> will return an error message following the “standard”
|
||||
@@ -556,11 +652,11 @@ marker showing where the error is.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<li id="section-28">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
<a class="pilcrow" href="#section-28">¶</a>
|
||||
</div>
|
||||
<p>Instead of showing the compiler’s stacktrace, show our custom error message
|
||||
(this is useful when the error bubbles up in Node.js applications that
|
||||
@@ -575,11 +671,11 @@ compile CoffeeScript for example).</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-24">
|
||||
<li id="section-29">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
<a class="pilcrow" href="#section-29">¶</a>
|
||||
</div>
|
||||
<p>Update a compiler SyntaxError with source code information if it didn’t have
|
||||
it already.</p>
|
||||
@@ -591,11 +687,11 @@ it already.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-25">
|
||||
<li id="section-30">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
<a class="pilcrow" href="#section-30">¶</a>
|
||||
</div>
|
||||
<p>Avoid screwing up the <code>stack</code> property of other errors (i.e. possible bugs).</p>
|
||||
|
||||
@@ -621,11 +717,11 @@ it already.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-26">
|
||||
<li id="section-31">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
<a class="pilcrow" href="#section-31">¶</a>
|
||||
</div>
|
||||
<p>Show only the first line on multi-line errors.</p>
|
||||
|
||||
@@ -637,11 +733,11 @@ it already.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-27">
|
||||
<li id="section-32">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
<a class="pilcrow" href="#section-32">¶</a>
|
||||
</div>
|
||||
<p>Check to see if we’re running on a color-enabled TTY.</p>
|
||||
|
||||
@@ -667,7 +763,83 @@ exports.nameWhitespaceCharacter = <span class="hljs-function"><span class="hljs-
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'\n'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'newline'</span>
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'\r'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'carriage return'</span>
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'\t'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'tab'</span>
|
||||
<span class="hljs-keyword">else</span> string</pre></div></div>
|
||||
<span class="hljs-keyword">else</span> string
|
||||
|
||||
exports.parseNumber = <span class="hljs-function"><span class="hljs-params">(string)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> NaN <span class="hljs-keyword">unless</span> string?
|
||||
|
||||
base = <span class="hljs-keyword">switch</span> string.charAt <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'b'</span> <span class="hljs-keyword">then</span> <span class="hljs-number">2</span>
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'o'</span> <span class="hljs-keyword">then</span> <span class="hljs-number">8</span>
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'x'</span> <span class="hljs-keyword">then</span> <span class="hljs-number">16</span>
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-literal">null</span>
|
||||
|
||||
<span class="hljs-keyword">if</span> base?
|
||||
parseInt string[<span class="hljs-number">2.</span>.].replace(<span class="hljs-regexp">/_/g</span>, <span class="hljs-string">''</span>), base
|
||||
<span class="hljs-keyword">else</span>
|
||||
parseFloat string.replace(<span class="hljs-regexp">/_/g</span>, <span class="hljs-string">''</span>)
|
||||
|
||||
exports.isFunction = <span class="hljs-function"><span class="hljs-params">(obj)</span> -></span> Object::toString.call(obj) <span class="hljs-keyword">is</span> <span class="hljs-string">'[object Function]'</span>
|
||||
exports.isNumber = isNumber = <span class="hljs-function"><span class="hljs-params">(obj)</span> -></span> Object::toString.call(obj) <span class="hljs-keyword">is</span> <span class="hljs-string">'[object Number]'</span>
|
||||
exports.isString = isString = <span class="hljs-function"><span class="hljs-params">(obj)</span> -></span> Object::toString.call(obj) <span class="hljs-keyword">is</span> <span class="hljs-string">'[object String]'</span>
|
||||
exports.isBoolean = isBoolean = <span class="hljs-function"><span class="hljs-params">(obj)</span> -></span> obj <span class="hljs-keyword">is</span> <span class="hljs-literal">yes</span> <span class="hljs-keyword">or</span> obj <span class="hljs-keyword">is</span> <span class="hljs-literal">no</span> <span class="hljs-keyword">or</span> Object::toString.call(obj) <span class="hljs-keyword">is</span> <span class="hljs-string">'[object Boolean]'</span>
|
||||
exports.isPlainObject = <span class="hljs-function"><span class="hljs-params">(obj)</span> -></span> <span class="hljs-keyword">typeof</span> obj <span class="hljs-keyword">is</span> <span class="hljs-string">'object'</span> <span class="hljs-keyword">and</span> !!obj <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> Array.isArray(obj) <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> isNumber(obj) <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> isString(obj) <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> isBoolean(obj)
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">unicodeCodePointToUnicodeEscapes</span> = <span class="hljs-params">(codePoint)</span> -></span>
|
||||
<span class="hljs-function"> <span class="hljs-title">toUnicodeEscape</span> = <span class="hljs-params">(val)</span> -></span>
|
||||
str = val.toString <span class="hljs-number">16</span>
|
||||
<span class="hljs-string">"\\u<span class="hljs-subst">#{repeat <span class="hljs-string">'0'</span>, <span class="hljs-number">4</span> - str.length}</span><span class="hljs-subst">#{str}</span>"</span>
|
||||
<span class="hljs-keyword">return</span> toUnicodeEscape(codePoint) <span class="hljs-keyword">if</span> codePoint < <span class="hljs-number">0x10000</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-33">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-33">¶</a>
|
||||
</div>
|
||||
<p>surrogate pair</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> high = Math.floor((codePoint - <span class="hljs-number">0x10000</span>) / <span class="hljs-number">0x400</span>) + <span class="hljs-number">0xD800</span>
|
||||
low = (codePoint - <span class="hljs-number">0x10000</span>) % <span class="hljs-number">0x400</span> + <span class="hljs-number">0xDC00</span>
|
||||
<span class="hljs-string">"<span class="hljs-subst">#{toUnicodeEscape(high)}</span><span class="hljs-subst">#{toUnicodeEscape(low)}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-34">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-34">¶</a>
|
||||
</div>
|
||||
<p>Replace <code>\u{...}</code> with <code>\uxxxx[\uxxxx]</code> in regexes without <code>u</code> flag</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.replaceUnicodeCodePointEscapes = <span class="hljs-function"><span class="hljs-params">(str, {flags, error, delimiter = <span class="hljs-string">''</span>} = {})</span> -></span>
|
||||
shouldReplace = flags? <span class="hljs-keyword">and</span> <span class="hljs-string">'u'</span> <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> flags
|
||||
str.replace UNICODE_CODE_POINT_ESCAPE, <span class="hljs-function"><span class="hljs-params">(match, escapedBackslash, codePointHex, offset)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> escapedBackslash <span class="hljs-keyword">if</span> escapedBackslash
|
||||
|
||||
codePointDecimal = parseInt codePointHex, <span class="hljs-number">16</span>
|
||||
<span class="hljs-keyword">if</span> codePointDecimal > <span class="hljs-number">0x10ffff</span>
|
||||
error <span class="hljs-string">"unicode code point escapes greater than \\u{10ffff} are not allowed"</span>,
|
||||
offset: offset + delimiter.length
|
||||
length: codePointHex.length + <span class="hljs-number">4</span>
|
||||
<span class="hljs-keyword">return</span> match <span class="hljs-keyword">unless</span> shouldReplace
|
||||
|
||||
unicodeCodePointToUnicodeEscapes codePointDecimal
|
||||
|
||||
UNICODE_CODE_POINT_ESCAPE = <span class="hljs-regexp">///
|
||||
( \\\\ ) <span class="hljs-comment"># Make sure the escape isn’t escaped.</span>
|
||||
|
|
||||
\\u\{ ( [\da-fA-F]+ ) \}
|
||||
///</span>g</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
@@ -128,8 +128,11 @@ helpers = CoffeeScript.helpers
|
||||
|
||||
CoffeeScript.transpile = <span class="hljs-function"><span class="hljs-params">(js, options)</span> -></span>
|
||||
<span class="hljs-keyword">try</span>
|
||||
babel = <span class="hljs-built_in">require</span> <span class="hljs-string">'babel-core'</span>
|
||||
<span class="hljs-keyword">catch</span></pre></div></div>
|
||||
babel = <span class="hljs-built_in">require</span> <span class="hljs-string">'@babel/core'</span>
|
||||
<span class="hljs-keyword">catch</span>
|
||||
<span class="hljs-keyword">try</span>
|
||||
babel = <span class="hljs-built_in">require</span> <span class="hljs-string">'babel-core'</span>
|
||||
<span class="hljs-keyword">catch</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -145,7 +148,7 @@ earlier if they don’t have Babel installed.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">'To use the transpile option, you must have the \'babel-core\' module installed'</span>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">'To use the transpile option, you must have the \'@babel/core\' module installed'</span>
|
||||
babel.transform js, options</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -400,8 +403,7 @@ CoffeeScript.register = <span class="hljs-function">-></span> <span class="hl
|
||||
Use CoffeeScript.register() or require the coffeescript/register module to require <span class="hljs-subst">#{ext}</span> files.
|
||||
"""</span>
|
||||
|
||||
CoffeeScript._compileFile = <span class="hljs-function"><span class="hljs-params">(filename, options = {})</span> -></span>
|
||||
raw = fs.readFileSync filename, <span class="hljs-string">'utf8'</span></pre></div></div>
|
||||
CoffeeScript._compileRawFileContent = <span class="hljs-function"><span class="hljs-params">(raw, filename, options = {})</span> -></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -447,6 +449,11 @@ information to error so it can be pretty-printed later.</p>
|
||||
|
||||
answer
|
||||
|
||||
CoffeeScript._compileFile = <span class="hljs-function"><span class="hljs-params">(filename, options = {})</span> -></span>
|
||||
raw = fs.readFileSync filename, <span class="hljs-string">'utf8'</span>
|
||||
|
||||
CoffeeScript._compileRawFileContent raw, filename, options
|
||||
|
||||
<span class="hljs-built_in">module</span>.exports = CoffeeScript</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -196,7 +196,7 @@ Unwrap that too.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> {Block, Assign, Value, Literal, Call, Code} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./nodes'</span>
|
||||
<div class="content"><div class='highlight'><pre> {Block, Assign, Value, Literal, Call, Code, Root} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./nodes'</span>
|
||||
|
||||
<span class="hljs-keyword">try</span></pre></div></div>
|
||||
|
||||
@@ -229,11 +229,11 @@ Unwrap that too.</p>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> tokens.length >= <span class="hljs-number">2</span> <span class="hljs-keyword">and</span> tokens[<span class="hljs-number">0</span>].generated <span class="hljs-keyword">and</span>
|
||||
tokens[<span class="hljs-number">0</span>].comments?.length <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> tokens[<span class="hljs-number">0</span>][<span class="hljs-number">1</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">''</span> <span class="hljs-keyword">and</span>
|
||||
tokens[<span class="hljs-number">0</span>].comments?.length <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> <span class="hljs-string">"<span class="hljs-subst">#{tokens[<span class="hljs-number">0</span>][<span class="hljs-number">1</span>]}</span>"</span> <span class="hljs-keyword">is</span> <span class="hljs-string">''</span> <span class="hljs-keyword">and</span>
|
||||
tokens[<span class="hljs-number">1</span>][<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'TERMINATOR'</span>
|
||||
tokens = tokens[<span class="hljs-number">2.</span>..]
|
||||
<span class="hljs-keyword">if</span> tokens.length >= <span class="hljs-number">1</span> <span class="hljs-keyword">and</span> tokens[tokens.length - <span class="hljs-number">1</span>].generated <span class="hljs-keyword">and</span>
|
||||
tokens[tokens.length - <span class="hljs-number">1</span>].comments?.length <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> tokens[tokens.length - <span class="hljs-number">1</span>][<span class="hljs-number">1</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">''</span>
|
||||
tokens[tokens.length - <span class="hljs-number">1</span>].comments?.length <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> <span class="hljs-string">"<span class="hljs-subst">#{tokens[tokens.length - <span class="hljs-number">1</span>][<span class="hljs-number">1</span>]}</span>"</span> <span class="hljs-keyword">is</span> <span class="hljs-string">''</span>
|
||||
tokens.pop()</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -264,7 +264,7 @@ Unwrap that too.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> ast = CoffeeScript.nodes tokens</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre> ast = CoffeeScript.nodes(tokens).body</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -310,7 +310,7 @@ Unwrap that too.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> ast = <span class="hljs-keyword">new</span> Block [<span class="hljs-keyword">new</span> Call ast]
|
||||
<div class="content"><div class='highlight'><pre> ast = <span class="hljs-keyword">new</span> Root <span class="hljs-keyword">new</span> Block [<span class="hljs-keyword">new</span> Call ast]
|
||||
js = ast.compile {bare: <span class="hljs-literal">yes</span>, locals: Object.keys(context), referencedVars, sharedScope: <span class="hljs-literal">yes</span>}
|
||||
<span class="hljs-keyword">if</span> transpile
|
||||
js = transpile.transpile(js, transpile.options).code</pre></div></div>
|
||||
@@ -376,7 +376,7 @@ undeclared variable <code>__</code>.</p>
|
||||
vm.runInContext js, context, filename
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">addMultilineHandler</span> = <span class="hljs-params">(repl)</span> -></span>
|
||||
{rli, inputStream, outputStream} = repl</pre></div></div>
|
||||
{inputStream, outputStream} = repl</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -412,15 +412,15 @@ undeclared variable <code>__</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> nodeLineListener = rli.listeners(<span class="hljs-string">'line'</span>)[<span class="hljs-number">0</span>]
|
||||
rli.removeListener <span class="hljs-string">'line'</span>, nodeLineListener
|
||||
rli.<span class="hljs-literal">on</span> <span class="hljs-string">'line'</span>, <span class="hljs-function"><span class="hljs-params">(cmd)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre> nodeLineListener = repl.listeners(<span class="hljs-string">'line'</span>)[<span class="hljs-number">0</span>]
|
||||
repl.removeListener <span class="hljs-string">'line'</span>, nodeLineListener
|
||||
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'line'</span>, <span class="hljs-function"><span class="hljs-params">(cmd)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> multiline.enabled
|
||||
multiline.buffer += <span class="hljs-string">"<span class="hljs-subst">#{cmd}</span>\n"</span>
|
||||
rli.setPrompt multiline.prompt
|
||||
rli.prompt <span class="hljs-literal">true</span>
|
||||
repl.setPrompt multiline.prompt
|
||||
repl.prompt <span class="hljs-literal">true</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
rli.setPrompt origPrompt
|
||||
repl.setPrompt origPrompt
|
||||
nodeLineListener cmd
|
||||
<span class="hljs-keyword">return</span></pre></div></div>
|
||||
|
||||
@@ -456,8 +456,8 @@ undeclared variable <code>__</code>.</p>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> multiline.buffer.match <span class="hljs-regexp">/\n/</span>
|
||||
multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
|
||||
rli.setPrompt origPrompt
|
||||
rli.prompt <span class="hljs-literal">true</span>
|
||||
repl.setPrompt origPrompt
|
||||
repl.prompt <span class="hljs-literal">true</span>
|
||||
<span class="hljs-keyword">return</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -473,7 +473,7 @@ undeclared variable <code>__</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> rli.line? <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> rli.line.match <span class="hljs-regexp">/^\s*$/</span></pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> repl.line? <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> repl.line.match <span class="hljs-regexp">/^\s*$/</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -489,10 +489,10 @@ undeclared variable <code>__</code>.</p>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
|
||||
rli.line = <span class="hljs-string">''</span>
|
||||
rli.cursor = <span class="hljs-number">0</span>
|
||||
rli.output.cursorTo <span class="hljs-number">0</span>
|
||||
rli.output.clearLine <span class="hljs-number">1</span></pre></div></div>
|
||||
repl.line = <span class="hljs-string">''</span>
|
||||
repl.cursor = <span class="hljs-number">0</span>
|
||||
repl.output.cursorTo <span class="hljs-number">0</span>
|
||||
repl.output.clearLine <span class="hljs-number">1</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -508,12 +508,12 @@ undeclared variable <code>__</code>.</p>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> multiline.buffer = multiline.buffer.replace <span class="hljs-regexp">/\n/g</span>, <span class="hljs-string">'\uFF00'</span>
|
||||
rli.emit <span class="hljs-string">'line'</span>, multiline.buffer
|
||||
repl.emit <span class="hljs-string">'line'</span>, multiline.buffer
|
||||
multiline.buffer = <span class="hljs-string">''</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
|
||||
rli.setPrompt multiline.initialPrompt
|
||||
rli.prompt <span class="hljs-literal">true</span>
|
||||
repl.setPrompt multiline.initialPrompt
|
||||
repl.prompt <span class="hljs-literal">true</span>
|
||||
<span class="hljs-keyword">return</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -580,7 +580,7 @@ undeclared variable <code>__</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> repl.rli.history = buffer.toString().split(<span class="hljs-string">'\n'</span>).reverse()</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre> repl.history = buffer.toString().split(<span class="hljs-string">'\n'</span>).reverse()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -595,7 +595,7 @@ undeclared variable <code>__</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> repl.rli.history.pop() <span class="hljs-keyword">if</span> stat.size > maxSize</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre> repl.history.pop() <span class="hljs-keyword">if</span> stat.size > maxSize</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -610,13 +610,13 @@ undeclared variable <code>__</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> repl.rli.history.shift() <span class="hljs-keyword">if</span> repl.rli.history[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">''</span>
|
||||
repl.rli.historyIndex = <span class="hljs-number">-1</span>
|
||||
lastLine = repl.rli.history[<span class="hljs-number">0</span>]
|
||||
<div class="content"><div class='highlight'><pre> repl.history.shift() <span class="hljs-keyword">if</span> repl.history[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">''</span>
|
||||
repl.historyIndex = <span class="hljs-number">-1</span>
|
||||
lastLine = repl.history[<span class="hljs-number">0</span>]
|
||||
|
||||
fd = fs.openSync filename, <span class="hljs-string">'a'</span>
|
||||
|
||||
repl.rli.addListener <span class="hljs-string">'line'</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -></span>
|
||||
repl.addListener <span class="hljs-string">'line'</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> code <span class="hljs-keyword">and</span> code.length <span class="hljs-keyword">and</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'.history'</span> <span class="hljs-keyword">and</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'.exit'</span> <span class="hljs-keyword">and</span> lastLine <span class="hljs-keyword">isnt</span> code</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -667,7 +667,7 @@ undeclared variable <code>__</code>.</p>
|
||||
<div class="content"><div class='highlight'><pre> repl.commands[getCommandId(repl, <span class="hljs-string">'history'</span>)] =
|
||||
help: <span class="hljs-string">'Show command history'</span>
|
||||
action: <span class="hljs-function">-></span>
|
||||
repl.outputStream.write <span class="hljs-string">"<span class="hljs-subst">#{repl.rli.history[..].reverse().join <span class="hljs-string">'\n'</span>}</span>\n"</span>
|
||||
repl.outputStream.write <span class="hljs-string">"<span class="hljs-subst">#{repl.history[..].reverse().join <span class="hljs-string">'\n'</span>}</span>\n"</span>
|
||||
repl.displayPrompt()
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">getCommandId</span> = <span class="hljs-params">(repl, commandName)</span> -></span></pre></div></div>
|
||||
@@ -699,19 +699,22 @@ undeclared variable <code>__</code>.</p>
|
||||
CoffeeScript.register()
|
||||
process.argv = [<span class="hljs-string">'coffee'</span>].concat process.argv[<span class="hljs-number">2.</span>.]
|
||||
<span class="hljs-keyword">if</span> opts.transpile
|
||||
transpile = {}
|
||||
<span class="hljs-keyword">try</span>
|
||||
transpile = {}
|
||||
transpile.transpile = <span class="hljs-built_in">require</span>(<span class="hljs-string">'babel-core'</span>).transform
|
||||
transpile.transpile = <span class="hljs-built_in">require</span>(<span class="hljs-string">'@babel/core'</span>).transform
|
||||
<span class="hljs-keyword">catch</span>
|
||||
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
|
||||
To use --transpile with an interactive REPL, babel-core must be installed either in the current folder or globally:
|
||||
npm install --save-dev babel-core
|
||||
or
|
||||
npm install --global babel-core
|
||||
And you must save options to configure Babel in one of the places it looks to find its options.
|
||||
See http://coffeescript.org/#transpilation
|
||||
'''</span>
|
||||
process.exit <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">try</span>
|
||||
transpile.transpile = <span class="hljs-built_in">require</span>(<span class="hljs-string">'babel-core'</span>).transform
|
||||
<span class="hljs-keyword">catch</span>
|
||||
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
|
||||
To use --transpile with an interactive REPL, @babel/core must be installed either in the current folder or globally:
|
||||
npm install --save-dev @babel/core
|
||||
or
|
||||
npm install --global @babel/core
|
||||
And you must save options to configure Babel in one of the places it looks to find its options.
|
||||
See https://coffeescript.org/#transpilation
|
||||
'''</span>
|
||||
process.exit <span class="hljs-number">1</span>
|
||||
transpile.options =
|
||||
filename: path.resolve process.cwd(), <span class="hljs-string">'<repl>'</span></pre></div></div>
|
||||
|
||||
@@ -739,7 +742,7 @@ the REPL, the only applicable option is <code>transpile</code>.</p>
|
||||
opts = merge replDefaults, opts
|
||||
repl = nodeREPL.start opts
|
||||
runInContext opts.prelude, repl.context, <span class="hljs-string">'prelude'</span> <span class="hljs-keyword">if</span> opts.prelude
|
||||
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function">-></span> repl.outputStream.write <span class="hljs-string">'\n'</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> repl.rli.closed
|
||||
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function">-></span> repl.outputStream.write <span class="hljs-string">'\n'</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> repl.closed
|
||||
addMultilineHandler repl
|
||||
addHistory repl, opts.historyFile, opts.historyMaxInputSize <span class="hljs-keyword">if</span> opts.historyFile</pre></div></div>
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ parentheses, and generally clean things up.</p>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
{throwSyntaxError} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span></pre></div></div>
|
||||
{throwSyntaxError, extractAllCommentTokens} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -234,11 +234,11 @@ output the token stream after it has been rewritten by this file.</p>
|
||||
@normalizeLines()
|
||||
@tagPostfixConditionals()
|
||||
@addImplicitBracesAndParens()
|
||||
@addParensToChainedDoIife()
|
||||
@rescueStowawayComments()
|
||||
@addLocationDataToGeneratedTokens()
|
||||
@enforceValidCSXAttributes()
|
||||
@fixOutdentLocationData()
|
||||
@enforceValidJSXAttributes()
|
||||
@fixIndentationLocationData()
|
||||
@exposeTokenDataToGrammar()
|
||||
<span class="hljs-keyword">if</span> process?.env?.DEBUG_REWRITTEN_TOKEN_STREAM
|
||||
<span class="hljs-built_in">console</span>.log <span class="hljs-string">'Rewritten token stream:'</span> <span class="hljs-keyword">if</span> process.env.DEBUG_TOKEN_STREAM
|
||||
<span class="hljs-built_in">console</span>.log (t[<span class="hljs-number">0</span>] + <span class="hljs-string">'/'</span> + t[<span class="hljs-number">1</span>] + (<span class="hljs-keyword">if</span> t.comments <span class="hljs-keyword">then</span> <span class="hljs-string">'*'</span> <span class="hljs-keyword">else</span> <span class="hljs-string">''</span>) <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> @tokens).join <span class="hljs-string">' '</span>
|
||||
@@ -386,14 +386,21 @@ Match it with its paired close.</p>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> closeOpenIndexes: <span class="hljs-function">-></span>
|
||||
startToken = <span class="hljs-literal">null</span>
|
||||
<span class="hljs-function"> <span class="hljs-title">condition</span> = <span class="hljs-params">(token, i)</span> -></span>
|
||||
token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">']'</span>, <span class="hljs-string">'INDEX_END'</span>]
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">action</span> = <span class="hljs-params">(token, i)</span> -></span>
|
||||
token[<span class="hljs-number">0</span>] = <span class="hljs-string">'INDEX_END'</span>
|
||||
<span class="hljs-keyword">if</span> @tokens.length >= i <span class="hljs-keyword">and</span> @tokens[i + <span class="hljs-number">1</span>][<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">':'</span>
|
||||
startToken[<span class="hljs-number">0</span>] = <span class="hljs-string">'['</span>
|
||||
token[<span class="hljs-number">0</span>] = <span class="hljs-string">']'</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
token[<span class="hljs-number">0</span>] = <span class="hljs-string">'INDEX_END'</span>
|
||||
|
||||
@scanTokens (token, i) ->
|
||||
@detectEnd i + <span class="hljs-number">1</span>, condition, action <span class="hljs-keyword">if</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'INDEX_START'</span>
|
||||
<span class="hljs-keyword">if</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'INDEX_START'</span>
|
||||
startToken = token
|
||||
@detectEnd i + <span class="hljs-number">1</span>, condition, action
|
||||
<span class="hljs-number">1</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -780,7 +787,12 @@ that creates grammatical ambiguities.</p>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> s = <span class="hljs-keyword">switch</span>
|
||||
<span class="hljs-keyword">when</span> @tag(i - <span class="hljs-number">1</span>) <span class="hljs-keyword">in</span> EXPRESSION_END <span class="hljs-keyword">then</span> start[<span class="hljs-number">1</span>]
|
||||
<span class="hljs-keyword">when</span> @tag(i - <span class="hljs-number">1</span>) <span class="hljs-keyword">in</span> EXPRESSION_END
|
||||
[startTag, startIndex] = start
|
||||
<span class="hljs-keyword">if</span> startTag <span class="hljs-keyword">is</span> <span class="hljs-string">'['</span> <span class="hljs-keyword">and</span> startIndex > <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> @tag(startIndex - <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'@'</span> <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> tokens[startIndex - <span class="hljs-number">1</span>].spaced
|
||||
startIndex - <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
startIndex
|
||||
<span class="hljs-keyword">when</span> @tag(i - <span class="hljs-number">2</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'@'</span> <span class="hljs-keyword">then</span> i - <span class="hljs-number">2</span>
|
||||
<span class="hljs-keyword">else</span> i - <span class="hljs-number">1</span>
|
||||
|
||||
@@ -910,6 +922,8 @@ the continuation of an object.</p>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> inImplicitObject() <span class="hljs-keyword">and</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'TERMINATOR'</span> <span class="hljs-keyword">and</span> prevTag <span class="hljs-keyword">isnt</span> <span class="hljs-string">','</span> <span class="hljs-keyword">and</span>
|
||||
<span class="hljs-keyword">not</span> (startsLine <span class="hljs-keyword">and</span> @looksObjectish(i + <span class="hljs-number">1</span>))
|
||||
endImplicitObject()
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> inImplicitControl() <span class="hljs-keyword">and</span> tokens[stackTop()[<span class="hljs-number">1</span>]][<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'CLASS'</span> <span class="hljs-keyword">and</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'TERMINATOR'</span>
|
||||
stack.pop()
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-keyword">break</span></pre></div></div>
|
||||
|
||||
@@ -967,13 +981,13 @@ array further up the stack, so give it a chance.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-38">¶</a>
|
||||
</div>
|
||||
<p>Make sure only strings and wrapped expressions are used in CSX attributes.</p>
|
||||
<p>Make sure only strings and wrapped expressions are used in JSX attributes.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> enforceValidCSXAttributes: <span class="hljs-function">-></span>
|
||||
<div class="content"><div class='highlight'><pre> enforceValidJSXAttributes: <span class="hljs-function">-></span>
|
||||
@scanTokens (token, i, tokens) ->
|
||||
<span class="hljs-keyword">if</span> token.csxColon
|
||||
<span class="hljs-keyword">if</span> token.jsxColon
|
||||
next = tokens[i + <span class="hljs-number">1</span>]
|
||||
<span class="hljs-keyword">if</span> next[<span class="hljs-number">0</span>] <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">'STRING_START'</span>, <span class="hljs-string">'STRING'</span>, <span class="hljs-string">'('</span>]
|
||||
throwSyntaxError <span class="hljs-string">'expected wrapped or quoted JSX attribute'</span>, next[<span class="hljs-number">2</span>]
|
||||
@@ -998,6 +1012,13 @@ to a token that will make it to the other side.</p>
|
||||
<span class="hljs-function"> <span class="hljs-title">insertPlaceholder</span> = <span class="hljs-params">(token, j, tokens, method)</span> -></span>
|
||||
tokens[method] generate <span class="hljs-string">'TERMINATOR'</span>, <span class="hljs-string">'\n'</span>, tokens[j] <span class="hljs-keyword">unless</span> tokens[j][<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'TERMINATOR'</span>
|
||||
tokens[method] generate <span class="hljs-string">'JS'</span>, <span class="hljs-string">''</span>, tokens[j], token
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">dontShiftForward</span> = <span class="hljs-params">(i, tokens)</span> -></span>
|
||||
j = i + <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">while</span> j <span class="hljs-keyword">isnt</span> tokens.length <span class="hljs-keyword">and</span> tokens[j][<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> DISCARDED
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-literal">yes</span> <span class="hljs-keyword">if</span> tokens[j][<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'INTERPOLATION_END'</span>
|
||||
j++
|
||||
<span class="hljs-literal">no</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">shiftCommentsForward</span> = <span class="hljs-params">(token, i, tokens)</span> -></span></pre></div></div>
|
||||
|
||||
@@ -1112,7 +1133,7 @@ safe token, while other tokens should shift forward.</p>
|
||||
ret = shiftCommentsBackward dummyToken, i - <span class="hljs-number">1</span>, tokens
|
||||
<span class="hljs-keyword">if</span> token.comments.length <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span>
|
||||
shiftCommentsForward token, i, tokens
|
||||
<span class="hljs-keyword">else</span></pre></div></div>
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">unless</span> dontShiftForward i, tokens</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -1167,17 +1188,26 @@ discarded tokens.</p>
|
||||
@scanTokens (token, i, tokens) ->
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> token[<span class="hljs-number">2</span>]
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span> <span class="hljs-keyword">unless</span> token.generated <span class="hljs-keyword">or</span> token.explicit
|
||||
<span class="hljs-keyword">if</span> token.fromThen <span class="hljs-keyword">and</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'INDENT'</span>
|
||||
token[<span class="hljs-number">2</span>] = token.origin[<span class="hljs-number">2</span>]
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">if</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'{'</span> <span class="hljs-keyword">and</span> nextLocation=tokens[i + <span class="hljs-number">1</span>]?[<span class="hljs-number">2</span>]
|
||||
{first_line: line, first_column: column} = nextLocation
|
||||
{first_line: line, first_column: column, range: [rangeIndex]} = nextLocation
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> prevLocation = tokens[i - <span class="hljs-number">1</span>]?[<span class="hljs-number">2</span>]
|
||||
{last_line: line, last_column: column} = prevLocation
|
||||
{last_line: line, last_column: column, range: [, rangeIndex]} = prevLocation
|
||||
column += <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
line = column = <span class="hljs-number">0</span>
|
||||
token[<span class="hljs-number">2</span>] =
|
||||
first_line: line
|
||||
first_column: column
|
||||
last_line: line
|
||||
last_column: column
|
||||
rangeIndex = <span class="hljs-number">0</span>
|
||||
token[<span class="hljs-number">2</span>] = {
|
||||
first_line: line
|
||||
first_column: column
|
||||
last_line: line
|
||||
last_column: column
|
||||
last_line_exclusive: line
|
||||
last_column_exclusive: column
|
||||
range: [rangeIndex, rangeIndex]
|
||||
}
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -1195,18 +1225,36 @@ location corresponding to the last “real” token under the node.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> fixOutdentLocationData: <span class="hljs-function">-></span>
|
||||
<div class="content"><div class='highlight'><pre> fixIndentationLocationData: <span class="hljs-function">-></span>
|
||||
@allComments ?= extractAllCommentTokens @tokens
|
||||
<span class="hljs-function"> <span class="hljs-title">findPrecedingComment</span> = <span class="hljs-params">(token, {afterPosition, indentSize, first, indented})</span> =></span>
|
||||
tokenStart = token[<span class="hljs-number">2</span>].range[<span class="hljs-number">0</span>]
|
||||
<span class="hljs-function"> <span class="hljs-title">matches</span> = <span class="hljs-params">(comment)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> comment.outdented
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-literal">no</span> <span class="hljs-keyword">unless</span> indentSize? <span class="hljs-keyword">and</span> comment.indentSize > indentSize
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-literal">no</span> <span class="hljs-keyword">if</span> indented <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> comment.indented
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-literal">no</span> <span class="hljs-keyword">unless</span> comment.locationData.range[<span class="hljs-number">0</span>] < tokenStart
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-literal">no</span> <span class="hljs-keyword">unless</span> comment.locationData.range[<span class="hljs-number">0</span>] > afterPosition
|
||||
<span class="hljs-literal">yes</span>
|
||||
<span class="hljs-keyword">if</span> first
|
||||
lastMatching = <span class="hljs-literal">null</span>
|
||||
<span class="hljs-keyword">for</span> comment <span class="hljs-keyword">in</span> @allComments <span class="hljs-keyword">by</span> <span class="hljs-number">-1</span>
|
||||
<span class="hljs-keyword">if</span> matches comment
|
||||
lastMatching = comment
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> lastMatching
|
||||
<span class="hljs-keyword">return</span> lastMatching
|
||||
<span class="hljs-keyword">return</span> lastMatching
|
||||
<span class="hljs-keyword">for</span> comment <span class="hljs-keyword">in</span> @allComments <span class="hljs-keyword">when</span> matches comment <span class="hljs-keyword">by</span> <span class="hljs-number">-1</span>
|
||||
<span class="hljs-keyword">return</span> comment
|
||||
<span class="hljs-literal">null</span>
|
||||
|
||||
@scanTokens (token, i, tokens) ->
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span> <span class="hljs-keyword">unless</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'OUTDENT'</span> <span class="hljs-keyword">or</span>
|
||||
(token.generated <span class="hljs-keyword">and</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'CALL_END'</span>) <span class="hljs-keyword">or</span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span> <span class="hljs-keyword">unless</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">'INDENT'</span>, <span class="hljs-string">'OUTDENT'</span>] <span class="hljs-keyword">or</span>
|
||||
(token.generated <span class="hljs-keyword">and</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'CALL_END'</span> <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> token.data?.closingTagNameToken) <span class="hljs-keyword">or</span>
|
||||
(token.generated <span class="hljs-keyword">and</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'}'</span>)
|
||||
prevLocationData = tokens[i - <span class="hljs-number">1</span>][<span class="hljs-number">2</span>]
|
||||
token[<span class="hljs-number">2</span>] =
|
||||
first_line: prevLocationData.last_line
|
||||
first_column: prevLocationData.last_column
|
||||
last_line: prevLocationData.last_line
|
||||
last_column: prevLocationData.last_column
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span></pre></div></div>
|
||||
isIndent = token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'INDENT'</span>
|
||||
prevToken = token.prevToken ? tokens[i - <span class="hljs-number">1</span>]
|
||||
prevLocationData = prevToken[<span class="hljs-number">2</span>]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -1217,32 +1265,29 @@ location corresponding to the last “real” token under the node.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-48">¶</a>
|
||||
</div>
|
||||
<p>Add parens around a <code>do</code> IIFE followed by a chained <code>.</code> so that the
|
||||
chaining applies to the executed function rather than the function
|
||||
object (see #3736)</p>
|
||||
<p>addLocationDataToGeneratedTokens() set the outdent’s location data
|
||||
to the preceding token’s, but in order to detect comments inside an
|
||||
empty “block” we want to look for comments preceding the next token.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> addParensToChainedDoIife: <span class="hljs-function">-></span>
|
||||
<span class="hljs-function"> <span class="hljs-title">condition</span> = <span class="hljs-params">(token, i)</span> -></span>
|
||||
@tag(i - <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'OUTDENT'</span>
|
||||
<span class="hljs-function"> <span class="hljs-title">action</span> = <span class="hljs-params">(token, i)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> CALL_CLOSERS
|
||||
@tokens.splice doIndex, <span class="hljs-number">0</span>, generate <span class="hljs-string">'('</span>, <span class="hljs-string">'('</span>, @tokens[doIndex]
|
||||
@tokens.splice i + <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, generate <span class="hljs-string">')'</span>, <span class="hljs-string">')'</span>, @tokens[i]
|
||||
doIndex = <span class="hljs-literal">null</span>
|
||||
@scanTokens (token, i, tokens) ->
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span> <span class="hljs-keyword">unless</span> token[<span class="hljs-number">1</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'do'</span>
|
||||
doIndex = i
|
||||
glyphIndex = i + <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">if</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'PARAM_START'</span>
|
||||
glyphIndex = <span class="hljs-literal">null</span>
|
||||
@detectEnd i + <span class="hljs-number">1</span>,
|
||||
<span class="hljs-function"><span class="hljs-params">(token, i)</span> -></span> @tag(i - <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'PARAM_END'</span>
|
||||
(token, i) -> glyphIndex = i
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span> <span class="hljs-keyword">unless</span> glyphIndex? <span class="hljs-keyword">and</span> @tag(glyphIndex) <span class="hljs-keyword">in</span> [<span class="hljs-string">'->'</span>, <span class="hljs-string">'=>'</span>] <span class="hljs-keyword">and</span> @tag(glyphIndex + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'INDENT'</span>
|
||||
@detectEnd glyphIndex + <span class="hljs-number">1</span>, condition, action
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">2</span></pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre> useNextToken = token.explicit <span class="hljs-keyword">or</span> token.generated
|
||||
<span class="hljs-keyword">if</span> useNextToken
|
||||
nextToken = token
|
||||
nextTokenIndex = i
|
||||
nextToken = tokens[nextTokenIndex++] <span class="hljs-keyword">while</span> (nextToken.explicit <span class="hljs-keyword">or</span> nextToken.generated) <span class="hljs-keyword">and</span> nextTokenIndex <span class="hljs-keyword">isnt</span> tokens.length - <span class="hljs-number">1</span>
|
||||
precedingComment = findPrecedingComment(
|
||||
<span class="hljs-keyword">if</span> useNextToken
|
||||
nextToken
|
||||
<span class="hljs-keyword">else</span>
|
||||
token
|
||||
afterPosition: prevLocationData.range[<span class="hljs-number">0</span>]
|
||||
indentSize: token.indentSize
|
||||
first: isIndent
|
||||
indented: useNextToken
|
||||
)
|
||||
<span class="hljs-keyword">if</span> isIndent
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span> <span class="hljs-keyword">unless</span> precedingComment?.newLine</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -1253,6 +1298,50 @@ object (see #3736)</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-49">¶</a>
|
||||
</div>
|
||||
<p>We don’t want e.g. an implicit call at the end of an <code>if</code> condition to
|
||||
include a following indented comment.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">return</span> <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> token.generated <span class="hljs-keyword">and</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'CALL_END'</span> <span class="hljs-keyword">and</span> precedingComment?.indented
|
||||
prevLocationData = precedingComment.locationData <span class="hljs-keyword">if</span> precedingComment?
|
||||
token[<span class="hljs-number">2</span>] =
|
||||
first_line:
|
||||
<span class="hljs-keyword">if</span> precedingComment?
|
||||
prevLocationData.first_line
|
||||
<span class="hljs-keyword">else</span>
|
||||
prevLocationData.last_line
|
||||
first_column:
|
||||
<span class="hljs-keyword">if</span> precedingComment?
|
||||
<span class="hljs-keyword">if</span> isIndent
|
||||
<span class="hljs-number">0</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
prevLocationData.first_column
|
||||
<span class="hljs-keyword">else</span>
|
||||
prevLocationData.last_column
|
||||
last_line: prevLocationData.last_line
|
||||
last_column: prevLocationData.last_column
|
||||
last_line_exclusive: prevLocationData.last_line_exclusive
|
||||
last_column_exclusive: prevLocationData.last_column_exclusive
|
||||
range:
|
||||
<span class="hljs-keyword">if</span> isIndent <span class="hljs-keyword">and</span> precedingComment?
|
||||
[
|
||||
prevLocationData.range[<span class="hljs-number">0</span>] - precedingComment.indentSize
|
||||
prevLocationData.range[<span class="hljs-number">1</span>]
|
||||
]
|
||||
<span class="hljs-keyword">else</span>
|
||||
prevLocationData.range
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-50">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-50">¶</a>
|
||||
</div>
|
||||
<p>Because our grammar is LALR(1), it can’t handle some single-line
|
||||
expressions that lack ending delimiters. The <strong>Rewriter</strong> adds the implicit
|
||||
blocks, so it doesn’t need to. To keep the grammar clean and tidy, trailing
|
||||
@@ -1269,11 +1358,11 @@ blocks are added.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-50">
|
||||
<li id="section-51">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-50">¶</a>
|
||||
<a class="pilcrow" href="#section-51">¶</a>
|
||||
</div>
|
||||
<p>Count <code>THEN</code> tags</p>
|
||||
|
||||
@@ -1303,11 +1392,11 @@ blocks are added.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-51">
|
||||
<li id="section-52">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-51">¶</a>
|
||||
<a class="pilcrow" href="#section-52">¶</a>
|
||||
</div>
|
||||
<p>Insert <code>OUTDENT</code> to close inner <code>IF</code>.</p>
|
||||
|
||||
@@ -1319,11 +1408,11 @@ blocks are added.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-52">
|
||||
<li id="section-53">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-52">¶</a>
|
||||
<a class="pilcrow" href="#section-53">¶</a>
|
||||
</div>
|
||||
<p>Insert <code>OUTDENT</code> to close outer <code>IF</code>.</p>
|
||||
|
||||
@@ -1335,11 +1424,11 @@ blocks are added.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-53">
|
||||
<li id="section-54">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-53">¶</a>
|
||||
<a class="pilcrow" href="#section-54">¶</a>
|
||||
</div>
|
||||
<p>Remove outdents from the end.</p>
|
||||
|
||||
@@ -1363,13 +1452,16 @@ blocks are added.</p>
|
||||
tokens.splice i, <span class="hljs-number">1</span>, @indentation()...
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">if</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">in</span> EXPRESSION_CLOSE
|
||||
<span class="hljs-keyword">if</span> token[<span class="hljs-number">1</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">';'</span> <span class="hljs-keyword">and</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'OUTDENT'</span>
|
||||
tokens[i + <span class="hljs-number">1</span>].prevToken = token
|
||||
moveComments token, tokens[i + <span class="hljs-number">1</span>]
|
||||
tokens.splice i, <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">0</span>
|
||||
<span class="hljs-keyword">if</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'CATCH'</span>
|
||||
<span class="hljs-keyword">for</span> j <span class="hljs-keyword">in</span> [<span class="hljs-number">1.</span><span class="hljs-number">.2</span>] <span class="hljs-keyword">when</span> @tag(i + j) <span class="hljs-keyword">in</span> [<span class="hljs-string">'OUTDENT'</span>, <span class="hljs-string">'TERMINATOR'</span>, <span class="hljs-string">'FINALLY'</span>]
|
||||
tokens.splice i + j, <span class="hljs-number">0</span>, @indentation()...
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">2</span> + j
|
||||
<span class="hljs-keyword">if</span> tag <span class="hljs-keyword">in</span> [<span class="hljs-string">'->'</span>, <span class="hljs-string">'=>'</span>] <span class="hljs-keyword">and</span> (@tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">','</span> <span class="hljs-keyword">or</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'.'</span> <span class="hljs-keyword">and</span> token.newLine)
|
||||
<span class="hljs-keyword">if</span> tag <span class="hljs-keyword">in</span> [<span class="hljs-string">'->'</span>, <span class="hljs-string">'=>'</span>] <span class="hljs-keyword">and</span> (@tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">in</span> [<span class="hljs-string">','</span>, <span class="hljs-string">']'</span>] <span class="hljs-keyword">or</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'.'</span> <span class="hljs-keyword">and</span> token.newLine)
|
||||
[indent, outdent] = @indentation tokens[i]
|
||||
tokens.splice i + <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, indent, outdent
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span>
|
||||
@@ -1387,11 +1479,11 @@ blocks are added.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-54">
|
||||
<li id="section-55">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-54">¶</a>
|
||||
<a class="pilcrow" href="#section-55">¶</a>
|
||||
</div>
|
||||
<p><code>ELSE</code> tag is not closed.</p>
|
||||
|
||||
@@ -1408,11 +1500,11 @@ blocks are added.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-55">
|
||||
<li id="section-56">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-55">¶</a>
|
||||
<a class="pilcrow" href="#section-56">¶</a>
|
||||
</div>
|
||||
<p>Tag postfix conditionals as such, so that we can parse them with a
|
||||
different precedence.</p>
|
||||
@@ -1440,11 +1532,36 @@ different precedence.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-56">
|
||||
<li id="section-57">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-56">¶</a>
|
||||
<a class="pilcrow" href="#section-57">¶</a>
|
||||
</div>
|
||||
<p>For tokens with extra data, we want to make that data visible to the grammar
|
||||
by wrapping the token value as a String() object and setting the data as
|
||||
properties of that object. The grammar should then be responsible for
|
||||
cleaning this up for the node constructor: unwrapping the token value to a
|
||||
primitive string and separately passing any expected token data properties</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> exposeTokenDataToGrammar: <span class="hljs-function">-></span>
|
||||
@scanTokens (token, i) ->
|
||||
<span class="hljs-keyword">if</span> token.generated <span class="hljs-keyword">or</span> (token.data <span class="hljs-keyword">and</span> Object.keys(token.data).length <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span>)
|
||||
token[<span class="hljs-number">1</span>] = <span class="hljs-keyword">new</span> String token[<span class="hljs-number">1</span>]
|
||||
token[<span class="hljs-number">1</span>][key] = val <span class="hljs-keyword">for</span> own key, val <span class="hljs-keyword">of</span> (token.data ? {})
|
||||
token[<span class="hljs-number">1</span>].generated = <span class="hljs-literal">yes</span> <span class="hljs-keyword">if</span> token.generated
|
||||
<span class="hljs-number">1</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-58">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-58">¶</a>
|
||||
</div>
|
||||
<p>Generate the indentation tokens, based on another token on the same line.</p>
|
||||
|
||||
@@ -1465,11 +1582,11 @@ different precedence.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-57">
|
||||
<li id="section-59">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-57">¶</a>
|
||||
<a class="pilcrow" href="#section-59">¶</a>
|
||||
</div>
|
||||
<p>Look up a tag by token index.</p>
|
||||
|
||||
@@ -1480,11 +1597,11 @@ different precedence.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-58">
|
||||
<li id="section-60">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-58">¶</a>
|
||||
<a class="pilcrow" href="#section-60">¶</a>
|
||||
</div>
|
||||
<h2 id="constants">Constants</h2>
|
||||
|
||||
@@ -1493,11 +1610,11 @@ different precedence.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-59">
|
||||
<li id="section-61">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-59">¶</a>
|
||||
<a class="pilcrow" href="#section-61">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -1505,11 +1622,11 @@ different precedence.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-60">
|
||||
<li id="section-62">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-60">¶</a>
|
||||
<a class="pilcrow" href="#section-62">¶</a>
|
||||
</div>
|
||||
<p>List of the token pairs that must be balanced.</p>
|
||||
|
||||
@@ -1524,17 +1641,18 @@ different precedence.</p>
|
||||
[<span class="hljs-string">'PARAM_START'</span>, <span class="hljs-string">'PARAM_END'</span>]
|
||||
[<span class="hljs-string">'INDEX_START'</span>, <span class="hljs-string">'INDEX_END'</span>]
|
||||
[<span class="hljs-string">'STRING_START'</span>, <span class="hljs-string">'STRING_END'</span>]
|
||||
[<span class="hljs-string">'INTERPOLATION_START'</span>, <span class="hljs-string">'INTERPOLATION_END'</span>]
|
||||
[<span class="hljs-string">'REGEX_START'</span>, <span class="hljs-string">'REGEX_END'</span>]
|
||||
]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-61">
|
||||
<li id="section-63">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-61">¶</a>
|
||||
<a class="pilcrow" href="#section-63">¶</a>
|
||||
</div>
|
||||
<p>The inverse mappings of <code>BALANCED_PAIRS</code> we’re trying to fix up, so we can
|
||||
look things up from either end.</p>
|
||||
@@ -1546,11 +1664,11 @@ look things up from either end.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-62">
|
||||
<li id="section-64">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-62">¶</a>
|
||||
<a class="pilcrow" href="#section-64">¶</a>
|
||||
</div>
|
||||
<p>The tokens that signal the start/end of a balanced pair.</p>
|
||||
|
||||
@@ -1566,11 +1684,11 @@ EXPRESSION_END = []
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-63">
|
||||
<li id="section-65">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-63">¶</a>
|
||||
<a class="pilcrow" href="#section-65">¶</a>
|
||||
</div>
|
||||
<p>Tokens that indicate the close of a clause of an expression.</p>
|
||||
|
||||
@@ -1581,11 +1699,11 @@ EXPRESSION_END = []
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-64">
|
||||
<li id="section-66">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-64">¶</a>
|
||||
<a class="pilcrow" href="#section-66">¶</a>
|
||||
</div>
|
||||
<p>Tokens that, if followed by an <code>IMPLICIT_CALL</code>, indicate a function invocation.</p>
|
||||
|
||||
@@ -1596,22 +1714,22 @@ EXPRESSION_END = []
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-65">
|
||||
<li id="section-67">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-65">¶</a>
|
||||
<a class="pilcrow" href="#section-67">¶</a>
|
||||
</div>
|
||||
<p>If preceded by an <code>IMPLICIT_FUNC</code>, indicates a function invocation.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>IMPLICIT_CALL = [
|
||||
<span class="hljs-string">'IDENTIFIER'</span>, <span class="hljs-string">'CSX_TAG'</span>, <span class="hljs-string">'PROPERTY'</span>, <span class="hljs-string">'NUMBER'</span>, <span class="hljs-string">'INFINITY'</span>, <span class="hljs-string">'NAN'</span>
|
||||
<span class="hljs-string">'IDENTIFIER'</span>, <span class="hljs-string">'JSX_TAG'</span>, <span class="hljs-string">'PROPERTY'</span>, <span class="hljs-string">'NUMBER'</span>, <span class="hljs-string">'INFINITY'</span>, <span class="hljs-string">'NAN'</span>
|
||||
<span class="hljs-string">'STRING'</span>, <span class="hljs-string">'STRING_START'</span>, <span class="hljs-string">'REGEX'</span>, <span class="hljs-string">'REGEX_START'</span>, <span class="hljs-string">'JS'</span>
|
||||
<span class="hljs-string">'NEW'</span>, <span class="hljs-string">'PARAM_START'</span>, <span class="hljs-string">'CLASS'</span>, <span class="hljs-string">'IF'</span>, <span class="hljs-string">'TRY'</span>, <span class="hljs-string">'SWITCH'</span>, <span class="hljs-string">'THIS'</span>
|
||||
<span class="hljs-string">'UNDEFINED'</span>, <span class="hljs-string">'NULL'</span>, <span class="hljs-string">'BOOL'</span>
|
||||
<span class="hljs-string">'UNARY'</span>, <span class="hljs-string">'YIELD'</span>, <span class="hljs-string">'AWAIT'</span>, <span class="hljs-string">'UNARY_MATH'</span>, <span class="hljs-string">'SUPER'</span>, <span class="hljs-string">'THROW'</span>
|
||||
<span class="hljs-string">'UNARY'</span>, <span class="hljs-string">'DO'</span>, <span class="hljs-string">'DO_IIFE'</span>, <span class="hljs-string">'YIELD'</span>, <span class="hljs-string">'AWAIT'</span>, <span class="hljs-string">'UNARY_MATH'</span>, <span class="hljs-string">'SUPER'</span>, <span class="hljs-string">'THROW'</span>
|
||||
<span class="hljs-string">'@'</span>, <span class="hljs-string">'->'</span>, <span class="hljs-string">'=>'</span>, <span class="hljs-string">'['</span>, <span class="hljs-string">'('</span>, <span class="hljs-string">'{'</span>, <span class="hljs-string">'--'</span>, <span class="hljs-string">'++'</span>
|
||||
]
|
||||
|
||||
@@ -1620,11 +1738,11 @@ IMPLICIT_UNSPACED_CALL = [<span class="hljs-string">'+'</span>, <span class="hlj
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-66">
|
||||
<li id="section-68">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-66">¶</a>
|
||||
<a class="pilcrow" href="#section-68">¶</a>
|
||||
</div>
|
||||
<p>Tokens that always mark the end of an implicit call for single-liners.</p>
|
||||
|
||||
@@ -1636,11 +1754,11 @@ IMPLICIT_UNSPACED_CALL = [<span class="hljs-string">'+'</span>, <span class="hlj
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-67">
|
||||
<li id="section-69">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-67">¶</a>
|
||||
<a class="pilcrow" href="#section-69">¶</a>
|
||||
</div>
|
||||
<p>Single-line flavors of block expressions that have unclosed endings.
|
||||
The grammar can’t disambiguate them, so we insert the implicit indentation.</p>
|
||||
@@ -1653,11 +1771,11 @@ SINGLE_CLOSERS = [<span class="hljs-string">'TERMINATOR'</span>, <span class="
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-68">
|
||||
<li id="section-70">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-68">¶</a>
|
||||
<a class="pilcrow" href="#section-70">¶</a>
|
||||
</div>
|
||||
<p>Tokens that end a line.</p>
|
||||
|
||||
@@ -1668,11 +1786,11 @@ SINGLE_CLOSERS = [<span class="hljs-string">'TERMINATOR'</span>, <span class="
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-69">
|
||||
<li id="section-71">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-69">¶</a>
|
||||
<a class="pilcrow" href="#section-71">¶</a>
|
||||
</div>
|
||||
<p>Tokens that close open calls when they follow a newline.</p>
|
||||
|
||||
@@ -1683,11 +1801,11 @@ SINGLE_CLOSERS = [<span class="hljs-string">'TERMINATOR'</span>, <span class="
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-70">
|
||||
<li id="section-72">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-70">¶</a>
|
||||
<a class="pilcrow" href="#section-72">¶</a>
|
||||
</div>
|
||||
<p>Tokens that prevent a subsequent indent from ending implicit calls/objects</p>
|
||||
|
||||
@@ -1698,11 +1816,11 @@ SINGLE_CLOSERS = [<span class="hljs-string">'TERMINATOR'</span>, <span class="
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-71">
|
||||
<li id="section-73">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-71">¶</a>
|
||||
<a class="pilcrow" href="#section-73">¶</a>
|
||||
</div>
|
||||
<p>Tokens that are swallowed up by the parser, never leading to code generation.
|
||||
You can spot these in <code>grammar.coffee</code> because the <code>o</code> function second
|
||||
@@ -1713,11 +1831,11 @@ the node that becomes <code>StringWithInterpolations</code>, and therefore
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>DISCARDED = [<span class="hljs-string">'('</span>, <span class="hljs-string">')'</span>, <span class="hljs-string">'['</span>, <span class="hljs-string">']'</span>, <span class="hljs-string">'{'</span>, <span class="hljs-string">'}'</span>, <span class="hljs-string">'.'</span>, <span class="hljs-string">'..'</span>, <span class="hljs-string">'...'</span>, <span class="hljs-string">','</span>, <span class="hljs-string">'='</span>, <span class="hljs-string">'++'</span>, <span class="hljs-string">'--'</span>, <span class="hljs-string">'?'</span>,
|
||||
<span class="hljs-string">'AS'</span>, <span class="hljs-string">'AWAIT'</span>, <span class="hljs-string">'CALL_START'</span>, <span class="hljs-string">'CALL_END'</span>, <span class="hljs-string">'DEFAULT'</span>, <span class="hljs-string">'ELSE'</span>, <span class="hljs-string">'EXTENDS'</span>, <span class="hljs-string">'EXPORT'</span>,
|
||||
<span class="hljs-string">'FORIN'</span>, <span class="hljs-string">'FOROF'</span>, <span class="hljs-string">'FORFROM'</span>, <span class="hljs-string">'IMPORT'</span>, <span class="hljs-string">'INDENT'</span>, <span class="hljs-string">'INDEX_SOAK'</span>, <span class="hljs-string">'LEADING_WHEN'</span>,
|
||||
<span class="hljs-string">'OUTDENT'</span>, <span class="hljs-string">'PARAM_END'</span>, <span class="hljs-string">'REGEX_START'</span>, <span class="hljs-string">'REGEX_END'</span>, <span class="hljs-string">'RETURN'</span>, <span class="hljs-string">'STRING_END'</span>, <span class="hljs-string">'THROW'</span>,
|
||||
<span class="hljs-string">'UNARY'</span>, <span class="hljs-string">'YIELD'</span>
|
||||
<div class="content"><div class='highlight'><pre>DISCARDED = [<span class="hljs-string">'('</span>, <span class="hljs-string">')'</span>, <span class="hljs-string">'['</span>, <span class="hljs-string">']'</span>, <span class="hljs-string">'{'</span>, <span class="hljs-string">'}'</span>, <span class="hljs-string">':'</span>, <span class="hljs-string">'.'</span>, <span class="hljs-string">'..'</span>, <span class="hljs-string">'...'</span>, <span class="hljs-string">','</span>, <span class="hljs-string">'='</span>, <span class="hljs-string">'++'</span>, <span class="hljs-string">'--'</span>, <span class="hljs-string">'?'</span>,
|
||||
<span class="hljs-string">'AS'</span>, <span class="hljs-string">'AWAIT'</span>, <span class="hljs-string">'CALL_START'</span>, <span class="hljs-string">'CALL_END'</span>, <span class="hljs-string">'DEFAULT'</span>, <span class="hljs-string">'DO'</span>, <span class="hljs-string">'DO_IIFE'</span>, <span class="hljs-string">'ELSE'</span>,
|
||||
<span class="hljs-string">'EXTENDS'</span>, <span class="hljs-string">'EXPORT'</span>, <span class="hljs-string">'FORIN'</span>, <span class="hljs-string">'FOROF'</span>, <span class="hljs-string">'FORFROM'</span>, <span class="hljs-string">'IMPORT'</span>, <span class="hljs-string">'INDENT'</span>, <span class="hljs-string">'INDEX_SOAK'</span>,
|
||||
<span class="hljs-string">'INTERPOLATION_START'</span>, <span class="hljs-string">'INTERPOLATION_END'</span>, <span class="hljs-string">'LEADING_WHEN'</span>, <span class="hljs-string">'OUTDENT'</span>, <span class="hljs-string">'PARAM_END'</span>,
|
||||
<span class="hljs-string">'REGEX_START'</span>, <span class="hljs-string">'REGEX_END'</span>, <span class="hljs-string">'RETURN'</span>, <span class="hljs-string">'STRING_END'</span>, <span class="hljs-string">'THROW'</span>, <span class="hljs-string">'UNARY'</span>, <span class="hljs-string">'YIELD'</span>
|
||||
].concat IMPLICIT_UNSPACED_CALL.concat IMPLICIT_END.concat CALL_CLOSERS.concat CONTROL_IN_IMPLICIT</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
8
docs/v2/browser-compiler-legacy/coffeescript.js
Normal file
8
docs/v2/browser-compiler-legacy/coffeescript.js
Normal file
File diff suppressed because one or more lines are too long
8
docs/v2/browser-compiler-modern/coffeescript.js
Normal file
8
docs/v2/browser-compiler-modern/coffeescript.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1701
docs/v2/index.html
1701
docs/v2/index.html
File diff suppressed because one or more lines are too long
18309
docs/v2/test.html
18309
docs/v2/test.html
File diff suppressed because it is too large
Load Diff
10
documentation/examples/dynamic_import.coffee
Normal file
10
documentation/examples/dynamic_import.coffee
Normal file
@@ -0,0 +1,10 @@
|
||||
# Your browser must support dynamic import to run this example.
|
||||
|
||||
do ->
|
||||
{ run } = await import('./browser-compiler-modern/coffeescript.js')
|
||||
run '''
|
||||
if 5 < new Date().getHours() < 9
|
||||
alert 'Time to make the coffee!'
|
||||
else
|
||||
alert 'Time to get some work done.'
|
||||
'''
|
||||
@@ -6,4 +6,4 @@ Object.defineProperty screen, 'height',
|
||||
get: ->
|
||||
this.width / this.ratio
|
||||
set: (val) ->
|
||||
this.width = val / this.ratio
|
||||
this.width = val * this.ratio
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'local-file.coffee'
|
||||
import './local-file.coffee'
|
||||
import 'coffeescript'
|
||||
|
||||
import _ from 'underscore'
|
||||
|
||||
@@ -1,718 +1 @@
|
||||
## Changelog
|
||||
|
||||
```
|
||||
releaseHeader('2018-02-01', '2.2.0', '2.1.1')
|
||||
```
|
||||
* This release fixes *all* currently open bugs, dating as far back as 2014, 2012 and 2011.
|
||||
* **Potential breaking change:** An inline `if` or `switch` statement with an ambiguous `else`, such as `if no then if yes then alert 1 else alert 2`, now compiles where the `else` always corresponds to the closest open `then`. Previously the behavior of an ambiguous `else` was unpredictable. If your code has any `if … then` or `switch … then` statements with multiple `then`s (and one or more `else`s) the compiled output might be different now, unless you had resolved ambiguity via parentheses. We made this change because the previous behavior was inconsistent and basically a bug: depending on what grammar was where, for example if there was an inline function or something that implied a block, the `else` might bind to an earlier `then` rather than a later `then`. Now an `else` essentially closes a block opened by a `then`, similar to closing an open parenthesis.
|
||||
* When a required `then` is missing, the error more accurately points out the location of the mistake.
|
||||
* An error is thrown when the `coffee` command is run in an environment that doesn’t support some ES2015 JavaScript features that the CoffeeScript compiler itself requires. This can happen if CoffeeScript is installed in Node older than version 6.
|
||||
* Destructuring with a non-final splat/spread, e.g. `[open, contents..., close] = tag.split('')` is now output using ES2015 rest syntax.
|
||||
* Functions named `get` or `set` can be used without parentheses in more cases, including when attached to `this` or `@` or `?.`; or when the first argument is an implicit object, e.g. `@set key: 'val'`.
|
||||
* Statements such as `break` can now be used inside parentheses, e.g. `(doSomething(); break) while condition` or `(pick(key); break) for key of obj`.
|
||||
* Bugfix for assigning to a property attached to `this`/`@` in destructuring, e.g. `({@prop = yes, @otherProp = no}) ->`.
|
||||
* Bugfix for incorrect errors being thrown about calling `super` with a parameter attached to `this` when said parameter is in a lower scope, e.g. `class Child extends Parent then constructor: -> super(-> @prop)`.
|
||||
* Bugfix to prevent a possible infinite loop when a `for` loop is given a variable to step by, e.g. `for x in [1..3] by step` (as opposed to `by 0.5` or some other primitive numeric value).
|
||||
* Bugfix to no longer declare iterator variables twice when evaluating a range, e.g. `end = 3; fn [0..end]`.
|
||||
* Bugfix for incorrect scope of variables in chained calls, e.g. `start(x = 3).then(-> x = 4)`.
|
||||
* Bugfix for incorrect scope of variables in a function passed to `do`, e.g. `for [1..3] then masked = 10; do -> alert masked`.
|
||||
* Bugfix to no longer throw a syntax error for a trailing comma in a function call, e.g. `fn arg1, arg2,`.
|
||||
* Bugfix for an expression in a property access, e.g. `a[!b in c..]`.
|
||||
* Bugfix to allow a line continuation backslash (`\`) at any point in a `for` line.
|
||||
|
||||
```
|
||||
releaseHeader('2017-12-29', '2.1.1', '2.1.0')
|
||||
```
|
||||
|
||||
* Bugfix to set the correct context for executable class bodies. So in `class @B extends @A then @property = 1`, the `@` in `@property` now refers to the class, not the global object.
|
||||
* Bugfix where anonymous classes were getting created using the same automatic variable name. They now each receive unique names, so as not to override each other.
|
||||
|
||||
|
||||
```
|
||||
releaseHeader('2017-12-10', '2.1.0', '2.0.3')
|
||||
```
|
||||
|
||||
* Computed property keys in object literals are now supported: `obj = { ['key' + i]: 42 }`, or `obj = [Symbol.iterator]: -> yield i++`.
|
||||
* Skipping of array elements, a.k.a. elision, is now supported: `arr = [a, , b]`, or `[, protocol] = url.match /^(.*):\/\//`.
|
||||
* [JSX fragments syntax](https://reactjs.org/blog/2017/11/28/react-v16.2.0-fragment-support.html) is now supported.
|
||||
* Bugfix where `///` within a `#` line comment inside a `///` block regex was erroneously closing the regex, rather than being treated as part of the comment.
|
||||
* Bugfix for incorrect output for object rest destructuring inside array destructuring.
|
||||
|
||||
```
|
||||
releaseHeader('2017-11-26', '2.0.3', '2.0.2')
|
||||
```
|
||||
|
||||
* Bugfix for `export default` followed by an implicit object that contains an explicit object, for example `exportedMember: { obj... }`.
|
||||
* Bugfix for `key, val of obj` after an implicit object member, e.g. `foo: bar for key, val of obj`.
|
||||
* Bugfix for combining array and object destructuring, e.g. `[ ..., {a, b} ] = arr`.
|
||||
* Bugfix for an edge case where it was possible to create a bound (`=>`) generator function, which should throw an error as such functions aren’t allowed in ES2015.
|
||||
* Bugfix for source maps: `.map` files should always have the same base filename as the requested output filename. So `coffee --map --output foo.js test.coffee` should generate `foo.js` and `foo.js.map`.
|
||||
* Bugfix for incorrect source maps generated when using `--transpile` with `--map` for multiple input files.
|
||||
* Bugfix for comments at the beginning or end of input into the REPL (`coffee --interactive`).
|
||||
|
||||
```
|
||||
releaseHeader('2017-10-26', '2.0.2', '2.0.1')
|
||||
```
|
||||
* `--transpile` now also applies to `require`d or `import`ed CoffeeScript files.
|
||||
* `--transpile` can be used with the REPL: `coffee --interactive --transpile`.
|
||||
* Improvements to comments output that should now cover all of the [Flow comment-based syntax](https://flow.org/en/docs/types/comments/). Inline `###` comments near [variable](https://flow.org/en/docs/types/variables/) initial assignments are now output in the variable declaration statement, and `###` comments near a [class and method names](https://flow.org/en/docs/types/generics/) are now output where Flow expects them.
|
||||
* Importing CoffeeScript keywords is now allowed, so long as they’re aliased: `import { and as andFn } from 'lib'`. (You could also do `import lib from 'lib'` and then reference `lib.and`.)
|
||||
* Calls to functions named `get` and `set` no longer throw an error when given a bracketless object literal as an argument: `obj.set propertyName: propertyValue`.
|
||||
* In the constructor of a derived class (a class that `extends` another class), you cannot call `super` with an argument that references `this`: `class Child extends Parent then constructor: (@arg) -> super(@arg)`. This isn’t allowed in JavaScript, and now the CoffeeScript compiler will throw an error. Instead, assign to `this` after calling `super`: `(arg) -> super(arg); @arg = arg`.
|
||||
* Bugfix for incorrect output when backticked statements and hoisted expressions were both in the same class body. This allows a backticked line like `` `field = 3` ``, for people using the experimental [class fields](https://github.com/tc39/proposal-class-fields) syntax, in the same class along with traditional class body expressions like `prop: 3` that CoffeeScript outputs as part of the class prototype.
|
||||
* Bugfix for comments not output before a complex `?` operation, e.g. `@a ? b`.
|
||||
* All tests now pass in Windows.
|
||||
|
||||
```
|
||||
releaseHeader('2017-09-26', '2.0.1', '2.0.0')
|
||||
```
|
||||
|
||||
* `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).
|
||||
* `--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.
|
||||
* 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/).
|
||||
|
||||
```
|
||||
releaseHeader('2017-09-18', '2.0.0', '2.0.0-beta5')
|
||||
```
|
||||
|
||||
* 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`.
|
||||
* Always populate source maps’ `sourcesContent` property.
|
||||
* Bugfixes for destructuring and for comments in JSX.
|
||||
* _Note that these are only the changes between 2.0.0-beta5 and 2.0.0. See below for all changes since 1.x._
|
||||
|
||||
```
|
||||
releaseHeader('2017-09-02', '2.0.0-beta5', '2.0.0-beta4')
|
||||
```
|
||||
|
||||
* Node 6 is now supported, and we will try to maintain that as the minimum required version for CoffeeScript 2 via the `coffee` command or Node API. Older versions of Node, or non-evergreen browsers, can compile via the [browser compiler](./browser-compiler/coffeescript.js).
|
||||
* The command line `--output` flag now allows you to specify an output filename, not just an output folder.
|
||||
* The command line `--require` flag now properly handles filenames or module names that are invalid identifiers (like an NPM module with a hyphen in the name).
|
||||
* `Object.assign`, output when object destructuring is used, is polyfilled using the same polyfill that Babel outputs. This means that polyfills shouldn’t be required unless support for Internet Explorer 8 or below is desired (or your own code uses a feature that requires a polyfill). See [ES2015+ Output](#es2015plus-output).
|
||||
* A string or JSX interpolation that contains only a comment (`"a#{### comment ###}b"` or `<div>{### comment ###}</div>`) is now output (`` `a${/* comment */}b` ``)
|
||||
* Interpolated strings (ES2015 template literals) that contain quotation marks no longer have the quotation marks escaped: `` `say "${message}"` ``
|
||||
* It is now possible to chain after a function literal (for example, to define a function and then call `.call` on it).
|
||||
* The results of the async tests are included in the output when you run `cake test`.
|
||||
* Bugfixes for object destructuring; expansions in function parameters; generated reference variables in function parameters; chained functions after `do`; splats after existential operator soaks in arrays (`[a?.b...]`); trailing `if` with splat in arrays or function parameters (`[a if b...]`); attempting to `throw` an `if`, `for`, `switch`, `while` or other invalid construct.
|
||||
* Bugfixes for syntactical edge cases: semicolons after `=` and other “mid-expression” tokens; spaces after `::`; and scripts that begin with `:` or `*`.
|
||||
* Bugfixes for source maps generated via the Node API; and stack trace line numbers when compiling CoffeeScript via the Node API from within a `.coffee` file.
|
||||
|
||||
```
|
||||
releaseHeader('2017-08-03', '2.0.0-beta4', '2.0.0-beta3')
|
||||
```
|
||||
|
||||
* This release includes [all the changes from 1.12.6 to 1.12.7](#1.12.7).
|
||||
* [Line comments](#comments) (starting with `#`) are now output in the generated JavaScript.
|
||||
* [Block comments](#comments) (delimited by `###`) are now allowed anywhere, including inline where they previously weren’t possible. This provides support for [static type annotations](#type-annotations) using Flow’s comments-based syntax.
|
||||
* Spread syntax (`...` for objects) is now supported in JSX tags: `<div {props...} />`.
|
||||
* Argument parsing for scripts run via `coffee` is improved. See [breaking changes](#breaking-changes-argument-parsing-and-shebang-lines).
|
||||
* CLI: Propagate `SIGINT` and `SIGTERM` signals when node is forked.
|
||||
* `await` in the REPL is now allowed without requiring a wrapper function.
|
||||
* `do super` is now allowed, and other accesses of `super` like `super.x.y` or `super['x'].y` now work.
|
||||
* Splat/spread syntax triple dots are now allowed on either the left or the right (so `props...` or `...props` are both valid).
|
||||
* Tagged template literals are recognized as callable functions.
|
||||
* Bugfixes for object spread syntax in nested properties.
|
||||
* Bugfixes for destructured function parameter default values.
|
||||
|
||||
```
|
||||
releaseHeader('2017-07-16', '1.12.7', '1.12.6')
|
||||
```
|
||||
|
||||
* Fix regressions in 1.12.6 related to chained function calls and indented `return` and `throw` arguments.
|
||||
* The REPL no longer warns about assigning to `_`.
|
||||
|
||||
```
|
||||
releaseHeader('2017-06-30', '2.0.0-beta3', '2.0.0-beta2')
|
||||
```
|
||||
|
||||
* [JSX](#jsx) is now supported.
|
||||
* [Object rest/spread properties](#object-spread) are now supported.
|
||||
* Bound (fat arrow) methods are once again supported in classes; though an error will be thrown if you attempt to call the method before it is bound. See [breaking changes for classes](#breaking-changes-classes).
|
||||
* The REPL no longer warns about assigning to `_`.
|
||||
* Bugfixes for destructured nested default values and issues related to chaining or continuing expressions across multiple lines.
|
||||
|
||||
|
||||
```
|
||||
releaseHeader('2017-05-16', '2.0.0-beta2', '2.0.0-beta1')
|
||||
```
|
||||
|
||||
* This release includes [all the changes from 1.12.5 to 1.12.6](#1.12.6).
|
||||
* Bound (fat arrow) methods in classes must be declared in the class constructor, after `super()` if the class is extending a parent class. See [breaking changes for classes](#breaking-changes-classes).
|
||||
* All unnecessary utility helper functions have been removed, including the polyfills for `indexOf` and `bind`.
|
||||
* The `extends` keyword now only works in the context of classes; it cannot be used to extend a function prototype. See [breaking changes for `extends`](#breaking-changes-super-extends).
|
||||
* Literate CoffeeScript is now parsed entirely based on indentation, similar to the 1.x implementation; there is no longer a dependency for parsing Markdown. See [breaking changes for Literate CoffeeScript parsing](#breaking-changes-literate-coffeescript).
|
||||
* JavaScript reserved words used as properties are no longer wrapped in quotes.
|
||||
* `require('coffeescript')` should now work in non-Node environments such as the builds created by Webpack or Browserify. This provides a more convenient way to include the browser compiler in builds intending to run in a browser environment.
|
||||
* Unreachable `break` statements are no longer added after `switch` cases that `throw` exceptions.
|
||||
* The browser compiler is now compiled using Babili and transpiled down to Babel’s `env` preset (should be safe for use in all browsers in current use, not just evergreen versions).
|
||||
* Calling functions `@get` or `@set` no longer throws an error about required parentheses. (Bare `get` or `set`, not attached to an object or `@`, [still intentionally throws a compiler error](#unsupported-get-set).)
|
||||
* If `$XDG_CACHE_HOME` is set, the REPL `.coffee_history` file is saved there.
|
||||
|
||||
```
|
||||
releaseHeader('2017-05-15', '1.12.6', '1.12.5')
|
||||
```
|
||||
|
||||
* The `return` and `export` keywords can now accept implicit objects (defined by indentation, without needing braces).
|
||||
* Support Unicode code point escapes (e.g. `\u{1F4A9}`).
|
||||
* The `coffee` command now first looks to see if CoffeeScript is installed under `node_modules` in the current folder, and executes the `coffee` binary there if so; or otherwise it runs the globally installed one. This allows you to have one version of CoffeeScript installed globally and a different one installed locally for a particular project. (Likewise for the `cake` command.)
|
||||
* Bugfixes for chained function calls not closing implicit objects or ternaries.
|
||||
* Bugfixes for incorrect code generated by the `?` operator within a termary `if` statement.
|
||||
* Fixed some tests, and failing tests now result in a nonzero exit code.
|
||||
|
||||
```
|
||||
releaseHeader('2017-04-14', '2.0.0-beta1', '2.0.0-alpha1')
|
||||
```
|
||||
|
||||
* Initial beta release of CoffeeScript 2. No further breaking changes are anticipated.
|
||||
* Destructured objects and arrays now output using ES2015+ syntax whenever possible.
|
||||
* Literate CoffeeScript now has much better support for parsing Markdown, thanks to using [Markdown-It](https://github.com/markdown-it/markdown-it) to detect Markdown sections rather than just looking at indentation.
|
||||
* Calling a function named `get` or `set` now requires parentheses, to disambiguate from the `get` or `set` keywords (which are [disallowed](#unsupported-get-set)).
|
||||
* The compiler now requires Node 7.6+, the first version of Node to support asynchronous functions without requiring a flag.
|
||||
|
||||
```
|
||||
releaseHeader('2017-04-10', '1.12.5', '1.12.4')
|
||||
```
|
||||
|
||||
* Better handling of `default`, `from`, `as` and `*` within `import` and `export` statements. You can now import or export a member named `default` and the compiler won’t interpret it as the `default` keyword.
|
||||
* Fixed a bug where invalid octal escape sequences weren’t throwing errors in the compiler.
|
||||
|
||||
|
||||
```
|
||||
releaseHeader('2017-02-21', '2.0.0-alpha1', '1.12.4')
|
||||
```
|
||||
|
||||
* Initial alpha release of CoffeeScript 2. The CoffeeScript compiler now outputs ES2015+ syntax whenever possible. See [breaking changes](#breaking-changes).
|
||||
* Classes are output using ES2015 `class` and `extends` keywords.
|
||||
* Added support for `async`/`await`.
|
||||
* Bound (arrow) functions now output as `=>` functions.
|
||||
* Function parameters with default values now use ES2015 default values syntax.
|
||||
* Splat function parameters now use ES2015 spread syntax.
|
||||
* Computed properties now use ES2015 syntax.
|
||||
* Interpolated strings (template literals) now use ES2015 backtick syntax.
|
||||
* Improved support for recognizing Markdown in Literate CoffeeScript files.
|
||||
* Mixing tabs and spaces in indentation is now disallowed.
|
||||
* Browser compiler is now minified using the Google Closure Compiler (JavaScript version).
|
||||
* Node 7+ required for CoffeeScript 2.
|
||||
|
||||
```
|
||||
releaseHeader('2017-02-18', '1.12.4', '1.12.3')
|
||||
```
|
||||
|
||||
* The `cake` commands have been updated, with new `watch` options for most tasks. Clone the [CoffeeScript repo](https://github.com/jashkenas/coffeescript) and run `cake` at the root of the repo to see the options.
|
||||
* Fixed a bug where `export`ing a referenced variable was preventing the variable from being declared.
|
||||
* Fixed a bug where the `coffee` command wasn’t working for a `.litcoffee` file.
|
||||
* Bugfixes related to tokens and location data, for better source maps and improved compatibility with downstream tools.
|
||||
|
||||
```
|
||||
releaseHeader('2017-01-24', '1.12.3', '1.12.2')
|
||||
```
|
||||
|
||||
* `@` values can now be used as indices in `for` expressions. This loosens the compilation of `for` expressions to allow the index variable to be an `@` value, e.g. `do @visit for @node, @index in nodes`. Within `@visit`, the index of the current node (`@node`) would be available as `@index`.
|
||||
* CoffeeScript’s patched `Error.prepareStackTrace` has been restored, with some revisions that should prevent the erroneous exceptions that were making life difficult for some downstream projects. This fixes the incorrect line numbers in stack traces since 1.12.2.
|
||||
* The `//=` operator’s output now wraps parentheses around the right operand, like the other assignment operators.
|
||||
|
||||
```
|
||||
releaseHeader('2016-12-16', '1.12.2', '1.12.1')
|
||||
```
|
||||
|
||||
* The browser compiler can once again be built unminified via `MINIFY=false cake build:browser`.
|
||||
* The error-prone patched version of `Error.prepareStackTrace` has been removed.
|
||||
* Command completion in the REPL (pressing tab to get suggestions) has been fixed for Node 6.9.1+.
|
||||
* The [browser-based tests](/v<%= majorVersion %>/test.html) now include all the tests as the Node-based version.
|
||||
|
||||
```
|
||||
releaseHeader('2016-12-07', '1.12.1', '1.12.0')
|
||||
```
|
||||
|
||||
* You can now import a module member named `default`, e.g. `import { default } from 'lib'`. Though like in ES2015, you cannot import an entire module and name it `default` (so `import default from 'lib'` is not allowed).
|
||||
* Fix regression where `from` as a variable name was breaking `for` loop declarations. For the record, `from` is not a reserved word in CoffeeScript; you may use it for variable names. `from` behaves like a keyword within the context of `import` and `export` statements, and in the declaration of a `for` loop; though you should also be able to use variables named `from` in those contexts, and the compiler should be able to tell the difference.
|
||||
|
||||
```
|
||||
releaseHeader('2016-12-04', '1.12.0', '1.11.1')
|
||||
```
|
||||
|
||||
* CoffeeScript now supports ES2015 [tagged template literals](#tagged-template-literals). Note that using tagged template literals in your code makes you responsible for ensuring that either your runtime supports tagged template literals or that you transpile the output JavaScript further to a version your target runtime(s) support.
|
||||
* CoffeeScript now provides a [`for…from`](#generator-iteration) syntax for outputting ES2015 [`for…of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of). (Sorry they couldn’t match, but we came up with `for…of` first for something else.) This allows iterating over generators or any other iterable object. Note that using `for…from` in your code makes you responsible for ensuring that either your runtime supports `for…of` or that you transpile the output JavaScript further to a version your target runtime(s) support.
|
||||
* Triple backticks (`` `````) allow the creation of embedded JavaScript blocks where escaping single backticks is not required, which should improve interoperability with ES2015 template literals and with Markdown.
|
||||
* Within single-backtick embedded JavaScript, backticks can now be escaped via `` \```.
|
||||
* The browser tests now run in the browser again, and are accessible [here](/v<%= majorVersion %>/test.html) if you would like to test your browser.
|
||||
* CoffeeScript-only keywords in ES2015 `import`s and `export`s are now ignored.
|
||||
* The compiler now throws an error on trying to export an anonymous class.
|
||||
* Bugfixes related to tokens and location data, for better source maps and improved compatibility with downstream tools.
|
||||
|
||||
```
|
||||
releaseHeader('2016-10-02', '1.11.1', '1.11.0')
|
||||
```
|
||||
|
||||
* Bugfix for shorthand object syntax after interpolated keys.
|
||||
* Bugfix for indentation-stripping in `"""` strings.
|
||||
* Bugfix for not being able to use the name “arguments” for a prototype property of class.
|
||||
* Correctly compile large hexadecimal numbers literals to `2e308` (just like all other large number literals do).
|
||||
|
||||
```
|
||||
releaseHeader('2016-09-24', '1.11.0', '1.10.0')
|
||||
```
|
||||
|
||||
* CoffeeScript now supports ES2015 [`import` and `export` syntax](#modules).
|
||||
* Added the `-M, --inline-map` flag to the compiler, allowing you embed the source map directly into the output JavaScript, rather than as a separate file.
|
||||
* A bunch of fixes for `yield`:
|
||||
* `yield return` can no longer mistakenly be used as an expression.
|
||||
* `yield` now mirrors `return` in that it can be used stand-alone as well as with expressions. Where you previously wrote `yield undefined`, you may now write simply `yield`. However, this means also inheriting the same syntax limitations that `return` has, so these examples no longer compile:
|
||||
```
|
||||
doubles = ->
|
||||
yield for i in [1..3]
|
||||
i * 2
|
||||
six = ->
|
||||
yield
|
||||
2 * 3
|
||||
```
|
||||
* The JavaScript output is a bit nicer, with unnecessary parentheses and spaces, double indentation and double semicolons around `yield` no longer present.
|
||||
* `&&=`, `||=`, `and=` and `or=` no longer accidentally allow a space before the equals sign.
|
||||
* Improved several error messages.
|
||||
* Just like `undefined` compiles to `void 0`, `NaN` now compiles into `0/0` and `Infinity` into `2e308`.
|
||||
* Bugfix for renamed destructured parameters with defaults. `({a: b = 1}) ->` no longer crashes the compiler.
|
||||
* Improved the internal representation of a CoffeeScript program. This is only noticeable to tools that use `CoffeeScript.tokens` or `CoffeeScript.nodes`. Such tools need to update to take account for changed or added tokens and nodes.
|
||||
* Several minor bug fixes, including:
|
||||
* The caught error in `catch` blocks is no longer declared unnecessarily, and no longer mistakenly named `undefined` for `catch`-less `try` blocks.
|
||||
* Unassignable parameter destructuring no longer crashes the compiler.
|
||||
* Source maps are now used correctly for errors thrown from .coffee.md files.
|
||||
* `coffee -e 'throw null'` no longer crashes.
|
||||
* The REPL no longer crashes when using `.exit` to exit it.
|
||||
* Invalid JavaScript is no longer output when lots of `for` loops are used in the same scope.
|
||||
* A unicode issue when using stdin with the CLI.
|
||||
|
||||
```
|
||||
releaseHeader('2015-09-03', '1.10.0', '1.9.3')
|
||||
```
|
||||
|
||||
* CoffeeScript now supports ES2015-style destructuring defaults.
|
||||
* `(offsetHeight: height) ->` no longer compiles. That syntax was accidental and partly broken. Use `({offsetHeight: height}) ->` instead. Object destructuring always requires braces.
|
||||
* Several minor bug fixes, including:
|
||||
* A bug where the REPL would sometimes report valid code as invalid, based on what you had typed earlier.
|
||||
* A problem with multiple JS contexts in the jest test framework.
|
||||
* An error in io.js where strict mode is set on internal modules.
|
||||
* A variable name clash for the caught error in `catch` blocks.
|
||||
|
||||
```
|
||||
releaseHeader('2015-05-27', '1.9.3', '1.9.2')
|
||||
```
|
||||
|
||||
* Bugfix for interpolation in the first key of an object literal in an implicit call.
|
||||
* Fixed broken error messages in the REPL, as well as a few minor bugs with the REPL.
|
||||
* Fixed source mappings for tokens at the beginning of lines when compiling with the `--bare` option. This has the nice side effect of generating smaller source maps.
|
||||
* Slight formatting improvement of compiled block comments.
|
||||
* Better error messages for `on`, `off`, `yes` and `no`.
|
||||
|
||||
```
|
||||
releaseHeader('2015-04-15', '1.9.2', '1.9.1')
|
||||
```
|
||||
|
||||
* Fixed a **watch** mode error introduced in 1.9.1 when compiling multiple files with the same filename.
|
||||
* Bugfix for `yield` around expressions containing `this`.
|
||||
* Added a Ruby-style `-r` option to the REPL, which allows requiring a module before execution with `--eval` or `--interactive`.
|
||||
* In `<script type="text/coffeescript">` tags, to avoid possible duplicate browser requests for .coffee files, you can now use the `data-src` attribute instead of `src`.
|
||||
* Minor bug fixes for IE8, strict ES5 regular expressions and Browserify.
|
||||
|
||||
```
|
||||
releaseHeader('2015-02-18', '1.9.1', '1.9.0')
|
||||
```
|
||||
|
||||
* Interpolation now works in object literal keys (again). You can use this to dynamically name properties.
|
||||
* Internal compiler variable names no longer start with underscores. This makes the generated JavaScript a bit prettier, and also fixes an issue with the completely broken and ungodly way that AngularJS “parses” function arguments.
|
||||
* Fixed a few `yield`-related edge cases with `yield return` and `yield throw`.
|
||||
* Minor bug fixes and various improvements to compiler error messages.
|
||||
|
||||
```
|
||||
releaseHeader('2015-01-29', '1.9.0', '1.8.0')
|
||||
```
|
||||
|
||||
* CoffeeScript now supports ES2015 generators. A generator is simply a function that `yield`s.
|
||||
* More robust parsing and improved error messages for strings and regexes — especially with respect to interpolation.
|
||||
* Changed strategy for the generation of internal compiler variable names. Note that this means that `@example` function parameters are no longer available as naked `example` variables within the function body.
|
||||
* Fixed REPL compatibility with latest versions of Node and Io.js.
|
||||
* Various minor bug fixes.
|
||||
|
||||
```
|
||||
releaseHeader('2014-08-26', '1.8.0', '1.7.1')
|
||||
```
|
||||
|
||||
* The `--join` option of the CLI is now deprecated.
|
||||
* Source maps now use `.js.map` as file extension, instead of just `.map`.
|
||||
* The CLI now exits with the exit code 1 when it fails to write a file to disk.
|
||||
* The compiler no longer crashes on unterminated, single-quoted strings.
|
||||
* Fixed location data for string interpolations, which made source maps out of sync.
|
||||
* The error marker in error messages is now correctly positioned if the code is indented with tabs.
|
||||
* Fixed a slight formatting error in CoffeeScript’s source map-patched stack traces.
|
||||
* The `%%` operator now coerces its right operand only once.
|
||||
* It is now possible to require CoffeeScript files from Cakefiles without having to register the compiler first.
|
||||
* The CoffeeScript REPL is now exported and can be required using `require 'coffeescript/repl'`.
|
||||
* Fixes for the REPL in Node 0.11.
|
||||
|
||||
```
|
||||
releaseHeader('2014-01-29', '1.7.1', '1.7.0')
|
||||
```
|
||||
|
||||
* Fixed a typo that broke node module lookup when running a script directly with the `coffee` binary.
|
||||
|
||||
```
|
||||
releaseHeader('2014-01-28', '1.7.0', '1.6.3')
|
||||
```
|
||||
|
||||
* When requiring CoffeeScript files in Node you must now explicitly register the compiler. This can be done with `require 'coffeescript/register'` or `CoffeeScript.register()`. Also for configuration such as Mocha’s, use **coffeescript/register**.
|
||||
* Improved error messages, source maps and stack traces. Source maps now use the updated `//#` syntax.
|
||||
* Leading `.` now closes all open calls, allowing for simpler chaining syntax.
|
||||
* Added `**`, `//` and `%%` operators and `...` expansion in parameter lists and destructuring expressions.
|
||||
* Multiline strings are now joined by a single space and ignore all indentation. A backslash at the end of a line can denote the amount of whitespace between lines, in both strings and heredocs. Backslashes correctly escape whitespace in block regexes.
|
||||
* Closing brackets can now be indented and therefore no longer cause unexpected error.
|
||||
* Several breaking compilation fixes. Non-callable literals (strings, numbers etc.) don’t compile in a call now and multiple postfix conditionals compile properly. Postfix conditionals and loops always bind object literals. Conditional assignment compiles properly in subexpressions. `super` is disallowed outside of methods and works correctly inside `for` loops.
|
||||
* Formatting of compiled block comments has been improved.
|
||||
* No more `-p` folders on Windows.
|
||||
* The `options` object passed to CoffeeScript is no longer mutated.
|
||||
|
||||
```
|
||||
releaseHeader('2013-06-02', '1.6.3', '1.6.2')
|
||||
```
|
||||
|
||||
* The CoffeeScript REPL now remembers your history between sessions. Just like a proper REPL should.
|
||||
* You can now use `require` in Node to load `.coffee.md` Literate CoffeeScript files. In the browser, `text/literate-coffeescript` script tags.
|
||||
* The old `coffee --lint` command has been removed. It was useful while originally working on the compiler, but has been surpassed by JSHint. You may now use `-l` to pass literate files in over **stdio**.
|
||||
* Bugfixes for Windows path separators, `catch` without naming the error, and executable-class-bodies-with- prototypal-property-attachment.
|
||||
|
||||
```
|
||||
releaseHeader('2013-03-18', '1.6.2', '1.6.1')
|
||||
```
|
||||
|
||||
* Source maps have been used to provide automatic line-mapping when running CoffeeScript directly via the `coffee` command, and for automatic line-mapping when running CoffeeScript directly in the browser. Also, to provide better error messages for semantic errors thrown by the compiler — [with colors, even](http://cl.ly/NdOA).
|
||||
* Improved support for mixed literate/vanilla-style CoffeeScript projects, and generating source maps for both at the same time.
|
||||
* Fixes for **1.6.x** regressions with overriding inherited bound functions, and for Windows file path management.
|
||||
* The `coffee` command can now correctly `fork()` both `.coffee` and `.js` files. (Requires Node.js 0.9+)
|
||||
|
||||
```
|
||||
releaseHeader('2013-03-05', '1.6.1', '1.5.0')
|
||||
```
|
||||
|
||||
* First release of [source maps](#source-maps). Pass the `--map` flag to the compiler, and off you go. Direct all your thanks over to [Jason Walton](https://github.com/jwalton).
|
||||
* Fixed a 1.5.0 regression with multiple implicit calls against an indented implicit object. Combinations of implicit function calls and implicit objects should generally be parsed better now — but it still isn’t good _style_ to nest them too heavily.
|
||||
* `.coffee.md` is now also supported as a Literate CoffeeScript file extension, for existing tooling. `.litcoffee` remains the canonical one.
|
||||
* Several minor fixes surrounding member properties, bound methods and `super` in class declarations.
|
||||
|
||||
```
|
||||
releaseHeader('2013-02-25', '1.5.0', '1.4.0')
|
||||
```
|
||||
|
||||
* First release of [Literate CoffeeScript](#literate).
|
||||
* The CoffeeScript REPL is now based on the Node.js REPL, and should work better and more familiarly.
|
||||
* Returning explicit values from constructors is now forbidden. If you want to return an arbitrary value, use a function, not a constructor.
|
||||
* You can now loop over an array backwards, without having to manually deal with the indexes: `for item in list by -1`
|
||||
* Source locations are now preserved in the CoffeeScript AST, although source maps are not yet being emitted.
|
||||
|
||||
```
|
||||
releaseHeader('2012-10-23', '1.4.0', '1.3.3')
|
||||
```
|
||||
|
||||
* The CoffeeScript compiler now strips Microsoft’s UTF-8 BOM if it exists, allowing you to compile BOM-borked source files.
|
||||
* Fix Node/compiler deprecation warnings by removing `registerExtension`, and moving from `path.exists` to `fs.exists`.
|
||||
* Small tweaks to splat compilation, backticks, slicing, and the error for duplicate keys in object literals.
|
||||
|
||||
```
|
||||
releaseHeader('2012-05-15', '1.3.3', '1.3.1')
|
||||
```
|
||||
|
||||
* Due to the new semantics of JavaScript’s strict mode, CoffeeScript no longer guarantees that constructor functions have names in all runtimes. See [#2052](https://github.com/jashkenas/coffeescript/issues/2052) for discussion.
|
||||
* Inside of a nested function inside of an instance method, it’s now possible to call `super` more reliably (walks recursively up).
|
||||
* Named loop variables no longer have different scoping heuristics than other local variables. (Reverts #643)
|
||||
* Fix for splats nested within the LHS of destructuring assignment.
|
||||
* Corrections to our compile time strict mode forbidding of octal literals.
|
||||
|
||||
```
|
||||
releaseHeader('2012-04-10', '1.3.1', '1.2.0')
|
||||
```
|
||||
|
||||
* CoffeeScript now enforces all of JavaScript’s **Strict Mode** early syntax errors at compile time. This includes old-style octal literals, duplicate property names in object literals, duplicate parameters in a function definition, deleting naked variables, setting the value of `eval` or `arguments`, and more. See a full discussion at [#1547](https://github.com/jashkenas/coffeescript/issues/1547).
|
||||
* The REPL now has a handy new multi-line mode for entering large blocks of code. It’s useful when copy-and-pasting examples into the REPL. Enter multi-line mode with `Ctrl-V`. You may also now pipe input directly into the REPL.
|
||||
* CoffeeScript now prints a `Generated by CoffeeScript VERSION` header at the top of each compiled file.
|
||||
* Conditional assignment of previously undefined variables `a or= b` is now considered a syntax error.
|
||||
* A tweak to the semantics of `do`, which can now be used to more easily simulate a namespace: `do (x = 1, y = 2) -> …`
|
||||
* Loop indices are now mutable within a loop iteration, and immutable between them.
|
||||
* Both endpoints of a slice are now allowed to be omitted for consistency, effectively creating a shallow copy of the list.
|
||||
* Additional tweaks and improvements to `coffee --watch` under Node’s “new” file watching API. Watch will now beep by default if you introduce a syntax error into a watched script. We also now ignore hidden directories by default when watching recursively.
|
||||
|
||||
```
|
||||
releaseHeader('2011-12-18', '1.2.0', '1.1.3')
|
||||
```
|
||||
|
||||
* Multiple improvements to `coffee --watch` and `--join`. You may now use both together, as well as add and remove files and directories within a `--watch`’d folder.
|
||||
* The `throw` statement can now be used as part of an expression.
|
||||
* Block comments at the top of the file will now appear outside of the safety closure wrapper.
|
||||
* Fixed a number of minor 1.1.3 regressions having to do with trailing operators and unfinished lines, and a more major 1.1.3 regression that caused bound functions _within_ bound class functions to have the incorrect `this`.
|
||||
|
||||
```
|
||||
releaseHeader('2011-11-08', '1.1.3', '1.1.2')
|
||||
```
|
||||
|
||||
* Ahh, whitespace. CoffeeScript’s compiled JS now tries to space things out and keep it readable, as you can see in the examples on this page.
|
||||
* You can now call `super` in class level methods in class bodies, and bound class methods now preserve their correct context.
|
||||
* JavaScript has always supported octal numbers `010 is 8`, and hexadecimal numbers `0xf is 15`, but CoffeeScript now also supports binary numbers: `0b10 is 2`.
|
||||
* The CoffeeScript module has been nested under a subdirectory to make it easier to `require` individual components separately, without having to use **npm**. For example, after adding the CoffeeScript folder to your path: `require('coffeescript/lexer')`
|
||||
* There’s a new “link” feature in Try CoffeeScript on this webpage. Use it to get a shareable permalink for your example script.
|
||||
* The `coffee --watch` feature now only works on Node.js 0.6.0 and higher, but now also works properly on Windows.
|
||||
* Lots of small bug fixes from **[@michaelficarra](https://github.com/michaelficarra)**, **[@geraldalewis](https://github.com/geraldalewis)**, **[@satyr](https://github.com/satyr)**, and **[@trevorburnham](https://github.com/trevorburnham)**.
|
||||
|
||||
```
|
||||
releaseHeader('2011-08-04', '1.1.2', '1.1.1')
|
||||
```
|
||||
|
||||
Fixes for block comment formatting, `?=` compilation, implicit calls against control structures, implicit invocation of a try/catch block, variadic arguments leaking from local scope, line numbers in syntax errors following heregexes, property access on parenthesized number literals, bound class methods and super with reserved names, a REPL overhaul, consecutive compiled semicolons, block comments in implicitly called objects, and a Chrome bug.
|
||||
|
||||
```
|
||||
releaseHeader('2011-05-10', '1.1.1', '1.1.0')
|
||||
```
|
||||
|
||||
Bugfix release for classes with external constructor functions, see issue #1182.
|
||||
|
||||
```
|
||||
releaseHeader('2011-05-01', '1.1.0', '1.0.1')
|
||||
```
|
||||
|
||||
When running via the `coffee` executable, `process.argv` and friends now report `coffee` instead of `node`. Better compatibility with **Node.js 0.4.x** module lookup changes. The output in the REPL is now colorized, like Node’s is. Giving your concatenated CoffeeScripts a name when using `--join` is now mandatory. Fix for lexing compound division `/=` as a regex accidentally. All `text/coffeescript` tags should now execute in the order they’re included. Fixed an issue with extended subclasses using external constructor functions. Fixed an edge-case infinite loop in `addImplicitParentheses`. Fixed exponential slowdown with long chains of function calls. Globals no longer leak into the CoffeeScript REPL. Splatted parameters are declared local to the function.
|
||||
|
||||
```
|
||||
releaseHeader('2011-01-31', '1.0.1', '1.0.0')
|
||||
```
|
||||
|
||||
Fixed a lexer bug with Unicode identifiers. Updated REPL for compatibility with Node.js 0.3.7\. Fixed requiring relative paths in the REPL. Trailing `return` and `return undefined` are now optimized away. Stopped requiring the core Node.js `util` module for back-compatibility with Node.js 0.2.5\. Fixed a case where a conditional `return` would cause fallthrough in a `switch` statement. Optimized empty objects in destructuring assignment.
|
||||
|
||||
```
|
||||
releaseHeader('2010-12-24', '1.0.0', '0.9.6')
|
||||
```
|
||||
|
||||
CoffeeScript loops no longer try to preserve block scope when functions are being generated within the loop body. Instead, you can use the `do` keyword to create a convenient closure wrapper. Added a `--nodejs` flag for passing through options directly to the `node` executable. Better behavior around the use of pure statements within expressions. Fixed inclusive slicing through `-1`, for all browsers, and splicing with arbitrary expressions as endpoints.
|
||||
|
||||
```
|
||||
releaseHeader('2010-12-06', '0.9.6', '0.9.5')
|
||||
```
|
||||
|
||||
The REPL now properly formats stacktraces, and stays alive through asynchronous exceptions. Using `--watch` now prints timestamps as files are compiled. Fixed some accidentally-leaking variables within plucked closure-loops. Constructors now maintain their declaration location within a class body. Dynamic object keys were removed. Nested classes are now supported. Fixes execution context for naked splatted functions. Bugfix for inversion of chained comparisons. Chained class instantiation now works properly with splats.
|
||||
|
||||
```
|
||||
releaseHeader('2010-11-21', '0.9.5', '0.9.4')
|
||||
```
|
||||
|
||||
0.9.5 should be considered the first release candidate for CoffeeScript 1.0. There have been a large number of internal changes since the previous release, many contributed from **satyr**’s [Coco](https://github.com/satyr/coco) dialect of CoffeeScript. Heregexes (extended regexes) were added. Functions can now have default arguments. Class bodies are now executable code. Improved syntax errors for invalid CoffeeScript. `undefined` now works like `null`, and cannot be assigned a new value. There was a precedence change with respect to single-line comprehensions: `result = i for i in list`
|
||||
used to parse as `result = (i for i in list)` by default … it now parses as
|
||||
`(result = i) for i in list`.
|
||||
|
||||
```
|
||||
releaseHeader('2010-09-21', '0.9.4', '0.9.3')
|
||||
```
|
||||
|
||||
CoffeeScript now uses appropriately-named temporary variables, and recycles their references after use. Added `require.extensions` support for **Node.js 0.3**. Loading CoffeeScript in the browser now adds just a single `CoffeeScript` object to global scope. Fixes for implicit object and block comment edge cases.
|
||||
|
||||
```
|
||||
releaseHeader('2010-09-16', '0.9.3', '0.9.2')
|
||||
```
|
||||
|
||||
CoffeeScript `switch` statements now compile into JS `switch` statements — they previously compiled into `if/else` chains for JavaScript 1.3 compatibility. Soaking a function invocation is now supported. Users of the RubyMine editor should now be able to use `--watch` mode.
|
||||
|
||||
```
|
||||
releaseHeader('2010-08-23', '0.9.2', '0.9.1')
|
||||
```
|
||||
|
||||
Specifying the start and end of a range literal is now optional, eg. `array[3..]`. You can now say `a not instanceof b`. Fixed important bugs with nested significant and non-significant indentation (Issue #637). Added a `--require` flag that allows you to hook into the `coffee` command. Added a custom `jsl.conf` file for our preferred JavaScriptLint setup. Sped up Jison grammar compilation time by flattening rules for operations. Block comments can now be used with JavaScript-minifier-friendly syntax. Added JavaScript’s compound assignment bitwise operators. Bugfixes to implicit object literals with leading number and string keys, as the subject of implicit calls, and as part of compound assignment.
|
||||
|
||||
```
|
||||
releaseHeader('2010-08-11', '0.9.1', '0.9.0')
|
||||
```
|
||||
|
||||
Bugfix release for **0.9.1**. Greatly improves the handling of mixed implicit objects, implicit function calls, and implicit indentation. String and regex interpolation is now strictly `#{ … }` (Ruby style). The compiler now takes a `--require` flag, which specifies scripts to run before compilation.
|
||||
|
||||
```
|
||||
releaseHeader('2010-08-04', '0.9.0', '0.7.2')
|
||||
```
|
||||
|
||||
The CoffeeScript **0.9** series is considered to be a release candidate for **1.0**; let’s give her a shakedown cruise. **0.9.0** introduces a massive backwards-incompatible change: Assignment now uses `=`, and object literals use `:`, as in JavaScript. This allows us to have implicit object literals, and YAML-style object definitions. Half assignments are removed, in favor of `+=`, `or=`, and friends. Interpolation now uses a hash mark `#` instead of the dollar sign `$` — because dollar signs may be part of a valid JS identifier. Downwards range comprehensions are now safe again, and are optimized to straight for loops when created with integer endpoints. A fast, unguarded form of object comprehension was added: `for all key, value of object`. Mentioning the `super` keyword with no arguments now forwards all arguments passed to the function, as in Ruby. If you extend class `B` from parent class `A`, if `A` has an `extended` method defined, it will be called, passing in `B` — this enables static inheritance, among other things. Cleaner output for functions bound with the fat arrow. `@variables` can now be used in parameter lists, with the parameter being automatically set as a property on the object — useful in constructors and setter functions. Constructor functions can now take splats.
|
||||
|
||||
```
|
||||
releaseHeader('2010-07-12', '0.7.2', '0.7.1')
|
||||
```
|
||||
|
||||
Quick bugfix (right after 0.7.1) for a problem that prevented `coffee` command-line options from being parsed in some circumstances.
|
||||
|
||||
```
|
||||
releaseHeader('2010-07-11', '0.7.1', '0.7.0')
|
||||
```
|
||||
|
||||
Block-style comments are now passed through and printed as JavaScript block comments – making them useful for licenses and copyright headers. Better support for running coffee scripts standalone via hashbangs. Improved syntax errors for tokens that are not in the grammar.
|
||||
|
||||
```
|
||||
releaseHeader('2010-06-28', '0.7.0', '0.6.2')
|
||||
```
|
||||
|
||||
Official CoffeeScript variable style is now camelCase, as in JavaScript. Reserved words are now allowed as object keys, and will be quoted for you. Range comprehensions now generate cleaner code, but you have to specify `by -1` if you’d like to iterate downward. Reporting of syntax errors is greatly improved from the previous release. Running `coffee` with no arguments now launches the REPL, with Readline support. The `<-` bind operator has been removed from CoffeeScript. The `loop` keyword was added, which is equivalent to a `while true` loop. Comprehensions that contain closures will now close over their variables, like the semantics of a `forEach`. You can now use bound function in class definitions (bound to the instance). For consistency, `a in b` is now an array presence check, and `a of b` is an object-key check. Comments are no longer passed through to the generated JavaScript.
|
||||
|
||||
```
|
||||
releaseHeader('2010-05-15', '0.6.2', '0.6.1')
|
||||
```
|
||||
|
||||
The `coffee` command will now preserve directory structure when compiling a directory full of scripts. Fixed two omissions that were preventing the CoffeeScript compiler from running live within Internet Explorer. There’s now a syntax for block comments, similar in spirit to CoffeeScript’s heredocs. ECMA Harmony DRY-style pattern matching is now supported, where the name of the property is the same as the name of the value: `{name, length}: func`. Pattern matching is now allowed within comprehension variables. `unless` is now allowed in block form. `until` loops were added, as the inverse of `while` loops. `switch` statements are now allowed without switch object clauses. Compatible with Node.js **v0.1.95**.
|
||||
|
||||
```
|
||||
releaseHeader('2010-04-12', '0.6.1', '0.6.0')
|
||||
```
|
||||
|
||||
Upgraded CoffeeScript for compatibility with the new Node.js **v0.1.90** series.
|
||||
|
||||
```
|
||||
releaseHeader('2010-04-03', '0.6.0', '0.5.6')
|
||||
```
|
||||
|
||||
Trailing commas are now allowed, a-la Python. Static properties may be assigned directly within class definitions, using `@property` notation.
|
||||
|
||||
```
|
||||
releaseHeader('2010-03-23', '0.5.6', '0.5.5')
|
||||
```
|
||||
|
||||
Interpolation can now be used within regular expressions and heredocs, as well as strings. Added the `<-` bind operator. Allowing assignment to half-expressions instead of special `||=`-style operators. The arguments object is no longer automatically converted into an array. After requiring `coffeescript`, Node.js can now directly load `.coffee` files, thanks to **registerExtension**. Multiple splats can now be used in function calls, arrays, and pattern matching.
|
||||
|
||||
```
|
||||
releaseHeader('2010-03-08', '0.5.5', '0.5.4')
|
||||
```
|
||||
|
||||
String interpolation, contributed by [Stan Angeloff](https://github.com/StanAngeloff). Since `--run` has been the default since **0.5.3**, updating `--stdio` and `--eval` to run by default, pass `--compile` as well if you’d like to print the result.
|
||||
|
||||
```
|
||||
releaseHeader('2010-03-03', '0.5.4', '0.5.3')
|
||||
```
|
||||
|
||||
Bugfix that corrects the Node.js global constants `__filename` and `__dirname`. Tweaks for more flexible parsing of nested function literals and improperly-indented comments. Updates for the latest Node.js API.
|
||||
|
||||
```
|
||||
releaseHeader('2010-02-27', '0.5.3', '0.5.2')
|
||||
```
|
||||
|
||||
CoffeeScript now has a syntax for defining classes. Many of the core components (Nodes, Lexer, Rewriter, Scope, Optparse) are using them. Cakefiles can use `optparse.coffee` to define options for tasks. `--run` is now the default flag for the `coffee` command, use `--compile` to save JavaScripts. Bugfix for an ambiguity between RegExp literals and chained divisions.
|
||||
|
||||
```
|
||||
releaseHeader('2010-02-25', '0.5.2', '0.5.1')
|
||||
```
|
||||
|
||||
Added a compressed version of the compiler for inclusion in web pages as
|
||||
`/v<%= majorVersion %>/browser-compiler/coffeescript.js`. It’ll automatically run any script tags with type `text/coffeescript` for you. Added a `--stdio` option to the `coffee` command, for piped-in compiles.
|
||||
|
||||
```
|
||||
releaseHeader('2010-02-24', '0.5.1', '0.5.0')
|
||||
```
|
||||
|
||||
Improvements to null soaking with the existential operator, including soaks on indexed properties. Added conditions to `while` loops, so you can use them as filters with `when`, in the same manner as comprehensions.
|
||||
|
||||
```
|
||||
releaseHeader('2010-02-21', '0.5.0', '0.3.2')
|
||||
```
|
||||
|
||||
CoffeeScript 0.5.0 is a major release, While there are no language changes, the Ruby compiler has been removed in favor of a self-hosting compiler written in pure CoffeeScript.
|
||||
|
||||
```
|
||||
releaseHeader('2010-02-08', '0.3.2', '0.3.0')
|
||||
```
|
||||
|
||||
`@property` is now a shorthand for `this.property`.
|
||||
Switched the default JavaScript engine from Narwhal to Node.js. Pass the `--narwhal` flag if you’d like to continue using it.
|
||||
|
||||
```
|
||||
releaseHeader('2010-01-26', '0.3.0', '0.2.6')
|
||||
```
|
||||
|
||||
CoffeeScript 0.3 includes major syntax changes:
|
||||
The function symbol was changed to `->`, and the bound function symbol is now `=>`.
|
||||
Parameter lists in function definitions must now be wrapped in parentheses.
|
||||
Added property soaking, with the `?.` operator.
|
||||
Made parentheses optional, when invoking functions with arguments.
|
||||
Removed the obsolete block literal syntax.
|
||||
|
||||
```
|
||||
releaseHeader('2010-01-17', '0.2.6', '0.2.5')
|
||||
```
|
||||
|
||||
Added Python-style chained comparisons, the conditional existence operator `?=`, and some examples from _Beautiful Code_. Bugfixes relating to statement-to-expression conversion, arguments-to-array conversion, and the TextMate syntax highlighter.
|
||||
|
||||
```
|
||||
releaseHeader('2010-01-13', '0.2.5', '0.2.4')
|
||||
```
|
||||
|
||||
The conditions in switch statements can now take multiple values at once — If any of them are true, the case will run. Added the long arrow `==>`, which defines and immediately binds a function to `this`. While loops can now be used as expressions, in the same way that comprehensions can. Splats can be used within pattern matches to soak up the rest of an array.
|
||||
|
||||
```
|
||||
releaseHeader('2010-01-12', '0.2.4', '0.2.3')
|
||||
```
|
||||
|
||||
Added ECMAScript Harmony style destructuring assignment, for dealing with extracting values from nested arrays and objects. Added indentation-sensitive heredocs for nicely formatted strings or chunks of code.
|
||||
|
||||
```
|
||||
releaseHeader('2010-01-11', '0.2.3', '0.2.2')
|
||||
```
|
||||
|
||||
Axed the unsatisfactory `ino` keyword, replacing it with `of` for object comprehensions. They now look like: `for prop, value of object`.
|
||||
|
||||
```
|
||||
releaseHeader('2010-01-10', '0.2.2', '0.2.1')
|
||||
```
|
||||
|
||||
When performing a comprehension over an object, use `ino`, instead of `in`, which helps us generate smaller, more efficient code at compile time.
|
||||
Added `::` as a shorthand for saying `.prototype.`
|
||||
The “splat” symbol has been changed from a prefix asterisk `*`, to a postfix ellipsis `...`
|
||||
Added JavaScript’s `in` operator, empty `return` statements, and empty `while` loops.
|
||||
Constructor functions that start with capital letters now include a safety check to make sure that the new instance of the object is returned.
|
||||
The `extends` keyword now functions identically to `goog.inherits` in Google’s Closure Library.
|
||||
|
||||
```
|
||||
releaseHeader('2010-01-05', '0.2.1', '0.2.0')
|
||||
```
|
||||
|
||||
Arguments objects are now converted into real arrays when referenced.
|
||||
|
||||
```
|
||||
releaseHeader('2010-01-05', '0.2.0', '0.1.6')
|
||||
```
|
||||
|
||||
Major release. Significant whitespace. Better statement-to-expression conversion. Splats. Splice literals. Object comprehensions. Blocks. The existential operator. Many thanks to all the folks who posted issues, with special thanks to [Liam O’Connor-Davis](https://github.com/liamoc) for whitespace and expression help.
|
||||
|
||||
```
|
||||
releaseHeader('2009-12-27', '0.1.6', '0.1.5')
|
||||
```
|
||||
|
||||
Bugfix for running `coffee --interactive` and `--run` from outside of the CoffeeScript directory. Bugfix for nested function/if-statements.
|
||||
|
||||
```
|
||||
releaseHeader('2009-12-26', '0.1.5', '0.1.4')
|
||||
```
|
||||
|
||||
Array slice literals and array comprehensions can now both take Ruby-style ranges to specify the start and end. JavaScript variable declaration is now pushed up to the top of the scope, making all assignment statements into expressions. You can use `\` to escape newlines. The `coffeescript` command is now called `coffee`.
|
||||
|
||||
```
|
||||
releaseHeader('2009-12-25', '0.1.4', '0.1.3')
|
||||
```
|
||||
|
||||
The official CoffeeScript extension is now `.coffee` instead of `.cs`, which properly belongs to [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)). Due to popular demand, you can now also use `=` to assign. Unlike JavaScript, `=` can also be used within object literals, interchangeably with `:`. Made a grammatical fix for chained function calls like `func(1)(2)(3)(4)`. Inheritance and super no longer use `__proto__`, so they should be IE-compatible now.
|
||||
|
||||
```
|
||||
releaseHeader('2009-12-25', '0.1.3', '0.1.2')
|
||||
```
|
||||
|
||||
The `coffee` command now includes `--interactive`, which launches an interactive CoffeeScript session, and `--run`, which directly compiles and executes a script. Both options depend on a working installation of Narwhal. The `aint` keyword has been replaced by `isnt`, which goes together a little smoother with `is`. Quoted strings are now allowed as identifiers within object literals: eg. `{"5+5": 10}`. All assignment operators now use a colon: `+:`, `-:`, `*:`, etc.
|
||||
|
||||
```
|
||||
releaseHeader('2009-12-24', '0.1.2', '0.1.1')
|
||||
```
|
||||
|
||||
Fixed a bug with calling `super()` through more than one level of inheritance, with the re-addition of the `extends` keyword. Added experimental [Narwhal](http://narwhaljs.org/) support (as a Tusk package), contributed by [Tom Robinson](http://blog.tlrobinson.net/), including **bin/cs** as a CoffeeScript REPL and interpreter. New `--no-wrap` option to suppress the safety function wrapper.
|
||||
|
||||
```
|
||||
releaseHeader('2009-12-24', '0.1.1', '0.1.0')
|
||||
```
|
||||
|
||||
Added `instanceof` and `typeof` as operators.
|
||||
|
||||
```
|
||||
releaseHeader('2009-12-24', '0.1.0', '8e9d637985d2dc9b44922076ad54ffef7fa8e9c2')
|
||||
```
|
||||
|
||||
Initial CoffeeScript release.
|
||||
|
||||
5
documentation/sections/changelog/0.1.0.md
Normal file
5
documentation/sections/changelog/0.1.0.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2009-12-24', '0.1.0', '8e9d637985d2dc9b44922076ad54ffef7fa8e9c2')
|
||||
```
|
||||
|
||||
Initial CoffeeScript release.
|
||||
5
documentation/sections/changelog/0.1.1.md
Normal file
5
documentation/sections/changelog/0.1.1.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2009-12-24', '0.1.1', '0.1.0')
|
||||
```
|
||||
|
||||
Added `instanceof` and `typeof` as operators.
|
||||
5
documentation/sections/changelog/0.1.2.md
Normal file
5
documentation/sections/changelog/0.1.2.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2009-12-24', '0.1.2', '0.1.1')
|
||||
```
|
||||
|
||||
Fixed a bug with calling `super()` through more than one level of inheritance, with the re-addition of the `extends` keyword. Added experimental [Narwhal](http://narwhaljs.org/) support (as a Tusk package), contributed by [Tom Robinson](http://blog.tlrobinson.net/), including **bin/cs** as a CoffeeScript REPL and interpreter. New `--no-wrap` option to suppress the safety function wrapper.
|
||||
5
documentation/sections/changelog/0.1.3.md
Normal file
5
documentation/sections/changelog/0.1.3.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2009-12-25', '0.1.3', '0.1.2')
|
||||
```
|
||||
|
||||
The `coffee` command now includes `--interactive`, which launches an interactive CoffeeScript session, and `--run`, which directly compiles and executes a script. Both options depend on a working installation of Narwhal. The `aint` keyword has been replaced by `isnt`, which goes together a little smoother with `is`. Quoted strings are now allowed as identifiers within object literals: eg. `{"5+5": 10}`. All assignment operators now use a colon: `+:`, `-:`, `*:`, etc.
|
||||
5
documentation/sections/changelog/0.1.4.md
Normal file
5
documentation/sections/changelog/0.1.4.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2009-12-25', '0.1.4', '0.1.3')
|
||||
```
|
||||
|
||||
The official CoffeeScript extension is now `.coffee` instead of `.cs`, which properly belongs to [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)). Due to popular demand, you can now also use `=` to assign. Unlike JavaScript, `=` can also be used within object literals, interchangeably with `:`. Made a grammatical fix for chained function calls like `func(1)(2)(3)(4)`. Inheritance and super no longer use `__proto__`, so they should be IE-compatible now.
|
||||
5
documentation/sections/changelog/0.1.5.md
Normal file
5
documentation/sections/changelog/0.1.5.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2009-12-26', '0.1.5', '0.1.4')
|
||||
```
|
||||
|
||||
Array slice literals and array comprehensions can now both take Ruby-style ranges to specify the start and end. JavaScript variable declaration is now pushed up to the top of the scope, making all assignment statements into expressions. You can use `\` to escape newlines. The `coffeescript` command is now called `coffee`.
|
||||
5
documentation/sections/changelog/0.1.6.md
Normal file
5
documentation/sections/changelog/0.1.6.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2009-12-27', '0.1.6', '0.1.5')
|
||||
```
|
||||
|
||||
Bugfix for running `coffee --interactive` and `--run` from outside of the CoffeeScript directory. Bugfix for nested function/if-statements.
|
||||
5
documentation/sections/changelog/0.2.0.md
Normal file
5
documentation/sections/changelog/0.2.0.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-01-05', '0.2.0', '0.1.6')
|
||||
```
|
||||
|
||||
Major release. Significant whitespace. Better statement-to-expression conversion. Splats. Splice literals. Object comprehensions. Blocks. The existential operator. Many thanks to all the folks who posted issues, with special thanks to [Liam O’Connor-Davis](https://github.com/liamoc) for whitespace and expression help.
|
||||
5
documentation/sections/changelog/0.2.1.md
Normal file
5
documentation/sections/changelog/0.2.1.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-01-05', '0.2.1', '0.2.0')
|
||||
```
|
||||
|
||||
Arguments objects are now converted into real arrays when referenced.
|
||||
10
documentation/sections/changelog/0.2.2.md
Normal file
10
documentation/sections/changelog/0.2.2.md
Normal file
@@ -0,0 +1,10 @@
|
||||
```
|
||||
releaseHeader('2010-01-10', '0.2.2', '0.2.1')
|
||||
```
|
||||
|
||||
When performing a comprehension over an object, use `ino`, instead of `in`, which helps us generate smaller, more efficient code at compile time.
|
||||
Added `::` as a shorthand for saying `.prototype.`
|
||||
The “splat” symbol has been changed from a prefix asterisk `*`, to a postfix ellipsis `...`
|
||||
Added JavaScript’s `in` operator, empty `return` statements, and empty `while` loops.
|
||||
Constructor functions that start with capital letters now include a safety check to make sure that the new instance of the object is returned.
|
||||
The `extends` keyword now functions identically to `goog.inherits` in Google’s Closure Library.
|
||||
5
documentation/sections/changelog/0.2.3.md
Normal file
5
documentation/sections/changelog/0.2.3.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-01-11', '0.2.3', '0.2.2')
|
||||
```
|
||||
|
||||
Axed the unsatisfactory `ino` keyword, replacing it with `of` for object comprehensions. They now look like: `for prop, value of object`.
|
||||
5
documentation/sections/changelog/0.2.4.md
Normal file
5
documentation/sections/changelog/0.2.4.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-01-12', '0.2.4', '0.2.3')
|
||||
```
|
||||
|
||||
Added ECMAScript Harmony style destructuring assignment, for dealing with extracting values from nested arrays and objects. Added indentation-sensitive heredocs for nicely formatted strings or chunks of code.
|
||||
5
documentation/sections/changelog/0.2.5.md
Normal file
5
documentation/sections/changelog/0.2.5.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-01-13', '0.2.5', '0.2.4')
|
||||
```
|
||||
|
||||
The conditions in switch statements can now take multiple values at once — If any of them are true, the case will run. Added the long arrow `==>`, which defines and immediately binds a function to `this`. While loops can now be used as expressions, in the same way that comprehensions can. Splats can be used within pattern matches to soak up the rest of an array.
|
||||
5
documentation/sections/changelog/0.2.6.md
Normal file
5
documentation/sections/changelog/0.2.6.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-01-17', '0.2.6', '0.2.5')
|
||||
```
|
||||
|
||||
Added Python-style chained comparisons, the conditional existence operator `?=`, and some examples from _Beautiful Code_. Bugfixes relating to statement-to-expression conversion, arguments-to-array conversion, and the TextMate syntax highlighter.
|
||||
10
documentation/sections/changelog/0.3.0.md
Normal file
10
documentation/sections/changelog/0.3.0.md
Normal file
@@ -0,0 +1,10 @@
|
||||
```
|
||||
releaseHeader('2010-01-26', '0.3.0', '0.2.6')
|
||||
```
|
||||
|
||||
CoffeeScript 0.3 includes major syntax changes:
|
||||
The function symbol was changed to `->`, and the bound function symbol is now `=>`.
|
||||
Parameter lists in function definitions must now be wrapped in parentheses.
|
||||
Added property soaking, with the `?.` operator.
|
||||
Made parentheses optional, when invoking functions with arguments.
|
||||
Removed the obsolete block literal syntax.
|
||||
6
documentation/sections/changelog/0.3.2.md
Normal file
6
documentation/sections/changelog/0.3.2.md
Normal file
@@ -0,0 +1,6 @@
|
||||
```
|
||||
releaseHeader('2010-02-08', '0.3.2', '0.3.0')
|
||||
```
|
||||
|
||||
`@property` is now a shorthand for `this.property`.
|
||||
Switched the default JavaScript engine from Narwhal to Node.js. Pass the `--narwhal` flag if you’d like to continue using it.
|
||||
5
documentation/sections/changelog/0.5.0.md
Normal file
5
documentation/sections/changelog/0.5.0.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-02-21', '0.5.0', '0.3.2')
|
||||
```
|
||||
|
||||
CoffeeScript 0.5.0 is a major release, While there are no language changes, the Ruby compiler has been removed in favor of a self-hosting compiler written in pure CoffeeScript.
|
||||
5
documentation/sections/changelog/0.5.1.md
Normal file
5
documentation/sections/changelog/0.5.1.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-02-24', '0.5.1', '0.5.0')
|
||||
```
|
||||
|
||||
Improvements to null soaking with the existential operator, including soaks on indexed properties. Added conditions to `while` loops, so you can use them as filters with `when`, in the same manner as comprehensions.
|
||||
6
documentation/sections/changelog/0.5.2.md
Normal file
6
documentation/sections/changelog/0.5.2.md
Normal file
@@ -0,0 +1,6 @@
|
||||
```
|
||||
releaseHeader('2010-02-25', '0.5.2', '0.5.1')
|
||||
```
|
||||
|
||||
Added a compressed version of the compiler for inclusion in web pages as
|
||||
`/v<%= majorVersion %>/browser-compiler-legacy/coffeescript.js`. It’ll automatically run any script tags with type `text/coffeescript` for you. Added a `--stdio` option to the `coffee` command, for piped-in compiles.
|
||||
5
documentation/sections/changelog/0.5.3.md
Normal file
5
documentation/sections/changelog/0.5.3.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-02-27', '0.5.3', '0.5.2')
|
||||
```
|
||||
|
||||
CoffeeScript now has a syntax for defining classes. Many of the core components (Nodes, Lexer, Rewriter, Scope, Optparse) are using them. Cakefiles can use `optparse.coffee` to define options for tasks. `--run` is now the default flag for the `coffee` command, use `--compile` to save JavaScripts. Bugfix for an ambiguity between RegExp literals and chained divisions.
|
||||
5
documentation/sections/changelog/0.5.4.md
Normal file
5
documentation/sections/changelog/0.5.4.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-03-03', '0.5.4', '0.5.3')
|
||||
```
|
||||
|
||||
Bugfix that corrects the Node.js global constants `__filename` and `__dirname`. Tweaks for more flexible parsing of nested function literals and improperly-indented comments. Updates for the latest Node.js API.
|
||||
5
documentation/sections/changelog/0.5.5.md
Normal file
5
documentation/sections/changelog/0.5.5.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-03-08', '0.5.5', '0.5.4')
|
||||
```
|
||||
|
||||
String interpolation, contributed by [Stan Angeloff](https://github.com/StanAngeloff). Since `--run` has been the default since **0.5.3**, updating `--stdio` and `--eval` to run by default, pass `--compile` as well if you’d like to print the result.
|
||||
5
documentation/sections/changelog/0.5.6.md
Normal file
5
documentation/sections/changelog/0.5.6.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-03-23', '0.5.6', '0.5.5')
|
||||
```
|
||||
|
||||
Interpolation can now be used within regular expressions and heredocs, as well as strings. Added the `<-` bind operator. Allowing assignment to half-expressions instead of special `||=`-style operators. The arguments object is no longer automatically converted into an array. After requiring `coffeescript`, Node.js can now directly load `.coffee` files, thanks to **registerExtension**. Multiple splats can now be used in function calls, arrays, and pattern matching.
|
||||
5
documentation/sections/changelog/0.6.0.md
Normal file
5
documentation/sections/changelog/0.6.0.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-04-03', '0.6.0', '0.5.6')
|
||||
```
|
||||
|
||||
Trailing commas are now allowed, a-la Python. Static properties may be assigned directly within class definitions, using `@property` notation.
|
||||
5
documentation/sections/changelog/0.6.1.md
Normal file
5
documentation/sections/changelog/0.6.1.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-04-12', '0.6.1', '0.6.0')
|
||||
```
|
||||
|
||||
Upgraded CoffeeScript for compatibility with the new Node.js **v0.1.90** series.
|
||||
5
documentation/sections/changelog/0.6.2.md
Normal file
5
documentation/sections/changelog/0.6.2.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-05-15', '0.6.2', '0.6.1')
|
||||
```
|
||||
|
||||
The `coffee` command will now preserve directory structure when compiling a directory full of scripts. Fixed two omissions that were preventing the CoffeeScript compiler from running live within Internet Explorer. There’s now a syntax for block comments, similar in spirit to CoffeeScript’s heredocs. ECMA Harmony DRY-style pattern matching is now supported, where the name of the property is the same as the name of the value: `{name, length}: func`. Pattern matching is now allowed within comprehension variables. `unless` is now allowed in block form. `until` loops were added, as the inverse of `while` loops. `switch` statements are now allowed without switch object clauses. Compatible with Node.js **v0.1.95**.
|
||||
5
documentation/sections/changelog/0.7.0.md
Normal file
5
documentation/sections/changelog/0.7.0.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-06-28', '0.7.0', '0.6.2')
|
||||
```
|
||||
|
||||
Official CoffeeScript variable style is now camelCase, as in JavaScript. Reserved words are now allowed as object keys, and will be quoted for you. Range comprehensions now generate cleaner code, but you have to specify `by -1` if you’d like to iterate downward. Reporting of syntax errors is greatly improved from the previous release. Running `coffee` with no arguments now launches the REPL, with Readline support. The `<-` bind operator has been removed from CoffeeScript. The `loop` keyword was added, which is equivalent to a `while true` loop. Comprehensions that contain closures will now close over their variables, like the semantics of a `forEach`. You can now use bound function in class definitions (bound to the instance). For consistency, `a in b` is now an array presence check, and `a of b` is an object-key check. Comments are no longer passed through to the generated JavaScript.
|
||||
5
documentation/sections/changelog/0.7.1.md
Normal file
5
documentation/sections/changelog/0.7.1.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-07-11', '0.7.1', '0.7.0')
|
||||
```
|
||||
|
||||
Block-style comments are now passed through and printed as JavaScript block comments – making them useful for licenses and copyright headers. Better support for running coffee scripts standalone via hashbangs. Improved syntax errors for tokens that are not in the grammar.
|
||||
5
documentation/sections/changelog/0.7.2.md
Normal file
5
documentation/sections/changelog/0.7.2.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-07-12', '0.7.2', '0.7.1')
|
||||
```
|
||||
|
||||
Quick bugfix (right after 0.7.1) for a problem that prevented `coffee` command-line options from being parsed in some circumstances.
|
||||
5
documentation/sections/changelog/0.9.0.md
Normal file
5
documentation/sections/changelog/0.9.0.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-08-04', '0.9.0', '0.7.2')
|
||||
```
|
||||
|
||||
The CoffeeScript **0.9** series is considered to be a release candidate for **1.0**; let’s give her a shakedown cruise. **0.9.0** introduces a massive backwards-incompatible change: Assignment now uses `=`, and object literals use `:`, as in JavaScript. This allows us to have implicit object literals, and YAML-style object definitions. Half assignments are removed, in favor of `+=`, `or=`, and friends. Interpolation now uses a hash mark `#` instead of the dollar sign `$` — because dollar signs may be part of a valid JS identifier. Downwards range comprehensions are now safe again, and are optimized to straight for loops when created with integer endpoints. A fast, unguarded form of object comprehension was added: `for all key, value of object`. Mentioning the `super` keyword with no arguments now forwards all arguments passed to the function, as in Ruby. If you extend class `B` from parent class `A`, if `A` has an `extended` method defined, it will be called, passing in `B` — this enables static inheritance, among other things. Cleaner output for functions bound with the fat arrow. `@variables` can now be used in parameter lists, with the parameter being automatically set as a property on the object — useful in constructors and setter functions. Constructor functions can now take splats.
|
||||
5
documentation/sections/changelog/0.9.1.md
Normal file
5
documentation/sections/changelog/0.9.1.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-08-11', '0.9.1', '0.9.0')
|
||||
```
|
||||
|
||||
Bugfix release for **0.9.1**. Greatly improves the handling of mixed implicit objects, implicit function calls, and implicit indentation. String and regex interpolation is now strictly `#{ … }` (Ruby style). The compiler now takes a `--require` flag, which specifies scripts to run before compilation.
|
||||
5
documentation/sections/changelog/0.9.2.md
Normal file
5
documentation/sections/changelog/0.9.2.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-08-23', '0.9.2', '0.9.1')
|
||||
```
|
||||
|
||||
Specifying the start and end of a range literal is now optional, eg. `array[3..]`. You can now say `a not instanceof b`. Fixed important bugs with nested significant and non-significant indentation (Issue #637). Added a `--require` flag that allows you to hook into the `coffee` command. Added a custom `jsl.conf` file for our preferred JavaScriptLint setup. Sped up Jison grammar compilation time by flattening rules for operations. Block comments can now be used with JavaScript-minifier-friendly syntax. Added JavaScript’s compound assignment bitwise operators. Bugfixes to implicit object literals with leading number and string keys, as the subject of implicit calls, and as part of compound assignment.
|
||||
5
documentation/sections/changelog/0.9.3.md
Normal file
5
documentation/sections/changelog/0.9.3.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-09-16', '0.9.3', '0.9.2')
|
||||
```
|
||||
|
||||
CoffeeScript `switch` statements now compile into JS `switch` statements — they previously compiled into `if/else` chains for JavaScript 1.3 compatibility. Soaking a function invocation is now supported. Users of the RubyMine editor should now be able to use `--watch` mode.
|
||||
5
documentation/sections/changelog/0.9.4.md
Normal file
5
documentation/sections/changelog/0.9.4.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-09-21', '0.9.4', '0.9.3')
|
||||
```
|
||||
|
||||
CoffeeScript now uses appropriately-named temporary variables, and recycles their references after use. Added `require.extensions` support for **Node.js 0.3**. Loading CoffeeScript in the browser now adds just a single `CoffeeScript` object to global scope. Fixes for implicit object and block comment edge cases.
|
||||
7
documentation/sections/changelog/0.9.5.md
Normal file
7
documentation/sections/changelog/0.9.5.md
Normal file
@@ -0,0 +1,7 @@
|
||||
```
|
||||
releaseHeader('2010-11-21', '0.9.5', '0.9.4')
|
||||
```
|
||||
|
||||
0.9.5 should be considered the first release candidate for CoffeeScript 1.0. There have been a large number of internal changes since the previous release, many contributed from **satyr**’s [Coco](https://github.com/satyr/coco) dialect of CoffeeScript. Heregexes (extended regexes) were added. Functions can now have default arguments. Class bodies are now executable code. Improved syntax errors for invalid CoffeeScript. `undefined` now works like `null`, and cannot be assigned a new value. There was a precedence change with respect to single-line comprehensions: `result = i for i in list`
|
||||
used to parse as `result = (i for i in list)` by default … it now parses as
|
||||
`(result = i) for i in list`.
|
||||
5
documentation/sections/changelog/0.9.6.md
Normal file
5
documentation/sections/changelog/0.9.6.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-12-06', '0.9.6', '0.9.5')
|
||||
```
|
||||
|
||||
The REPL now properly formats stacktraces, and stays alive through asynchronous exceptions. Using `--watch` now prints timestamps as files are compiled. Fixed some accidentally-leaking variables within plucked closure-loops. Constructors now maintain their declaration location within a class body. Dynamic object keys were removed. Nested classes are now supported. Fixes execution context for naked splatted functions. Bugfix for inversion of chained comparisons. Chained class instantiation now works properly with splats.
|
||||
5
documentation/sections/changelog/1.0.0.md
Normal file
5
documentation/sections/changelog/1.0.0.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2010-12-24', '1.0.0', '0.9.6')
|
||||
```
|
||||
|
||||
CoffeeScript loops no longer try to preserve block scope when functions are being generated within the loop body. Instead, you can use the `do` keyword to create a convenient closure wrapper. Added a `--nodejs` flag for passing through options directly to the `node` executable. Better behavior around the use of pure statements within expressions. Fixed inclusive slicing through `-1`, for all browsers, and splicing with arbitrary expressions as endpoints.
|
||||
5
documentation/sections/changelog/1.0.1.md
Normal file
5
documentation/sections/changelog/1.0.1.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2011-01-31', '1.0.1', '1.0.0')
|
||||
```
|
||||
|
||||
Fixed a lexer bug with Unicode identifiers. Updated REPL for compatibility with Node.js 0.3.7\. Fixed requiring relative paths in the REPL. Trailing `return` and `return undefined` are now optimized away. Stopped requiring the core Node.js `util` module for back-compatibility with Node.js 0.2.5\. Fixed a case where a conditional `return` would cause fallthrough in a `switch` statement. Optimized empty objects in destructuring assignment.
|
||||
5
documentation/sections/changelog/1.1.0.md
Normal file
5
documentation/sections/changelog/1.1.0.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2011-05-01', '1.1.0', '1.0.1')
|
||||
```
|
||||
|
||||
When running via the `coffee` executable, `process.argv` and friends now report `coffee` instead of `node`. Better compatibility with **Node.js 0.4.x** module lookup changes. The output in the REPL is now colorized, like Node’s is. Giving your concatenated CoffeeScripts a name when using `--join` is now mandatory. Fix for lexing compound division `/=` as a regex accidentally. All `text/coffeescript` tags should now execute in the order they’re included. Fixed an issue with extended subclasses using external constructor functions. Fixed an edge-case infinite loop in `addImplicitParentheses`. Fixed exponential slowdown with long chains of function calls. Globals no longer leak into the CoffeeScript REPL. Splatted parameters are declared local to the function.
|
||||
5
documentation/sections/changelog/1.1.1.md
Normal file
5
documentation/sections/changelog/1.1.1.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2011-05-10', '1.1.1', '1.1.0')
|
||||
```
|
||||
|
||||
Bugfix release for classes with external constructor functions, see issue #1182.
|
||||
5
documentation/sections/changelog/1.1.2.md
Normal file
5
documentation/sections/changelog/1.1.2.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2011-08-04', '1.1.2', '1.1.1')
|
||||
```
|
||||
|
||||
Fixes for block comment formatting, `?=` compilation, implicit calls against control structures, implicit invocation of a try/catch block, variadic arguments leaking from local scope, line numbers in syntax errors following heregexes, property access on parenthesized number literals, bound class methods and super with reserved names, a REPL overhaul, consecutive compiled semicolons, block comments in implicitly called objects, and a Chrome bug.
|
||||
11
documentation/sections/changelog/1.1.3.md
Normal file
11
documentation/sections/changelog/1.1.3.md
Normal file
@@ -0,0 +1,11 @@
|
||||
```
|
||||
releaseHeader('2011-11-08', '1.1.3', '1.1.2')
|
||||
```
|
||||
|
||||
* Ahh, whitespace. CoffeeScript’s compiled JS now tries to space things out and keep it readable, as you can see in the examples on this page.
|
||||
* You can now call `super` in class level methods in class bodies, and bound class methods now preserve their correct context.
|
||||
* JavaScript has always supported octal numbers `010 is 8`, and hexadecimal numbers `0xf is 15`, but CoffeeScript now also supports binary numbers: `0b10 is 2`.
|
||||
* The CoffeeScript module has been nested under a subdirectory to make it easier to `require` individual components separately, without having to use **npm**. For example, after adding the CoffeeScript folder to your path: `require('coffeescript/lexer')`
|
||||
* There’s a new “link” feature in Try CoffeeScript on this webpage. Use it to get a shareable permalink for your example script.
|
||||
* The `coffee --watch` feature now only works on Node.js 0.6.0 and higher, but now also works properly on Windows.
|
||||
* Lots of small bug fixes from **[@michaelficarra](https://github.com/michaelficarra)**, **[@geraldalewis](https://github.com/geraldalewis)**, **[@satyr](https://github.com/satyr)**, and **[@trevorburnham](https://github.com/trevorburnham)**.
|
||||
11
documentation/sections/changelog/1.10.0.md
Normal file
11
documentation/sections/changelog/1.10.0.md
Normal file
@@ -0,0 +1,11 @@
|
||||
```
|
||||
releaseHeader('2015-09-03', '1.10.0', '1.9.3')
|
||||
```
|
||||
|
||||
* CoffeeScript now supports ES2015-style destructuring defaults.
|
||||
* `(offsetHeight: height) ->` no longer compiles. That syntax was accidental and partly broken. Use `({offsetHeight: height}) ->` instead. Object destructuring always requires braces.
|
||||
* Several minor bug fixes, including:
|
||||
* A bug where the REPL would sometimes report valid code as invalid, based on what you had typed earlier.
|
||||
* A problem with multiple JS contexts in the jest test framework.
|
||||
* An error in io.js where strict mode is set on internal modules.
|
||||
* A variable name clash for the caught error in `catch` blocks.
|
||||
31
documentation/sections/changelog/1.11.0.md
Normal file
31
documentation/sections/changelog/1.11.0.md
Normal file
@@ -0,0 +1,31 @@
|
||||
```
|
||||
releaseHeader('2016-09-24', '1.11.0', '1.10.0')
|
||||
```
|
||||
|
||||
* CoffeeScript now supports ES2015 [`import` and `export` syntax](#modules).
|
||||
* Added the `-M, --inline-map` flag to the compiler, allowing you embed the source map directly into the output JavaScript, rather than as a separate file.
|
||||
* A bunch of fixes for `yield`:
|
||||
* `yield return` can no longer mistakenly be used as an expression.
|
||||
* `yield` now mirrors `return` in that it can be used stand-alone as well as with expressions. Where you previously wrote `yield undefined`, you may now write simply `yield`. However, this means also inheriting the same syntax limitations that `return` has, so these examples no longer compile:
|
||||
```
|
||||
doubles = ->
|
||||
yield for i in [1..3]
|
||||
i * 2
|
||||
six = ->
|
||||
yield
|
||||
2 * 3
|
||||
```
|
||||
* The JavaScript output is a bit nicer, with unnecessary parentheses and spaces, double indentation and double semicolons around `yield` no longer present.
|
||||
* `&&=`, `||=`, `and=` and `or=` no longer accidentally allow a space before the equals sign.
|
||||
* Improved several error messages.
|
||||
* Just like `undefined` compiles to `void 0`, `NaN` now compiles into `0/0` and `Infinity` into `2e308`.
|
||||
* Bugfix for renamed destructured parameters with defaults. `({a: b = 1}) ->` no longer crashes the compiler.
|
||||
* Improved the internal representation of a CoffeeScript program. This is only noticeable to tools that use `CoffeeScript.tokens` or `CoffeeScript.nodes`. Such tools need to update to take account for changed or added tokens and nodes.
|
||||
* Several minor bug fixes, including:
|
||||
* The caught error in `catch` blocks is no longer declared unnecessarily, and no longer mistakenly named `undefined` for `catch`-less `try` blocks.
|
||||
* Unassignable parameter destructuring no longer crashes the compiler.
|
||||
* Source maps are now used correctly for errors thrown from .coffee.md files.
|
||||
* `coffee -e 'throw null'` no longer crashes.
|
||||
* The REPL no longer crashes when using `.exit` to exit it.
|
||||
* Invalid JavaScript is no longer output when lots of `for` loops are used in the same scope.
|
||||
* A unicode issue when using stdin with the CLI.
|
||||
8
documentation/sections/changelog/1.11.1.md
Normal file
8
documentation/sections/changelog/1.11.1.md
Normal file
@@ -0,0 +1,8 @@
|
||||
```
|
||||
releaseHeader('2016-10-02', '1.11.1', '1.11.0')
|
||||
```
|
||||
|
||||
* Bugfix for shorthand object syntax after interpolated keys.
|
||||
* Bugfix for indentation-stripping in `"""` strings.
|
||||
* Bugfix for not being able to use the name “arguments” for a prototype property of class.
|
||||
* Correctly compile large hexadecimal numbers literals to `2e308` (just like all other large number literals do).
|
||||
12
documentation/sections/changelog/1.12.0.md
Normal file
12
documentation/sections/changelog/1.12.0.md
Normal file
@@ -0,0 +1,12 @@
|
||||
```
|
||||
releaseHeader('2016-12-04', '1.12.0', '1.11.1')
|
||||
```
|
||||
|
||||
* CoffeeScript now supports ES2015 [tagged template literals](#tagged-template-literals). Note that using tagged template literals in your code makes you responsible for ensuring that either your runtime supports tagged template literals or that you transpile the output JavaScript further to a version your target runtime(s) support.
|
||||
* CoffeeScript now provides a [`for…from`](#generator-iteration) syntax for outputting ES2015 [`for…of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of). (Sorry they couldn’t match, but we came up with `for…of` first for something else.) This allows iterating over generators or any other iterable object. Note that using `for…from` in your code makes you responsible for ensuring that either your runtime supports `for…of` or that you transpile the output JavaScript further to a version your target runtime(s) support.
|
||||
* Triple backticks (`` `````) allow the creation of embedded JavaScript blocks where escaping single backticks is not required, which should improve interoperability with ES2015 template literals and with Markdown.
|
||||
* Within single-backtick embedded JavaScript, backticks can now be escaped via `` \```.
|
||||
* The browser tests now run in the browser again, and are accessible [here](/v<%= majorVersion %>/test.html) if you would like to test your browser.
|
||||
* CoffeeScript-only keywords in ES2015 `import`s and `export`s are now ignored.
|
||||
* The compiler now throws an error on trying to export an anonymous class.
|
||||
* Bugfixes related to tokens and location data, for better source maps and improved compatibility with downstream tools.
|
||||
6
documentation/sections/changelog/1.12.1.md
Normal file
6
documentation/sections/changelog/1.12.1.md
Normal file
@@ -0,0 +1,6 @@
|
||||
```
|
||||
releaseHeader('2016-12-07', '1.12.1', '1.12.0')
|
||||
```
|
||||
|
||||
* You can now import a module member named `default`, e.g. `import { default } from 'lib'`. Though like in ES2015, you cannot import an entire module and name it `default` (so `import default from 'lib'` is not allowed).
|
||||
* Fix regression where `from` as a variable name was breaking `for` loop declarations. For the record, `from` is not a reserved word in CoffeeScript; you may use it for variable names. `from` behaves like a keyword within the context of `import` and `export` statements, and in the declaration of a `for` loop; though you should also be able to use variables named `from` in those contexts, and the compiler should be able to tell the difference.
|
||||
8
documentation/sections/changelog/1.12.2.md
Normal file
8
documentation/sections/changelog/1.12.2.md
Normal file
@@ -0,0 +1,8 @@
|
||||
```
|
||||
releaseHeader('2016-12-16', '1.12.2', '1.12.1')
|
||||
```
|
||||
|
||||
* The browser compiler can once again be built unminified via `MINIFY=false cake build:browser`.
|
||||
* The error-prone patched version of `Error.prepareStackTrace` has been removed.
|
||||
* Command completion in the REPL (pressing tab to get suggestions) has been fixed for Node 6.9.1+.
|
||||
* The [browser-based tests](/v<%= majorVersion %>/test.html) now include all the tests as the Node-based version.
|
||||
7
documentation/sections/changelog/1.12.3.md
Normal file
7
documentation/sections/changelog/1.12.3.md
Normal file
@@ -0,0 +1,7 @@
|
||||
```
|
||||
releaseHeader('2017-01-24', '1.12.3', '1.12.2')
|
||||
```
|
||||
|
||||
* `@` values can now be used as indices in `for` expressions. This loosens the compilation of `for` expressions to allow the index variable to be an `@` value, e.g. `do @visit for @node, @index in nodes`. Within `@visit`, the index of the current node (`@node`) would be available as `@index`.
|
||||
* CoffeeScript’s patched `Error.prepareStackTrace` has been restored, with some revisions that should prevent the erroneous exceptions that were making life difficult for some downstream projects. This fixes the incorrect line numbers in stack traces since 1.12.2.
|
||||
* The `//=` operator’s output now wraps parentheses around the right operand, like the other assignment operators.
|
||||
8
documentation/sections/changelog/1.12.4.md
Normal file
8
documentation/sections/changelog/1.12.4.md
Normal file
@@ -0,0 +1,8 @@
|
||||
```
|
||||
releaseHeader('2017-02-18', '1.12.4', '1.12.3')
|
||||
```
|
||||
|
||||
* The `cake` commands have been updated, with new `watch` options for most tasks. Clone the [CoffeeScript repo](https://github.com/jashkenas/coffeescript) and run `cake` at the root of the repo to see the options.
|
||||
* Fixed a bug where `export`ing a referenced variable was preventing the variable from being declared.
|
||||
* Fixed a bug where the `coffee` command wasn’t working for a `.litcoffee` file.
|
||||
* Bugfixes related to tokens and location data, for better source maps and improved compatibility with downstream tools.
|
||||
6
documentation/sections/changelog/1.12.5.md
Normal file
6
documentation/sections/changelog/1.12.5.md
Normal file
@@ -0,0 +1,6 @@
|
||||
```
|
||||
releaseHeader('2017-04-10', '1.12.5', '1.12.4')
|
||||
```
|
||||
|
||||
* Better handling of `default`, `from`, `as` and `*` within `import` and `export` statements. You can now import or export a member named `default` and the compiler won’t interpret it as the `default` keyword.
|
||||
* Fixed a bug where invalid octal escape sequences weren’t throwing errors in the compiler.
|
||||
10
documentation/sections/changelog/1.12.6.md
Normal file
10
documentation/sections/changelog/1.12.6.md
Normal file
@@ -0,0 +1,10 @@
|
||||
```
|
||||
releaseHeader('2017-05-15', '1.12.6', '1.12.5')
|
||||
```
|
||||
|
||||
* The `return` and `export` keywords can now accept implicit objects (defined by indentation, without needing braces).
|
||||
* Support Unicode code point escapes (e.g. `\u{1F4A9}`).
|
||||
* The `coffee` command now first looks to see if CoffeeScript is installed under `node_modules` in the current folder, and executes the `coffee` binary there if so; or otherwise it runs the globally installed one. This allows you to have one version of CoffeeScript installed globally and a different one installed locally for a particular project. (Likewise for the `cake` command.)
|
||||
* Bugfixes for chained function calls not closing implicit objects or ternaries.
|
||||
* Bugfixes for incorrect code generated by the `?` operator within a termary `if` statement.
|
||||
* Fixed some tests, and failing tests now result in a nonzero exit code.
|
||||
6
documentation/sections/changelog/1.12.7.md
Normal file
6
documentation/sections/changelog/1.12.7.md
Normal file
@@ -0,0 +1,6 @@
|
||||
```
|
||||
releaseHeader('2017-07-16', '1.12.7', '1.12.6')
|
||||
```
|
||||
|
||||
* Fix regressions in 1.12.6 related to chained function calls and indented `return` and `throw` arguments.
|
||||
* The REPL no longer warns about assigning to `_`.
|
||||
8
documentation/sections/changelog/1.2.0.md
Normal file
8
documentation/sections/changelog/1.2.0.md
Normal file
@@ -0,0 +1,8 @@
|
||||
```
|
||||
releaseHeader('2011-12-18', '1.2.0', '1.1.3')
|
||||
```
|
||||
|
||||
* Multiple improvements to `coffee --watch` and `--join`. You may now use both together, as well as add and remove files and directories within a `--watch`’d folder.
|
||||
* The `throw` statement can now be used as part of an expression.
|
||||
* Block comments at the top of the file will now appear outside of the safety closure wrapper.
|
||||
* Fixed a number of minor 1.1.3 regressions having to do with trailing operators and unfinished lines, and a more major 1.1.3 regression that caused bound functions _within_ bound class functions to have the incorrect `this`.
|
||||
12
documentation/sections/changelog/1.3.1.md
Normal file
12
documentation/sections/changelog/1.3.1.md
Normal file
@@ -0,0 +1,12 @@
|
||||
```
|
||||
releaseHeader('2012-04-10', '1.3.1', '1.2.0')
|
||||
```
|
||||
|
||||
* CoffeeScript now enforces all of JavaScript’s **Strict Mode** early syntax errors at compile time. This includes old-style octal literals, duplicate property names in object literals, duplicate parameters in a function definition, deleting naked variables, setting the value of `eval` or `arguments`, and more. See a full discussion at [#1547](https://github.com/jashkenas/coffeescript/issues/1547).
|
||||
* The REPL now has a handy new multi-line mode for entering large blocks of code. It’s useful when copy-and-pasting examples into the REPL. Enter multi-line mode with `Ctrl-V`. You may also now pipe input directly into the REPL.
|
||||
* CoffeeScript now prints a `Generated by CoffeeScript VERSION` header at the top of each compiled file.
|
||||
* Conditional assignment of previously undefined variables `a or= b` is now considered a syntax error.
|
||||
* A tweak to the semantics of `do`, which can now be used to more easily simulate a namespace: `do (x = 1, y = 2) -> …`
|
||||
* Loop indices are now mutable within a loop iteration, and immutable between them.
|
||||
* Both endpoints of a slice are now allowed to be omitted for consistency, effectively creating a shallow copy of the list.
|
||||
* Additional tweaks and improvements to `coffee --watch` under Node’s “new” file watching API. Watch will now beep by default if you introduce a syntax error into a watched script. We also now ignore hidden directories by default when watching recursively.
|
||||
9
documentation/sections/changelog/1.3.3.md
Normal file
9
documentation/sections/changelog/1.3.3.md
Normal file
@@ -0,0 +1,9 @@
|
||||
```
|
||||
releaseHeader('2012-05-15', '1.3.3', '1.3.1')
|
||||
```
|
||||
|
||||
* Due to the new semantics of JavaScript’s strict mode, CoffeeScript no longer guarantees that constructor functions have names in all runtimes. See [#2052](https://github.com/jashkenas/coffeescript/issues/2052) for discussion.
|
||||
* Inside of a nested function inside of an instance method, it’s now possible to call `super` more reliably (walks recursively up).
|
||||
* Named loop variables no longer have different scoping heuristics than other local variables. (Reverts #643)
|
||||
* Fix for splats nested within the LHS of destructuring assignment.
|
||||
* Corrections to our compile time strict mode forbidding of octal literals.
|
||||
7
documentation/sections/changelog/1.4.0.md
Normal file
7
documentation/sections/changelog/1.4.0.md
Normal file
@@ -0,0 +1,7 @@
|
||||
```
|
||||
releaseHeader('2012-10-23', '1.4.0', '1.3.3')
|
||||
```
|
||||
|
||||
* The CoffeeScript compiler now strips Microsoft’s UTF-8 BOM if it exists, allowing you to compile BOM-borked source files.
|
||||
* Fix Node/compiler deprecation warnings by removing `registerExtension`, and moving from `path.exists` to `fs.exists`.
|
||||
* Small tweaks to splat compilation, backticks, slicing, and the error for duplicate keys in object literals.
|
||||
9
documentation/sections/changelog/1.5.0.md
Normal file
9
documentation/sections/changelog/1.5.0.md
Normal file
@@ -0,0 +1,9 @@
|
||||
```
|
||||
releaseHeader('2013-02-25', '1.5.0', '1.4.0')
|
||||
```
|
||||
|
||||
* First release of [Literate CoffeeScript](#literate).
|
||||
* The CoffeeScript REPL is now based on the Node.js REPL, and should work better and more familiarly.
|
||||
* Returning explicit values from constructors is now forbidden. If you want to return an arbitrary value, use a function, not a constructor.
|
||||
* You can now loop over an array backwards, without having to manually deal with the indexes: `for item in list by -1`
|
||||
* Source locations are now preserved in the CoffeeScript AST, although source maps are not yet being emitted.
|
||||
8
documentation/sections/changelog/1.6.1.md
Normal file
8
documentation/sections/changelog/1.6.1.md
Normal file
@@ -0,0 +1,8 @@
|
||||
```
|
||||
releaseHeader('2013-03-05', '1.6.1', '1.5.0')
|
||||
```
|
||||
|
||||
* First release of [source maps](#source-maps). Pass the `--map` flag to the compiler, and off you go. Direct all your thanks over to [Jason Walton](https://github.com/jwalton).
|
||||
* Fixed a 1.5.0 regression with multiple implicit calls against an indented implicit object. Combinations of implicit function calls and implicit objects should generally be parsed better now — but it still isn’t good _style_ to nest them too heavily.
|
||||
* `.coffee.md` is now also supported as a Literate CoffeeScript file extension, for existing tooling. `.litcoffee` remains the canonical one.
|
||||
* Several minor fixes surrounding member properties, bound methods and `super` in class declarations.
|
||||
8
documentation/sections/changelog/1.6.2.md
Normal file
8
documentation/sections/changelog/1.6.2.md
Normal file
@@ -0,0 +1,8 @@
|
||||
```
|
||||
releaseHeader('2013-03-18', '1.6.2', '1.6.1')
|
||||
```
|
||||
|
||||
* Source maps have been used to provide automatic line-mapping when running CoffeeScript directly via the `coffee` command, and for automatic line-mapping when running CoffeeScript directly in the browser. Also, to provide better error messages for semantic errors thrown by the compiler — [with colors, even](http://cl.ly/NdOA).
|
||||
* Improved support for mixed literate/vanilla-style CoffeeScript projects, and generating source maps for both at the same time.
|
||||
* Fixes for **1.6.x** regressions with overriding inherited bound functions, and for Windows file path management.
|
||||
* The `coffee` command can now correctly `fork()` both `.coffee` and `.js` files. (Requires Node.js 0.9+)
|
||||
8
documentation/sections/changelog/1.6.3.md
Normal file
8
documentation/sections/changelog/1.6.3.md
Normal file
@@ -0,0 +1,8 @@
|
||||
```
|
||||
releaseHeader('2013-06-02', '1.6.3', '1.6.2')
|
||||
```
|
||||
|
||||
* The CoffeeScript REPL now remembers your history between sessions. Just like a proper REPL should.
|
||||
* You can now use `require` in Node to load `.coffee.md` Literate CoffeeScript files. In the browser, `text/literate-coffeescript` script tags.
|
||||
* The old `coffee --lint` command has been removed. It was useful while originally working on the compiler, but has been surpassed by JSHint. You may now use `-l` to pass literate files in over **stdio**.
|
||||
* Bugfixes for Windows path separators, `catch` without naming the error, and executable-class-bodies-with- prototypal-property-attachment.
|
||||
14
documentation/sections/changelog/1.7.0.md
Normal file
14
documentation/sections/changelog/1.7.0.md
Normal file
@@ -0,0 +1,14 @@
|
||||
```
|
||||
releaseHeader('2014-01-28', '1.7.0', '1.6.3')
|
||||
```
|
||||
|
||||
* When requiring CoffeeScript files in Node you must now explicitly register the compiler. This can be done with `require 'coffeescript/register'` or `CoffeeScript.register()`. Also for configuration such as Mocha’s, use **coffeescript/register**.
|
||||
* Improved error messages, source maps and stack traces. Source maps now use the updated `//#` syntax.
|
||||
* Leading `.` now closes all open calls, allowing for simpler chaining syntax.
|
||||
* Added `**`, `//` and `%%` operators and `...` expansion in parameter lists and destructuring expressions.
|
||||
* Multiline strings are now joined by a single space and ignore all indentation. A backslash at the end of a line can denote the amount of whitespace between lines, in both strings and heredocs. Backslashes correctly escape whitespace in block regexes.
|
||||
* Closing brackets can now be indented and therefore no longer cause unexpected error.
|
||||
* Several breaking compilation fixes. Non-callable literals (strings, numbers etc.) don’t compile in a call now and multiple postfix conditionals compile properly. Postfix conditionals and loops always bind object literals. Conditional assignment compiles properly in subexpressions. `super` is disallowed outside of methods and works correctly inside `for` loops.
|
||||
* Formatting of compiled block comments has been improved.
|
||||
* No more `-p` folders on Windows.
|
||||
* The `options` object passed to CoffeeScript is no longer mutated.
|
||||
5
documentation/sections/changelog/1.7.1.md
Normal file
5
documentation/sections/changelog/1.7.1.md
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
releaseHeader('2014-01-29', '1.7.1', '1.7.0')
|
||||
```
|
||||
|
||||
* Fixed a typo that broke node module lookup when running a script directly with the `coffee` binary.
|
||||
15
documentation/sections/changelog/1.8.0.md
Normal file
15
documentation/sections/changelog/1.8.0.md
Normal file
@@ -0,0 +1,15 @@
|
||||
```
|
||||
releaseHeader('2014-08-26', '1.8.0', '1.7.1')
|
||||
```
|
||||
|
||||
* The `--join` option of the CLI is now deprecated.
|
||||
* Source maps now use `.js.map` as file extension, instead of just `.map`.
|
||||
* The CLI now exits with the exit code 1 when it fails to write a file to disk.
|
||||
* The compiler no longer crashes on unterminated, single-quoted strings.
|
||||
* Fixed location data for string interpolations, which made source maps out of sync.
|
||||
* The error marker in error messages is now correctly positioned if the code is indented with tabs.
|
||||
* Fixed a slight formatting error in CoffeeScript’s source map-patched stack traces.
|
||||
* The `%%` operator now coerces its right operand only once.
|
||||
* It is now possible to require CoffeeScript files from Cakefiles without having to register the compiler first.
|
||||
* The CoffeeScript REPL is now exported and can be required using `require 'coffeescript/repl'`.
|
||||
* Fixes for the REPL in Node 0.11.
|
||||
9
documentation/sections/changelog/1.9.0.md
Normal file
9
documentation/sections/changelog/1.9.0.md
Normal file
@@ -0,0 +1,9 @@
|
||||
```
|
||||
releaseHeader('2015-01-29', '1.9.0', '1.8.0')
|
||||
```
|
||||
|
||||
* CoffeeScript now supports ES2015 generators. A generator is simply a function that `yield`s.
|
||||
* More robust parsing and improved error messages for strings and regexes — especially with respect to interpolation.
|
||||
* Changed strategy for the generation of internal compiler variable names. Note that this means that `@example` function parameters are no longer available as naked `example` variables within the function body.
|
||||
* Fixed REPL compatibility with latest versions of Node and Io.js.
|
||||
* Various minor bug fixes.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user