@@ -44,16 +44,26 @@ export {createTemporaryReferenceSet} from 'react-client/src/ReactFlightTemporary
4444
4545export type { TemporaryReferenceSet } ;
4646
47- function findSourceMapURL ( filename : string , environmentName : string ) {
48- const url = new URL ( '/__rspack_source_map' , window . location . origin ) ;
49- url . searchParams . set ( 'filename' , filename ) ;
50- url . searchParams . set ( 'environmentName' , environmentName ) ;
51- return url . toString ( ) ;
47+ let findSourceMapURLCallback : FindSourceMapURLCallback | null = null ;
48+
49+ function setFindSourceMapURLCallback ( fn : FindSourceMapURLCallback ) {
50+ findSourceMapURLCallback = fn ;
51+ }
52+
53+ function callCurrentFindSourceMapURLCallback (
54+ fileName : string ,
55+ environmentName : string ,
56+ ) : null | string {
57+ if ( findSourceMapURLCallback ) {
58+ return findSourceMapURLCallback ( fileName , environmentName ) ;
59+ }
60+ return null ;
5261}
5362
5463type CallServerCallback = < A , T > (string, args: A) => Promise < T > ;
5564
5665let callServer: CallServerCallback | null = null;
66+
5767export function setServerCallback(fn: CallServerCallback) {
5868 callServer = fn ;
5969}
@@ -78,15 +88,14 @@ export function createServerReference<A: Iterable<any>, T>(
7888 id + '#' + exportName ,
7989 callCurrentServerCallback ,
8090 undefined ,
81- findSourceMapURL ,
91+ callCurrentFindSourceMapURLCallback ,
8292 exportName ,
8393 ) ;
8494}
8595
8696export type Options = {
8797 debugChannel ?: { writable ?: WritableStream , readable ?: ReadableStream , ...} ,
8898 temporaryReferences ? : TemporaryReferenceSet ,
89- findSourceMapURL ?: FindSourceMapURLCallback ,
9099 replayConsoleLogs ?: boolean ,
91100 environmentName ?: string ,
92101 startTime ?: number ,
@@ -135,9 +144,7 @@ function createResponseFromOptions(options: void | Options) {
135144 options && options . temporaryReferences
136145 ? options . temporaryReferences
137146 : undefined ,
138- __DEV__ && options && options . findSourceMapURL
139- ? options . findSourceMapURL
140- : undefined ,
147+ __DEV__ && findSourceMapURLCallback ? findSourceMapURLCallback : undefined ,
141148 __DEV__ ? ( options ? options . replayConsoleLogs !== false : true ) : false , // defaults to true
142149 __DEV__ && options && options . environmentName
143150 ? options . environmentName
@@ -323,7 +330,12 @@ function encodeReply(
323330 } ) ;
324331}
325332
326- export { createFromFetch , createFromReadableStream , encodeReply } ;
333+ export {
334+ createFromFetch ,
335+ createFromReadableStream ,
336+ encodeReply ,
337+ setFindSourceMapURLCallback ,
338+ } ;
327339
328340if (__DEV__) {
329341 injectIntoDevTools ( ) ;
0 commit comments