Babel plugin
Install and configure @parallax-rn/babel-plugin, which maps what is on screen to your source code.
@parallax-rn/babel-plugin is the build-time part of Parallax. In development builds it writes, for every file with JSX, a table of its elements: where each is used, which component it is in, what it was imported from and the testID you wrote. It registers the table in the running app, so a tool can map what is on screen to a file and line.
It never changes the code you wrote; it appends one statement. It has no third-party runtime dependencies.
Install
-
In the app's project root, add the package:
npm i -D @parallax-rn/babel-plugin@0.1.0-beta.2, or your package manager's equivalent. Use the same version as the MCP server. -
List the plugin in your Babel config, before
react-native-worklets/pluginif you use it (that plugin must be last):// babel.config.js module.exports = { presets: ['module:@react-native/babel-preset'], plugins: ['@parallax-rn/babel-plugin', 'react-native-worklets/plugin'], }; -
Restart Metro with
--reset-cache:npx react-native start --reset-cache(bare React Native) ornpx expo start -c(Expo). Metro's transform cache does not notice a change ofbabel.config.jsor of the plugin. -
Run
npx -y @parallax-rn/mcp@0.1.0-beta.2 doctorin the project root. It reads the tables from the running app.
Update
Update the package, then restart Metro with --reset-cache. Until the cache is reset, tables written by the older version stay in the bundle and point to wrong files and lines. Every table carries the plugin version, and doctor and status warn "source tables are stale" when it differs from the installed one.
Options
['@parallax-rn/babel-plugin', { injectTestIDs: false, root: process.cwd(), exclude: ['/stories/'] }]| Option | Default | What it does |
|---|---|---|
injectTestIDs | false | Gives react-native primitives that have no testID (and no spread) one named prn:<file>::<n>, so the accessibility tree shows them. This adds nodes to the tree. Elements that already have a testID are never touched. |
root | Babel's working directory (Metro's project root) | File paths in the tables are relative to it. A file outside root gets no table. For sources outside the project, set root to a directory that contains them. |
exclude | [] | Regular expressions (as strings) matched against the relative path. node_modules is always excluded. |
Unknown options are an error. Files with no JSX, files in node_modules, generated files (marked @generated or codegen in the first three comments) and files outside root get no table.
Development only
- The plugin is active only when Babel's environment is
development. Otherwise the output is what it would be without the plugin. - It is a build error when Babel's environment is
developmentbutNODE_ENVisproduction(a release pipeline told to build a development bundle). The error says to build releases withdev=false. - The emitted code is guarded by
__DEV__. - There is no option to force the plugin on in a release build.
Check a release bundle in CI
parallax-bundle-check searches a release bundle, or the Hermes bytecode made from it, for what the plugin and the SDK leave behind: __PARALLAX_RN__, __PARALLAX_RN_PUSH__ and injected prn:…::n ids.
npx parallax-bundle-check ios/build/main.jsbundleAdd --json for machine-readable output. Exit code 0 means clean, 1 means something was found (listed with counts), 2 means a usage or file error.