Git Product home page Git Product logo

traceur-compiler's Introduction

Join the chat at https://gitter.im/google/traceur-compiler Build Status

Traceur logo

What is Traceur?

Traceur is a JavaScript.next-to-JavaScript-of-today compiler that allows you to use features from the future today. Traceur supports ES6 as well as some experimental ES.next features.

Traceur's goal is to inform the design of new JavaScript features which are only valuable if they allow you to write better code. Traceur allows you to try out new and proposed language features today, helping you say what you mean in your code while informing the standards process.

JavaScript's evolution needs your input. Try out the new language features. Tell us how they work for you and what's still causing you to use more boilerplate and "design patterns" than you prefer.

What now? What can Traceur do for me?

Read the Getting Started page to get up and running. You can use some language features right now and even try it out in your browser here. Just type in some code and see what Traceur produces. For an idea of what is available and what we have in the pipeline, see the Language Features page.

The JSConf 2011 presentation of Traceur describes the goals of the project and what it can do today. Some documentation is on the wiki on this site. Extra demos are in the source repository.

We also presented Traceur at NodeConf 2011. The video is available on YouTube.

Questions, suggestions, and comments can be directed to the discussion group.

traceur-compiler's People

Contributors

arcanis avatar arv avatar caitp avatar crisptrutski avatar domenic avatar eddyb avatar fitzgen avatar guybedford avatar hzr avatar johnjbarton avatar jshen212 avatar mathiasbynens avatar mciparelli avatar mprobst avatar pflannery avatar rodyhaddad avatar rolftimmermans avatar seidtgeist avatar slightlyoff avatar stevenvachon avatar terasaka2k avatar termina1 avatar tomibelan avatar tuchk4 avatar ulrikdem avatar ultcombo avatar usrbincc avatar vicb avatar vojtajina avatar yokomizor avatar

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

traceur-compiler's Issues

Comma Optional After Method and Accessor Properties in Object Literals.

Original author: [email protected] (August 15, 2011 19:38:37)

From Narcissus...

Comma Optional After Method and Accessor Properties in Object Literals.

(There is not currently an separate Harmony proposal for this feature)

Within an object literal the comma that separates individual property definitions is optional after method and accessor property definitions. For example this:

var obj = {
a: 0,
__foo: null,
someMethod() {
doSomething();
}
get foo() {return __foo}
set foo(v) {__foo = v}
}
means exactly the same thing as:

var obj = {
a: 0,
__foo: null,
someMethod() {
doSomething();
}, //<-- note comma
get foo() {return __foo}, //<-- note comma
set foo(v) {__foo = v}
}

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=36

Project.addExternalModule not called when using Compiler.js

Original author: [email protected] (September 25, 2011 01:41:07)

What steps will reproduce the problem?

  1. Include traceur.js and bootstrap.js
  2. Edit bootstrap.js to have project url as window.location.href
  3. Add a script tag with text/traceur that contains the following code:
    module a = require("test_a.js");
    module b = require("test_b.js");
    module c = require("test_c.js");
    console.log(c.name);

What is the expected output? What do you see instead?
The expected output is "C" and no error messages. Instead i see a error message due to Project.getModuleForUrl being called before Project.addExternalModule and therefore failing on the assert causing Error('Assertion failed').

What version of the product are you using? On what operating system?
I'm running from trunk revision r325 in Chrome 16.0.899.0

Please provide any additional information below.
The tests in tests/unit/runtime/test_modules.html all pass on my browser but as far as I can see it doesn't use Compiler.js but instead CodeLoader from modules.js
When should Project.addExternalModule be called for require statements? I have looked at the code but because the CodeLoader and the Compiler is quite different I do not really understand where code loading should be performed when using the Compiler.

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=44

"Missing URL" error when used in Node.JS

Original author: aikar%[email protected] (September 19, 2011 12:31:03)

What steps will reproduce the problem?

  1. Checkout http://github.com/aikar/traceur which I wrote a loader to middleman module loads to run through traceur
  2. delete traceur folder and recheckout from SVN (I commented out the error in traceur/src/semantics/symbols/ModuleSymbol.js)
  3. run node test.js
  4. Witness "Missing URL". For bigger projects it spams alot more.

What is the expected output? What do you see instead?
No error

What version of the product are you using? On what operating system?
latest trunk as of 9/19/11

Please provide any additional information below.

NOTE: To get traceur to work with node.js I had to disable the FreeVariableChecker like so:
traceur.semantics.FreeVariableChecker.checkProgram = function() {}

This is due to Traceur blowing up saying module was not defined.

also, to assist debugging I threw in an exception to get a stack trace:

Error: Missing URL
at Object.ModuleSymbol (/home/aikar/projects/nodeib/node_modules/traceur/traceur/src/semantics/symbols/ModuleSymbol.js:36:13)
at Object.Project (/home/aikar/projects/nodeib/node_modules/traceur/traceur/src/semantics/symbols/Project.js:45:24)
at Object..js (/home/aikar/projects/nodeib/node_modules/traceur/traceur.js:34:19)
at Module.load (module.js:343:31)
at Function._load (module.js:302:12)
at require (module.js:355:19)
at Object.<anonymous> (/home/aikar/projects/nodeib/node_modules/traceur/test.js:2:7)
at Module._compile (module.js:411:26)
at Object.<anonymous> (module.js:417:10)
at Module.load (module.js:343:31)

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=41

Parse tree validation error when using await.

Original author: [email protected] (July 15, 2011 16:05:28)

This piece of code does compile but bails out when validating the parse tree although it looks perfectly fine to me:

function makeSync(fn) {
return function() {
var self = this;
var callArgs = Array.prototype.slice.call(arguments);

    var err, args;
    function callDeferred() {
        var deferred = new Deferred();
        fn.apply(self, callArgs.concat(function(err, varargs) {
            if (err) {
                deferred.errback(err);
            } else {
                args = Array.prototype.slice.call(arguments, 1)
                deferred.callback(args);
            }
        }));
        return deferred;
    }
    await callDeferred();
    return args;
}

};

The error I get is:
"Error: Parse tree validation failure 'statement expected' at (unknown):"

I'm using the version embedded into https://github.com/aikar/traceur so I don't knwo exactly which svn revision it is.

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=34

Change testing framework

Original author: [email protected] (May 12, 2011 00:17:55)

We currently use Closure Library testing framework which is similar to JSUnit. The current testing framework depends on globals (not entirely true but we use them for convenience) but Harmony is all about strict mode and true lexical scoping so globals are bad.

I was trying to change to using strict evals in the tests but since you cannot introduce new bindings a lot of tests started failing.

This made me want to get rid of Closure library tests and either use Jasmine or build something simple ourselves.

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=23

Generators can't be used to define an iterator

Original author: [email protected] (April 19, 2011 19:07:22)

In C# you can use generators to define the GetEnumerator() method. It's not clear to me that this works in the current implementation, because our generators always return an object with iterator. In C# parlance this is the difference between a generator that returns IEnumerator<T> vs IEnumerable<T>. How do we do it in JS without strong types?

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=8

BoundIndentifierAccumulator issues

Original author: [email protected] (April 12, 2011 22:33:54)

arv had the following comments about this code:

https://chromereviews.googleplex.com/2741024/diff/1/src/semantics/BoundIdentifierAccumulator.js
File src/semantics/BoundIdentifierAccumulator.js (right):

https://chromereviews.googleplex.com/2741024/diff/1/src/semantics/BoundIdentifierAccumulator.js#newcode85
src/semantics/BoundIdentifierAccumulator.js:85: * Then only {@code "f"}
is bound; {@code "x"} and {@code "y"} are
I find this confusing. Maybe it is just a documentation issue.

Can you add a test that the bound identifiers in the following statement
does not include f?

var x = function f() {};

https://chromereviews.googleplex.com/2741024/diff/1/src/semantics/BoundIdentifierAccumulator.js#newcode108
src/semantics/BoundIdentifierAccumulator.js:108: * enclosing scope.
Yeah, the text here is really confusing. A function expression makes the
name of the function bound in the function body, but the name of the
function is not seen outside the function.

https://chromereviews.googleplex.com/2741024/diff/1/src/semantics/BoundIdentifierAccumulator.js#newcode122
src/semantics/BoundIdentifierAccumulator.js:122: * Reports {@code "g"}
as being bound, because the function
This is incorrect. In ES5, function statements are not allowed in blocks
(most engines allow them but that is an extension). In ES.next function
statements in blocks have let binding.

I don't think we need to fix these issues in this patch but we should
file bugs.

https://chromereviews.googleplex.com/2741024/diff/1/src/semantics/BoundIdentifierAccumulator.js#newcode227
src/semantics/BoundIdentifierAccumulator.js:227:
Do we need to visit ForEachStatements too? Or is it guaranteed that the
for-each pass happens before this is used?

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=1

Spread does not work on static class methods

Original author: aikar%[email protected] (September 18, 2011 13:57:30)

What steps will reproduce the problem?

  1. define a class with a static method that attempts to use spread
  2. Call it.
  3. witness undefined error

What is the expected output? What do you see instead?
for spread to work, spread doesnt work

What version of the product are you using? On what operating system?
v0.10 - Ubuntu 11.04 x64 - Node.JS v0.4.11

Please provide any additional information below.

