Skip to content

Commit

Permalink
Fix web-example (software-mansion#6111)
Browse files Browse the repository at this point in the history
## Summary

Following the transition to a monorepo structure, our web-example app
stopped working due to an asset loading issue. Turns out that the
`getAssetByID` function from `react-native-web` was being called from
the incorrect module. We believe this might have resulted in one module
blocking an asset while another module was trying to load it, causing
the application to crash.

This PR modifies the `metro.config.js` inside the `web-example` folder.
It is now configured to ignore the `@react-native` module from the root,
which allows assets to load correctly.

## Test plan

Run `web-example`.
  • Loading branch information
m-bert authored Jun 13, 2024
1 parent 9afd252 commit 5e830b2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/web-example/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const { getDefaultConfig } = require('expo/metro-config');

const path = require('path');
const exclusionList = require('metro-config/src/defaults/exclusionList');
const escape = require('escape-string-regexp');

// Find the project and workspace directories
const projectRoot = __dirname;
Expand All @@ -15,4 +18,13 @@ config.resolver.nodeModulesPaths = [
path.resolve(monorepoRoot, 'node_modules'),
];

const modulesToBlock = ['@react-native'];

config.resolver.blacklistRE = exclusionList(
modulesToBlock.map(
(m) =>
new RegExp(`^${escape(path.join(monorepoRoot, 'node_modules', m))}\\/.*$`)
)
);

module.exports = config;

0 comments on commit 5e830b2

Please sign in to comment.