Skip to content

Verify React Native compatibility - #56

Merged
willwade merged 8 commits into
AACTools:mainfrom
sonicbaume:experiment/metro-bundle-check
Oct 13, 2026
Merged

willwade merged 8 commits into
AACTools:mainfrom
sonicbaume:experiment/metro-bundle-check

Conversation

@chrisbaume

Copy link
Copy Markdown
Contributor

This update is built upon #55. It checks for React Native compatibility by attempting to bundle the browser distribution with Metro. The check is included in the CI workflow to avoid incompatible builds.

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.
Add scripts/verify-rn-bundle.js and an isolated Metro fixture
(test/rn-metro-check, babel-preset-expo) that bundles a copy of dist/browser
with the actual React Native bundler. Running the real resolver catches Node
core modules reached transitively through dependencies, which scanning our own
compiled files cannot see.

This probe originally failed on the xml2js dependency chain
(xml2js -> events/timers, sax -> stream). With the validators now on
fast-xml-parser the browser build bundles cleanly, so xml2js is not needed in
the fixture.

Metro lives only in the fixture, not in the library's runtime deps. Run with
npm run verify:rn-bundle.
Replace the React Native-only section in scripts/README.md with a Browser
verification section covering verify-browser-build.js, verify-rn-bundle.js
and smoke-browser-bundle.js.
Add an rn-bundle job that installs the Metro fixture and runs
npm run verify:rn-bundle, so a browser build that Metro/Hermes cannot bundle
(for example a dependency that pulls in Node core modules) fails CI.

Pinned to Node 22 because Metro 0.87 requires >= 22.13, while the test matrix
also runs Node 20.
Fold the Metro guard into the existing test job on the Node 22 leg instead of
a separate job, reusing the root install and the dist/browser that test:ci
already builds. Metro 0.87 requires Node >= 22.13, so the steps are skipped on
the Node 20 leg.
@willwade

Copy link
Copy Markdown
Collaborator

Merged — a real Metro probe in CI is exactly the right guard, and catching transitive Node-core imports is the part a dist scan can't do. Nice.

@willwade
willwade merged commit 95e3fd8 into AACTools:main Oct 13, 2026
2 checks passed
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