My code that didn't work:
class Config {
class get(...args) {
return Config.getInstance().getConf(...args)
}

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=39

Argument defaults does not work on class static methods

Original author: aikar%[email protected] (September 19, 2011 12:18:53)

What steps will reproduce the problem?
Make the following class:
class foo { class init(bar = null) { console.log("Foo"); } }

Witness error:
TypeError: Cannot read property 'value' of undefined
at /home/aikar/projects/nodeib/node_modules/traceur/traceur/src/codegeneration/ParseTreeFactory.js:158:47
at Array.forEach (native)
at createParameters (/home/aikar/projects/nodeib/node_modules/traceur/traceur/src/codegeneration/ParseTreeFactory.js:155:26)
at Object.transformStaticMethodAssignment_ (/home/aikar/projects/nodeib/node_modules/traceur/traceur/src/codegeneration/ClassTransformer.js:309:15)
at Object.<anonymous> (/home/aikar/projects/nodeib/node_modules/traceur/traceur/src/codegeneration/ClassTransformer.js:219:30)
at Array.forEach (native)
at Object.createStaticMembers_ (/home/aikar/projects/nodeib/node_modules/traceur/traceur/src/codegeneration/ClassTransformer.js:216:30)
at Object.transformClassDeclaration (/home/aikar/projects/nodeib/node_modules/traceur/traceur/src/codegeneration/ClassTransformer.js:162:40)
at Object.transformAny (/home/aikar/projects/nodeib/node_modules/traceur/traceur/src/codegeneration/ParseTreeTransformer.js:115:37)
at Object.transformList (/home/aikar/projects/nodeib/node_modules/traceur/traceur/src/codegeneration/ParseTreeTransformer.js:131:32)

What is the expected output? What do you see instead?

want: Foo
see: Error

What version of the product are you using? On what operating system?
latest trunk as of sep 19/11

Please provide any additional information below.

May be related to http://code.google.com/p/traceur-compiler/issues/detail?id=39 which I also reported as an issue with static class methods.

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=40

Split Module into multiple files

Original author: unigossi (June 09, 2011 19:17:04)

I don't know what's the plan for harmony, but with the current implementation of tracuer it isn't possible to have one module in multiple files.

At the moment code like this:
module m {

}
is turned into:
var m =(function() {
"use strict";
return this;
}).call(Object.create(null));

can't it be:

var m =(function() {
"use strict";
return this;
}).call(m || Object.create(null));

The original thought by me was doing sth like this:

Class1.js:
module m {
export class Class1 {
//...
}
}

Class2.js:
module m {
export class Class2 {
//...
}
}

Will this be possible?

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=32

await should be an expression, not a statement

Original author: [email protected] (May 09, 2011 23:14:37)

See the example at:

http://wiki.ecmascript.org/doku.php?id=strawman:deferred_functions#returning_values_from_deferred_functions

It doesn't compile yet. There's a TODO in the parser:

// TODO: await should be an expression, not a statement
// await[ identifier = ] expression;
/** ... */
parseAwaitStatement_: function() {

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=18

Script loading

Original author: [email protected] (May 11, 2011 22:33:11)

I have a simple script loader based on the contents of bootstrap.js. It works perfectly as far as loading and executing the included scripts. The problem is that if I try to use any variables defined in the loaded file, the compiler sees an "undefined" variable before loading the scripts and never executes the script that loaded the file.

Is there a reason that the compiler has to stop when it encounters an undefined variable? This is already done by the interpreter so I don't see why the compiler should throw an exception. Also, there should be a script loader built in.

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=22

Support for ECMA-357 E4X syntax

Original author: [email protected] (May 16, 2011 17:39:35)

Disclaimer: I know V8 does not support E4X and has no intention of adding it.

Users of E4X who target Firefox/Spidermonkey are still users of Javascript and can benefit from tools which exist for the language. Traceur is one such tool that can:

  • Validate ES5/ES.next compliance
  • Rewrite undesired syntax into clean syntax

Please consider supporting optional E4X support in the Traceur parser to pass through to the output code so that Firefox/Spidermonkey users of E4X can use Traceur.

Also, if ECMA-357 ever changes, for instance, to remove XML literals from the token stream, users who wish to migrate from this syntax to something more benign will be able to take advantage of tools such as Traceur to do the rewriting. (e.g. "foo = <bar/>" -> "foo = new XML('<bar/>')")

Or, alternatively, using Traceur to rewrite E4X syntax to something else entirely (JSON?) in order to migrate code that only runs on Spidemonkey to run on V8 as well.

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=27

createClass issues

Original author: [email protected] (April 15, 2011 21:21:49)

Erik pointed out some problems in the createClass implementation we've been using:

> https://chromereviews.googleplex.com/2793013/diff/3001/src/runtime.js#newcode183
> src/runtime.js:183: proto.proto = base.prototype;
> This is a red flag.
>
> In general it is not allowed to set the proto. There are some exceptions, like
> in an object literal and to work around limitations with extending DOM and built
> in classes.
>
> What is the intent and can we solve it some other way? I don't understand why we
> are changing the proto this way. The proto should already be an instanceof base
> before this statement.
>
> What happens if proto is used in more than one place?

Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=2

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.