Giter Club home page Giter Club logo

coffeescriptredux's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coffeescriptredux's Issues

Feature request: getters/setters

Is there any chance that we could get support for ES5 getters and setters inside object literal? The syntax is very simple and this feature would be very useful to framework authors.

According to http://kangax.github.com/es5-compat-table/ getters/setters are already supported by all browsers except IE <= 8.

myObject =
  _a: 10

  get a: ->
    return @a

  set a: (value) ->
    @_a = value

Would compile to:

myObject = {
  _a: 10,

  get a() {
    return this._a;
  },

  set a(value) {
    this._a = value;
  }
}

Unexpected newlines

Hello,

I'm trying your compiler for the first time, and it's complaining that I have unexpected newlines in my source. Typically this occurs when I separate function arguments with a newline, such as

foo(a,
b)

Any idea what's up with that? Also do you plan on adding a more detailed usage menu or other documentation?

Thanks!

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/85535-unexpected-newlines?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github).

CoffeeScript compiler statically compiled

It would be nice to have CoffeeScript compiler statically compiled.
Closure compiler checks syntax, variable references, and types, and warns about common JavaScript pitfalls with unbeatable level of compression.
It's easily possible with Google Closure type annotations and github.com/Steida/este dev stack.
You can even run your tests on source file change and see results immediately in console.

I'm just curious what is your opinion.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Enforce Syntax

