Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,57 +29,69 @@ jobs:
uses: docker-practice/actions-setup-docker@1.0.8
if: matrix.platform == 'macos-latest'

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
# We need `git log` to find git-subtree versions
fetch-depth: 0

- name: Yarn cache
uses: actions/cache@v3
- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
path: "**/.yarn/cache"
key: ${{ hashFiles('**/yarn.lock') }}
node-version: 22
cache: 'pnpm'

- name: Install dependencies
run: yarn install --immutable
env:
YARN_ENABLE_SCRIPTS: 0
run: pnpm install --frozen-lockfile --ignore-scripts

- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.9

- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: '5.0.1'
actions-cache-folder: 'emsdk-cache'

- name: EMSDK cache
- name: EMSDK cache (Docker fallback)
uses: actions/cache@v3
with:
path: "emsdk-cache"
key: ${{ hashFiles('scripts/emcc.sh') }}
key: emsdk-docker-${{ hashFiles('scripts/emcc.sh') }}

- name: Environment info
run: |
echo $(which node) v$(node --version)
echo $(which yarn) v$(yarn --version)
echo $(which pnpm) v$(pnpm --version)
echo $(which npx) v$(npx --version)
echo $(npx which tsc) $(npx tsc --version)
echo $(npx which tsup) $(npx tsup --version)
echo $(npx which esbuild) v$(npx esbuild --version)
echo "emcc: $(which emcc) $(emcc --version | head -1)"
echo "sccache: $(which sccache) $(sccache --version)"

- name: Build
run: yarn build
run: pnpm run build
env:
SCCACHE_GHA_ENABLED: "true"

- name: sccache stats
run: sccache --show-stats

- name: Check types
run: yarn check:types
run: pnpm run check:types

- name: Check package.jsons
run: yarn check:packages
run: pnpm run check:packages

- name: Test
run: yarn test:slow
run: pnpm run test:slow

