Skip to content

json as string in JS bundle #1461

Open
Open

Description

@retyui

Webpack wraps JSON objects inside JSON.parse('...') strings primarily for JavaScript parsing performance and memory optimization. Does it make to apply this V8 optimisation from webpack for Hermes engine (especially for apps with huge json locales)

https://github.com/webpack/webpack/blob/69adee615b758639f3499d54c0b1d62f8328c6f2/lib/json/JsonGenerator.js#L230-L237

Image

Activity

  1. retyui commented on Sep 17, 2026

    @retyui
    ContributorAuthor

    Tested perf. and memory usage on React Native 0.88.x with flashlight (Samsung S10)

    // JSON
    require('./huge.json'); // 4mb
    
    // JSON.parse('str')
    require('./huge.js'); // File `module.exports = JSON.parse('<json as string>');` 
    Image

    I thunk we need to turn off this optimisation to improve CPU/Memory usage


    To test

    flashlight test --bundleId "com.rn88"\
      --testCommand "adb shell monkey -p com.rn88 -c android.intent.category.LAUNCHER 1"\
      --duration 1000\
      --iterationCount 20\
      --resultsTitle "require('huge.json')"\
      --resultsFilePath "before.json"
    
    
    flashlight report before.json after.json 
  2. added a commit that references this issue on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions