2018-02-04 07:51:40 +01:00
|
|
|
Compiler frontend for node.js
|
|
|
|
=============================
|
|
|
|
|
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
|
|
|
|
For an up to date list of available command line options, see:
|
|
|
|
|
|
|
|
```
|
|
|
|
$> asc --help
|
|
|
|
```
|
|
|
|
|
|
|
|
API
|
|
|
|
---
|
|
|
|
|
|
|
|
The API accepts the same options as the CLI but also lets you override stdout and stderr and/or provide a callback. Example:
|
|
|
|
|
|
|
|
```js
|
2018-05-28 18:55:51 +02:00
|
|
|
const asc = require("assemblyscript/cli/asc");
|
2018-02-04 07:51:40 +01:00
|
|
|
asc.main([
|
|
|
|
"myModule.ts",
|
2018-03-03 18:38:38 +01:00
|
|
|
"--binaryFile", "myModule.wasm",
|
|
|
|
"--optimize",
|
2018-02-04 07:51:40 +01:00
|
|
|
"--sourceMap",
|
|
|
|
"--measure"
|
|
|
|
], {
|
|
|
|
stdout: process.stdout,
|
|
|
|
stderr: process.stderr
|
|
|
|
}, function(err) {
|
|
|
|
if (err)
|
|
|
|
throw err;
|
|
|
|
...
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
Available command line options can also be obtained programmatically:
|
|
|
|
|
|
|
|
```js
|
2018-05-28 18:55:51 +02:00
|
|
|
const options = require("assemblyscript/cli/asc.json");
|
2018-02-04 07:51:40 +01:00
|
|
|
...
|
|
|
|
```
|
2018-03-20 21:56:24 -04:00
|
|
|
|
2018-04-04 14:39:40 +02:00
|
|
|
You can also compile a source string directly, for example in a browser environment:
|
2018-03-20 21:56:24 -04:00
|
|
|
|
|
|
|
```js
|
2018-04-04 14:39:40 +02:00
|
|
|
const { binary, text, stdout, stderr } = asc.compileString(`...`, { optimize: 2 });
|
|
|
|
...
|
2018-03-20 21:56:24 -04:00
|
|
|
```
|