@@ -27,10 +27,9 @@ const REACT_SOURCES_EXTENSION_KEY = 'x_react_sources';
2727const FB_SOURCES_EXTENSION_KEY = 'x_facebook_sources' ;
2828
2929/**
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.
3433 */
3534function normalizeSourcePath (
3635 sourceInput : string ,
@@ -41,6 +40,18 @@ function normalizeSourcePath(
4140
4241 // eslint-disable-next-line react-internal/no-primitive-constructors
4342 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 ;
4455 return util . computeSourceURL ( sourceRoot , source ) ;
4556}
4657
0 commit comments