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.compilersfrom 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 thantypein import attributes. - Import attributes are now passed to
ModuleDelegate.readandModuleDelegate.resolveas 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. evalScriptfrom "quickjs:engine" now supports an "async" option which supports top-level await and returns a Promise.
- 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
Workerfrom the "quickjs:os" module now functions on Windows.- Added cross-realm
Path.isPathtype checking method, similar toArray.isArray.is(..., types.Path)andis(..., Path)were changed to use this method instead of instanceof.
- The functionality of the
execfunction 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,CreateProcesscan be used (on Windows only) instead. Userequire("quickjs:os").platformto 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
chmodfunction (ie. add/remove this flag without touching existing flags) was added. - Low-level C
formatValuefunction 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 runningyavascript --print-types.- We now publish binaries for FreeBSD.
- On Linux, the
npmpackage 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)andis(..., Path)were changed to usePath.isPathinstead of instanceof.std.exit()andstd.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
execworks 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
curlbinary. This includesstd.urlGetas well as loading modules using thehttp:,https:, ornpm: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 usingexecif not. The npm package has been modified to autodetect glibc or musl and use the correct binary as appropriate.
- This has improved the reliability of
- When using the repl, stdout is no longer line-buffered.
Full Changelog: v0.15.0...v0.16.0