@@ -27,10 +27,9 @@ const REACT_SOURCES_EXTENSION_KEY = 'x_react_sources';
27
27
const FB_SOURCES_EXTENSION_KEY = 'x_facebook_sources' ;
28
28
29
29
/**
30
- * Extracted from the logic in [email protected] 's SourceMapConsumer.
31
- * By default, source names are normalized using the same logic that the
32
- * `[email protected] ` package uses internally. This is crucial for keeping the
33
- * sources list in sync with a `SourceMapConsumer` instance.
30
+ * Extracted from the logic in [email protected] 's SourceMapConsumer.
31
+ * By default, source names are normalized using the same logic that the `[email protected] ` package uses internally.
32
+ * This is crucial for keeping the sources list in sync with a `SourceMapConsumer` instance.
34
33
*/
35
34
function normalizeSourcePath (
36
35
sourceInput : string ,
@@ -41,6 +40,18 @@ function normalizeSourcePath(
41
40
42
41
// eslint-disable-next-line react-internal/no-primitive-constructors
43
42
source = String ( source ) ;
43
+ // Some source maps produce relative source paths like "./foo.js" instead of
44
+ // "foo.js". Normalize these first so that future comparisons will succeed.
45
+ // See bugzil.la/1090768.
46
+ source = util . normalize ( source ) ;
47
+ // Always ensure that absolute sources are internally stored relative to
48
+ // the source root, if the source root is absolute. Not doing this would
49
+ // be particularly problematic when the source root is a prefix of the
50
+ // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
51
+ source =
52
+ sourceRoot != null && util . isAbsolute ( sourceRoot ) && util . isAbsolute ( source )
53
+ ? util . relative ( sourceRoot , source )
54
+ : source ;
44
55
return util . computeSourceURL ( sourceRoot , source ) ;
45
56
}
46
57
0 commit comments