react / react/metro

Add option for generating *named* module factories

Open
#585 5 comments 1 reaction 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

_ I was blind, but now I see_

Hi, I'm profiling a RN app, and I'm looking into time it takes to do all the imports at app startup. Here's what the profiler could show me out of the box:

Captura de pantalla 2020-08-26 a las 10 38 01

Nothing. I see minor clues here and there, but I don't know which files correspond to which boxes. Absolutely useless.

I made a very minor change to Metro to spit out Modules like so:

// (normally this function is anonymous)
__d(function ____app_components_TaskDetails_CommentsList_helpers_js(/* ... */) {

And now, the profiling experience is completely transformed:

Captura de pantalla 2020-08-26 a las 10 37 40

I don't have a proper patch at this time, but it's literally a ~10LOC change: https://gist.github.com/radex/cc0e443f019bc0f94a76fcbd9200b48e

It would be quite trivial to add this to dev mode/profiling mode/under a flag, and if not — I'm making this post in case my contraption is useful to anyone else

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 the linked ~10-line gist and trace Metro's module-factory generation path. Add an opt-in mode or flag that emits names derived from module paths, then verify that profiling output identifies the corresponding files without changing the default output.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.