Skip to content

Use fast-xml-parser for all XML parsing - #55

Merged
willwade merged 2 commits into
AACTools:mainfrom
sonicbaume:fix/fast-xml-parser
Oct 13, 2026
Merged

willwade merged 2 commits into
AACTools:mainfrom
sonicbaume:fix/fast-xml-parser

Conversation

@chrisbaume

Copy link
Copy Markdown
Contributor

Currently there are two XML parsers - fast-xml-parser and xml2js. However, xml2js includes node.js dependencies so can't be compiled for React Native. This update removes xml2js and uses fast-xml-parser for all XML parsing. This is done via a function that emulates xml2js's behaviour, including validating the string and throwing an error if it fails.

The Gridset/Snap/TouchChat validators used xml2js, which requires the Node
core modules events and timers (and its sax dependency requires stream). Metro
cannot resolve those in React Native/Expo, so the browser distribution could
not be bundled and needed Vite polyfills/aliases for web.

Add a shared src/utils/xml.ts wrapper around fast-xml-parser (already a
dependency and Node-free) configured to keep the xml2js output shape:
attributes grouped under $, every non-root element always an array, and
string values. Well-formedness is checked with XMLValidator first because
fast-xml-parser is permissive.

Update the three validators and drop xml2js, its @types (which was wrongly
listed as a runtime dependency), and the transitive sax/xmlbuilder packages.
All 847 tests pass.
@chrisbaume chrisbaume changed the title Fix/fast xml parser Use fast-xml-parser for all XML parsing Oct 13, 2026
@willwade

Copy link
Copy Markdown
Collaborator

Thanks Chris — nice work keeping the xml2js-compatible shape (the array-wrapping via isArray is a clever emulation). Merged.

@willwade
willwade merged commit 6a0a718 into AACTools:main Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants