Broken production with Metro bundler (ReferenceError)
See original GitHub issueHi 👋
On the latest version, a modification (somewhere around here) broke the metro bundler in production mode (and possibly other production apps? It’s not tied to minification, but I didn’t tried on other bundlers).

urql version: 1.9.7
Steps to reproduce
- Create a new React Native project
- Add
urql@1.9.7
, wrap your app in aProvider
with an urql client - Build your app for production
- Starts your app. It will crash at client init.
Expected behavior
No JS ReferenceError
.
Actual behavior
For some reason, the variable is not declared.
Debugging
In order to spot the issue, I created a server to serve the unminified production bundle to my debug application. Create a file at project root:
// server.js
const express = require("express");
const app = express();
app.use((req, res, next) => {
console.log(req.url);
res.setHeader("Content-Type", "application/javascript");
next();
});
app.use("/", express.static("."));
app.use("/assets", express.static("."));
app.get("/status", (_req, res) => {
res.send("packager-status:running");
});
app.listen(8081, () => {
console.log("Serving directory as localhost:8081");
});
Build a bundle with:
yarn react-native bundle --entry-file index.js --bundle-output index.bundle --platform ios --dev false --minify false
Then run the server.js
file to fake metro bundler, it will be easier to debug.
Fix
The missing declaration is f
:
If I add it manually to the bundle, it works:
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
SHA-1 for file ... is not computed when using resolver ... - GitHub
I solved this issue by using yarn start instead of starting project with react-native start (it uses npm start). I have been adding...
Read more >Metro Bundler fails while trying to resolve module `immer ...
So I tried to manually remove node_modules/ and reinstall packages with yarn , restart the Expo server, doing all this after restarting my ......
Read more >Using Hermes in React Native - LogRocket Blog
Here is a list of break-in changes for Hemes in React Native 0.70: More work on performance; React Native Hermes integration: going forward,...
Read more >* a module failed to load due to an error and `appregistry ...
This can happen if: Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and...
Read more >Metro bundler - Expo Documentation
const { getDefaultConfig } = require('expo/metro-config'); const config = getDefaultConfig(__dirname); // Remove all console logs in production... config.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks, that was fast!
This should be released in
@urql/core@1.11.5
, so a quickyarn upgrade @urql/core
should fix the issue 👍 https://github.com/FormidableLabs/urql/releases/tag/%40urql%2Fcore%401.11.5