@@ -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' ;
@@ -480,44 +478,3 @@ export const makeWrappedCreateRequestHandler = (options?: { instrumentTracing?:
480478 return wrapRequestHandler ( requestHandler , newBuild , options ) ;
481479 } ;
482480 } ;
483-
484- /**
485- * Helper to load a module in both CJS and ESM contexts.
486- * In ESM, we use createRequire to create a require function.
487- * In CJS, we use the standard loadModule.
488- */
489- function loadModuleCompat < T > ( moduleName : string ) : T | undefined {
490- // Check if we're in ESM context (module doesn't exist)
491- if ( typeof module === 'undefined' ) {
492- // ESM context - use createRequire to get a require function
493- try {
494- // eslint-disable-next-line @typescript-eslint/no-var-requires
495- const require = createRequire ( import . meta. url ) ;
496- return require ( moduleName ) as T ;
497- } catch {
498- return undefined ;
499- }
500- } else {
501- // CJS context - use loadModule with module reference
502- // eslint-disable-next-line @typescript-eslint/no-explicit-any
503- return loadModule < T > ( moduleName , module as any ) ;
504- }
505- }
506-
507- /**
508- * Monkey-patch Remix's `createRequestHandler` from `@remix-run/server-runtime`
509- * which Remix Adapters (https://remix.run/docs/en/v1/api/remix) use underneath.
510- */
511- export function instrumentServer ( options ?: { instrumentTracing ?: boolean } ) : void {
512- const pkg = loadModuleCompat < {
513- createRequestHandler : CreateRequestHandlerFunction ;
514- } > ( '@remix-run/server-runtime' ) ;
515-
516- if ( ! pkg ) {
517- DEBUG_BUILD && debug . warn ( 'Remix SDK was unable to require `@remix-run/server-runtime` package.' ) ;
518-
519- return ;
520- }
521-
522- fill ( pkg , 'createRequestHandler' , makeWrappedCreateRequestHandler ( options ) ) ;
523- }
0 commit comments