mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 15:12:12 +00:00
Update README
This commit is contained in:
parent
27f0621ee9
commit
2a7f40953a
82
README.md
82
README.md
@ -7,7 +7,7 @@
|
||||
|
||||
**AssemblyScript** compiles strictly typed [TypeScript](http://www.typescriptlang.org) (basically JavaScript with types) to [WebAssembly](http://webassembly.org) using [Binaryen](https://github.com/WebAssembly/binaryen). It generates lean and mean WebAssembly modules while being just an `npm install` away.
|
||||
|
||||
See [the AssemblyScript wiki](https://github.com/AssemblyScript/assemblyscript/wiki) for instructions and documentation. You can also try it out in [WebAssembly Studio](https://webassembly.studio)!
|
||||
Try it out in [WebAssembly Studio](https://webassembly.studio)!
|
||||
|
||||
Motivation
|
||||
----------
|
||||
@ -20,6 +20,40 @@ Motivation
|
||||
|
||||
> I do think [compiling TypeScript into WASM] is tremendously useful. It allows JavaScript developers to create WASM modules without having to learn C. – Colin Eberhardt, [Exploring different approaches to building WebAssembly modules](http://blog.scottlogic.com/2017/10/17/wasm-mandelbrot.html) (Oct 17, 2017)
|
||||
|
||||
Getting started
|
||||
---------------
|
||||
|
||||
All the details are provided in the [AssemblyScript wiki](https://github.com/AssemblyScript/assemblyscript/wiki) - make sure to pay it a visit. With that being said, the easiest way to get started with AssemblyScript is to point npm at the GitHub repository (for now)
|
||||
|
||||
```
|
||||
$> npm install --save-dev AssemblyScript/assemblyscript
|
||||
```
|
||||
|
||||
followed by [scaffolding](https://github.com/AssemblyScript/assemblyscript/wiki/Using-the-CLI#scaffolding-with-asinit) a new project including the necessary configuration files, for example in the current directory:
|
||||
|
||||
```
|
||||
$> npx asinit .
|
||||
```
|
||||
|
||||
Once the project is set up, it's just a matter of using your existing [TypeScript tooling](https://code.visualstudio.com) while coding, and [using the CLI](https://github.com/AssemblyScript/assemblyscript/wiki/Using-the-CLI) to build to WebAssembly, either manually, or using (and maybe modifying) the generated build task in the generated `package.json`:
|
||||
|
||||
```
|
||||
$> npm run asbuild
|
||||
```
|
||||
|
||||
The compiler's API can also [be used programmatically](./bin).
|
||||
|
||||
If you rather prefer an installation suitable for development, pretty much the same can be achieved by cloning the GitHub repository instead:
|
||||
|
||||
```
|
||||
$> git clone https://github.com/AssemblyScript/assemblyscript.git
|
||||
$> cd assemblyscript
|
||||
$> npm install
|
||||
$> npm link
|
||||
```
|
||||
|
||||
**Note** that a fresh clone of the compiler will use the distribution files in `dist/`, but it can also run [the sources](./src) directly through ts-node after an `npm run clean`, which is useful in development. This condition can also be checked by running `asc -v` (it is running the sources if it states `-dev`).
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
@ -38,42 +72,26 @@ Examples
|
||||
* **[WASM parser](./lib/parse)**<br />
|
||||
A WebAssembly binary parser in WebAssembly.
|
||||
|
||||
Or browse the [compiler tests](./tests/compiler) for a more in-depth overview of what's supported already. One of them is a [showcase](./tests/compiler/showcase.ts).
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Note that this version of the compiler is relatively new and that some features a TypeScript programmer might expect are [still in the works](https://github.com/AssemblyScript/assemblyscript/wiki/Status-and-Roadmap) (see also: [Limitations](https://github.com/AssemblyScript/assemblyscript/wiki/Limitations)). Therefore, it's not on [npm](https://www.npmjs.com/package/assemblyscript), yet, but you can already try it out today:
|
||||
|
||||
```
|
||||
$> git clone https://github.com/AssemblyScript/assemblyscript.git
|
||||
$> cd assemblyscript
|
||||
$> npm install
|
||||
$> npm link
|
||||
```
|
||||
|
||||
Alternatively, it's also possible to point npm to the GitHub repository for now:
|
||||
|
||||
```
|
||||
$> npm install AssemblyScript/assemblyscript
|
||||
```
|
||||
|
||||
Afterwards, once [your project is configured](https://github.com/AssemblyScript/assemblyscript/wiki/Configuring-a-project), it's just a matter of using your existing [TypeScript tooling](https://code.visualstudio.com) while coding, and [running the CLI](https://github.com/AssemblyScript/assemblyscript/wiki/Using-the-CLI) to build to WebAssembly:
|
||||
|
||||
```
|
||||
$> asc myModule.ts -o myModule.wasm --optimize --validate --sourceMap
|
||||
```
|
||||
|
||||
Building
|
||||
--------
|
||||
|
||||
To build an UMD bundle to `dist/assemblyscript.js` (depends on [binaryen.js](https://github.com/AssemblyScript/binaryen.js)):
|
||||
To build an UMD bundle to `dist/assemblyscript.js` (depends on [binaryen.js](https://github.com/AssemblyScript/binaryen.js)), including a browser version of asc to `dist/asc.js` (depends on assemblyscript.js):
|
||||
|
||||
```
|
||||
$> npm run build
|
||||
```
|
||||
|
||||
This also builds a browser version of [asc](./bin) to `dist/asc.js` (depends on assemblyscript.js).
|
||||
Cleaning the distributions files (again):
|
||||
|
||||
```
|
||||
$> npm run clean
|
||||
```
|
||||
|
||||
Linting potential changes:
|
||||
|
||||
```
|
||||
$> npm run lint
|
||||
```
|
||||
|
||||
Running the [tests](./tests):
|
||||
|
||||
@ -81,4 +99,8 @@ Running the [tests](./tests):
|
||||
$> npm test
|
||||
```
|
||||
|
||||
**Note** that freshly cloned copies of the compiler will use the distribution files, but it can also run [the sources](./src) directly through ts-node after an `npm run clean`, which is useful in development. This condition can also be checked by running `asc -v` (it is running the sources if it states `-dev`).
|
||||
Running everything in order (lint, clean, test, build, test):
|
||||
|
||||
```
|
||||
$> npm run all
|
||||
```
|
||||
|
@ -374,7 +374,7 @@ exports.main = function main(argv, options, callback) {
|
||||
}
|
||||
|
||||
// Enable additional features if specified
|
||||
var features = args.feature;
|
||||
var features = args.enable;
|
||||
if (features != null) {
|
||||
if (typeof features === "string") features = features.split(",");
|
||||
for (let i = 0, k = features.length; i < k; ++i) {
|
||||
|
@ -149,7 +149,7 @@
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"feature": {
|
||||
"enable": {
|
||||
"desc": [
|
||||
"Enables additional (experimental) WebAssembly features.",
|
||||
"",
|
||||
@ -157,7 +157,8 @@
|
||||
" mutable-global Enables mutable global imports and exports",
|
||||
""
|
||||
],
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"aliases": [ "feature" ]
|
||||
},
|
||||
"measure": {
|
||||
"desc": "Prints measuring information on I/O and compile times.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user