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

globalize-compiler-plus

v0.0.10

Published

Includes all messages in the globalize-compiler process even if not statically referenced

Downloads

3

Readme

Overview

Wraps globalize-compiler to allow for simpler use:

  1. Locales are inferred from Messages.json file
  2. All keys/values in Messages.json are compiled into the output, without having to reference them statically in the input .js files

Background

I started with globalize-webpack-plugin, but had some dislikes/issues:

  • There is some narly stuff going on in this example at the bottom of file. I'd prefer complicating the build process over the product. See Usage below for how this tool approaches that problem (dynamically pulling locales, as needed)
  • The example also unfortunately works for just one locale, and its unclear to me, being new to the JS world, what I would need to do to get that to work
  • It is unusable for me. Partly documented here, you must statically reference every key (that you'd like bundled) in your message json.

This solution aims to simplify and close the gap on the above issues. I chose to build from globalize-compiler for a few reasons:

  • It's 95% there
  • CLI and simple function calls easier to reason about vs webpack and globalize internals. Something like KISS
  • It's a more universal solution compatible with any build tool and UI tool (angular, react, riot, pure js vs rolling your own as suggested here)

Usage

The inputs provided to globalize-plus-compiler are of the same format of globalize-compiler, with the exception of locales which can be a comma separated list, but isn't required. Locales, when not provided, are derived from the messages.json file.

One additional input argument is used for JS build helpers, such as webpack. It is a path to where the formatters live, relative to the app root, so that locales can be pulled dynamically, as needed.

Output is also exactly the same. Compiled JS files that contain the formatters and messages for the application and locale.

Use npm scripts, gulp tasks, etc... to run this.

CLI

> npm install globalize-compiler-plus --save-dev

> globalize-compiler-plus -m test/messages.json -a path/to/app/root -o test/output/ test/*.js

> tree test/output/

test/output/
  ├── formatters-de.js
  ├── formatters-en.js
  ├── formatters-es.js
  └── webpack-helper.js

JS usage

Works, but TBD on docs...

Examples

https://github.com/lp-/webpack-riot-uikit-globalize-jsdata-template

Thanks

rxaviers and the Globalize team