npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

metro-bundler-cli

v1.0.7

Published

A command line tool of metro bundler

Downloads

33

Readme

metro-bundler-cli

metro-bundler-cli is a command line tool to bundle react native project. This project is created mainly for bundle splitting. There is another similar project rn-packger, but it uses module name as module id, which is not stable enough and not unique enough across projects. Moreover, bundles generated using rn-packager under DEV mode are not able to run. So I made this tool to provide better bundle experience.

FEATURE

  • More stable and more unique module id
    Official metro-bundler uses incremental number as module id, which has some defects when splitting bundle. You can refer to this issue [Discuss]Problems about unstable numeric module ID. for more details. rn-packger made some improvements over module id creator. It uses module name which will downgrade to a relative path included project name when no module name is provided as module id, but project name is also unstable enough, for developers may rename a repo when cloning it to local. Two different projects may also have the same name, which is likely to case module conflicts. metro-bundler-cli uses hash of local path and module content as module id, which is more stable and more unique. Project name won't affect module id. Even two modules of two different projects have the some path, they will have different id as they have different content. By the way, stable module id is just an alternative and is not default. You must set use-stable-id flag to be true when you want to use stable id.

  • Support bundle splitting
    You can split your bundle into base bundle and business bundle with 'metro-bundler-cli'. React native base bundle is stable and it's size is much bigger than business bundle usually. Splitting bundle into base bundle and business bundle is benefit of reducing business bundle downloading time and accelerating business bundle loading time.

INSTALLATION

Install with npm globally:

npm install --global metro-bundler-cli

or as a dependency for your project:

npm install --save metro-bundler-cli

USAGE

metro-bundler-cli extends the officail bundle command line tool rather than change it, so you can bundle as usual with metro-bundler-cli.

metro-bundler bundle  \
--entry-file index.js  \
--bundle-output dist/business.jsbundle  \
--assets-dest dist \
--platform ios  \
--dev false

metro-bundler-cli exposes three more options.

  • use-stable-id: If true, use stable module id;
  • manifest-output: Manifest file path, if set, modules' information will be output to it;
  • exclude: Manifest file path, if set, modules in this file will be excluded from bundle.

Generate base bundle

metro-bundler bundle \
--entry-file base.js  \
--bundle-output dist/base.jsbundle  \
--assets-dest dist \
--manifest-output dist/base.manifest.json  \
--platform ios  \
--dev false
--use-stable-id true

Generate business bundle

metro-bundler bundle  \
--entry-file index.js  \
--bundle-output dist/business.jsbundle  \
--manifest-output dist/business.manifest.json  \
--assets-dest dist \
--exclude dist/base.manifest.json   \
--platform ios  \
--dev false
--use-stable-id true