assemblyscript/cli at main · AssemblyScript/assemblyscript
Repository navigation
cli
Directory actions
More options
Directory actions
More options
Latest commit
History
History
View commit history for this file.
cli
Folders and files
| Name | Name | Last commit message | Last commit date |
|---|---|---|---|
parent directory.. | |||
| README.md | README.md | ||
| index.d.ts | index.d.ts | ||
| index.js | index.js | ||
| options.json | options.json | ||
| tsconfig.json | tsconfig.json | ||
README.md
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. Example:
import asc from "assemblyscript/asc";
const { error, stdout } = await asc.main([
"myModule.ts",
"--outFile", "myModule.wasm",
"--optimize",
"--sourceMap",
"--stats"
]);
if (error) {
console.log("Compilation failed: " + error.message);
} else {
console.log(stdout.toString());
}
The result has the following structure:
| Property | Description |
|---|---|
| error | Encountered error, if any |
| stdout | Standard output stream |
| stderr | Standard error stream |
| stats | Statistics |
You can also compile a single source string directly (note that this API has limited functionality):
import asc from "assemblyscript/asc";
const { binary, text, stdout, stderr } = await asc.compileString(`...`, { optimize: 2 });
...
Available command line options can also be obtained programmatically:
import { options } from "assemblyscript/asc";
...