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

fix(metro-config): keep existing URL parts when rewriting virtual entrypoint urls #23546

Merged
merged 4 commits into from
Jul 16, 2023

Conversation

byCedric
Copy link
Member

Why

Metro uses the server.rewriteRequestUrl during hot module reloads, and uses the output as both sourceMappingUrl and sourceUrl. These two properties are important for debugging, as it essentially tells the debugger all original information it needs about the transpiled file.

On initial load, this works fine, but after changing a file, Metro sends an incorrect URL to the debugger. This causes issues when updating the original sources within the debuggers.

image

How

  • Added test case to keep existing protocol, host, and port to the rewritten URL (if defined)
  • Only replaced the pathname when URL is a full URL.

Test Plan

See added test

Checklist

@byCedric byCedric requested a review from EvanBacon July 15, 2023 08:48
@expo-bot expo-bot added the bot: passed checks ExpoBot has nothing to complain about label Jul 15, 2023
@byCedric byCedric merged commit a4e3c26 into main Jul 16, 2023
7 checks passed
@byCedric byCedric deleted the @bycedric/metro-config/fix-url-rewrites branch July 16, 2023 07:16
byCedric added a commit that referenced this pull request Jul 16, 2023
…rypoint urls (#23546)

Metro uses the `server.rewriteRequestUrl` during hot module reloads, and
uses the output as both `sourceMappingUrl` and `sourceUrl`. These two
properties are important for debugging, as it essentially tells the
debugger all original information it needs about the transpiled file.

On initial load, this works fine, but after changing a file, Metro sends
an incorrect URL to the debugger. This causes issues when updating the
original sources within the debuggers.

![image](https://github.com/expo/expo/assets/1203991/960bc795-d098-4bc6-b3f9-8bb4085effc7)

- Added test case to keep existing `protocol`, `host`, and `port` to the
rewritten URL (if defined)
- Only replaced the `pathname` when URL is a full URL.

See added test

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).
byCedric added a commit that referenced this pull request Jul 18, 2023
…rypoint urls (#23546)

# Why

Metro uses the `server.rewriteRequestUrl` during hot module reloads, and
uses the output as both `sourceMappingUrl` and `sourceUrl`. These two
properties are important for debugging, as it essentially tells the
debugger all original information it needs about the transpiled file.

On initial load, this works fine, but after changing a file, Metro sends
an incorrect URL to the debugger. This causes issues when updating the
original sources within the debuggers.


![image](https://github.com/expo/expo/assets/1203991/960bc795-d098-4bc6-b3f9-8bb4085effc7)

# How

- Added test case to keep existing `protocol`, `host`, and `port` to the
rewritten URL (if defined)
- Only replaced the `pathname` when URL is a full URL.

# Test Plan

See added test

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants