File tree 4 files changed +21
-4
lines changed
4 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 13
13
import NativeSourceCode from '../../NativeModules/specs/NativeSourceCode' ;
14
14
15
15
let _cachedDevServerURL : ?string ;
16
+ let _cachedFullBundleURL : ?string ;
16
17
const FALLBACK = 'http://localhost:8081/' ;
17
18
18
19
type DevServerInfo = {
19
20
url : string ,
21
+ fullBundleUrl : ?string ,
20
22
bundleLoadedFromServer : boolean ,
21
23
...
22
24
} ;
@@ -27,14 +29,15 @@ type DevServerInfo = {
27
29
*/
28
30
function getDevServer ( ) : DevServerInfo {
29
31
if ( _cachedDevServerURL === undefined ) {
30
- const match = NativeSourceCode . getConstants ( ) . scriptURL . match (
31
- / ^ h t t p s ? : \/ \/ .* ?\/ / ,
32
- ) ;
32
+ const scriptUrl = NativeSourceCode . getConstants ( ) . scriptURL ;
33
+ const match = scriptUrl . match ( / ^ h t t p s ? : \/ \/ .* ?\/ / ) ;
33
34
_cachedDevServerURL = match ? match [ 0 ] : null ;
35
+ _cachedFullBundleURL = match ? scriptUrl : null ;
34
36
}
35
37
36
38
return {
37
39
url : _cachedDevServerURL || FALLBACK ,
40
+ fullBundleUrl : _cachedFullBundleURL ,
38
41
bundleLoadedFromServer : _cachedDevServerURL !== null ,
39
42
} ;
40
43
}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ const MetroHMRClient = require('metro/src/lib/bundle-modules/HMRClient');
16
16
const Platform = require ( './Platform' ) ;
17
17
const prettyFormat = require ( 'pretty-format' ) ;
18
18
19
+ import getDevServer from '../Core/Devtools/getDevServer' ;
19
20
import NativeRedBox from '../NativeModules/specs/NativeRedBox' ;
20
21
import * as LogBoxData from '../LogBox/Data/LogBoxData' ;
21
22
import type { ExtendedError } from '../Core/Devtools/parseErrorStack' ;
@@ -159,8 +160,15 @@ const HMRClient: HMRClientNativeInterface = {
159
160
const client = new MetroHMRClient ( `ws://${ wsHost } /hot` ) ;
160
161
hmrClient = client ;
161
162
163
+ const { fullBundleUrl } = getDevServer ( ) ;
162
164
pendingEntryPoints . push (
163
- `ws://${ wsHost } /hot?bundleEntry=${ bundleEntry } &platform=${ platform } ` ,
165
+ // HMRServer understands regular bundle URLs, so prefer that in case
166
+ // there are any important URL parameters we can't reconstruct from
167
+ // `setup()`'s arguments.
168
+ fullBundleUrl ??
169
+ // The ws://.../hot?bundleEntry= format is an alternative to specifying
170
+ // a regular HTTP bundle URL.
171
+ `ws://${ wsHost } /hot?bundleEntry=${ bundleEntry } &platform=${ platform } ` ,
164
172
) ;
165
173
166
174
client . on ( 'connection-error' , e => {
Original file line number Diff line number Diff line change 105
105
"pretty-format" : " ^26.0.1" ,
106
106
"promise" : " ^8.0.3" ,
107
107
"prop-types" : " ^15.7.2" ,
108
+ "qs" : " ^6.5.1" ,
108
109
"react-devtools-core" : " ^4.6.0" ,
109
110
"react-refresh" : " ^0.4.0" ,
110
111
"regenerator-runtime" : " ^0.13.2" ,
Original file line number Diff line number Diff line change @@ -6231,6 +6231,11 @@ punycode@^2.1.0, punycode@^2.1.1:
6231
6231
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
6232
6232
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
6233
6233
6234
+ qs@^6.5.1 :
6235
+ version "6.9.4"
6236
+ resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.4.tgz#9090b290d1f91728d3c22e54843ca44aea5ab687"
6237
+ integrity sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==
6238
+
6234
6239
qs@~6.5.2 :
6235
6240
version "6.5.2"
6236
6241
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
You can’t perform that action at this time.
0 commit comments