libphonenumber-bundler CLI

0.4.0 · maintenance · verified Tue Apr 21

This package provides a Command Line Interface (CLI) utility designed to compile and bundle Google's official `libphonenumber` JavaScript port into a single, standalone JavaScript file. Unlike modern alternatives like `libphonenumber-js` which are independent rewrites, this tool directly uses the original Closure-compiled JavaScript output from Google's project, aiming for a faithful reproduction of its full functionality, including its potentially larger footprint and reliance on Closure's API patterns. The current stable version, 0.4.0, has not seen updates in over two years, indicating a maintenance status for the bundler tool itself, although it can fetch recent versions of the upstream `libphonenumber` source code. Its key differentiator is simplifying the process of obtaining a self-contained, official `libphonenumber` bundle without requiring a complex build setup, making it suitable for projects that prefer a direct script inclusion or a CommonJS module of the original Google library rather than a streamlined rewrite.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates global installation, listing available `libphonenumber` versions, bundling a specific version, and basic browser usage of the generated file.

npm install -g libphonenumber-bundler

# List available libphonenumber versions to bundle
lpn-bundler list

# Bundle a specific version of libphonenumber (e.g., 8.12.57) to a file
lpn-bundler bundle -t 8.12.57 -o libphonenumber.js

# Example usage of the generated file (libphonenumber.js) in a browser:
// <script src="libphonenumber.js"></script>
// <script>
//   const phoneUtil = libphonenumber.PhoneNumberUtil.getInstance();
//   const number = phoneUtil.parse('+12024561414', 'US');
//   console.log(phoneUtil.isValidNumber(number));
//   console.log(phoneUtil.format(number, libphonenumber.PhoneNumberFormat.INTERNATIONAL));
// </script>

view raw JSON →