Skip to content

Commit a7c87e6

Browse files
authored
BREAKING CHANGE: ESM, JS bindings, triple equals and general cleanup (#2157)
1 parent cf5a10a commit a7c87e6

File tree

779 files changed

+127990
-251587
lines changed

Some content is hidden

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

779 files changed

+127990
-251587
lines changed

.eslintignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
dist/
2-
docs/
32
lib/binaryen.js
43
lib/parse/index.js
5-
out/
4+
build/
65
raw/
76
tests/parser/
87

.eslintrc.js .eslintrc.cjs

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* global module */
2+
13
module.exports = {
24
root: true,
35
parser: "@typescript-eslint/parser",
@@ -15,9 +17,14 @@ module.exports = {
1517
ecmaFeatures: {}
1618
},
1719
globals: {
20+
"globalThis": "readonly",
1821
"BigInt64Array": "readonly",
1922
"BigUint64Array": "readonly",
20-
"__non_webpack_require__": "readonly"
23+
"WebAssembly": "readonly",
24+
"FinalizationRegistry": "readonly",
25+
"fetch": "readonly",
26+
"URL": "readonly",
27+
"console": "readonly"
2128
},
2229

2330
// === General rules =========================================================
@@ -218,8 +225,7 @@ module.exports = {
218225

219226
{
220227
files: [
221-
"./index.d.ts",
222-
"./index.release.d.ts",
228+
"./dist/*.d.ts"
223229
],
224230
rules: {
225231
// Our definitions are complicated, and all attempts to describe them

.gitattributes

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
bin/* text eol=lf
22
dist/* binary
33
scripts/*.sh eol=lf
4-
lib/binaryen.js binary
54
tests/compiler/std/string-encoding.ts eol=lf
5+
src/bindings/js.ts eol=lf
6+
src/bindings/tsd.ts eol=lf

.github/workflows/publish.yml

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4848
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4949
run: |
50+
node ./scripts/prepublish
5051
if [ $(node -pe "require('./package.json').version") != "0.0.0" ]; then
5152
npx aspublish
5253
fi
@@ -59,3 +60,4 @@ jobs:
5960
npm publish --access public
6061
fi
6162
cd ../..
63+
node ./scripts/prepublish --reset

.github/workflows/test.yml

+31-83
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ jobs:
2020
else
2121
printf "\nOK: Distributions files have not been modified.\n";
2222
fi
23-
test:
24-
name: "Compiler (Linux, node ${{ matrix.node_version }})"
25-
runs-on: ubuntu-latest
23+
compiler:
24+
name: "Compiler (${{ matrix.os }}, node ${{ matrix.node_version }})"
25+
runs-on: ${{ matrix.os }}-latest
2626
needs: check
2727
strategy:
2828
matrix:
29+
os: ["ubuntu", "macos"]
30+
# TODO: re-enable "windows", see https://github.com/npm/cli/issues/4234
2931
node_version: ["current", "lts_latest"]
3032
steps:
3133
- uses: actions/[email protected]
@@ -34,87 +36,33 @@ jobs:
3436
node-version: ${{ matrix.node_version }}
3537
- name: Install dependencies
3638
run: npm ci --no-audit
37-
- name: Clean distribution files
38-
run: npm run clean
39-
- name: Check sources
40-
run: npm run check
41-
- name: Test sources
42-
run: npm test
43-
- name: Build distribution files
39+
- name: Build
4440
run: npm run build
45-
- name: Update entry file
46-
run: npm run prepare-ci
47-
- name: Test distribution
48-
run: npm test
49-
- name: Test browser build
50-
run: node tests/browser-asc
51-
# see: https://github.com/npm/cli/issues/4234
52-
# test-windows:
53-
# name: "Compiler (Windows, node current)"
54-
# runs-on: windows-latest
55-
# needs: check
56-
# steps:
57-
# - uses: actions/[email protected]
58-
# - uses: dcodeIO/setup-node-nvm@master
59-
# with:
60-
# node-version: current
61-
# - name: Install dependencies
62-
# run: npm ci --no-audit
63-
# - name: Clean distribution files
64-
# run: npm run clean
65-
# - name: Test sources
66-
# run: npm test
67-
# - name: Build distribution files
68-
# run: npm run build
69-
# - name: Update entry file
70-
# run: npm run prepare-ci
71-
# - name: Test distribution
72-
# run: npm test
73-
# - name: Test browser build
74-
# run: node tests/browser-asc
75-
test-macos:
76-
name: "Compiler (MacOS, node current)"
77-
runs-on: macos-latest
78-
needs: check
79-
steps:
80-
- uses: actions/[email protected]
81-
- uses: dcodeIO/setup-node-nvm@master
82-
with:
83-
node-version: current
84-
- name: Install dependencies
85-
run: npm ci --no-audit
86-
- name: Clean distribution files
87-
run: npm run clean
88-
- name: Test sources
89-
run: npm test
90-
- name: Build distribution files
91-
run: npm run build
92-
- name: Update entry file
93-
run: npm run prepare-ci
94-
- name: Test distribution
41+
- name: Check
42+
run: npm run check
43+
- name: Test
9544
run: npm test
96-
- name: Test browser build
97-
run: node tests/browser-asc
98-
test-bootstrap:
99-
name: "Compiler (Bootstrap)"
45+
bootstrap:
46+
name: "Bootstrap (${{ matrix.target }})"
10047
runs-on: ubuntu-latest
10148
needs: check
49+
strategy:
50+
matrix:
51+
target: ["debug", "release"]
10252
steps:
10353
- uses: actions/[email protected]
10454
- uses: dcodeIO/setup-node-nvm@master
10555
with:
10656
node-version: current
10757
- name: Install dependencies
10858
run: npm ci --no-audit
109-
- name: Clean distribution files
110-
run: npm run clean
111-
- name: Bootstrap the compiler
112-
run: npm run bootstrap
113-
- name: Run compiler tests (untouched-bootstrap)
114-
run: npm run test:compiler -- --wasm out/assemblyscript.untouched-bootstrap.wasm
115-
- name: Run compiler tests (optimized-bootstrap)
116-
run: npm run test:compiler -- --wasm out/assemblyscript.optimized-bootstrap.wasm
117-
test-features:
59+
- name: Build
60+
run: npm run build
61+
- name: Bootstrap
62+
run: npm run bootstrap:${{ matrix.target }}
63+
- name: Test
64+
run: npm run test:compiler -- --wasm build/assemblyscript.${{ matrix.target }}-bootstrap.js
65+
features:
11866
name: "Features"
11967
runs-on: ubuntu-latest
12068
needs: check
@@ -126,14 +74,14 @@ jobs:
12674
node-version: 18.0.0-v8-canary20211115037fd7ae8d
12775
- name: Install dependencies
12876
run: npm ci --no-audit
129-
- name: Clean distribution files
130-
run: npm run clean
77+
- name: Build
78+
run: npm run build
13179
- name: Test experimental features
13280
env:
133-
ASC_FEATURES: threads,reference-types,bigint-integration,gc
81+
ASC_FEATURES: threads,reference-types,gc,exception-handling
13482
run: |
135-
npm run test:compiler rt/flags features/js-bigint-integration features/reference-types features/threads std-wasi/process std-wasi/crypto
136-
test-runtimes:
83+
npm run test:compiler features/threads features/reference-types features/gc features/exception-handling
84+
runtimes:
13785
name: "Runtimes"
13886
runs-on: ubuntu-latest
13987
needs: check
@@ -144,8 +92,8 @@ jobs:
14492
node-version: current
14593
- name: Install dependencies
14694
run: npm ci --no-audit
147-
- name: Clean distribution files
148-
run: npm run clean
95+
- name: Build
96+
run: npm run build
14997
- name: Test default allocator
15098
run: |
15199
cd tests/allocators/default
@@ -158,7 +106,7 @@ jobs:
158106
npm run build
159107
cd ..
160108
npm test stub
161-
test-loader:
109+
loader:
162110
name: "Loader"
163111
runs-on: ubuntu-latest
164112
needs: check
@@ -169,8 +117,8 @@ jobs:
169117
node-version: current
170118
- name: Install dependencies
171119
run: npm ci --no-audit
172-
- name: Clean distribution files
173-
run: npm run clean
120+
- name: Build
121+
run: npm run build
174122
- name: Test the loader
175123
run: |
176124
cd lib/loader

.gitignore

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
npm-debug.*
2-
dist/
3-
docs/
41
node_modules/
5-
out/
2+
*debug.log
3+
dist/
4+
build/
65
raw/
76
.history
87
*.backup
98
.vscode
109
.idea
10+
cli/index.generated.js
11+
src/diagnosticMessages.generated.ts

CODE_OF_CONDUCT.md

-46
This file was deleted.

README.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,25 @@
3131

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

34-
<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>
34+
<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>
3535

3636
<p align="center">
3737
<a href="https://assemblyscript.org/#sponsors"><img src="https://assemblyscript.org/sponsors.svg" alt="Sponsor logos" width="720" /></a>
3838
</p>
39+
40+
## Development instructions
41+
42+
A development environment can be set up by cloning the repository:
43+
44+
```sh
45+
git clone https://github.com/AssemblyScript/assemblyscript.git
46+
cd assemblyscript
47+
npm install
48+
npm link
49+
```
50+
51+
The link step is optional and makes the development instance available globally. The full process is documented as part of the repository:
52+
53+
* [Compiler instructions](./src)
54+
* [Runtime instructions](./std/assembly/rt)
55+
* [Test instructions](./tests)

bin/asc

-20
This file was deleted.

bin/asc.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env node
2+
3+
const [ nodePath, thisPath, ...args ] = process.argv;
4+
const nodeArgs = process.execArgv;
5+
6+
const hasSourceMaps = nodeArgs.includes("--enable-source-maps");
7+
const posCustomArgs = args.indexOf("--");
8+
const isDeno = typeof Deno !== "undefined";
9+
10+
if (isDeno) {
11+
process.on = function() { /* suppress 'not implemented' message */ };
12+
}
13+
14+
if ((!hasSourceMaps || ~posCustomArgs) && !isDeno) {
15+
if (!hasSourceMaps) {
16+
nodeArgs.push("--enable-source-maps");
17+
}
18+
if (~posCustomArgs) {
19+
nodeArgs.push(...args.slice(posCustomArgs + 1));
20+
args.length = posCustomArgs;
21+
}
22+
(await import("child_process")).spawnSync(
23+
nodePath,
24+
[...nodeArgs, thisPath, ...args],
25+
{ stdio: "inherit" }
26+
);
27+
} else {
28+
const { error } = (await import("../dist/asc.js")).main(process.argv.slice(2), {
29+
stdout: process.stdout,
30+
stderr: process.stderr
31+
});
32+
if (error) process.exitCode = 1;
33+
}

0 commit comments

Comments
 (0)