Skip to content

v0.16.0

Latest

Choose a tag to compare

@suchipi suchipi released this 06 Jun 08:34
· 32 commits to main since this release

This is a big update which has been a long time coming!

New Stuff

  • The underlying engine has been updated to support most of the ES2023 specification (it was previously ES2020). Notably, several new Array methods are now present.
  • WHATWG TextEncoder and TextDecoder, support were added, with non-standard extensions to support encoding into encodings other than utf-8.
    • Accessible via the "quickjs:encoding" module.
    • Supported encodings: "utf-8", "utf-16le", "utf-16be", "shift_jis", "windows-1252", "windows-1251", "big5", "euc-kr", "euc-jp", "gb18030"
  • Support for import attributes (eg import ... with { type: "json" }) added.
    • The supported types importable via type attributes match the builtin file-extension based filetype handlers: "civet", "coffeescript", "javascript", "json", "json5", "jsx", "toml", "typescript", "tsx", and "yaml"/"yml".
    • Support for an additional import attributes argument has been added to file-loading APIs like require, require.resolve, engine.importModule (from "quickjs:engine"), engine.resolveModule, etc.
    • More types can be added by adding properties to ModuleDelegate.compilers from the "quickjs:engine" module.
    • A module being imported can inspect the import attributes it's being imported with via import.meta.attributes. You can specify values other than type in import attributes.
    • Import attributes are now passed to ModuleDelegate.read and ModuleDelegate.resolve as a third argument.
  • Top-level await support was overhauled and improved dramatically.
    • Generally speaking, it should "just work", but you should be aware that attempting to load a module which uses top-level await from a synchronous module loading function (like require) will throw an Error.
    • evalScript from "quickjs:engine" now supports an "async" option which supports top-level await and returns a Promise.
  • Worker from the "quickjs:os" module now functions on Windows.
  • Added cross-realm Path.isPath type checking method, similar to Array.isArray.
    • is(..., types.Path) and is(..., Path) were changed to use this method instead of instanceof.
  • The functionality of the exec function and related code was improved on Windows.
  • It's now possible to create and read symbolic links on Windows using filesystem APIs.
  • Windows-specific process spawning APIs are now available from the "quickjs:os" module: CreateProcess, WaitForSingleObject, etc.
    • exec() still works on Windows, but it makes some assumptions in order to try to behave consistently with POSIX exec on other platforms. If these assumptions aren't desirable, CreateProcess can be used (on Windows only) instead. Use require("quickjs:os").platform to detect the current OS.
  • Additional serialization options were added to "quickjs:bytecode", and bytecode serialization now supports reference cycles by default.
  • Diff-based call signature for the chmod function (ie. add/remove this flag without touching existing flags) was added.
  • Low-level C formatValue function was added to the "quickjs:engine" module. It has the ability to print things which aren't observable from JS, like a function's closures, and print in a read-only mode which can't affect the JS runtime (Proxy skip).
  • yavascript.getTypesDts() function was added which returns the TypeScript .d.ts types for the currently-running YavaScript binary. These are the same types which get printed when running yavascript --print-types.
  • We now publish binaries for FreeBSD.
  • On Linux, the npm package for yavascript now attempts to detect the libc in use and use either a glibc or muslc build when feasible, instead of always using the static build. The static build is still used as a fallback when the libc detection fails.

Breaking Changes

  • is(..., types.Path) and is(..., Path) were changed to use Path.isPath instead of instanceof.
  • std.exit() and std.setExitCode(...) were moved to the "quickjs:cmdline" module: require("quickjs:cmdline").exit()
  • setTimeout and setInterval are no longer present in the "quickjs:os" module; they've been moved to the new "quickjs:timers" module.
    • But they're still available as globals.
  • Some of the underlying semantics of how exec works on Windows were changed. These should not be observable in most cases, but should be noted nonetheless.
  • All web fetching functionality was changed to use libcurl4 (loaded dynamically) instead of shelling out to the curl binary. This includes std.urlGet as well as loading modules using the http:, https:, or npm: prefixes.
    • This has improved the reliability of std.urlGet. However, as a result of this change, web fetching no longer works in the statically-linked Linux builds. Please use either the gnu (glibc) or musl (muslc) build if feasible, and shell out to curl yourself using exec if not. The npm package has been modified to autodetect glibc or musl and use the correct binary as appropriate.
  • When using the repl, stdout is no longer line-buffered.

Full Changelog: v0.15.0...v0.16.0