You can try RacketScript in your browser at RacketScript Playground.
RacketScript is work-in-progress and is not mature and stable. Several Racket features and libraries are not yet implemeted (eg. number pyramid, contracts, tail calls, primitives). That said, we encourage experimentation, user feedback, discussions, bug reports and pull requests.
Following system packages are required -
RacketScript can be installed by running one of the following commands in your terminal.
For installation via
raco pkg install racketscript
For installation via
sh -c "$(curl -fsSL https://raw.githubusercontent.com/vishesh/racketscript/master/install.sh)"
Or, for installation via
sh -c "$(wget https://raw.githubusercontent.com/vishesh/racketscript/master/install.sh -O -)"
See Basic Usage to get started.
Install from Github
Once RacketScript is cloned in your machine -
- Fire up your terminal and goto the root directory of the repository.
make setupto install RacketScript compiler and all its dependencies.
Although not required, it is strongly recommeded that you install Traceur, and Gulp as global packages.
npm install -g traceur gulp
If you do not wish to pollute your root NPM directory, you can set a
custom global location by changing your
echo "prefix = $HOME/.npm-packages" >> ~/.npmrc. Then add
RacketScript will generate Gulpfiles to compile ES6 to ES5 using Traceur or Babel. If you wish to run ES6 modules directly, install Traceur using NPM. Babel is recommended for writing NodeJS programs.
RacketScript compiler is named
racks -h # show help
To compile a Racket source file:
# Installs all NPM dependencies and compile file.rkt racks /path/to/file.rkt
The above command will create a output build directory named
js-build, copy RacketScript runtime, copy other support files,
install NPM dependencies, compile
file.rkt and its dependencies.
The compiled ES6 modules typically goto one of following three folders:
- "modules": The normal Racket files.
- "collects": Racket collects source files.
- "links": Other third party packages.
Here are few other examples that would come in handy:
By default tail call optimization is turned off. To enable translation
of self recursive tail calls to loop, pass
racks --enable-self-tail /path/to/source.rkt
By default RacketScript will use Traceur and produce
dist/compiled.js. To execute inside NodeJS, execute
in output directory. For running in browser, either use
traceur-browser target, or include the Traceur runtime along with
A more robust (and less portable) way, is to run the ES6 modules
modules directly from Traceur. Goto
directory and execute
$ traceur /path/to/source.js.
RacketScript could also use
Babel. It will compile each assembled ES6
module to ES5, and put it in
dist directory, persevering original
directory structure. Replace above command with following -
# Use `--target` or `-t` flag. racks --target babel /path/to/source.rkt
This will compile each ES6 module generated by RacketScript, and put
script file produced by Babel in
dist can be executed directly using
Node. Babel is highly recommended if your target is NodeJS.
Contributing to RacketScript
Please read Contribution Guidelines.