- name: Build tarballs
run: yarn tarball && du -h build/tar/*
run: pnpm run tarball && du -h build/tar/*

- name: Test release with NodeJS minimal ESModule example
run: ./scripts/smoketest-node-minimal.ts
Expand All @@ -94,7 +106,7 @@ jobs:
run: ./scripts/smoketest-vite.ts

- name: Check lint
run: yarn lint
run: pnpm run lint

- name: Check format
run: yarn check:format
run: pnpm run check:format
8 changes: 8 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Use hoisted node-modules linker (like yarn's nodeLinker: node-modules)
node-linker=hoisted

# Hoist all packages to root node_modules for compatibility with yarn-style resolution
shamefully-hoist=true

# Equivalent to yarn's enableGlobalCache: false
# pnpm uses content-addressable store by default, no need to disable
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@
"emscripten.h": "c",
"quickjs-atom.h": "c"
},
"files.exclude": {
".yarn/releases/*": true
}
"files.exclude": {}
}
893 changes: 0 additions & 893 deletions .yarn/releases/yarn-4.0.2.cjs

This file was deleted.

7 changes: 0 additions & 7 deletions .yarnrc.yml

This file was deleted.

5 changes: 0 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
## v0.32.0

- [#227](https://github.com/justjake/quickjs-emscripten/pull/227)

- Re-works function binding in `newFunction` to use a different proxying strategy based on a new abstraction, `HostRef`. HostRef allows tracking references of host values from guest handles. Once all references to the HostRef object are disposed (either in the host, or GC'd in the guest), the host value will be dereferenced and become garbage collectable.
- Functions passed to `newFunction` are interned in the runtime's `HostRefMap` until dereferenced.
- `HostRef` is also exposed directly for use from `QuickJSContext`, see `newHostRef`, `toHostRef`, `unwrapHostRef` in the docs.
Expand Down Expand Up @@ -140,7 +139,6 @@ In edge cases, you might want to use the IIFE build which provides QuickJS as th
- We now differentiate between runtime environments at build time using Node.JS package.json [export conditions in subpath exports][conditions], instead of including support for all environments in a single build. While this resolves open issues with relatively modern bundlers like webpack@5 and vite, it may cause regressions if you use an older bundler that doesn't understand the "browser" condition.
- The release variants - RELEASE_SYNC (the default), and RELEASE_ASYNC - no longer embed the WebAssembly code inside a JS file. Instead, they attempt to load the WebAssembly code from a separate file. Very old bundlers may not understand this syntax, or your web server may not serve the .wasm files correctly. Please test in a staging environment to verify your production build works as expected.
- quickjs-emscripten now uses [subpath exports in package.json][conditions]. Imports of specific files must be removed. The only valid import paths for quickjs-emscripten are:

- `import * from 'quickjs-emscripten'` (the library)
- `import packageJson from 'quickjs-emscripten/package.json'`
- `import { DEBUG_SYNC, DEBUG_ASYNC, RELEASE_SYNC, RELEASE_ASYNC } from 'quickjs-emscripten/variants'` (these are exported from the main import, but are also available as their own files)
Expand All @@ -154,14 +152,12 @@ In edge cases, you might want to use the IIFE build which provides QuickJS as th
## v0.24.0

- [#127](https://github.com/justjake/quickjs-emscripten/pull/127) Upgrade to quickjs 2023-12-09:

- added Object.hasOwn, {String|Array|TypedArray}.prototype.at, {Array|TypedArray}.prototype.findLast{Index}
- BigInt support is enabled even if CONFIG_BIGNUM disabled
- updated to Unicode 15.0.0
- misc bug fixes

- [#125](https://github.com/justjake/quickjs-emscripten/pull/125) (thanks to @tbrockman):

- Synchronizes quickjs to include the recent commit to address CVE-2023-31922.

- [#111](https://github.com/justjake/quickjs-emscripten/pull/111) (thanks to @yourWaifu) ArrayBuffer and binary json encoding:
Expand All @@ -182,7 +178,6 @@ In edge cases, you might want to use the IIFE build which provides QuickJS as th
- [#104](https://github.com/justjake/quickjs-emscripten/pull/104) BigInt support.
- [#100](https://github.com/justjake/quickjs-emscripten/pull/100) **Breaking change** upgrade Emscripten version and switch to `async import(...)` for loading variants.
We also drop support for older browsers and Node versions:

- Node >= 16 is required
- Safari >= 14.1 is required
- Typescript >= 4.7 is recommended, but not required.
Expand Down
38 changes: 31 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

## Package Manager

Use `corepack yarn` to run yarn commands, e.g.:
Use `corepack pnpm` to run pnpm commands, e.g.:

- `corepack yarn install`
- `corepack yarn build`
- `corepack yarn build:ts`
- `corepack pnpm install`
- `corepack pnpm build`
- `corepack pnpm build:ts`

## Building Variants

Expand All @@ -17,7 +17,7 @@ To build a variant:
```bash
cd packages/variant-quickjs-<name>
make # builds the C code with emscripten
corepack yarn build:ts # builds the TypeScript wrapper
corepack pnpm build:ts # builds the TypeScript wrapper
```

## Emscripten
Expand All @@ -31,7 +31,7 @@ corepack yarn build:ts # builds the TypeScript wrapper
Run all tests:

```bash
corepack yarn test
corepack pnpm test
```

Run tests for a specific variant (e.g., quickjs-ng only):
Expand All @@ -49,7 +49,31 @@ Other test filters:

## Git

- Never use `git commit --amend` - always create new commits
- Never use `git commit --amend` - always create new commits. It's better to have a history of what was actually done since branches get rebased/squashed anyway when merged.
- Before pushing, run `pnpm run prettier` and `pnpm run lint` to fix formatting and lint issues. No need to check after every commit - just before pushing.

## CI Workflow

After pushing a PR, monitor CI using the `gh` CLI:

```bash
# Check CI status for a PR
gh pr checks <PR_NUMBER>

# View a specific job's progress
gh run view --job=<JOB_ID>

# Get logs for failed steps
gh run view <RUN_ID> --log-failed
```

When CI fails:
1. Get the failed logs with `gh run view <RUN_ID> --log-failed | tail -100`
2. Fix the issue locally
3. Commit the fix (new commit, don't amend)
4. Push and repeat until CI passes

The full CI build takes ~20 minutes due to emscripten compilation.

## Key Files

Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -844,19 +844,16 @@ audited. Please use with care in production settings.
thinking comes next. Last updated 2022-03-18.

1. Further work on module loading APIs:

- Create modules via Javascript, instead of source text.
- Scan source text for imports, for ahead of time or concurrent loading.
(This is possible with third-party tools, so lower priority.)

2. Higher-level tools for reading QuickJS values:

- Type guard functions: `context.isArray(handle)`, `context.isPromise(handle)`, etc.
- Iteration utilities: `context.getIterable(handle)`, `context.iterateObjectEntries(handle)`.
This better supports user-level code to deserialize complex handle objects.

3. Higher-level tools for creating QuickJS values:

- Devise a way to avoid needing to mess around with handles when setting up
the environment.
- Consider integrating
Expand Down
1 change: 0 additions & 1 deletion doc/.nojekyll

This file was deleted.

34 changes: 22 additions & 12 deletions doc/@jitl/quickjs-asmjs-mjs-release-sync/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[quickjs-emscripten](../../packages.md) • **@jitl/quickjs-asmjs-mjs-release-sync** • [Readme](README.md) \| [Exports](exports.md)
[**quickjs-emscripten**](../../README.md)

***

[quickjs-emscripten](../../packages.md) / @jitl/quickjs-asmjs-mjs-release-sync

# @jitl/quickjs-asmjs-mjs-release-sync

Compiled to pure Javascript, no WebAssembly required.
Expand All @@ -17,15 +19,6 @@ const QuickJS = await newQuickJSWASMModuleFromVariant(variant)

This variant was built with the following settings:

## Contents

- [Library: quickjs](README.md#library-quickjs)
- [Release mode: release](README.md#release-mode-release)
- [Exports: import](README.md#exports-import)
- [Extra async magic? No](README.md#extra-async-magic-no)
- [Single-file, or separate .wasm file? asmjs](README.md#single-file-or-separate-wasm-file-asmjs)
- [More details](README.md#more-details)

## Library: quickjs

The original [bellard/quickjs](https://github.com/bellard/quickjs) library.
Expand Down Expand Up @@ -86,6 +79,23 @@ Variant-specific Emscripten build flags:
]
```

***
## Variables

### default

> `const` **default**: [`QuickJSSyncVariant`](../../quickjs-emscripten/interfaces/QuickJSSyncVariant.md)

Defined in: [index.ts:19](https://github.com/justjake/quickjs-emscripten/blob/main/packages/variant-quickjs-asmjs-mjs-release-sync/src/index.ts#L19)

### @jitl/quickjs-asmjs-mjs-release-sync

[Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-asmjs-mjs-release-sync/README.md) |
Compiled to pure Javascript, no WebAssembly required.

Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/)
| Variable | Setting | Description |
| -- | -- | -- |
| library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2025-09-13+f1139494](https://github.com/bellard/quickjs/commit/f1139494d18a2053630c5ed3384a42bb70db3c53) vendored to quickjs-emscripten on 2026-02-15. |
| releaseMode | release | Optimized for performance; use when building/deploying your application. |
| syncMode | sync | The default, normal build. Note that both variants support regular async functions. |
| emscriptenInclusion | asmjs | The C library code is compiled to Javascript, no WebAssembly used. Sometimes called "asmjs". This is the slowest possible option, and is intended for constrained environments that do not support WebAssembly, like quickjs-for-quickjs. |
| exports | import | Has these package.json export conditions |
40 changes: 0 additions & 40 deletions doc/@jitl/quickjs-asmjs-mjs-release-sync/exports.md

This file was deleted.

Loading