-
- Re-works function binding in
newFunctionto 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
newFunctionare interned in the runtime'sHostRefMapuntil dereferenced. HostRefis also exposed directly for use fromQuickJSContext, seenewHostRef,toHostRef,unwrapHostRefin the docs.- Added
QuickJSContext.newConstructorFunction, such functions will have theirthisset to the newly constructed object, although they may also return a new object.
- Re-works function binding in
-
#244 Upgrade quickjs-ng to v0.12.1.
-
#243 (thanks to @josh-) Upgrade bellard/quickjs to 2025-09-13+f1139494. Review the QuickJS changelog for details.
- Some intrinsics like
BigIntare now always enabled. - BigNum extension removed.
- Some intrinsics like
-
#242 Upgrade to Emscripten 5.0.1.
-
#221 (thanks to @melbourne2991) Support generator return values in QuickJSIterator.
- #137
- Add
quickjs-for-quickjs, a package that can run inside quickjs, so you can put quickjs inside your quickjs. - Possibly breaking: Fix a build system bug that made commonjs or esm variants include both types, thus being larger than they needed to be. After upgrading a variant to this release, you should verify that it can be imported/required as expected. You may need to add additional variants if you were using an "esm" variant from both cjs and esm.
- Add
- #200 Inspect and iterate handles, equality, changes to result types, changes to debug logging.
- #195 Export
setDebugMode
- For objects and arrays: add
context.getOwnPropertyNames(handle, options)to iterate the key or array index handles. - For arrays: add
context.getLength(handle)which readshandle.lengthand returns it as a number or undefined to make writingfor (i=0;i<length;i++)loops easier. - For iterable collections like Map, Set, Array: add
context.getIterator(handle)callshandle[Symbol.iterator]()and then exposes the result as anIterableIteratorto host javascript.
- The
SuccessOrFail<T, QuickJSHandle>return type is largely replaced with a new return typeDisposableSuccess<T> | DisposableFail<QuickJSHandle>. The new type implementsresult.unwrap()as a replacement forcontext.unwrapResult(result). It also implementsdispose()directly, so you no longer need to distinguish between success and failure to clean up. - add
context.callMethod(handle, 'methodName'), this makes it easier to call methods likecontext.callMethod(handle, 'keys')orcontext.callMethod('values')which can be used with the new iterator.
- Added
context.eq(a, b),context.sameValue(a, b),context.sameValueZero(a, b)
Debug logging is now disabled by default, even when using a DEBUG variant. It can be enabled on a runtime-by-runtime basis with runtime.setDebugMode(boolean) or context.runtime.setDebugMode(boolean), or globally using setDebugMode(boolean). As with before, you should use a DEBUG variant to see logs from the WebAssembly C code.
- #179 Add a work-around for a bug in Webkit ARM to quickjs build variants. quickjs-ng is still affected by this bug.
- #161 Fix a bug where
context.evalCode(..., { type: 'module' })would return success when some kinds of error occurred when usingquickjsvariants.- Also adds
context.getPromiseState(handle)to resolve promises synchronously.
- Also adds
- #154 ESModule exports
context.evalCode(code, filename, { type: "module" })or whencodeis detected to be a module: now returns a handle to the module's exports, or a promise handle that resolves to the module's exports.- Added
context.getPromiseState(handle)which returns the state of a promise handle, and can be unwrapped withcontext.unwrapResult(promiseState).
- #159 add LICENSE file and SPDX license identifiers to all packages.
- #155 Update library versions and add versions to documentation.
- quickjs version 2024-01-13+229b07b9 vendored to quickjs-emscripten on 2024-02-11.
- Evaluating a ES Module with
context.evalCode(...)now returns a Promise object instead ofundefined.
- Evaluating a ES Module with
- quickjs-ng version git+229b07b9 vendored to quickjs-emscripten on 2024-02-11.
- quickjs version 2024-01-13+229b07b9 vendored to quickjs-emscripten on 2024-02-11.
- #147 Support providing and retrieving WebAssembly.Memory
- Fixes #146 by adding
wasmMemory: WebAssembly.Memoryoption fornewVariant, andmod.getWasmMemory()method forQuickJS[Async]WASMModule. - Fixes #138 by
- removing internal use of
usingstatement. - Use ESBuild
Symbol.for('Symbol.dispose')ifSymbol.disposeisn't defined globally.
- removing internal use of
- Fixes #146 by adding
- #136, #116 (thanks to @GrantMatejka) Expose ability to configure Context's intrinsic objects.
- #135 (thanks to @saghul) Add
quickjs-ngvariants. quickjs-ng is a fork of quickjs under active development. It implements more EcmaScript standards and removes some of quickjs's custom language features like BigFloat. - #134 Support using statement for Disposable. If you
using value = vm.unwrapResult(vm.evalCode("1+1")), the value will be automatically disposed when the scope exits. - #133 WebAssembly loading options & Cloudflare Worker support. Added an example of using quickjs-emscripten in a Cloudflare Worker.
- #130 Fix some README and docs quibbles.
- #129 Improve packaging strategy, native ES Modules, and browser-first builds.
quickjs-emscripten is re-organized into several NPM packages in a monorepo structure:
quickjs-emscripten(install size 7.5mb) - mostly backwards compatible all-in-one package. This package installs the WASM files for DEBUG_SYNC, DEBUG_ASYNC, RELEASE_SYNC and RELEASE_ASYNC variants as NPM dependencies. Its total install size is reduced from ~quickjs-emscripten-core(install size 573kb) - just the Typescript code, should be compatible with almost any runtime. You can use this with a single a-la-carte build variant, such as@jitl/quickjs-wasmfile-release-syncto reduce the total install size needed to run QuickJS to ~1.1mb.- Several a-la-carte build variants, named
@jitl/quickjs-{wasmfile,singlefile-{esm,cjs,browser}}-{debug,release}-{sync,asyncify}. See the quickjs-emscripten-core docs for more details.
quickjs-emscripten uses package.json export conditions to provide native ES Modules for NodeJS and the browser when appropriate. Most bundlers, like Webpack@5 and Vite, will understand conditions and work out of the box. This should enable advanced tree-shaking, although I'm not sure how much benefit is possible with the library.
You can also use quickjs-emscripten directly from an HTML file in two ways:
<!doctype html>
<!-- Import from a ES Module CDN -->
<script type="module">
import { getQuickJS } from "https://esm.run/quickjs-emscripten@0.25.0"
const QuickJS = await getQuickJS()
console.log(QuickJS.evalCode("1+1"))
</script>In edge cases, you might want to use the IIFE build which provides QuickJS as the global QJS.
<!doctype html>
<!-- Add a script tag to load the library as the QJS global -->
<script
src="https://cdn.jsdelivr.net/npm/quickjs-emscripten@0.25.0-rc.11/dist/index.global.js"
type="text/javascript"
></script>
<!-- Then use the QJS global in a script tag -->
<script type="text/javascript">
QJS.getQuickJS().then((QuickJS) => {
console.log(QuickJS.evalCode("1+1"))
})
</script>-
We now differentiate between runtime environments at build time using Node.JS package.json export conditions in subpath exports, 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. 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)
You should update your imports to use one of these paths. Notably, the WASM files can no longer be directly imported from the
quickjs-emscriptenpackage. -
If you have errors about missing type files, you may need to upgrade to
typescript@5and set moduleResolution tonode16in your tsconfig.json. This shouldn't be necessary for most users.
-
#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 (thanks to @tbrockman):
- Synchronizes quickjs to include the recent commit to address CVE-2023-31922.
-
#111 (thanks to @yourWaifu) ArrayBuffer and binary json encoding:
context.newArrayBuffer(bufferLike)creates an ArrayBuffer in the VM from a buffer-like object.context.getArrayBuffer(handle)creates a view on an ArrayBuffer in the VM as a UInt8Array on the host.context.encodeBinaryJSON(handle)encodes a QuickJS handle in QuickJS's binary format (like JSON.stringify)context.decodeBinaryJSON(handle)decodes a QuickJS handle containing the binary format (like JSON.parse)
- #114 (thanks to @yar2001) improve stack size for ASYNCIFY build variants:
- Change the default ASYNCIFY_STACK_SIZE from 4096 bytes to 81920 bytes. This equates to an increase from approximately 12 to 297 function frames. See the PR for more details.
QuickJSAsyncRuntime.setMaxStackSize(stackSizeBytes)now also adjusts the ASYNCIFY_STACK_SIZE for the entire module.
- #78, #105 (thanks to @ayaboy) add Symbol helpers
context.newUniqueSymbol,context.newSymbolFor, as well as support for symbols incontext.dump. - #104 BigInt support.
- #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.
- #94 (thanks to @swimmadude66) allows QuickJS to create many more functions before overflowing.
- #66 (thanks to @BickelLukas) fixes
ReferenceErrorwhen running in browser due toglobal.process
- #61 (thanks to @torywheelwright):
- Add
QuickJSRuntime.setMaxStackSize(stackSizeBytes)to protect against stack overflows. - Add option
maxStackSizeByteswhen creating runtimes.
- Add
- Change default branch
mastertomain. - Add option
memoryLimitByteswhen creating runtimes.
This is a large release! The summary is:
- There are several breaking API changes to align our abstractions with the underlying QuickJS library.
- There's a new build variant build with Emscripten's ASYNCIFY that allows synchronous code inside QuickJS to use asynchronous code running on the host.
- Both build variants have basic support for loading and evaluating EcmaScript modules, but only the ASYNCIFY variant can asynchronously load EcmaScript code.
This release introduces class QuickJSRuntime. This class wraps QuickJS's JSRuntime* type:
JSRuntimerepresents a Javascript runtime corresponding to an object heap. Several runtimes can exist at the same time but they cannot exchange objects. Inside a given runtime, no multi-threading is supported.
QuickJSRuntime.newContextcreates a new context inside an existing runtime.QuickJSRuntime.setModuleLoaderenables EcmaScript module loading.
This release renames QuickJSVm to class QuickJSContext, and removes some methods.
The new class wraps QuickJS's JSContext* type:
JSContextrepresents a Javascript context (or Realm). Each JSContext has its own global objects and system objects. There can be several JSContexts per JSRuntime [...], similar to frames of the same origin sharing Javascript objects in a web browser.
QuickJSContext replaces QuickJSVm as the main way to interact with the
environment inside the QuickJS virtual machine.
QuickJSContext.runtimeprovides access to a context's parent runtime.QuickJSContext.evalCodenow takes an options argument to set eval mode to'module'.
There are also Asyncified versions of both QuickJSRuntime (QuickJSRuntimeAsync) and QuickJSContext (QuickJSContextAsync). These variants trade some runtime performance for additional features.
QuickJSRuntimeAsync.setModuleLoaderaccepts module loaders that returnPromise<string>.QuickJSContextAsync.newAsyncifiedFunctionallows creating async functions that act like sync functions inside the VM.
class QuickJSVm is removed. Most functionality is available on
QuickJSContext, with identical function signatures. Functionality related to
runtime limits, memory limits, and pending jobs moved to QuickJSRuntime.
Migration guide:
- Replace usages with QuickJSContext.
- Replace the following methods:
vm.hasPendingJob->context.runtime.hasPendingJobvm.setInterruptHandler->context.runtime.setInterruptHandlervm.removeInterruptHandler->context.runtime.removeInterruptHandlervm.executePendingJobs->context.runtime.executePendingJobsvm.setMemoryLimit->context.runtime.setMemoryLimitvm.computeMemoryUsage->context.runtime.computeMemoryUsage
QuickJS.createVm() is removed.
Migration guide: use QuickJS.newContext() instead.
This is the last version containing class QuickJSVm and constructor
QuickJS.createVm().