Debugging multiple MiniApps
Inside a new directory (e.g.
workspace), clone all MiniApps that you want to debug.
In this example, for two MiniApps
list-miniapp, the directory structure should look like this:
ern linkin each MiniApp directory.
The ern link command is needed to map the source location between the composite and the MiniApp directory, but also to ensure that any changes to the MiniApp directory are propagated to the Composite.
yarn init --yes(or
npm init --yes) in the parent directory (
workspace) to create a
package.jsonfile. Then add the React Native dependencies:
Use the same versions of
react-nativethat are used by the MiniApps (in this example React Native 0.60.6).
The structure should now look like this:
"name": "Attach to packager",
Note that the package name of the MiniApp could be different from the directory name in the workspace folder.
At this point our directory structure should look like:
│ └── launch.json
The basic setup is now complete. If you need to add more MiniApps, clone them into the
ern link, and add a corresponding mapping entry to
Pass an absolute path as the
ern start [options] --compositeDir /path/to/workspace/composite
The MiniApps to include in the composite can be passed using the
-m) flag. If no other options are defined, the
ern startcommand requires an active Cauldron. See
ern start --helpfor more information.
Once composite generation is done, we should have the following structure:
│ └── launch.json
workspacedirectory in VS Code (if you have not done so already) and launch the native application (if it is not already running). It may have been launched automatically by
To attach VS Code to the React Native debugger, run the Attach to packager debug configuration. Make sure the
ern startcommand has completed and is still running in the background. You will notice an indicator that will keep spinning until the next step is completed.
In the native application, bring up the React Native developer menu, and turn on JS Debugging by tapping Debug (Android) or Debug JS Remotely (iOS). This will result in attaching to the Visual Studio Code debugger. If debugging was already turned on in the native app, disable it first, then re-enable it. In VS Code you should now see that the debugger was attached. Check if the breakpoints are triggered in the sources of
list-miniapp, and debug the MiniApps in VS Code.