Skip to content

Commit

Permalink
BREAKING CHANGE: ESM, JS bindings, triple equals and general cleanup (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO authored Mar 21, 2022
1 parent cf5a10a commit a7c87e6
Show file tree
Hide file tree
Showing 779 changed files with 127,990 additions and 251,587 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
dist/
docs/
lib/binaryen.js
lib/parse/index.js
out/
build/
raw/
tests/parser/

Expand Down
12 changes: 9 additions & 3 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global module */

module.exports = {
root: true,
parser: "@typescript-eslint/parser",
Expand All @@ -15,9 +17,14 @@ module.exports = {
ecmaFeatures: {}
},
globals: {
"globalThis": "readonly",
"BigInt64Array": "readonly",
"BigUint64Array": "readonly",
"__non_webpack_require__": "readonly"
"WebAssembly": "readonly",
"FinalizationRegistry": "readonly",
"fetch": "readonly",
"URL": "readonly",
"console": "readonly"
},

// === General rules =========================================================
Expand Down Expand Up @@ -218,8 +225,7 @@ module.exports = {

{
files: [
"./index.d.ts",
"./index.release.d.ts",
"./dist/*.d.ts"
],
rules: {
// Our definitions are complicated, and all attempts to describe them
Expand Down
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
bin/* text eol=lf
dist/* binary
scripts/*.sh eol=lf
lib/binaryen.js binary
tests/compiler/std/string-encoding.ts eol=lf
src/bindings/js.ts eol=lf
src/bindings/tsd.ts eol=lf
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
node ./scripts/prepublish
if [ $(node -pe "require('./package.json').version") != "0.0.0" ]; then
npx aspublish
fi
Expand All @@ -59,3 +60,4 @@ jobs:
npm publish --access public
fi
cd ../..
node ./scripts/prepublish --reset
114 changes: 31 additions & 83 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ jobs:
else
printf "\nOK: Distributions files have not been modified.\n";
fi
test:
name: "Compiler (Linux, node ${{ matrix.node_version }})"
runs-on: ubuntu-latest
compiler:
name: "Compiler (${{ matrix.os }}, node ${{ matrix.node_version }})"
runs-on: ${{ matrix.os }}-latest
needs: check
strategy:
matrix:
os: ["ubuntu", "macos"]
# TODO: re-enable "windows", see https://github.com/npm/cli/issues/4234
node_version: ["current", "lts_latest"]
steps:
- uses: actions/[email protected]
Expand All @@ -34,87 +36,33 @@ jobs:
node-version: ${{ matrix.node_version }}
- name: Install dependencies
run: npm ci --no-audit
- name: Clean distribution files
run: npm run clean
- name: Check sources
run: npm run check
- name: Test sources
run: npm test
- name: Build distribution files
- name: Build
run: npm run build
- name: Update entry file
run: npm run prepare-ci
- name: Test distribution
run: npm test
- name: Test browser build
run: node tests/browser-asc
# see: https://github.com/npm/cli/issues/4234
# test-windows:
# name: "Compiler (Windows, node current)"
# runs-on: windows-latest
# needs: check
# steps:
# - uses: actions/[email protected]
# - uses: dcodeIO/setup-node-nvm@master
# with:
# node-version: current
# - name: Install dependencies
# run: npm ci --no-audit
# - name: Clean distribution files
# run: npm run clean
# - name: Test sources
# run: npm test
# - name: Build distribution files
# run: npm run build
# - name: Update entry file
# run: npm run prepare-ci
# - name: Test distribution
# run: npm test
# - name: Test browser build
# run: node tests/browser-asc
test-macos:
name: "Compiler (MacOS, node current)"
runs-on: macos-latest
needs: check
steps:
- uses: actions/[email protected]
- uses: dcodeIO/setup-node-nvm@master
with:
node-version: current
- name: Install dependencies
run: npm ci --no-audit
- name: Clean distribution files
run: npm run clean
- name: Test sources
run: npm test
- name: Build distribution files
run: npm run build
- name: Update entry file
run: npm run prepare-ci
- name: Test distribution
- name: Check
run: npm run check
- name: Test
run: npm test
- name: Test browser build
run: node tests/browser-asc
test-bootstrap:
name: "Compiler (Bootstrap)"
bootstrap:
name: "Bootstrap (${{ matrix.target }})"
runs-on: ubuntu-latest
needs: check
strategy:
matrix:
target: ["debug", "release"]
steps:
- uses: actions/[email protected]
- uses: dcodeIO/setup-node-nvm@master
with:
node-version: current
- name: Install dependencies
run: npm ci --no-audit
- name: Clean distribution files
run: npm run clean
- name: Bootstrap the compiler
run: npm run bootstrap
- name: Run compiler tests (untouched-bootstrap)
run: npm run test:compiler -- --wasm out/assemblyscript.untouched-bootstrap.wasm
- name: Run compiler tests (optimized-bootstrap)
run: npm run test:compiler -- --wasm out/assemblyscript.optimized-bootstrap.wasm
test-features:
- name: Build
run: npm run build
- name: Bootstrap
run: npm run bootstrap:${{ matrix.target }}
- name: Test
run: npm run test:compiler -- --wasm build/assemblyscript.${{ matrix.target }}-bootstrap.js
features:
name: "Features"
runs-on: ubuntu-latest
needs: check
Expand All @@ -126,14 +74,14 @@ jobs:
node-version: 18.0.0-v8-canary20211115037fd7ae8d
- name: Install dependencies
run: npm ci --no-audit
- name: Clean distribution files
run: npm run clean
- name: Build
run: npm run build
- name: Test experimental features
env:
ASC_FEATURES: threads,reference-types,bigint-integration,gc
ASC_FEATURES: threads,reference-types,gc,exception-handling
run: |
npm run test:compiler rt/flags features/js-bigint-integration features/reference-types features/threads std-wasi/process std-wasi/crypto
test-runtimes:
npm run test:compiler features/threads features/reference-types features/gc features/exception-handling
runtimes:
name: "Runtimes"
runs-on: ubuntu-latest
needs: check
Expand All @@ -144,8 +92,8 @@ jobs:
node-version: current
- name: Install dependencies
run: npm ci --no-audit
- name: Clean distribution files
run: npm run clean
- name: Build
run: npm run build
- name: Test default allocator
run: |
cd tests/allocators/default
Expand All @@ -158,7 +106,7 @@ jobs:
npm run build
cd ..
npm test stub
test-loader:
loader:
name: "Loader"
runs-on: ubuntu-latest
needs: check
Expand All @@ -169,8 +117,8 @@ jobs:
node-version: current
- name: Install dependencies
run: npm ci --no-audit
- name: Clean distribution files
run: npm run clean
- name: Build
run: npm run build
- name: Test the loader
run: |
cd lib/loader
Expand Down
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
npm-debug.*
dist/
docs/
node_modules/
out/
*debug.log
dist/
build/
raw/
.history
*.backup
.vscode
.idea
cli/index.generated.js
src/diagnosticMessages.generated.ts
46 changes: 0 additions & 46 deletions CODE_OF_CONDUCT.md

This file was deleted.

19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,25 @@

<h2 align="center">Thanks to our sponsors!</h2>

<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>
<p align="justify">Most of the maintainers and 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>

<p align="center">
<a href="https://assemblyscript.org/#sponsors"><img src="https://assemblyscript.org/sponsors.svg" alt="Sponsor logos" width="720" /></a>
</p>

## Development instructions

A development environment can be set up by cloning the repository:

```sh
git clone https://github.com/AssemblyScript/assemblyscript.git
cd assemblyscript
npm install
npm link
```

The link step is optional and makes the development instance available globally. The full process is documented as part of the repository:

* [Compiler instructions](./src)
* [Runtime instructions](./std/assembly/rt)
* [Test instructions](./tests)
20 changes: 0 additions & 20 deletions bin/asc

This file was deleted.

33 changes: 33 additions & 0 deletions bin/asc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env node

const [ nodePath, thisPath, ...args ] = process.argv;
const nodeArgs = process.execArgv;

const hasSourceMaps = nodeArgs.includes("--enable-source-maps");
const posCustomArgs = args.indexOf("--");
const isDeno = typeof Deno !== "undefined";

if (isDeno) {
process.on = function() { /* suppress 'not implemented' message */ };
}

if ((!hasSourceMaps || ~posCustomArgs) && !isDeno) {
if (!hasSourceMaps) {
nodeArgs.push("--enable-source-maps");
}
if (~posCustomArgs) {
nodeArgs.push(...args.slice(posCustomArgs + 1));
args.length = posCustomArgs;
}
(await import("child_process")).spawnSync(
nodePath,
[...nodeArgs, thisPath, ...args],
{ stdio: "inherit" }
);
} else {
const { error } = (await import("../dist/asc.js")).main(process.argv.slice(2), {
stdout: process.stdout,
stderr: process.stderr
});
if (error) process.exitCode = 1;
}
Loading

0 comments on commit a7c87e6

Please sign in to comment.