Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.73] Backport JSC-safe request URLs #994

Merged
merged 2 commits into from Jun 5, 2023
Merged

Conversation

robhogan
Copy link
Contributor

@robhogan robhogan commented Jun 3, 2023

Backport commits relating to the fix for facebook/react-native#36794 to the 0.73 branch, currently used by RN 0.71.x.

  • bd357c8 Accept bundle and symbolication requests in JSC-safe format (//& in place of ?)
  • bce6b27 Emit JSC-safe URLs in HMR, //# sourceURL, Content-Location

Changelog:

- **[Feature]** Support URLs for both bundling and symbolication requests using `//&` instead of `?` as a query string delimiter
- **[Fix]** Emit source URLs in a format that will not be stripped by JavaScriptCore

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 3, 2023
@robhogan robhogan changed the title [0.73 [0.73] Backport JSC-safe request URLs Jun 3, 2023
@robhogan robhogan changed the base branch from main to 0.73.x June 3, 2023 13:18
@codecov-commenter
Copy link

codecov-commenter commented Jun 3, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01 🎉

Comparison is base (f9020e1) 79.82% compared to head (8147dfd) 79.84%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##           0.73.x     #994      +/-   ##
==========================================
+ Coverage   79.82%   79.84%   +0.01%     
==========================================
  Files         209      209              
  Lines       10667    10681      +14     
  Branches     2583     2585       +2     
==========================================
+ Hits         8515     8528      +13     
- Misses       2152     2153       +1     
Impacted Files Coverage Δ
.../metro/src/DeltaBundler/Serializers/hmrJSBundle.js 82.50% <100.00%> (+0.44%) ⬆️
packages/metro/src/Server.js 87.79% <100.00%> (+0.36%) ⬆️
packages/metro/src/lib/parseOptionsFromUrl.js 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

… place of `?`)

Summary:
The first part of implementing react-native-community/discussions-and-proposals#646 to address facebook/react-native#36794.

This allows Metro to respond to bundle and symbolication requests that use URLs with `//&` in place of `?` as a query delimiter.

```
**[Feature]**: Support URLs for both bundling and symbolication requests using `//&` instead of `?` as a query string delimiter
```

(Note: This does *not* add support for registering HMR entry points in the JSC-safe format - that's not necessary at this point, if at all, and I'm keen to minimise the footprint of this stack for easier backporting.)

Reviewed By: huntie

Differential Revision: D45983877

fbshipit-source-id: e799f76cd26c2ca8026b4d1bf70a582814ae1790
Summary:
Pull Request resolved: #989

The remaining Metro part of the implementation of react-native-community/discussions-and-proposals#646, to fix (along with an RN change):
 - facebook/react-native#36794 and
 - expo/expo#22008

This ensures that Metro always and consistently emits "JSC-safe" (i.e., `//&` query-delimited) URLs where they are used as a "source URL" for evaluated JS. This includes:
 - `sourceURL` within the JSON HMR payload (`HmrModule`)
 - `//# sourceURL` comments within the body of a base or HMR bundle
 - The new `Content-Location` header delivered in response to an HTTP bundle request.

Clients will be expected to use these as source URL arguments to JS engines, in preference to the URL on which they might have connected/requested the bundle originally.

```
* **[Fix]**: Emit source URLs in a format that will not be stripped by JavaScriptCore
```

Reviewed By: GijsWeterings

Differential Revision: D45983876

fbshipit-source-id: 3e7f0118091424b9c1b1d40e4eb7baeb5be1f48f
@robhogan robhogan merged commit 8088bc2 into 0.73.x Jun 5, 2023
6 checks passed
@robhogan robhogan mentioned this pull request Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants