react / react/metro

out of tree platform sourcemap URL incorrectly lacks http protocol

Open
#406 1 comment 16 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.6k
Forks
696
Avg merge
8m
Merged PRs (30d)
7

Description

Do you want to request a feature or report a bug?
Report a bug

What is the current behavior?
See microsoft/react-native-windows#2482.

Sourcemap URLs end up with the format //localhost:8081/App.uwp.map?platform=uwp... on react-native-windows, which breaks because of the Blob loading done in the debugger UI.
Metro specifically fixes this on android and iOS here:

        // The remote chrome debugger loads bundles via Blob urls, whose
        // protocol is blob:http. This breaks loading source maps through
        // protocol-relative URLs, which is why we must force the HTTP protocol
        // when loading the bundle for either iOS or Android.
        protocol:
          platform != null && platform.match(/^(android|ios)$/) ? 'http' : '',

but because react-native-windows uses "uwp" as the platform, it continues to have the same issue.

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.
See repro steps in microsoft/react-native-windows#2482

What is the expected behavior?
metro returns a sourceMapUrl with a protocol of http, instead of no protocol, on uwp platforms. Ideally Metro does not have to end up maintaining an exhaustive list of react native platforms, so perhaps a way to configure this behavior?

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
metro@0.49.2
node@v10.15.0
npm@6.5.0
OS: Windows 10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Metro's packages/metro/src/lib/parseOptionsFromUrl.js, then follow the reproduction referenced in microsoft/react-native-windows#2482. Check how out-of-tree platforms produce sourceMapUrl values and verify that the uwp case returns an HTTP protocol without requiring an exhaustive platform list.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.