https://github.com/angular/atscript-playground
A repo to play with AtScript.
https://github.com/angular/atscript-playground
Last synced: 3 months ago
JSON representation
A repo to play with AtScript.
- Host: GitHub
- URL: https://github.com/angular/atscript-playground
- Owner: angular
- Archived: true
- Created: 2014-10-30T21:59:00.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2018-03-25T18:17:03.000Z (almost 8 years ago)
- Last Synced: 2025-10-06T00:33:42.370Z (3 months ago)
- Language: JavaScript
- Size: 39.1 KB
- Stars: 142
- Watchers: 23
- Forks: 25
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## AtScript Playground
This is an empty repo to make it easy to experiment with AtScript.
### Initial setup
```bash
# Clone the repo...
git clone https://github.com/vojtajina/atscript-playground.git
cd atscript-playground
# Then, you need to install all the dependencies...
npm install
# If you want to be able to use global commands `karma` and `gulp`...
npm install -g karma-cli gulp
```
### The minimal example
Our example consists of two files:
* `atscript-playground/src/something.ats` defines a simple class that returns the sum of two input values
* `atscript-playground/src/main.ats` imports that class and prints a message to the console
### Running the example in the browser
To run in the browser, you need to first build the project. This creates a `build/` directory that contains the transpiled `*.js` files that are created from your AtScript project.
```bash
# Do initial build, start a webserver and re-build on every file change...
gulp build serve watch
```
Open a browser and look in the console log to see the result.
### Running the tests
The tests are in `atscript-playground/test/something_spec.ats`. Run them using Karma, like so:
```bash
karma start
```
Karma opens a browser window for running tests. To see the actual test output (and errors), look for the log in the terminal window where you issued the `karma start` command.
### What are all the pieces involved?
#### [Traceur]
Transpiles AtScript code into regular ES5 (today's JavaScript) so that it can be run in a current browser.
#### [RequireJS]
Traceur is configured to transpile AtScript modules into AMD syntax and we use RequireJS to load the code in the browser. This is just temporary until we improve the ES Module Loader polyfill ([more details](https://github.com/angular/atscript-playground/issues/3)).
#### [Assert] library
When `typeAssertions: true` option is used, Traceur generates run-time type assertions such as `assert.type(x, Object)`. The assert library does the actual run-time check. Of course, you can use your own assert library.
The idea with type assertions is that you only use them during the development/testing and when deploying, you use `typeAssertions: false`.
#### [Karma]
Test runner that runs the tests in specified browsers, every time that you change a file.
#### [Gulp]
Task runner to make defining and running the tasks simpler.
[AtScript]: http://atscript.org
[Traceur]: https://github.com/google/traceur-compiler
[RequireJS]: http://requirejs.org
[Assert]: https://github.com/angular/assert
[Karma]: http://karma-runner.github.io/
[Gulp]: http://gulpjs.com