Expat for Linux
v2.8.5LinuxExpat 2.8.5 for native Node.js addons on Linux, precompiled for x64 and arm64, glibc 2.28 or later as @crossbind/port-expat-linux.
Install
The addons and their loader land in dist; the Node.js playbook has the whole flow.
Usage
The examples the WebAssembly page runs, as Linux compiles them: the same headers and the same calls. They are checked on the WebAssembly build.
Turn XML into JavaScript objects
The calls most Expat code makes: XML_ParserCreate, an element handler and a character data handler, then XML_Parse. A malformed document throws with the line and column where Expat stopped.
Read namespaced XML whatever the prefixes
XML_ParserCreateNS resolves every prefix to its namespace URI before your handlers see a name, and XML_SetStartNamespaceDeclHandler reports the declarations themselves.
Expand entities without a billion laughs
Expat expands the entities a document declares and stops the ones that blow up: XML_SetBillionLaughsAttackProtectionMaximumAmplification and …ActivationThreshold set how far.
"Stream a file through Expat" writes its input with m.FS, which Linux does not have; the C++ takes paths, so it works unchanged on files in the app's storage. It runs on the WebAssembly page.
What is different on Linux
crossbind build -p linuxlinks one.nodeaddon per architecture intodist, next to a loader,dist/<name>.native.cjs, thatrequireandimportboth load. A plaincrossbind buildskips it.await initNative()once, then call the classes: calls are synchronous, and no Worker is involved.- The library and the C++ runtime are linked into the addon statically. It runs on glibc 2.28 or later (RHEL 8, Debian 10, Ubuntu 20.04 and newer), not on musl distributions such as Alpine.
- There is no
m.FS: the C++ reads real paths, and data such asGDAL_DATAorproj.dbis copied todist/data. - The build runs in Docker on any host, a Mac included.
worker_threadsare not supported yet.
Other platforms
- Expat overview: the apps, every platform's setup and the packages.
- Expat for WebAssembly: browsers, Node.js and edge runtimes.
- Expat for Android: React Native apps on Android.
- Expat for iOS: React Native apps on iOS.
- Expat for macOS: native Node.js addons and Electron on macOS.
- Expat for Windows: native Node.js addons on Windows.
- Expat for WASI: command-line programs under wasmtime.
Facts on this page come from the port manifests in the repository and from what npm served on beta when the site was built. See the Libraries guide for the full consumer flow.