File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,14 @@ export function mainEntryPlugin(opts: { platform: 'ios' | 'android' | 'visionos'
6767 }
6868
6969 if ( opts . hmrActive ) {
70+ // Seed platform globals on the primary bundle realm using the same
71+ // CLI-derived platform that drives global-defines.ts. This ensures
72+ // HMR-delivered HTTP ESM modules can reliably read platform flags
73+ imports += `globalThis.__DEV__ = ${ opts . isDevMode ? 'true' : 'false' } ;\n` ;
74+ imports += `globalThis.__ANDROID__ = ${ opts . platform === 'android' ? 'true' : 'false' } ;\n` ;
75+ imports += `globalThis.__IOS__ = ${ opts . platform === 'ios' ? 'true' : 'false' } ;\n` ;
76+ imports += `globalThis.__VISIONOS__ = ${ opts . platform === 'visionos' ? 'true' : 'false' } ;\n` ;
77+ imports += `globalThis.__APPLE__ = ${ opts . platform === 'ios' || opts . platform === 'visionos' ? 'true' : 'false' } ;\n` ;
7078 // ---- Vendor manifest bootstrap ----
7179 // Use single self-contained vendor module to avoid extra imports affecting chunking
7280 imports += "import vendorManifest, { __nsVendorModuleMap } from '@nativescript/vendor';\n" ;
You can’t perform that action at this time.
0 commit comments