JSX - a faster, safer, easier JavaScript
JavaScript Perl Perl6 HTML CSS Makefile Other
Latest commit a554cd4 Sep 15, 2015 @kazuho kazuho Merge pull request #337 from ojwb/patch-1
Fix typo: "generatedy" -> "generated"
Permalink
Failed to load latest commit information.
bin dead-copy bin/jsx-profile-server to src/profile-server.jsx May 9, 2014
complete add small doc for jsx --completion Sep 19, 2012
doc [doc update] profiler is now "jsx-profile-server" May 14, 2014
etc mv src/doc etc/doc-template Apr 14, 2014
example fix name Jun 8, 2014
extlib add Text::MicroTemplate to extlib May 8, 2014
idl2jsx update web.jsx Nov 19, 2013
lib use Function() to obtain global ref (for better compatibility with st… May 7, 2014
src Fix typo: "generatedy" -> "generated" Sep 15, 2015
submodules port profile-server to JSX May 12, 2014
t cherry-pick the test case from PR #329 May 20, 2014
tmp keep tmp/ Feb 5, 2013
tool update bootstrap-compiler.js Jun 8, 2014
web web/build.pl no longer loads the compilation server (was it actually … Apr 10, 2014
xt/optimize-bench add a benchmark test script Aug 2, 2013
.gitattributes add .gitattributes to use [diff "jsx"] section in gitconfig Jul 3, 2013
.gitignore doc/ must not be ignored Jun 9, 2014
.gitmodules port profile-server to JSX May 12, 2014
.npmignore strip-down the files packed as npm Apr 14, 2014
.proverc remove --trap flag from .prove Jul 22, 2013
.travis.yml allow travis failure on node.js 0.8, the environment fails to install… May 20, 2014
CONTRIBUTING.md add CONTRIBUTING.md May 5, 2013
Changes releng for 0.9.89 May 19, 2014
HACKING.md add "Bootstrap" section to HACKING.md Apr 3, 2013
LICENSE add "et al." to the copyright clause of each file, clarify in LICENSE… Dec 10, 2013
Makefile port profile-server to JSX May 12, 2014
README.md Fix typo in README.md Nov 28, 2014
gruntfile.js do not watch src/meta.jsx on `grunt watch` Aug 3, 2013
package.json update dependencies Jun 8, 2014
release-engineering.md close #144; the author must do `make publish` instead of `npm publish` Apr 30, 2013

README.md

NAME Build Status

JSX - a faster, safer, easier JavaScript

INSTALLATION

The JSX compiler toolkit is released as a npm package, so you can install it with npm install -g jsx.

COMPILATION

There's jsx(1) command to compile JSX source code into JavaScript.

Type the following commands and see what happens:

# run Hello World in JSX
jsx --run example/hello.jsx

# compile it and output the generated code to stdout
jsx example/hello.jsx

# compile it with full optimizations
jsx --release --output hello.jsx.js example/hello.jsx

# compile it for node and execute it
jsx --executable node --output hello.jsx.js example/hello.jsx
./hello.jsx.js # displays "Hello, world!"

# run a test, calling _Test#test*()
jsx --test example/import.jsx # import.jsx has _Test

jsx --help shows how to to use the jsx command.

INTRODUCTION

Here is a fizzbuzz problem, which can be executed by jsx --run fizzbuzz.jsx, showing a basic syntax of JSX.

class _Main {
    static function main(args :string[]) : void {
        for (var i = 1; i <= 100; ++i) {
            if (i % 15 == 0)
                log "FizzBuzz";
            else if (i % 3 == 0)
                log "Fizz";
            else if (i % 5 == 0)
                log "Buzz";
            else
                log i;
        }
    }
}

See the documentation for details.

EXAMPLES

There are JSX source files in example/ and web/example/, and the the test directory t/.

DEVELOPMENT OF JSX COMPILER

If you are interested in development of the JSX compiler, you should set up your environment after cloning the repo. The SDK development requires LSB 4.1 (Perl 5.8.8 and some UNIX commands) as well as NodeJS 0.8.0 or later.

To setup JSX SDK, type the following command:

git clone --recursive git://github.com/jsx/JSX.git
cd JSX
make # to build bin/jsx
# edit JSX compiler source files
make test # to make sure it works

We recommend to install jsx(1) as a link of $JSX/bin/jsx to ~/bin/jsx.

ln -s "$PWD/bin/jsx" ~/bin

DEVELOPMENT WEB SERVER

There's a web interface, which provides a web compiler and web application examples. Type the following commands to run the server:

make server # to run an HTTP daemon
open http://localhost:2012/

This server is also used to show results of JSX profiler. See Using the Profiler for details.

TESTING

There are unit tests in t/ directory. Just type the following command to run the tests:

make test

These test cases are executed by prove(1) and dispatched by t/util/test-runner, and also requires phantomjs(1)

Note that if you make a pull request you have to make sure make test-all for complete tests.

NOTE: There are some TODO tests, which should be resolved in a future. make show-todo shows such TODOs.

WINDOWS SUPPORT

npm install -g jsx should work even on Windows.

RESOURCES