import { join } from 'path' ; import type { StaticComponent , TamaguiInternalConfig } from '@tamagui/core' ; import { createTamagui } from '@tamagui/core-node' ; let loadedTamagui = null ; export function loadTamagui ( props ) { if ( loadedTamagui ) { return loadedTamagui ; } process . env . IS_STATIC = 'is_static' ; const proxyWorm = require ( '@tamagui/fake-react-native' ) ; const Mod = require ( 'module' ) ; const og = Mod . prototype . require ; Mod . prototype . require = function ( path ) { if ( path . startsWith ( 'react-native' ) && ! path . startsWith ( 'react-native-web/dist/cjs/exports' ) ) { return proxyWorm ; } return og . apply ( this , arguments ) ; } ; const configPath = join ( process . cwd ( ) , props . config ) ; const tamaguiConfigExport = require ( configPath ) ; const tamaguiConfig = ( tamaguiConfigExport [ 'default' ] || tamaguiConfigExport ) as TamaguiInternalConfig ; const components = { } ; for ( const module of props . components ) { const exported = require ( module ) ; Object . assign ( components , exported ) ; } process . env . IS_STATIC = undefined ; Mod . prototype . require = og ; createTamagui ( tamaguiConfig ) ; loadedTamagui = { components , tamaguiConfig , } ; return loadedTamagui ; }