Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider updating our test matrix to support other js runtimes like Deno, or Bun, and so on #176

Open
mrchrisadams opened this issue Oct 16, 2023 · 2 comments

Comments

@mrchrisadams
Copy link
Member

The number of runtimes that are javascript or typescript compatible is growing.

Our tests assume nodejs as it's the most popular, but we're seeing Deno turn up in all kinds of places like Cloudflare workers (I think), and bun is also shaping up into a plausible alternative.

Our tests use jest right now via node - how would we support the other tools if we wanted to demonstrate wider support?

Here's our current unit test github action that runs on every PR or push to master:

name: Unit tests
on:
  push:
  pull_request:
  # snip

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [14.x, 16.x, 18.x]
    steps:
    - uses: actions/checkout@v3
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v3
      with:
        node-version: ${{ matrix.node-version }}
    - name: Install
      run: npm ci
    - name: Verify lint
      run: npm run lint
    - name: Run unit tests
      run: npm test
@mrchrisadams
Copy link
Member Author

mrchrisadams commented Nov 26, 2023

Wow, it looks like you can now compile javascript directly to wasm now, meaning you don't even need a runtime like Nodejs, Deno, Bun and so on - just something that can consume webassembly.

Javy is the tool that can do this:
https://github.com/bytecodealliance/javy

There are all kinds of restrictions on what you can actually do, but it might be a fun hackday project to see you can make tiny versions of CO2.js that can be consumed in other languages like python or php and so on, if they can consume WASM.

For example, I believe Python can consume WASM files using its wasmtime library, and PHP can do the same with wasmer-php.

More links below:

https://community.collabnix.com/using-webassembly-with-python
https://thenewstack.io/python-and-webassembly-elevating-performance-for-web-apps/

@mrchrisadams
Copy link
Member Author

Another interesting side effect of WASM would be a nice bump in efficiency, if this paper is anything to go by.

https://repositorio.inesctec.pt/server/api/core/bitstreams/0870fb76-d463-456b-9e34-5b33bb7c0dd1/content

This paper gives numbers for showing the same code run in JavaScript, and then using WASM. So, in addition to being able to be run in other runtimes, might also be more efficient.

We would probably need some way of making the types more explicit to compile to WASM. I think reading up on the WIT stuff below would shed some light.

https://component-model.bytecodealliance.org/design/wit.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant