@@ -26,7 +26,12 @@ const REACT_METADATA_INDEX_IN_FB_METADATA = 1;
2626const REACT_SOURCES_EXTENSION_KEY = 'x_react_sources' ;
2727const FB_SOURCES_EXTENSION_KEY = 'x_facebook_sources' ;
2828
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+ */
3035function normalizeSourcePath (
3136 sourceInput : string ,
3237 map : { + sourceRoot ?: ?string , ...} ,
@@ -36,30 +41,13 @@ function normalizeSourcePath(
3641
3742 // eslint-disable-next-line react-internal/no-primitive-constructors
3843 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 ) ;
5345}
5446
5547/**
5648 * Consumes the `x_react_sources` or `x_facebook_sources` metadata field from a
5749 * source map and exposes ways to query the React DevTools specific metadata
5850 * 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.
6351 */
6452export class SourceMapMetadataConsumer {
6553 _sourceMap : MixedSourceMap ;
0 commit comments