Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ module.exports = {
// Quite often, dealing with multiple related cases at once or otherwise
// falling through is exactly the point of using a switch.
"no-fallthrough": "off",
"no-useless-assignment": "off",
"no-unassigned-vars": "off",
"preserve-caught-error": "off",

// Typical false-positives here are `do { ... } while (true)` statements or
// similar, but the only option provided here is not checking any loops.
Expand Down
199 changes: 102 additions & 97 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,48 @@ name: Test
on:
push:
branches:
- main
- main
pull_request:
jobs:
check:
name: "Check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: "Check that distribution files are unmodified"
if: github.event_name == 'pull_request'
run: |
if git --no-pager diff --name-only $(git rev-parse origin/${{ github.base_ref }})...${{ github.sha }} | grep -q "^dist/"; then
printf "\nThe pull request modifies distribution files, but it shouldn't.\n" &&
printf "Please see https://github.com/AssemblyScript/assemblyscript/blob/main/CONTRIBUTING.md\n" &&
exit 1;
else
printf "\nOK: Distributions files have not been modified.\n";
fi
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24'
- name: "Check that distribution files are unmodified"
if: github.event_name == 'pull_request'
run: |
if git --no-pager diff --name-only $(git rev-parse origin/${{ github.base_ref }})...${{ github.sha }} | grep -q "^dist/"; then
printf "\nThe pull request modifies distribution files, but it shouldn't.\n" &&
printf "Please see https://github.com/AssemblyScript/assemblyscript/blob/main/CONTRIBUTING.md\n" &&
exit 1;
else
printf "\nOK: Distributions files have not been modified.\n";
fi
compiler:
name: "Compiler (${{ matrix.os }}, node ${{ matrix.node_version }})"
runs-on: ${{ matrix.os }}-latest
needs: check
strategy:
matrix:
os: ["ubuntu", "macos", "windows"]
node_version: ["current", "lts/*"]
node_version: ["25", "lts/*"]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node_version }}
- name: Install dependencies
run: npm ci --no-audit
- name: Build
run: npm run build
- name: Check
run: npm run check
- name: Test
run: npm test
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node_version }}
- name: Install dependencies
run: npm ci --no-audit
- name: Build
run: npm run build
- name: Check
run: npm run check
- name: Test
run: npm test
bootstrap:
name: "Bootstrap (${{ matrix.target }})"
runs-on: ubuntu-latest
Expand All @@ -49,95 +52,97 @@ jobs:
matrix:
target: ["debug", "release"]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: current
- name: Install dependencies
run: npm ci --no-audit
- name: Build
run: npm run build
- name: "Bootstrap ${{ matrix.target }}"
run: npm run bootstrap:${{ matrix.target }}
- name: "Test ${{ matrix.target }}"
run: npm run test:compiler -- --wasm build/assemblyscript.${{ matrix.target }}-bootstrap.js
- name: "Compile ${{ matrix.target }} -> ${{ matrix.target == 'debug' && 'release' || 'debug' }}"
run: node bin/asc --config src/asconfig.json --target ${{ matrix.target == 'debug' && 'release' || 'debug' }}-bootstrap --wasm ./build/assemblyscript.${{ matrix.target }}-bootstrap.js
- name: "Test ${{ matrix.target == 'debug' && 'release' || 'debug' }}"
run: npm run test:compiler -- --wasm build/assemblyscript.${{ matrix.target == 'debug' && 'release' || 'debug' }}-bootstrap.js
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: current
- name: Install dependencies
run: npm ci --no-audit
- name: Build
run: npm run build
- name: "Bootstrap ${{ matrix.target }}"
run: npm run bootstrap:${{ matrix.target }}
- name: "Test ${{ matrix.target }}"
run: npm run test:compiler -- --wasm build/assemblyscript.${{ matrix.target }}-bootstrap.js
- name: "Compile ${{ matrix.target }} -> ${{ matrix.target == 'debug' && 'release' || 'debug' }}"
run: node bin/asc --config src/asconfig.json --target ${{ matrix.target == 'debug' && 'release' || 'debug' }}-bootstrap --wasm ./build/assemblyscript.${{ matrix.target }}-bootstrap.js
- name: "Test ${{ matrix.target == 'debug' && 'release' || 'debug' }}"
run: npm run test:compiler -- --wasm build/assemblyscript.${{ matrix.target == 'debug' && 'release' || 'debug' }}-bootstrap.js
features:
name: "Features"
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
- name: Install dependencies
run: npm ci --no-audit
- name: Build
run: npm run build
- name: Test experimental features
env:
ASC_FEATURES: threads,reference-types,gc,exception-handling
run: |
npm run test:compiler features/threads features/reference-types features/gc features/exception-handling bindings/esm bindings/raw
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24'
- name: Install dependencies
run: npm ci --no-audit
- name: Build
run: npm run build
- name: Test experimental features
env:
ASC_FEATURES: threads,reference-types,gc,exception-handling
run: |
npm run test:compiler features/threads features/reference-types features/gc features/exception-handling bindings/esm bindings/raw
runtimes:
name: "Runtimes"
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: current
- name: Install dependencies
run: npm ci --no-audit
- name: Build
run: npm run build
- name: Test default allocator
run: |
cd tests/allocators/default
npm run build
cd ..
npm test default
- name: Test stub allocator
run: |
cd tests/allocators/stub
npm run build
cd ..
npm test stub
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: current
- name: Install dependencies
run: npm ci --no-audit
- name: Build
run: npm run build
- name: Test default allocator
run: |
cd tests/allocators/default
npm run build
cd ..
npm test default
- name: Test stub allocator
run: |
cd tests/allocators/stub
npm run build
cd ..
npm test stub
loader:
name: "Loader"
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: current
- name: Install dependencies
run: npm ci --no-audit
- name: Build
run: npm run build
- name: Test the loader
run: |
cd lib/loader
npm run asbuild
npm run test
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: current
- name: Install dependencies
run: npm ci --no-audit
- name: Build
run: npm run build
- name: Test the loader
run: |
cd lib/loader
npm run asbuild
npm run test
coverage:
name: "Coverage"
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
- name: Install dependencies
run: npm ci --no-audit
- name: Build
run: npm run build
- name: Collect coverage
run: npx c8 -r none -- npm test
- name: Output coverage summary
run: npx c8 report -r text-summary
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
- name: Install dependencies
run: npm ci --no-audit
- name: Build
run: npm run build
- name: Collect coverage
run: npx c8 -r none -- npm test
- name: Output coverage summary
run: npx c8 report -r text-summary
7 changes: 7 additions & 0 deletions cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ export async function main(argv, options) {
switch (opts.runtime) {
case "stub": runtime = 0; break;
case "minimal": runtime = 1; break;
case "memory": runtime = 3; break;
/* incremental */
default: runtime = 2; break;
}
Expand Down Expand Up @@ -731,6 +732,12 @@ export async function main(argv, options) {
try {
module = assemblyscript.compile(program);
} catch (e) {
let numErrors = checkDiagnostics(program, stderr, opts.disableWarning, options.reportDiagnostic, stderrColors.enabled);
if (numErrors) {
const err = Error(`${numErrors} compile error(s)`);
err.stack = err.message;
return prepareResult(err);
}
crash("compile", e);
}
stats.compileTime += stats.end(begin);
Expand Down
6 changes: 5 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default tseslint.config(
]
},


eslint.configs.recommended,

// === General rules =========================================================
Expand Down Expand Up @@ -65,14 +66,17 @@ export default tseslint.config(
// It is perfectly fine to declare top-level variables with `var`, yet this
// rule doesn't provide configuration options that would help.
"no-var": "off",
"no-useless-assignment": "off",
"no-unassigned-vars": "off",
"preserve-caught-error": "off",

// Quite often, dealing with multiple related cases at once or otherwise
// falling through is exactly the point of using a switch.
"no-fallthrough": "off",

// Typical false-positives here are `do { ... } while (true)` statements or
// similar, but the only option provided here is not checking any loops.
"no-constant-condition": ["error", { checkLoops: false }],
"no-constant-condition": ["error", {checkLoops: false}],

// Functions are nested in blocks occasionally, and there haven't been any
// problems with this so far, so turning the check off.
Expand Down
2 changes: 1 addition & 1 deletion lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Additional packages provided by the main package.

| Package | Description
|------------------------------------|-------------------------
| [@assemblyscript/loader](./loader) | Module loader utility
| [@btc-vision/as-loader](./loader) | Module loader utility
| [@assemblyscript/rtrace](./rtrace) | Runtime tracing utility
| binaryen | Binaryen proxy

Expand Down
10 changes: 5 additions & 5 deletions lib/loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A tiny module loader that makes working with AssemblyScript modules as convenien
## Example

```ts
import loader from "@assemblyscript/loader"; // or require
import loader from "@btc-vision/as-loader"; // or require
loader.instantiate(
// Binary to instantiate
fetch("optimized.wasm"), // or fs.readFileSync
Expand All @@ -24,19 +24,19 @@ The loader basically instantiates the module using `WebAssembly` APIs, but also

## Installation

The loader can be installed from [npm](https://www.npmjs.com/package/@assemblyscript/loader):
The loader can be installed from [npm](https://www.npmjs.com/package/@btc-vision/as-loader):

```sh
npm install --save @assemblyscript/loader
npm install --save @btc-vision/as-loader
```

On the web:

```html
<!-- ESM -->
<script type="module" src="https://cdn.jsdelivr.net/npm/@assemblyscript/loader/index.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@btc-vision/as-loader/index.js"></script>
<!-- UMD -->
<script src="https://cdn.jsdelivr.net/npm/@assemblyscript/loader/umd/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@btc-vision/as-loader/umd/index.js"></script>
```

## Usage
Expand Down
Loading