@@ -370,9 +370,9 @@ describe('sentryRemixVitePlugin', () => {
370370 const result = plugin . transform ( code , id ) ;
371371
372372 expect ( result ) . not . toBeNull ( ) ;
373- expect ( result ?. code ) . toContain ( 'global ._sentryRemixRouteManifest' ) ;
373+ expect ( result ?. code ) . toContain ( 'globalThis ._sentryRemixRouteManifest' ) ;
374374 expect ( result ?. code ) . toContain ( code ) ;
375- expect ( result ?. code ) . toContain ( "typeof global !== 'undefined'" ) ;
375+ expect ( result ?. code ) . toContain ( "typeof globalThis !== 'undefined'" ) ;
376376 } ) ;
377377
378378 it ( 'should handle files with "entry.client" in path' , ( ) => {
@@ -526,7 +526,7 @@ describe('sentryRemixVitePlugin', () => {
526526 const result = plugin . transform ( code , id ) ;
527527
528528 expect ( result ) . not . toBeNull ( ) ;
529- expect ( result ?. code ) . toContain ( 'global ._sentryRemixRouteManifest' ) ;
529+ expect ( result ?. code ) . toContain ( 'globalThis ._sentryRemixRouteManifest' ) ;
530530 } ) ;
531531
532532 it ( 'should handle files with "entry.server" in path' , ( ) => {
@@ -550,7 +550,36 @@ describe('sentryRemixVitePlugin', () => {
550550 const result = plugin . transform ( code , id ) ;
551551
552552 expect ( result ) . not . toBeNull ( ) ;
553- expect ( result ?. code ) . toContain ( 'global._sentryRemixRouteManifest' ) ;
553+ expect ( result ?. code ) . toContain ( 'globalThis._sentryRemixRouteManifest' ) ;
554+ } ) ;
555+
556+ it ( 'should inject manifest into Hydrogen/Cloudflare server.ts files' , ( ) => {
557+ fs . writeFileSync ( path . join ( routesDir , 'index.tsx' ) , '// index' ) ;
558+
559+ const plugin = sentryRemixVitePlugin ( ) as Plugin & {
560+ configResolved : ( config : ResolvedConfig ) => void ;
561+ transform : ( code : string , id : string ) => { code : string ; map : null } | null ;
562+ } ;
563+
564+ const mockConfig : Partial < ResolvedConfig > = {
565+ root : tempDir ,
566+ command : 'build' ,
567+ mode : 'production' ,
568+ } ;
569+
570+ plugin . configResolved ( mockConfig as ResolvedConfig ) ;
571+
572+ const code = 'console.log("Hydrogen server");' ;
573+
574+ // Test various server.ts paths
575+ const paths = [ '/app/server.ts' , 'server.ts' , '/Users/project/server.ts' ] ;
576+
577+ paths . forEach ( id => {
578+ const result = plugin . transform ( code , id ) ;
579+ expect ( result ) . not . toBeNull ( ) ;
580+ expect ( result ?. code ) . toContain ( 'globalThis._sentryRemixRouteManifest' ) ;
581+ expect ( result ?. code ) . toContain ( 'console.log("Hydrogen server");' ) ;
582+ } ) ;
554583 } ) ;
555584 } ) ;
556585} ) ;
0 commit comments