Skip to content

Commit 2fb5b56

Browse files
committed
add fixtures for hermes and react-native sourcemaps
1 parent a086b92 commit 2fb5b56

File tree

8 files changed

+50
-0
lines changed

8 files changed

+50
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
.DS_Store
12
target
23
Cargo.lock

tests/fixtures/hermes/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
The sourcemap here was generated like this:
2+
3+
```sh
4+
$ hermes -O -emit-binary -output-source-map -out=output input.js
5+
```
6+
7+
When running the bytecode, we get the following stacktrace:
8+
9+
```
10+
Error: lets throw!
11+
at foo (address at unknown:1:57)
12+
at global (address at unknown:1:27)
13+
```

tests/fixtures/hermes/input.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
foo();
2+
3+
function foo() {
4+
throw new Error("lets throw!");
5+
}

tests/fixtures/hermes/output.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
The sourcemap here was generated like this:
2+
3+
Basically this is the same that the `react-native` gradle file does, see:
4+
https://github.com/facebook/react-native/blob/4185a45be40e014d5e6315c70de00fe5f76c726a/react.gradle#L156-L204
5+
6+
```sh
7+
$ npx react-native bundle --platform android --entry-file input.js --bundle-output intermediate.js --sourcemap-output intermediate.js.map
8+
$ hermes -O -emit-binary -output-source-map -out=intermediate2 intermediate.js
9+
$ node react-native/scripts/compose-source-maps.js intermediate.js.map intermediate2.js.map -o output.map
10+
```
11+
12+
When running the bytecode, we will get the following stacktrace
13+
(probably a bit different when done in react-native properly):
14+
15+
```
16+
Error: lets throw!
17+
at foo (address at unknown:1:11939)
18+
at anonymous (address at unknown:1:11857)
19+
at loadModuleImplementation (address at unknown:1:2608)
20+
at guardedLoadModule (address at unknown:1:1973)
21+
at metroRequire (address at unknown:1:1494)
22+
at global (address at unknown:1:508)
23+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { foo } from "./module.js"
2+
3+
foo();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function foo() {
2+
throw new Error("lets throw!");
3+
}

tests/fixtures/react-native-hermes/output.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)