Registry / devops / dumpmeta-webpack-plugin

dumpmeta-webpack-plugin

JSON →
library0.2.0jsnpmunverified

The `dumpmeta-webpack-plugin` is a Webpack plugin designed to save build-time metadata to a specified file, typically for post-build analysis or integration with other tools. As of its current stable version, 0.2.0, it offers compatibility with Webpack 5. The plugin differentiates itself through its simplicity and a `prepare` option that allows developers to precisely extract and format the desired properties from Webpack's `stats` object before serialization, ensuring only relevant, JSON-serializable data is saved. While release cadence appears infrequent, updates address major Webpack version compatibility. It serves as a focused utility for build introspection rather than a comprehensive reporting tool.

npm install dumpmeta-webpack-plugin
INSTALL
IMPORT
SIG · DUMPMETA-WEBPACK-P
D
dumpmeta-webpack-plugin
devopsjavascriptv0.2.0
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.

DumpMetaPlugin
import { DumpMetaPlugin } from 'dumpmeta-webpack-plugin';
const DumpMetaPlugin = require('dumpmeta-webpack-plugin');
For CommonJS environments, use the named require syntax. For ESM, use the named import.
DumpMetaPlugin (CommonJS)
const { DumpMetaPlugin } = require('dumpmeta-webpack-plugin');
import DumpMetaPlugin from 'dumpmeta-webpack-plugin';
This is the correct CommonJS syntax for importing the named export. Avoid default import as it's not a default export.
DumpMetaPluginOptions
import type { DumpMetaPluginOptions } from 'dumpmeta-webpack-plugin';
Used for type-checking the plugin's configuration options in TypeScript projects.

Demonstrates how to configure and use `DumpMetaPlugin` in a `webpack.config.js` to save custom build metadata, including build hash and timestamps, to a `meta.json` file.

import { DumpMetaPlugin } from 'dumpmeta-webpack-plugin'; import path from 'path'; export default { mode: 'production', entry: './src/index.js', output: { filename: 'bundle.js', path: path.resolve(__dirname, 'dist'), }, plugins: [ // ... other webpack plugins ... new DumpMetaPlugin({ filename: 'dist/meta.json', // Specify the output path for the metadata file prepare: stats => ({ // Customize the metadata to save. Ensure data is JSON-serializable. hash: stats.hash, // The build hash version: stats.version, // Webpack version buildTime: new Date().toISOString(), // Timestamp of the build modulesCount: stats.compilation.modules.length, // Number of compiled modules errors: stats.hasErrors(), // Check if the build had errors warnings: stats.hasWarnings() // Check if the build had warnings }) }) ] };
Debug
Known issues
breakingVersion 0.2.0 introduced compatibility with Webpack 5. While the plugin itself aims to be backwards compatible, internal changes in Webpack's `stats` object structure between major versions might affect custom `prepare` functions written for older Webpack versions.
fix
Review and update your `prepare` function logic when migrating to Webpack 5 to ensure it correctly extracts properties from the potentially changed `stats` object structure. Refer to Webpack 5's `stats` documentation.
affects: >=0.2.0
gotchaThe `prepare` option's return value *must* be JSON-serializable. If it returns functions, Promises, or other non-serializable JavaScript objects, the plugin will fail when attempting to write the file.
fix
Ensure that the object returned by your `prepare` function contains only primitive values, arrays, and plain objects. Transform complex types (e.g., Dates) into serializable formats like ISO strings.
affects: >=0.1.0
gotchaThis plugin is typically a development dependency (`--save-dev`) as it operates during the build process and is not required at runtime in production bundles.
fix
Install using `npm install dumpmeta-webpack-plugin --save-dev` or `yarn add dumpmeta-webpack-plugin --dev`.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: DumpMetaPlugin is not a constructor
Attempting to import `DumpMetaPlugin` as a default export or incorrectly using `require`.
fix
For ES Modules, use `import { DumpMetaPlugin } from 'dumpmeta-webpack-plugin';`. For CommonJS, use `const { DumpMetaPlugin } = require('dumpmeta-webpack-plugin');`.
Failed to serialize Webpack metadata: Converting circular structure to JSON
The `prepare` function returned an object that contains circular references, which JSON.stringify cannot handle.
fix
Carefully inspect the object returned by your `prepare` function. Ensure it does not include any properties that recursively refer back to themselves or parent objects. Only extract specific, necessary primitive properties.
WebpackError: [dumpmeta-webpack-plugin] Error writing metadata file: EACCES: permission denied, open '/path/to/meta.json'
The plugin does not have sufficient write permissions to the specified `filename` path.
fix
Ensure that the directory where `meta.json` is to be written has appropriate write permissions for the user running the Webpack build. Alternatively, specify a different output `filename` to a writable location.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
webpackrequiredThis is a Webpack plugin and requires Webpack as a peer dependency for its functionality.
Agent activity
2 hits · last 30 days
node
2
Resources
dumpmeta-webpack-plugin — npm install dumpmeta-webpack-plugin · libregistry