@@ -26,7 +26,12 @@ const REACT_METADATA_INDEX_IN_FB_METADATA = 1;
26
26
const REACT_SOURCES_EXTENSION_KEY = 'x_react_sources' ;
27
27
const FB_SOURCES_EXTENSION_KEY = 'x_facebook_sources' ;
28
28
29
- // Extracted from source-map@0.5.6's SourceMapConsumer
29
+ /**
30
+ * Extracted from the logic in source-map@0.8.0-beta.0's SourceMapConsumer.
31
+ * By default, source names are normalized using the same logic that the
32
+ * `source-map@0.8.0-beta.0` package uses internally. This is crucial for keeping the
33
+ * sources list in sync with a `SourceMapConsumer` instance.
34
+ */
30
35
function normalizeSourcePath (
31
36
sourceInput : string ,
32
37
map : { + sourceRoot ?: ?string , ...} ,
@@ -36,30 +41,13 @@ function normalizeSourcePath(
36
41
37
42
// eslint-disable-next-line react-internal/no-primitive-constructors
38
43
source = String ( source ) ;
39
- // Some source maps produce relative source paths like "./foo.js" instead of
40
- // "foo.js". Normalize these first so that future comparisons will succeed.
41
- // See bugzil.la/1090768.
42
- source = util . normalize ( source ) ;
43
- // Always ensure that absolute sources are internally stored relative to
44
- // the source root, if the source root is absolute. Not doing this would
45
- // be particularly problematic when the source root is a prefix of the
46
- // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
47
- source =
48
- sourceRoot != null && util . isAbsolute ( sourceRoot ) && util . isAbsolute ( source )
49
- ? util . relative ( sourceRoot , source )
50
- : source ;
51
-
52
- return source ;
44
+ return util . computeSourceURL ( sourceRoot , source ) ;
53
45
}
54
46
55
47
/**
56
48
* Consumes the `x_react_sources` or `x_facebook_sources` metadata field from a
57
49
* source map and exposes ways to query the React DevTools specific metadata
58
50
* included in those fields.
59
- *
60
- * By default, source names are normalized using the same logic that the
61
- * `source-map@0.5.6` package uses internally. This is crucial for keeping the
62
- * sources list in sync with a `SourceMapConsumer` instance.
63
51
*/
64
52
export class SourceMapMetadataConsumer {
65
53
_sourceMap : MixedSourceMap ;
0 commit comments