9
9
10
10
import { parse } from '@babel/parser' ;
11
11
import LRU from 'lru-cache' ;
12
- import { SourceMapConsumer } from 'source-map' ;
12
+ import { SourceMapConsumer } from 'source-map-js ' ;
13
13
import { getHookName } from '../astUtils' ;
14
14
import { areSourceMapsAppliedToErrors } from '../ErrorTester' ;
15
15
import { __DEBUG__ } from 'react-devtools-shared/src/constants' ;
@@ -107,7 +107,6 @@ const originalURLToMetadataCache: LRUCache<
107
107
108
108
export async function parseHookNames (
109
109
hooksTree : HooksTree ,
110
- wasmMappingsURL : string ,
111
110
) : Thenable < HookNames | null > {
112
111
const hooksList : Array < HooksNode > = [ ] ;
113
112
flattenHooksList ( hooksTree , hooksList ) ;
@@ -167,9 +166,7 @@ export async function parseHookNames(
167
166
}
168
167
169
168
return loadSourceFiles ( locationKeyToHookSourceData )
170
- . then ( ( ) =>
171
- extractAndLoadSourceMaps ( locationKeyToHookSourceData , wasmMappingsURL ) ,
172
- )
169
+ . then ( ( ) => extractAndLoadSourceMaps ( locationKeyToHookSourceData ) )
173
170
. then ( ( ) => parseSourceAST ( locationKeyToHookSourceData ) )
174
171
. then ( ( ) => updateLruCache ( locationKeyToHookSourceData ) )
175
172
. then ( ( ) => findHookNames ( hooksList , locationKeyToHookSourceData ) ) ;
@@ -191,7 +188,6 @@ function decodeBase64String(encoded: string): Object {
191
188
192
189
function extractAndLoadSourceMaps (
193
190
locationKeyToHookSourceData : Map < string , HookSourceData > ,
194
- wasmMappingsURL : string ,
195
191
) : Promise < * > {
196
192
// SourceMapConsumer.initialize() does nothing when running in Node (aka Jest)
197
193
// because the wasm file is automatically read from the file system
@@ -202,8 +198,6 @@ function extractAndLoadSourceMaps(
202
198
'extractAndLoadSourceMaps() Initializing source-map library ...' ,
203
199
) ;
204
200
}
205
-
206
- SourceMapConsumer . initialize ( { 'lib/mappings.wasm' : wasmMappingsURL } ) ;
207
201
}
208
202
209
203
// Deduplicate fetches, since there can be multiple location keys per source map.
@@ -259,11 +253,7 @@ function extractAndLoadSourceMaps(
259
253
hookSourceData . metadataConsumer = new SourceMapMetadataConsumer (
260
254
parsed ,
261
255
) ;
262
- setPromises . push (
263
- new SourceMapConsumer ( parsed ) . then ( sourceConsumer => {
264
- hookSourceData . sourceConsumer = sourceConsumer ;
265
- } ) ,
266
- ) ;
256
+ hookSourceData . sourceConsumer = new SourceMapConsumer ( parsed ) ;
267
257
break ;
268
258
}
269
259
} else {
@@ -299,10 +289,10 @@ function extractAndLoadSourceMaps(
299
289
fetchFile ( url ) . then (
300
290
sourceMapContents => {
301
291
const parsed = JSON . parse ( sourceMapContents ) ;
302
- return new SourceMapConsumer ( parsed ) . then ( sourceConsumer => ( {
303
- sourceConsumer,
292
+ return {
293
+ sourceConsumer : new SourceMapConsumer ( parsed ) ,
304
294
metadataConsumer : new SourceMapMetadataConsumer ( parsed ) ,
305
- } ) ) ;
295
+ } ;
306
296
} ,
307
297
// In this case, we fall back to the assumption that the source has no source map.
308
298
// This might indicate an (unlikely) edge case that had no source map,
0 commit comments