@@ -24,7 +24,6 @@ declare const CGRectMake: any;
2424declare const CGPointMake : any ;
2525declare const CGSizeMake : any ;
2626declare const UIEdgeInsetsMake : any ;
27- declare const require : any ;
2827declare const WebSocket : any | undefined ;
2928
3029type JSONObject = Record < string , unknown > ;
@@ -195,11 +194,26 @@ function installAngularSourceLocationCaptureShim(): void {
195194 return ;
196195 }
197196
197+ // Resolve `@nativescript/angular` through an indirect, runtime-only require.
198+ // The literal `require("@nativescript/angular")` call would otherwise be
199+ // statically detected by web bundlers (Vite/esbuild/webpack/Rollup) running
200+ // in non-Angular host apps (Vue, Solid, Svelte, React, vanilla), causing
201+ // them to fail with "Could not resolve '@nativescript/angular'". Using a
202+ // global-scope require lookup with a non-literal module id keeps the
203+ // integration purely opt-in at runtime — present only when Angular is.
198204 const angular = safeCall ( ( ) => {
199- if ( typeof require !== "function" ) {
205+ const scope : any =
206+ typeof globalThis !== "undefined"
207+ ? globalThis
208+ : typeof global !== "undefined"
209+ ? ( global as any )
210+ : null ;
211+ const runtimeRequire : any = scope ?. require ;
212+ if ( typeof runtimeRequire !== "function" ) {
200213 return null ;
201214 }
202- return require ( "@nativescript/angular" ) ;
215+ const moduleId = [ "@nativescript" , "angular" ] . join ( "/" ) ;
216+ return runtimeRequire ( moduleId ) ;
203217 } , null ) as any ;
204218 const viewUtilPrototype = angular ?. ɵViewUtil ?. ViewUtil ?. prototype ;
205219 if (
0 commit comments