@@ -24,7 +24,6 @@ import {
2424 hasSpansEnabled ,
2525 httpHeadersToSpanAttributes ,
2626 isNodeEnv ,
27- loadModule ,
2827 SEMANTIC_ATTRIBUTE_SENTRY_OP ,
2928 SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ,
3029 SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ,
@@ -35,7 +34,6 @@ import {
3534 winterCGRequestToRequestData ,
3635 withIsolationScope ,
3736} from '@sentry/core' ;
38- import { createRequire } from 'module' ;
3937import { DEBUG_BUILD } from '../utils/debug-build' ;
4038import { createRoutes , getTransactionName } from '../utils/utils' ;
4139import { extractData , isResponse , json } from '../utils/vendor/response' ;
@@ -477,44 +475,3 @@ export const makeWrappedCreateRequestHandler = (options?: { instrumentTracing?:
477475 return wrapRequestHandler ( requestHandler , newBuild , options ) ;
478476 } ;
479477 } ;
480-
481- /**
482- * Helper to load a module in both CJS and ESM contexts.
483- * In ESM, we use createRequire to create a require function.
484- * In CJS, we use the standard loadModule.
485- */
486- function loadModuleCompat < T > ( moduleName : string ) : T | undefined {
487- // Check if we're in ESM context (module doesn't exist)
488- if ( typeof module === 'undefined' ) {
489- // ESM context - use createRequire to get a require function
490- try {
491- // eslint-disable-next-line @typescript-eslint/no-var-requires
492- const require = createRequire ( import . meta. url ) ;
493- return require ( moduleName ) as T ;
494- } catch {
495- return undefined ;
496- }
497- } else {
498- // CJS context - use loadModule with module reference
499- // eslint-disable-next-line @typescript-eslint/no-explicit-any
500- return loadModule < T > ( moduleName , module as any ) ;
501- }
502- }
503-
504- /**
505- * Monkey-patch Remix's `createRequestHandler` from `@remix-run/server-runtime`
506- * which Remix Adapters (https://remix.run/docs/en/v1/api/remix) use underneath.
507- */
508- export function instrumentServer ( options ?: { instrumentTracing ?: boolean } ) : void {
509- const pkg = loadModuleCompat < {
510- createRequestHandler : CreateRequestHandlerFunction ;
511- } > ( '@remix-run/server-runtime' ) ;
512-
513- if ( ! pkg ) {
514- DEBUG_BUILD && debug . warn ( 'Remix SDK was unable to require `@remix-run/server-runtime` package.' ) ;
515-
516- return ;
517- }
518-
519- fill ( pkg , 'createRequestHandler' , makeWrappedCreateRequestHandler ( options ) ) ;
520- }
0 commit comments