This document collects tips and tricks for debugging common issues. If you'd like to see a workaround documented here, please submit it to our GitHub issues.
If you see an error while rendering from the server, it can often be hard to diagnose. There's a few ways to debug it.
First, we've found turning off Vite external dependencies entirely will often help, what it does is make Vite use esbuild and apply CommonJS transforms for compatibility, transforming all of them into your .vite directory. You can enable it like so:
vite.config.ts
{
ssr:{
noExternal:true
}
}
The reason we don't turn this on by default it is can cause other issues, namely if a node module relies on, say, __dirname, or __filename, then when they are transformed into the .vite folder these paths will change. Another reason we don't turn it on by default is that it can slow things down.
If you do find the individual module that is causing an issue, you can also configure it quickly using the deps option in the One Vite plugin configuration.
In general you want to add any dependency like this to optimizeDeps.exclude. But One has some default optimizeDeps options we add that may prevent that.
You can use fixDependencies in your vite.config.ts:
When using bundlers like Vite, Rollup, or esbuild, developers often encounter issues with React Native and Expo packages originally designed to work only for Metro. Metro’s tolerant nature allows certain practices that other bundlers may not support, such as:
Including Flow types in distributed .js files.
Including JSX syntax in .js files instead of .jsx.
Releasing packages as ESM-only without proper declarations in package.json (e.g., missing "type": "module") or appropriate .mjs extensions.
These issues can break builds and require specific handling to make the packages compatible with non-Metro bundlers. Related error messages you might encounter includes:
The JSX syntax extension is not currently enabled.
The esbuild loader for this file is currently set to "js" but it must be set to "jsx" to be able to parse JSX syntax.
SWC failed to transform file following with a syntax error parsing something like import type.
To workaround these issues, you can use the package patching feature of One to fix the packages that are causing problems. Here's an example:
We encourage you to open an issue on our GitHub repository if you encounter similar issues, as your feedback helps us improve One's compatibility with React Native packages.If you've resolved an issue with a patch, we'd love for you to share your patch configuration. Alternatively, feel free to reach out, and we'll gladly assist in finding a solution to get things working.
If appropriate, it's also nice to reach out to the maintainers of those packages to help improve their compatibility with non-Metro bundlers.