Skip to content

Commit eabad4d

Browse files
committed
merge with upstream
2 parents 0c73215 + 64ec8b9 commit eabad4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+16545
-11278
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ module.exports = {
8787
"es6": true
8888
},
8989
files: [
90-
"**/*.js"
90+
"**/*.js",
91+
"bin/*"
9192
],
9293
rules: {
9394
// Node's support for ESM is still not great, but this rule is likely

.github/ISSUE_TEMPLATE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!--
2+
Thanks for submitting an issue to AssemblyScript! Please take a moment to
3+
read the contributing guidelines linked below to get off to a good start 🙂
4+
-->

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!--
2+
Thanks for submitting a pull request to AssemblyScript! Please take a moment to
3+
review the contributing guidelines linked below, and confirm with an [x] 🙂
4+
-->
5+
6+
7+
8+
9+
10+
- [ ] I've read the contributing guidelines

CONTRIBUTING.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,20 @@ Submitting Pull Requests
3535

3636
Instructions are similar to those for bug reports. Please provide the following information:
3737

38+
* If this is not a trivial fix, consider **creating an issue to discuss first** and **later link to it from the PR**.
3839
* Use a **clear and descriptive title** for the pull request.
39-
* Provide a **description of the suggested changes** in as many details as necessary.
40+
* Provide a **description of the changes** in as many details as necessary.
4041
* **Document your new code** where necessary.
4142
* Please **refrain from refactoring (unrelated code)** as it makes your pull request easier to review.
4243
* **Create tests for your new code** where necessary. For creating or updating tests, please see the [Test Instructions](./tests).
4344

44-
Before submitting your pull request, please make sure that the following conditions are met:
45+
Before submitting your pull request, also make sure that the following conditions are met:
4546

4647
* Your new code **adheres to the code style** through running `npm run check`.
4748
* Your new code **passes all existing and new tests** through running `npm run test`.
4849
* Your PR **excludes distribution files** in `dist/**`.
4950
* You appended yourself to the **list of contributors** in the [NOTICE](./NOTICE) file.
51+
52+
Please note that if a pull request is rather complicated, i.e. touches lots of internals, or became stale, it is not uncommon that a core contributor performs the final integration to get it done in good conscience while naming you as a co-author.
53+
54+
Thank you!

NOTICE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ under the licensing terms detailed in LICENSE:
2121
* Vladimir Tikhonov <reg@tikhonov.by>
2222
* Duncan Uszkay <duncan.uszkay@shopify.com>
2323
* Surma <surma@surma.dev>
24+
* Julien Letellier <letellier.julien@gmail.com>
25+
* Guido Zuidhof <me@guido.io>
2426

2527
Portions of this software are derived from third-party works licensed under
2628
the following terms:

README.md

Lines changed: 23 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,34 @@
1-
![](https://avatars1.githubusercontent.com/u/28916798?s=64) AssemblyScript
2-
=================
3-
4-
[![Actions Status](https://github.com/AssemblyScript/assemblyscript/workflows/Test/badge.svg?branch=master&event=push)](https://github.com/AssemblyScript/assemblyscript/actions) [![npm](https://img.shields.io/npm/v/assemblyscript.svg?color=0074C1)](https://www.npmjs.com/package/assemblyscript) [![npm@nightly](https://img.shields.io/npm/v/assemblyscript/nightly.svg?color=0074C1)](https://www.npmjs.com/package/assemblyscript)
5-
6-
**AssemblyScript** compiles a strict subset of [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.
7-
8-
Check out the [documentation](https://docs.assemblyscript.org) or try it out in [WebAssembly Studio](https://webassembly.studio)!
9-
10-
---
11-
12-
<h3 align="center">Our Sponsors</h3>
131
<p align="center">
14-
<a href="https://opencollective.com/assemblyscript/tiers/sponsor/0/website" target="_blank"><img src="https://opencollective.com/assemblyscript/tiers/sponsor/0/avatar.svg"></a>
15-
<a href="https://opencollective.com/assemblyscript/tiers/sponsor/1/website" target="_blank"><img src="https://opencollective.com/assemblyscript/tiers/sponsor/1/avatar.svg"></a>
16-
<a href="https://opencollective.com/assemblyscript/tiers/sponsor/2/website" target="_blank"><img src="https://opencollective.com/assemblyscript/tiers/sponsor/2/avatar.svg"></a>
17-
<a href="https://opencollective.com/assemblyscript/tiers/sponsor/3/website" target="_blank"><img src="https://opencollective.com/assemblyscript/tiers/sponsor/3/avatar.svg"></a>
18-
<a href="https://opencollective.com/assemblyscript/tiers/sponsor/4/website" target="_blank"><img src="https://opencollective.com/assemblyscript/tiers/sponsor/4/avatar.svg"></a>
19-
<a href="https://opencollective.com/assemblyscript/tiers/sponsor/5/website" target="_blank"><img src="https://opencollective.com/assemblyscript/tiers/sponsor/5/avatar.svg"></a>
20-
<a href="https://opencollective.com/assemblyscript/tiers/sponsor/6/website" target="_blank"><img src="https://opencollective.com/assemblyscript/tiers/sponsor/6/avatar.svg"></a>
21-
<a href="https://opencollective.com/assemblyscript/tiers/sponsor/7/website" target="_blank"><img src="https://opencollective.com/assemblyscript/tiers/sponsor/7/avatar.svg"></a>
22-
<a href="https://opencollective.com/assemblyscript/tiers/sponsor/8/website" target="_blank"><img src="https://opencollective.com/assemblyscript/tiers/sponsor/8/avatar.svg"></a>
23-
<a href="https://opencollective.com/assemblyscript/tiers/sponsor/9/website" target="_blank"><img src="https://opencollective.com/assemblyscript/tiers/sponsor/9/avatar.svg"></a>
2+
<a href="https://assemblyscript.org" target="_blank" rel="noopener"><img width="100" src="https://avatars1.githubusercontent.com/u/28916798?s=200&v=4" alt="AssemblyScript logo"></a>
243
</p>
25-
<br />
26-
<h3 align="center">Our Backers</h3>
27-
<p align="center">
28-
<a href="https://opencollective.com/assemblyscript#backers" target="_blank"><img src="https://opencollective.com/assemblyscript/backer.svg?avatarHeight=44" /></a>
29-
</p>
30-
31-
The core team members and most contributors do this open source work in their free time. If you use AssemblyScript for a serious task or plan to do so, and you'd like us to invest more time on it, [please donate to our OpenCollective](https://opencollective.com/assemblyscript). By sponsoring this project, your logo will show up above. Thank you so much for your support!
32-
33-
---
344

35-
Motivation
36-
----------
5+
<h1 align="center">AssemblyScript Compiler</h1>
376

38-
> You are now able to write WebAssembly, without learning a new language, and harness all these benefits WebAssembly might offer you. I think that is kind of powerful. [...] It [AssemblyScript] is absolutely usable, and very enjoyable! - Surma, [WebAssembly for Web Developers (Google I/O ’19)](https://youtu.be/njt-Qzw0mVY) (May 8th, 2019)
39-
40-
> AssemblyScript was frictionless. Not only does it allow you to use TypeScript to write WebAssembly, [...] it also produces glue-free WebAssembly modules that are very small with decent performance. – Surma, [Replacing a hot path in your app's JavaScript with WebAssembly](https://developers.google.com/web/updates/2019/02/hotpath-with-wasm) (Feb 16, 2019)
7+
<p align="center">
8+
<a href="https://github.com/AssemblyScript/assemblyscript/actions"><img src="https://github.com/AssemblyScript/assemblyscript/workflows/Test/badge.svg?branch=master&event=push" alt="Actions Status" /></a>
9+
<a href="https://www.npmjs.com/package/assemblyscript"><img src="https://img.shields.io/npm/v/assemblyscript.svg?color=0074C1" alt="npm package" /></a>
10+
<a href="https://www.npmjs.com/package/assemblyscript"><img src="https://img.shields.io/npm/v/assemblyscript/nightly.svg?color=0074C1" alt="npm package (nightly)" /></a>
11+
</p>
4112

42-
> Perhaps the fundamental issue [to get a small .wasm file] is that JavaScript is the only language for which the Web runtime is a perfect fit. Close relatives that were designed to compile to it, like TypeScript, can be very efficient as well. But languages like C, C++, Rust, and so forth were not originally designed for that purpose. – Alon Zakai, [Small WebAssembly Binaries with Rust + Emscripten](https://kripken.github.io/blog/binaryen/2018/04/18/rust-emscripten.html) (Apr 18, 2018)
13+
<p align="justify">AssemblyScript compiles a strict variant of <a href="http://www.typescriptlang.org">TypeScript</a> (basically JavaScript with types) to <a href="http://webassembly.org">WebAssembly</a> using <a href="https://github.com/WebAssembly/binaryen">Binaryen</a>. It generates lean and mean WebAssembly modules while being just an <code>npm install</code> away.</p>
4314

44-
> JavaScript's heyday as the only browser language is over, but most web developers are used to writing JavaScript, and learning a new syntax just to get access to WebAssembly is not (always) ideal. If only there was something in to bridge the gap… – Jani Tarvainen, [TypeScript is the bridge between JavaScript and WebAssembly](https://malloc.fi/typescript-bridge-javascript-webassembly) (Feb 20, 2018)
15+
<p align="center">
16+
<a href="https://assemblyscript.org">About</a> ·
17+
<a href="https://assemblyscript.org/introduction.html">Introduction</a> ·
18+
<a href="https://assemblyscript.org/quick-start.html">Quick start</a> ·
19+
<a href="https://assemblyscript.org/development.html">Development instructions</a>
20+
</p>
4521

46-
> 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)
22+
<h2 align="center">Contributors</h2>
4723

48-
Further resources
49-
-----------------
24+
<p align="center">
25+
<a href="https://assemblyscript.org/#contributors"><img src="https://assemblyscript.org/contributors.svg" alt="Contributor logos" /></a>
26+
</p>
5027

51-
* [Documentation](https://docs.assemblyscript.org)<br />
52-
Introduction, quick start, examples and general usage instructions.
28+
<h2 align="center">Thanks to our sponsors!</h2>
5329

54-
* [Development instructions](https://docs.assemblyscript.org/details/development)<br />
55-
How to set up a development environment (to submit a pull request).
30+
<p align="justify">Most of the core team members and most contributors do this open source work in their free time. If you use AssemblyScript for a serious task or plan to do so, and you'd like us to invest more time on it, <a href="https://opencollective.com/assemblyscript/donate" target="_blank" rel="noopener">please donate</a> to our <a href="https://opencollective.com/assemblyscript" target="_blank" rel="noopener">OpenCollective</a>. By sponsoring this project, your logo will show up below. Thank you so much for your support!</p>
5631

57-
* [Project governance](https://github.com/AssemblyScript/working-group)<br />
58-
Discussions, goals, roadmaps, assets, etc. related to development and project organization.
32+
<p align="center">
33+
<a href="https://assemblyscript.org/#sponsors"><img src="https://assemblyscript.org/sponsors.svg" alt="Sponsor logos" /></a>
34+
</p>

bin/asinit

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ const compilerDir = path.join(__dirname, "..");
4242
const compilerVersion = require(path.join(compilerDir, "package.json")).version;
4343
const assemblyDir = path.join(projectDir, "assembly");
4444
const tsconfigFile = path.join(assemblyDir, "tsconfig.json");
45-
const tsconfigBase = path.relative(assemblyDir, path.join(compilerDir, "std", "assembly.json"));
45+
let tsconfigBase = path.relative(assemblyDir, path.join(compilerDir, "std", "assembly.json"));
46+
if (/^(\.\.[/\\])*node_modules[/\\]assemblyscript[/\\]/.test(tsconfigBase)) {
47+
// Use node resolution if the compiler is a normal dependency
48+
tsconfigBase = "assemblyscript/std/assembly.json";
49+
}
4650
const entryFile = path.join(assemblyDir, "index.ts");
4751
const buildDir = path.join(projectDir, "build");
4852
const testsDir = path.join(projectDir, "tests");
@@ -247,7 +251,7 @@ function ensureGitignore() {
247251
}
248252

249253
function ensurePackageJson() {
250-
console.log("- Making sure that 'package.json' contains the build commands...")
254+
console.log("- Making sure that 'package.json' contains the build commands...");
251255
const entryPath = path.relative(projectDir, entryFile).replace(/\\/g, "/");
252256
const buildUntouched = "asc " + entryPath + " -b build/untouched.wasm -t build/untouched.wat --sourceMap --debug";
253257
const buildOptimized = "asc " + entryPath + " -b build/optimized.wasm -t build/optimized.wat --sourceMap --optimize";

cli/asc.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,20 @@ exports.main = function main(argv, options, callback) {
207207
// Check for unknown arguments
208208
if (opts.unknown.length) {
209209
opts.unknown.forEach(arg => {
210-
stderr.write(colorsUtil.stderr.yellow("WARN: ") + "Unknown option '" + arg + "'" + EOL);
210+
stderr.write(colorsUtil.stderr.yellow("WARNING ") + "Unknown option '" + arg + "'" + EOL);
211211
});
212212
}
213213

214214
// Check for trailing arguments
215215
if (opts.trailing.length) {
216-
stderr.write(colorsUtil.stderr.yellow("WARN: ") + "Unsupported trailing arguments: " + opts.trailing.join(" ") + EOL);
216+
stderr.write(colorsUtil.stderr.yellow("WARNING ") + "Unsupported trailing arguments: " + opts.trailing.join(" ") + EOL);
217217
}
218218

219219
// Use default callback if none is provided
220220
if (!callback) callback = function defaultCallback(err) {
221221
var code = 0;
222222
if (err) {
223-
stderr.write(colorsUtil.stderr.red("ERROR: ") + err.stack.replace(/^ERROR: /i, "") + EOL);
223+
stderr.write(colorsUtil.stderr.red("FAILURE ") + err.stack.replace(/^ERROR: /i, "") + EOL);
224224
code = 1;
225225
}
226226
return code;
@@ -534,15 +534,20 @@ exports.main = function main(argv, options, callback) {
534534
var internalPath;
535535
while ((internalPath = assemblyscript.nextFile(program)) != null) {
536536
let file = getFile(internalPath, assemblyscript.getDependee(program, internalPath));
537-
if (!file) return callback(Error("Import '" + internalPath + "' not found."));
538-
stats.parseCount++;
539-
stats.parseTime += measure(() => {
540-
assemblyscript.parse(program, file.sourceText, file.sourcePath, false);
541-
});
537+
if (file) {
538+
stats.parseCount++;
539+
stats.parseTime += measure(() => {
540+
assemblyscript.parse(program, file.sourceText, file.sourcePath, false);
541+
});
542+
} else {
543+
assemblyscript.parse(program, null, internalPath + extension.ext, false);
544+
}
542545
}
543546
var numErrors = checkDiagnostics(program, stderr);
544547
if (numErrors) {
545-
return callback(Error(numErrors + " parse error(s)"));
548+
const err = Error(numErrors + " parse error(s)");
549+
err.stack = err.message; // omit stack
550+
return callback(err);
546551
}
547552
}
548553

@@ -577,8 +582,8 @@ exports.main = function main(argv, options, callback) {
577582
let sourceText = readFile(sourcePath + extension.ext, baseDir);
578583
if (sourceText == null) {
579584
sourceText = readFile(sourcePath + "/index" + extension.ext, baseDir);
580-
if (sourceText == null) return callback(Error("Entry file '" + sourcePath + extension.ext + "' not found."));
581-
sourcePath += "/index" + extension.ext;
585+
if (sourceText != null) sourcePath += "/index" + extension.ext;
586+
else sourcePath += extension.ext;
582587
} else {
583588
sourcePath += extension.ext;
584589
}
@@ -634,7 +639,9 @@ exports.main = function main(argv, options, callback) {
634639
var numErrors = checkDiagnostics(program, stderr);
635640
if (numErrors) {
636641
if (module) module.dispose();
637-
return callback(Error(numErrors + " compile error(s)"));
642+
const err = Error(numErrors + " compile error(s)");
643+
err.stack = err.message; // omit stack
644+
return callback(err);
638645
}
639646

640647
// Call afterCompile transform hook

examples/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)