Skip to content

Minor Performance improvements#88

Merged
mrkpatchaa merged 37 commits intomainfrom
performance-improvements
Apr 23, 2026
Merged

Minor Performance improvements#88
mrkpatchaa merged 37 commits intomainfrom
performance-improvements

Conversation

@mrkpatchaa
Copy link
Copy Markdown
Collaborator

@mrkpatchaa mrkpatchaa commented Apr 21, 2026

Related to #61
I tried sub path imports to import only specific weights of icons. But that was generating too many files. NPM even rejected the publish.

I added benchmark script to measure impact of different imports. Here are the results:
Follow this link to understand the experimental three shaking support from Expo.

  ╔══════════════════════════════════════════════════════════════════╗
  ║     Phosphor React Native — Metro Bundle Size Report            ║
  ╚══════════════════════════════════════════════════════════════════╝

  Platform   : iOS
  Minified   : yes
  Tree-shake : no
  Tarball    : phosphor-react-native-3.0.5.tgz
  Bundler    : real Metro via `expo export --platform ios`
  ────────────────────────────────────────────────────────────────────────────────────────────────────
  Scenario                                                             minified         gz  vs base
  ────────────────────────────────────────────────────────────────────────────────────────────────────
  Baseline — no phosphor import                                       1672.0 kB   722.2 kB        —
  Main barrel, 1 icon  (AcornIcon)                                    8597.4 kB  2038.8 kB    +182%
  Main barrel, 3 icons  (Acorn, AddressBookTabs, AddressBook)         8597.6 kB  2039.1 kB    +182%
  Src deep import, 1 icon  (AcornIcon)                                1875.5 kB   792.1 kB     +10%
  Src deep import, 3 icons  (Acorn, AddressBookTabs, AddressBook)     1884.0 kB   794.7 kB     +10%
  ────────────────────────────────────────────────────────────────────────────────────────────────────

  ╔══════════════════════════════════════════════════════════════════╗
  ║     Phosphor React Native — Metro Bundle Size Report            ║
  ╚══════════════════════════════════════════════════════════════════╝

  Platform   : iOS
  Minified   : yes
  Tree-shake : yes (experimental)
  Tarball    : phosphor-react-native-3.0.5.tgz
  Bundler    : real Metro via `expo export --platform ios`
  ────────────────────────────────────────────────────────────────────────────────────────────────────
  Scenario                                                             minified         gz  vs base
  ────────────────────────────────────────────────────────────────────────────────────────────────────
  Baseline — no phosphor import                                       1652.0 kB   713.1 kB        —
  Main barrel, 1 icon  (AcornIcon)                                    1853.9 kB   782.4 kB     +10%
  Main barrel, 3 icons  (Acorn, AddressBookTabs, AddressBook)         1863.3 kB   785.1 kB     +10%
  Src deep import, 1 icon  (AcornIcon)                                1853.6 kB   782.3 kB     +10%
  Src deep import, 3 icons  (Acorn, AddressBookTabs, AddressBook)     1862.8 kB   785.0 kB     +10%
  ────────────────────────────────────────────────────────────────────────────────────────────────────


- icon-base-single.tsx: lightweight IconBase with pre-resolved ReactElement paths
- generator: generateSingleWeightDef/Icon/AllSingleWeightDirs for src/<weight>/ dirs
- scripts/build-weights.mjs: compile each weight to lib/{module,commonjs,typescript}/<weight>/
- tests: lib-weight-subpaths.test.ts verifies all 6 weight outputs
- Rename 'Single' tab to 'Perf'
- Section 1: React.memo demo — tap button to increment parent renders,
  icons with stable props skip re-renders (render count stays at 1)
- Section 2: Per-weight subpath imports from /regular and /bold barrels
- Section 3: Classic multi-weight import showing all 6 weight variants
@mrkpatchaa mrkpatchaa changed the title Performance improvements : subpath import to reduce bundle size WIP: Performance improvements Apr 23, 2026
@mrkpatchaa mrkpatchaa changed the title WIP: Performance improvements Minor Performance improvements Apr 23, 2026
@mrkpatchaa mrkpatchaa merged commit 96e4b43 into main Apr 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants