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

webpack-format-messages

v3.0.1

Published

Beautiful formatting for Webpack messages; ported from Create React App!

Downloads

109,978

Readme

webpack-format-messages

Beautiful formatting for Webpack messages; ported from Create React App!

The console output from CRA is very well-done! Unfortunately, the only way to use it is to install all of react-dev-utils, which is quite a module-rich tree. While there is nothing wrong with this, many times I'd prefer a quick install for my custom Webpack configs (which aren't always React-related).

If you are already using react-dev-utils, you do not need this module and should do this instead:

const formatMessages = require('react-dev-utils/formatWebpackMessages');

Differences

The source code of this module is (nearly) a direct copy-paste of the original file. Only two modifications have been made:

  1. The code has been tailored to run in a Node-specific environment --- the original can also be run in the browser.
  2. The module input expects a Webpack stats object --- the original required a toJson() transformation

Install

$ npm install webpack-format-messages --save-dev

Usage

const webpack = require('webpack');
const formatMessages = require('webpack-format-messages');
// or
const { formatMessages } = require('webpack-format-messages');

const compiler = webpack(/* config */);

compiler.hooks.invalid.tap('invalid', function() {
  console.log('Compiling...');
});

compiler.hooks.done.tap('done', (stats) => {
  const messages = formatMessages(stats);

  if (!messages.errors.length && !messages.warnings.length) {
    console.log('Compiled successfully!');
  }

  if (messages.errors.length) {
    console.log('Failed to compile.');
    messages.errors.forEach(e => console.log(e));
    return;
  }

  if (messages.warnings.length) {
    console.log('Compiled with warnings.');
    messages.warnings.forEach(w => console.log(w));
  }
});

API

formatMessages(stats)

Returns: { errors: string[], warnings: string[] }

Extracts & prettifies warning and error messages from Webpack.

Note: This is also the default export.

stats

Type: Object

A Webpack stats object.

formatMessage(message)

Returns: string

Transforms an individual webpack stats message object into a string.

Note: You probably don't want to use this directly! It's used by formatMessages for you.

Related

Credits

This module is pulled directly from react-dev-utils, provided by Facebook Incubator.

This package exists solely as a standalone install~!