Looking over this thread on Hacker News regarding readability (http://news.ycombinator.com/item?id=4533737) I thought I would comment here:

Would it be possible to include a compiler option that enforces syntax and eliminates optionals? Things like parenthesis, etc? It seems like readability is a common complaint in the CS world and I think that this would do much to alleviate those pains.

Example:

foo = (a, b) ->
   a * b   

foo 2, 4 # throws error

foo( 2, 4) # correct.  

And so on.

`f() in [0, 1]`, `f() in []`

Short compilation for in doesn't take into account side effects. A temporary fix would be to disable that optimisation and always use the helper.

commander not found during make

$ make deps; make test

#...

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module 'commander'
    at Function._resolveFilename (module.js:334:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:357:17)
    at require (module.js:368:17)
    at Object.<anonymous> (/Users/rpflo/Code/github/clones/CoffeeScriptRedux/node_modules/mocha/bin/_mocha:7:15)
    at Module._compile (module.js:432:26)
    at Object..js (module.js:450:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)
    at Array.0 (module.js:470:10)
make: *** [test] Error 1

Maybe something somewhere is expecting a global node_module, haven't looked yet, just posted the error.

Associative array key gets converted to property access

I've been playing around with the project (again!) and came across this odd case:

# input.coffee
options = {}
if options['source-map']  # NOTE: 'source-map' as array access
  console.log 'Hello!'
// $ bin/coffee --optimise --js < hello.coffee
// Generated by CoffeeScript 2.0.0
void function () {
  var options;
  options = {};
  if (options.source-map)  // NOTE: in JavaScript, this is now property access and invalid
    console.log('Hello!');
}.call(this);

This was observed when running src/command.coffee through the compiler.

syntax error

I'm trying redux for the first time on production code that works in cs 1.3.3. Here are the first two syntax errors before I gave up ...

Syntax error on line 1, column 1: unexpected '#'
1 : ###
^ :~^
2 : /root/CoffeeScriptRedux/bin/coffee --js < /ri/utils/coffee_watcher.cof
3 : ###
4 :

Syntax error on line 22, column 13: unexpected '='
19 : monitor = compileOne = null
20 : firstPass = yes
21 :
22 : do doOneDir = ->
^^ :~~~~~~~~~~~~~^
23 :    if not (dir = dirsPending.shift())
24 :            if firstPass
2

Running bin/coffee --help causing TypeError

I have compiled CoffeeScriptRedux by following the instructions in the README file. If I know try to execute coffee script via: bin/coffee --help.

I am getting the following error:

 TypeError: Cannot read property 'length' of undefined
     at /Users/weyertdeboer/Development/Third-Party/CoffeeScriptRedux/lib/coffee-     script/command.js:287:19
     at wrap (/Users/weyertdeboer/Development/Third-Party/CoffeeScriptRedux/lib/coffee-     script/command.js:293:7)
     at Object.<anonymous> (/Users/weyertdeboer/Development/Third-     Party/CoffeeScriptRedux/lib/coffee-script/command.js:354:95)
     at Module._compile (module.js:449:26)

All the unit tests during compilations where successful ( โœ” 201 tests complete (3893ms))
The only issue I have was during make install:

npm http 404 https://registry.npmjs.org/cscodegen
npm WARN optional dep failed, continuing cscodegen@~0.1.0

Parameterless functionLiteral raw value

A functionLiteral with no parameters generates an '(undefined)' raw value instead of '()'. Example:

$ bin/coffee --parse --cli 'f = () -> 42'
 :
        raw: '(undefined) -> 42',

I didn't check ther rest of grammar.pegjs for similar occurences of this problem.

Here's a patch that fixes it:

diff --git a/src/grammar.pegjs b/src/grammar.pegjs
index d7c9c84..14c64fb 100644
--- a/src/grammar.pegjs
+++ b/src/grammar.pegjs
@@ -691,7 +691,7 @@ functionLiteral
   = params:("(" _ parameterList? _ ")" _)? arrow:("->" / "=>") body:functionBody? {
       if(!body) body = {block: null, raw: ''};
       var raw =
-        (params ? params[0] + params[1] + params[2].raw + params[3] + params[4] + params[5] : '') +
+        (params ? params[0] + params[1] + (params[2] && params[2].raw) + params[3] + params[4] + params[5] : '') +
         arrow + body.raw;
       var constructor;
       switch(arrow) {

can't compile anything

Sorry for the lame issue, but I can't find you on twitter or IRC.

If I use ./bin/coffee -c ~/somefile.coffee from CoffeeScriptRedux it just locks up my terminal. I can do coffee -c ~/somefile.coffee using the original coffee bin script and it works just fine.

Everything appears to be setup correctly since make test passes all the tests. :(

rewrite `assignment` function in `src/compiler.coffee` to operate on CS AST nodes

This is necessary to support splices.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/85541-rewrite-assignment-function-in-src-compiler-coffee-to-operate-on-cs-ast-nodes?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github).

Generate a single JavaScript asset

Firstly, this is incredibly cool. I'm in utter disbelief at how amazing this project turned out.

For most of my production work, I compile coffeescript to javascript as part of my build process using Mozilla Rhino. The standard coffeescript distribution includes a single coffee-script-1.3.3.js file. In my build process, I load this file into the JavaScript context and then call CoffeeScript.compile(coffeeScriptSrc); to retrieve my compiled output.

However, the make output of CoffeeScriptRedux is split up into multiple files under lib/coffeescript with several dependencies (requirejs, etc). This works great in node and the command line, but I'm wondering how hard it would be to configure the Redux build to generate a single file for use outside the command line? I imagine this would also be useful for anyone compiling CoffeeScript in the browser itself.

Alternatively, do you have any advice on the order in which I'd need to load each js file individually into the JavaScript context for compilation to work?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/85549-generate-a-single-javascript-asset?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github).

Improve logging; more details about what failed.

Hi,

I found this project (actually, I remember the Kickstarter project) and give it a try. Especially the source map support is a strong feature. Of course, I know that this is still in development, but I don't care.

Anyway, I've checkout the sources, run make deps && make test and tried it on my cs plugin. But it did not work.

$ bin/coffee --source-map  -i ../jquery-autosuggest/src/jquery.autoSuggest.coffee
invalid indentation
$ bin/coffee --debug --source-map  -i ../jquery-autosuggest/src/jquery.autoSuggest.coffee
### PREPROCESSED CS ###
invalid indentation

So, that's bad. I'm a developer (haha, we are on GitHub), so I would like to investigate myself or give you a more technical analysis, let's say "formatting x is buggy".

So, is there a solution to let the parser to be more.. ehm chatty? How can I find and answer which line has an incorrect indentation?

Feature request: Coffeescript metaprogramming

Hi!
I'm wondering if (compile or runtime) metaprogramming is a concern for the future design of coffeescript.
Since you're rewriting the AST manipulation logic it seems like a good point to do this right.

Command-line should reject unknown flags

I decided to give the compiler a try and issued:

$ bin/coffee -h

which resulted in Error: ENOENT, no such file or directory '-h'. There should probably be a safeguard in the command.coffee file which makes sure no unparsed options remain. E.g., expected message was:

Error: unrecognized option: -h

option to output helper functions in a separate file

On large projects where dependencies and compilation are handled by the framework (RequireJS in my case) all files are compiled separately and then merged together by the optimizer. This results in each file having its own set of utility functions.

Since i'm using classes and lots of inheritance, i have __extends, __hasProp and the like copied literally a hundred times.

Maybe the compiler could be given an optional flag to dump helpers only once. Then it should be developers responsibility to require this file before others.

scoping issue with auto-declaration

This one's going to require us to push expressions inside statements so we no longer need to generate IIFEs:

$ bin/coffee --js --no-optimise
x = switch c
  when 0 then a = b
  else a = c
a?

// Generated by CoffeeScript 2.0.0
void function () {
  var x;
  x = function () {
    var a;
    switch (c) {
    case 0:
      return a = b;
    default:
      return a = c;
    }
  }.call(this);
  'undefined' !== typeof a && null != a;
}.call(this);

Is this a reportable issue?

There's a lot of probably bad conventions of gotten used to being able to do in coffee that I'm not even sure are supposed to be ok in coffeescript, but since it was the first syntax errors I encountered in my own code with this project I thought I'd ask:

something = () -> 1
something
  a: 2
.something 3

error

Is this something worth reporting at this point? Is this project's goal to handle all issues like this, or was that bad coffeescript?

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Represent comments in the AST

I'm looking forward to create a successor of Codo that uses CoffeeScriptRedux. I saw that I could get a JSON-serialised AST representation of the input with the --parse option, which would be the perfect base for further processing, but I noticed that comments aren't represented in the AST. The given CoffeeScript file

# Comment
class Test

is represented with

{ type: 'CS.Program',
  block: 
   { type: 'CS.Class',
     nameAssignee: { type: 'CS.Identifier', data: 'Test' },
     parent: undefined,
     ctor: undefined,
     block: undefined,
     name: { type: 'CS.Identifier', data: 'Test' },
     boundMembers: [] } }

This also applies to the original CoffeeScript and the current Codo implementation pre-processes the source code to convert comments to block comments. This works well for most situations, but it's still an ugly hack.

Is this by intention for some reason? It would be great to have comments in the AST to enable robust tooling support.

Thanks a lot for your work.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/825361-represent-comments-in-the-ast?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github).

Support for ctags generation?

Do you plan on supporting ctags generation?

I just started porting the CoffeeTags command line tool from Ruby to CoffeeScript (https://github.com/delaaxe/coffee-tags) to see if I'd be able to improve it since it's kind of buggy and not very complete. Then I thought I could just use CoffeeScript 2.0 (when it'll be ready) to do most of the dirty work and output some sort of a filtered AST representation for the tags file.

I don't know much about parsing, lexers etc., so I might be wrong and I'm not sure if that would be the right way to go..

I'd be glad to have your thoughts on the matter ,

Axel

change interface of CompoundAssignOp

Currently, the op member is the constructor of a binary operator that is allowed to be part of a compound assignment. This does not convert to JSON nicely. It should instead be a JSON primitive of some sort or an instance of another node.

optimisation issue with `do`

$ cat parserTest.coffee
a = 0
do -> a = 1
$ bin/coffee --js -i parserTest.coffee
(function () {
  var a, a;
  a = 0;
  a = void 0;
}.call(this));
$ bin/coffee --js -i parserTest.coffee --no-optimise
(function () {
  var a;
  a = 0;
  (function () {
    var a;
    return a = 1;
  }());
}.call(this));

Unexpected ',' when used to start line

Code

      _.delay =>
        if not rpcConnected
          if retryCount < 3
            connect()
            tryConnect()
            retryCount += 1
          else
            authManager.connectionFailed()
      , 800

Error

Error: Syntax error on line 138, column 7: unexpected ','
135 :             retryCount += 1
136 :           else
137 :             authManager.connectionFailed()
138 :       , 800
^^^ :~~~~~~~^
139 : 

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/85531-unexpected-when-used-to-start-line?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github).

Feature request: support UTF BOM markers

As UTF BOM markers are a real problem with the current compiler, I want to open a feature request about this from early on.
Basically, when the compiler encounters a BOM, it should put the same BOM at the start of the generated JS file, outside the closure surrounding the generated code.

CC @pke @superquadratic @doo

'cjs-string-scanner' is not in the npm registry

npm install fails because cjs-string-scanner is not in the npm registry

npm ERR! 404 'cjs-string-scanner' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.

npm ERR! System Darwin 12.1.0
npm ERR! command "/usr/local/n/versions/0.8.6/bin/node" "/usr/local/n/current/bin/npm" "i"
npm ERR! cwd /Users/mccullough/dev/CoffeeScriptRedux
npm ERR! node -v v0.8.6
npm ERR! npm -v 1.1.48
npm ERR! code E404

cscodegen not an npm

npm WARN optional dep failed, continuing cscodegen@~0.1.0

when running npm install of coffeescriptredux, this is the error i get.

I tried symlinking cscodegen from your github directory, but that didn't seem to help.

Any ideas?

Test is falling (master)

make -j test
mkdir -p lib/coffee-script/bootstrap
bin/coffee --js --bare <"src/compiler.coffee" >"lib/coffee-script/bootstrap/compiler.js"
bin/coffee --js --bare <"src/functional-helpers.coffee" >"lib/coffee-script/bootstrap/functional-helpers.js"
bin/coffee --js --bare <"src/helpers.coffee" >"lib/coffee-script/bootstrap/helpers.js"
bin/coffee --js --bare <"src/js-nodes.coffee" >"lib/coffee-script/bootstrap/js-nodes.js"
bin/coffee --js --bare <"src/module.coffee" >"lib/coffee-script/bootstrap/module.js"
bin/coffee --js --bare <"src/nodes.coffee" >"lib/coffee-script/bootstrap/nodes.js"
bin/coffee --js --bare <"src/optimiser.coffee" >"lib/coffee-script/bootstrap/optimiser.js"
bin/coffee --js --bare <"src/preprocessor.coffee" >"lib/coffee-script/bootstrap/preprocessor.js"
printf %s "module.exports = " >"lib/coffee-script/bootstrap/parser.js"
bin/coffee --js --bare <"src/command.coffee" >"lib/coffee-script/bootstrap/command.js"
node_modules/.bin/pegjs --track-line-and-column --cache <"src/grammar.pegjs" >>"lib/coffee-script/bootstrap/parser.js"
mv lib/coffee-script/bootstrap/* lib/coffee-script
rmdir lib/coffee-script/bootstrap
bin/coffee --js --bare <"src/command.coffee" >"lib/coffee-script/command.js.tmp" && mv "lib/coffee-script/command.js.tmp" "lib/coffee-script/command.js"
bin/coffee --js --bare <"src/compiler.coffee" >"lib/coffee-script/compiler.js.tmp" && mv "lib/coffee-script/compiler.js.tmp" "lib/coffee-script/compiler.js"
bin/coffee --js --bare <"src/functional-helpers.coffee" >"lib/coffee-script/functional-helpers.js.tmp" && mv "lib/coffee-script/functional-helpers.js.tmp" "lib/coffee-script/functional-helpers.js"
bin/coffee --js --bare <"src/helpers.coffee" >"lib/coffee-script/helpers.js.tmp" && mv "lib/coffee-script/helpers.js.tmp" "lib/coffee-script/helpers.js"
bin/coffee --js --bare <"src/js-nodes.coffee" >"lib/coffee-script/js-nodes.js.tmp" && mv "lib/coffee-script/js-nodes.js.tmp" "lib/coffee-script/js-nodes.js"
bin/coffee --js --bare <"src/module.coffee" >"lib/coffee-script/module.js.tmp" && mv "lib/coffee-script/module.js.tmp" "lib/coffee-script/module.js"
bin/coffee --js --bare <"src/nodes.coffee" >"lib/coffee-script/nodes.js.tmp" && mv "lib/coffee-script/nodes.js.tmp" "lib/coffee-script/nodes.js"
bin/coffee --js --bare <"src/optimiser.coffee" >"lib/coffee-script/optimiser.js.tmp" && mv "lib/coffee-script/optimiser.js.tmp" "lib/coffee-script/optimiser.js"
bin/coffee --js --bare <"src/preprocessor.coffee" >"lib/coffee-script/preprocessor.js.tmp" && mv "lib/coffee-script/preprocessor.js.tmp" "lib/coffee-script/preprocessor.js"
printf %s "module.exports = " >"lib/coffee-script/parser.js.tmp"
node_modules/.bin/pegjs --track-line-and-column --cache <"src/grammar.pegjs" >>"lib/coffee-script/parser.js.tmp"
mv "lib/coffee-script/parser.js.tmp" "lib/coffee-script/parser.js"
node_modules/.bin/mocha --compilers coffee:. -u tdd -R dot

/home/dals/projects/coffee/test/string-interpolation.coffee:1
(function (exports, require, module, __filename, __dirname) { suite 'String In
                                                                    ^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected string
    at Module._compile (module.js:437:25)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Mocha.loadFiles (/home/dals/projects/coffee/node_modules/mocha/lib/mocha.js:135:27)
    at Array.forEach (native)
    at Mocha.loadFiles (/home/dals/projects/coffee/node_modules/mocha/lib/mocha.js:132:14)
    at Mocha.run (/home/dals/projects/coffee/node_modules/mocha/lib/mocha.js:251:8)
    at Object.<anonymous> (/home/dals/projects/coffee/node_modules/mocha/bin/_mocha:324:7)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

Git sub-modules vs. package.json

I have been wondering why Git sub-modules are used over proper package.json dependencies? There also seems to be a build step (make deps) involved which is not very intuitive.

In the case of PEG.js until your changes are merged, it makes sense to keep a Git sub-module or use GitHub tarballs perhaps? I also saw you follow Dignifiedquire/pegjs-coffee-plugin and I am guessing you are going to be experimenting with it at some point?

Anyhows, a proper package.json should make it much easier to manage dependencies and to install CSII without the hassle of Git or build steps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.