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 🙏

© 2025 – Pkg Stats / Ryan Hefner

messages-combiner

v0.0.9

Published

`Messages Combiner` is a library designed to facilitate the combination and organization of localization message files. It provides a CLI tool and programmatic API to watch for changes in message files, combine them based on specified namespaces, and outp

Readme

Messages Combiner

Messages Combiner is a library designed to facilitate the combination and organization of localization message files. It provides a CLI tool and programmatic API to watch for changes in message files, combine them based on specified namespaces, and output the combined messages into separate files for each language.

Usage

Example 1: Execute via CLI

npx messages-combiner -p /path/to/your/project -o /path/to/output

For more options, please refer to the Options description below.

Example 2: Execute via Programmatic API

import { combineWatcher,combine } from 'messages-combiner';

startWatcher('/path/to/your/project', {
    basePath:'src',
    output:'/path/to/output',
    namespace:{
        '/locales/**/*':'common',
        '/app/**/*':'page',
        '/components/**/*':'component',
    },
    // you can also use config file to define options, The default is mcombiner.json relative your path argument
    configFile:'pathto/my_mcombiner.json',
});
combine('/path/to/your/project', {
    // same as above
})

Options

Options:

  • -p, --path : Path to watch. This is a required option that specifies the directory where your message files are located.
  • -w, --watch : Watch the file changes. default is true.
  • -o, --output : Output directory. This optional parameter specifies the directory where the combined message files will be saved. Default is i18n/messages.
  • -n, --namespace : Namespace mapping in JSON format. This optional parameter allows you to define custom namespaces to organize your message files.
  • -b, --base-path : Base path for the watcher. This optional parameter specifies the base path for the watcher.
  • -c, --config-file : Configuration file for the watcher. This optional parameter allows you to specify a configuration file that contains the options for the watcher.

You can also use a configuration file to define the options. The configuration file is a JSON file that contains the options for the watcher. The configuration file is located in the root directory of your project. The configuration file is named .mcombiner.json.

Configuration File

The configuration file is a JSON file that contains the options for the watcher. The configuration file is located in the root directory of your project. The configuration file is named .mcombiner.json.

{
    "basePath":"src",
    "output":"i18n/messages",
    "namespace":{
        "/locales/**/*":"common",
        "/app/**/*":"page",
        "/components/**/*":"component"
    }
}

Key Features:

  • Namespace Mapping: Define custom namespaces to organize your message files.
  • File Watching: Automatically watch for changes in your message files and update the combined output accordingly.
  • Configurable Output: Specify the output directory for the combined message files.
  • CLI and Programmatic API: Use the provided CLI tool for quick setup or integrate the library programmatically into your project.

How It Works:

  1. Watch for Changes: The library uses chokidar to watch for changes in the specified directory.
  2. Combine Messages: When a change is detected, the library reads the message files, applies namespace mappings, and combines the messages.
  3. Output Combined Messages: The combined messages are written to separate files for each language in the specified output directory.