Skip to content

Commit 82f540f

Browse files
committed
If we always add sourceURL even when we have source maps, the native stack gets source mappe
1 parent dd8f789 commit 82f540f

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

packages/react-client/src/ReactFlightClient.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,10 +1614,6 @@ function resolveErrorDev(
16141614
} else {
16151615
error = callStack();
16161616
}
1617-
// Overriding the stack isn't really necessary at this point and maybe we should just
1618-
// leave the native one. However, the native one gets printed unsource mapped with
1619-
// reportError. If that's fixed it might be better to use the native one.
1620-
error.stack = stack;
16211617
}
16221618

16231619
(error: any).digest = digest;
@@ -1723,20 +1719,21 @@ function createFakeFunction<T>(
17231719
// point to the original source.
17241720
let code;
17251721
if (line <= 1) {
1726-
code = '_=>' + ' '.repeat(col < 4 ? 0 : col - 4) + '_()\n' + comment + '\n';
1722+
code = '_=>' + ' '.repeat(col < 4 ? 0 : col - 4) + '_()\n' + comment;
17271723
} else {
17281724
code =
17291725
comment +
17301726
'\n'.repeat(line - 2) +
17311727
'_=>\n' +
17321728
' '.repeat(col < 1 ? 0 : col - 1) +
1733-
'_()\n';
1729+
'_()';
17341730
}
17351731

1732+
if (filename) {
1733+
code += '\n//# sourceURL=' + filename;
1734+
}
17361735
if (sourceMap) {
1737-
code += '//# sourceMappingURL=' + sourceMap;
1738-
} else if (filename) {
1739-
code += '//# sourceURL=' + filename;
1736+
code += '\n//# sourceMappingURL=' + sourceMap;
17401737
}
17411738

17421739
let fn: FakeFunction<T>;

0 commit comments

Comments
 (0)