Registry / devops / webpack-format-messages

webpack-format-messages

JSON →
library3.0.1jsnpmunverified

Beautiful formatting for Webpack messages, ported from Create React App. Version 3.0.1 is the current stable release, with TypeScript definitions and native ESM support via the `exports` map. This package extracts and prettifies Webpack error and warning messages from a stats object, providing clean console output similar to Create React App. It differs from `react-dev-utils/formatWebpackMessages` by accepting a Webpack stats object directly (not the toJson() output) and by being a lightweight standalone install (under 10 kB) without the heavy `react-dev-utils` dependency. Key differentiators: zero browser dependency, pure Node.js environment, and a simple API with two functions (`formatMessages` and `formatMessage`). Release cadence is sporadic; last major release was v3.0.0 with breaking changes to Node.js 13.0-13.7 support.

npm install webpack-format-messages
INSTALL
IMPORT
SIG · WEBPACK-FORMAT-MES
W
webpack-format-messages
devopsjavascriptv3.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

formatMessages
import formatMessages from 'webpack-format-messages'
const formatMessages = require('webpack-format-messages').default
Default export since v1; named export also available but default is preferred. ESM entry via exports map; Node 13.0-13.7 may need additional flags.
formatMessages
const { formatMessages } = require('webpack-format-messages')
const formatMessages = require('webpack-format-messages')
Named export works in CJS. Default export also available as module.exports; the named export is the same function.
formatMessage
import { formatMessage } from 'webpack-format-messages'
import formatMessage from 'webpack-format-messages'
This is a named export, not default. Use destructuring to access it.

Creates a Webpack compiler, taps the done hook, and uses formatMessages to pretty-print errors and warnings.

const webpack = require('webpack'); const formatMessages = require('webpack-format-messages'); const compiler = webpack({ // minimal config entry: './src/index.js', mode: 'development', }); compiler.hooks.done.tap('report', (stats) => { const messages = formatMessages(stats); if (messages.errors.length) { console.log('Errors:\n' + messages.errors.join('\n')); } if (messages.warnings.length) { console.log('Warnings:\n' + messages.warnings.join('\n')); } }); compiler.run((err) => { if (err) console.error(err); });
Debug
Known issues
breakingNode.js 13.0 - 13.7 users may experience import errors due to the `exports` map added in v3.0.0.
fix
Upgrade to Node >= 13.8 or use `--experimental-exports` flag, or downgrade to v2.x.
affects: >=3.0.0 <3.0.0
deprecatedUse of CommonJS require without destructuring may rely on the default export, which is deprecated in favor of named exports for clarity.
fix
Use `const { formatMessages } = require('webpack-format-messages')` or `import formatMessages from ...`.
affects: >=3.0.0
gotchaThe function expects a Webpack `stats` object, not the JSON from `stats.toJson()`.
fix
Pass the raw stats object from the done callback (the argument provided to the hook).
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'webpack-format-messages'
Package not installed or not in node_modules.
fix
Run `npm install --save-dev webpack-format-messages`
TypeError: formatMessages is not a function
Importing the wrong export: default vs named.
fix
Use `import formatMessages from 'webpack-format-messages'` or `const { formatMessages } = require('webpack-format-messages')`
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Node.js version < 12 or missing `--experimental-require-module` flag; package has ESM exports map.
fix
Upgrade Node to >= 14, or use dynamic import(`webpack-format-messages`) or set `type: 'module'` in package.json.
Upgrade
Version history
3.0.1latest on npm
Audit
Dependencies
kleurrequiredused for colorizing output messages
Agent activity
7 hits · last 30 days
node
6
Resources
webpack-format-messages — npm install webpack-format-messages · libregistry