Skip to content

Reduce the Lumos bundle size #516

@homura

Description

@homura

Background

We've received some feedback from community developers that Lumos is quite large when bundled, which is not friendly for mobile devices

Bundle Analyzer Output

image

stats.json.zip
lumos@487f3235fcfc83409f7752f94962e343684686b5 uncompressed version: 1.7 MB

  • several different versions of bn.js in the bundle, probably due to browserify-crypto and lumos/hd together
  • more than one buffer.js in the bundle
  • cost-effective third-party libraries, such as ludash.isequal

Plan

  • Refactor the require("crypto") to import by demand
  • Unify multiple version dependencies into one version
  • Refactor some oversized third-party libraries with simple functions, such as lodash.isequal
  • Transpile to both ESM and CommonJS, add the module field to point to ESM result
  • Mark the package.json to "sideEffects: false" if it is possible
    • When refactoring, note that @ckb-lumos/config-manager may not be directly marked as "sideEffect: false" since the config.initializeConfig is side-effected
  • Decouple the data structure in the @ckb-lumos/rpc from the axios, allowing developers to choose their own HTTP client if they don't want to use the lumos integrated one

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