1import { Platform } from 'expo-modules-core'; 2import qs from 'qs'; 3 4const getDevServer = () => { 5 // Disable for SSR 6 if (!Platform.isDOMAvailable) { 7 return { 8 bundleLoadedFromServer: true, 9 fullBundleUrl: '', 10 url: '', 11 }; 12 } 13 14 return { 15 // The bundle is always loaded from a server in the browser. 16 bundleLoadedFromServer: true, 17 18 /** URL but ensures that platform query param is added. */ 19 get fullBundleUrl() { 20 if (document?.currentScript && 'src' in document.currentScript) { 21 return document.currentScript.src; 22 } 23 24 const url = window.location.toString(); 25 const query = qs.parse(url); 26 27 return ( 28 location.origin + 29 location.pathname + 30 '?' + 31 qs.stringify({ ...query, platform: Platform.OS }) 32 ); 33 }, 34 url: location.origin + location.pathname, 35 }; 36}; 37 38export default getDevServer; 39