99
1010import { parse } from '@babel/parser' ;
1111import LRU from 'lru-cache' ;
12- import { SourceMapConsumer } from 'source-map' ;
12+ import { SourceMapConsumer } from 'source-map-js ' ;
1313import { getHookName } from '../astUtils' ;
1414import { areSourceMapsAppliedToErrors } from '../ErrorTester' ;
1515import { __DEBUG__ } from 'react-devtools-shared/src/constants' ;
@@ -107,7 +107,6 @@ const originalURLToMetadataCache: LRUCache<
107107
108108export async function parseHookNames (
109109 hooksTree : HooksTree ,
110- wasmMappingsURL : string ,
111110) : Thenable < HookNames | null > {
112111 const hooksList : Array < HooksNode > = [ ] ;
113112 flattenHooksList ( hooksTree , hooksList ) ;
@@ -167,9 +166,7 @@ export async function parseHookNames(
167166 }
168167
169168 return loadSourceFiles ( locationKeyToHookSourceData )
170- . then ( ( ) =>
171- extractAndLoadSourceMaps ( locationKeyToHookSourceData , wasmMappingsURL ) ,
172- )
169+ . then ( ( ) => extractAndLoadSourceMaps ( locationKeyToHookSourceData ) )
173170 . then ( ( ) => parseSourceAST ( locationKeyToHookSourceData ) )
174171 . then ( ( ) => updateLruCache ( locationKeyToHookSourceData ) )
175172 . then ( ( ) => findHookNames ( hooksList , locationKeyToHookSourceData ) ) ;
@@ -191,7 +188,6 @@ function decodeBase64String(encoded: string): Object {
191188
192189function extractAndLoadSourceMaps (
193190 locationKeyToHookSourceData : Map < string , HookSourceData > ,
194- wasmMappingsURL : string ,
195191) : Promise < * > {
196192 // SourceMapConsumer.initialize() does nothing when running in Node (aka Jest)
197193 // because the wasm file is automatically read from the file system
@@ -202,8 +198,6 @@ function extractAndLoadSourceMaps(
202198 'extractAndLoadSourceMaps() Initializing source-map library ...' ,
203199 ) ;
204200 }
205-
206- SourceMapConsumer . initialize ( { 'lib/mappings.wasm' : wasmMappingsURL } ) ;
207201 }
208202
209203 // Deduplicate fetches, since there can be multiple location keys per source map.
@@ -259,11 +253,7 @@ function extractAndLoadSourceMaps(
259253 hookSourceData . metadataConsumer = new SourceMapMetadataConsumer (
260254 parsed ,
261255 ) ;
262- setPromises . push (
263- new SourceMapConsumer ( parsed ) . then ( sourceConsumer => {
264- hookSourceData . sourceConsumer = sourceConsumer ;
265- } ) ,
266- ) ;
256+ hookSourceData . sourceConsumer = new SourceMapConsumer ( parsed ) ;
267257 break ;
268258 }
269259 } else {
@@ -299,10 +289,10 @@ function extractAndLoadSourceMaps(
299289 fetchFile ( url ) . then (
300290 sourceMapContents => {
301291 const parsed = JSON . parse ( sourceMapContents ) ;
302- return new SourceMapConsumer ( parsed ) . then ( sourceConsumer => ( {
303- sourceConsumer,
292+ return {
293+ sourceConsumer : new SourceMapConsumer ( parsed ) ,
304294 metadataConsumer : new SourceMapMetadataConsumer ( parsed ) ,
305- } ) ) ;
295+ } ;
306296 } ,
307297 // In this case, we fall back to the assumption that the source has no source map.
308298 // This might indicate an (unlikely) edge case that had no source map,
0 commit comments