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.70] Backport JSC-safe request URLs #996

Merged
merged 2 commits into from
Jun 5, 2023
Merged

Conversation

robhogan
Copy link
Contributor

@robhogan robhogan commented Jun 5, 2023

Backport commits relating to the fix for facebook/react-native#36794 to the 0.70 branch, currently used by RN 0.69.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

… 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
@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 5, 2023
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 c87589f into 0.70.x Jun 5, 2023
@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.

3 participants