Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ config.resolver.alias = {
// Ensure polyfills are resolved correctly
config.resolver.sourceExts = [...config.resolver.sourceExts, 'cjs', 'mjs'];

// Add custom resolver to handle Node.js modules
config.resolver.resolveRequest = (context, moduleName, platform) => {
// Handle Node.js built-in modules
if (config.resolver.alias[moduleName]) {
return {
type: 'sourceFile',
filePath: require.resolve(config.resolver.alias[moduleName]),
};
}

// Fall back to default resolution
return context.resolveRequest(context, moduleName, platform);
};
// Add blockList to exclude problematic files
config.resolver.blockList = [
/node_modules\/.*\/node_modules\/react-native\/.*/,
];

// Add watchFolders to ensure Metro watches the correct directories
config.watchFolders = [
__dirname,
`${__dirname}/node_modules`,
];

module.exports = config;
6 changes: 3 additions & 3 deletions polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import * as stream from 'stream-browserify';
global.stream = stream;

// Events polyfill
import { EventEmitter } from 'events';
global.EventEmitter = EventEmitter;
import * as events from 'events';
global.EventEmitter = events.EventEmitter;

// Util polyfill
import util from 'util';
Expand Down Expand Up @@ -56,7 +56,7 @@ global.require = (id) => {
module = stream;
break;
case 'events':
module = require('events');
module = events;
break;
case 'util':
module = require('util');
Expand Down