diff --git a/metro.config.js b/metro.config.js index 61f60dab..7c30530f 100644 --- a/metro.config.js +++ b/metro.config.js @@ -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; diff --git a/polyfills.js b/polyfills.js index ae91ca72..e6fe2179 100644 --- a/polyfills.js +++ b/polyfills.js @@ -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'; @@ -56,7 +56,7 @@ global.require = (id) => { module = stream; break; case 'events': - module = require('events'); + module = events; break; case 'util': module = require('util');