-
Notifications
You must be signed in to change notification settings - Fork 627
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Terminate module source maps with a null mapping
Summary: Changelog: * **[Fix]:** Guard against invalid symbolication in Chrome DevTools by terminating each module's source map with a null mapping. ## The bug Metro's bundles include a bit of top-level generated code at the end, which today has no source mappings whatsoever. In Chrome DevTools, this results in stack traces that look corrupt if they include any frames in that region of the bundle: this is because Chrome falls back to the nearest preceding mapping, which happens to come from a different module entirely. ## The fix Here, we add code to `metro-transform-worker` to ensure that we always emit an extra mapping (with no embedded source location) to mark the end of the last line of each module. When concatenated into a bundle, this causes Chrome DevTools to return this null mapping for all generated locations in the bottom of the bundle. This is strictly better than returning a random incorrect source file, regardless of what the "ideal" way to represent that code might be. NOTE: The Metro server's source map infra is hacky and outdated, preventing us from using safe abstractions like `BundleBuilder` that have this type of automatic termination built-in (as well as from emitting any actual mappings for the trailing code in the bundle). We'll likely want to follow up with a deeper refactor there. Reviewed By: GijsWeterings Differential Revision: D55066677 fbshipit-source-id: 879524b0b49cfb1c137daac2083aeafe24f0e193
- Loading branch information
1 parent
79c10e9
commit 96c6b89
Showing
4 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -389,6 +389,10 @@ Array [ | |
20, | ||
40, | ||
], | ||
Array [ | ||
24, | ||
3, | ||
], | ||
], | ||
}, | ||
"type": "js/module", | ||
|